Skip to content

Commit

Permalink
Revert compile version back to JDK 11, since we still want to support…
Browse files Browse the repository at this point in the history
… LTS versions. Use ArquillianServletRunnerEE9 when initializing arquillian container. Cleaned up output processing. Fixed dependency issues.
  • Loading branch information
urbim committed Jan 17, 2024
1 parent 7363b5d commit ccb4e8c
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 60 deletions.
20 changes: 15 additions & 5 deletions kumuluzee-arquillian-container/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@
<artifactId>kumuluzee-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet-jakarta</artifactId>
<version>${arquillian.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.testenricher</groupId>
<artifactId>arquillian-testenricher-cdi-jakarta</artifactId>
<version>${arquillian.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.testenricher</groupId>
<artifactId>arquillian-testenricher-resource-jakarta</artifactId>
<version>${arquillian.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.testenricher</groupId>
<artifactId>arquillian-testenricher-initialcontext</artifactId>
<version>${arquillian.version}</version>
</dependency>

<dependency>
Expand All @@ -54,6 +53,11 @@
</dependency>

<!-- Dependencies required for tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-jax-rs-jersey</artifactId>
Expand All @@ -62,12 +66,18 @@
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>${arquillian.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency><!-- Required to properly forward exception from container to test framework -->
<groupId>com.kumuluz.ee</groupId>
<artifactId>kumuluzee-cdi-weld</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public static void main(String[] args) {

EeApplication app = new EeApplication();

KumuluzServer ser = app.getServer();
if (ser instanceof ServletServer server) {
KumuluzServer server = app.getServer();
if (server instanceof ServletServer) {
// print metadata (gets intercepted by parent process)
// print port
Integer port = EeConfig.getInstance().getServer().getHttp().getPort();
Expand All @@ -61,7 +61,7 @@ public static void main(String[] args) {
metadataSb.append(MSG_METADATA_PREFIX).append(port).append('\t');

// print information about the servlets
List<ServletWrapper> servlets = server.getRegisteredServlets();
List<ServletWrapper> servlets = ((ServletServer) server).getRegisteredServlets();
for (ServletWrapper s : servlets) {
metadataSb.append(s.getName()).append(':').append(s.getContextPath()).append('\t');
}
Expand All @@ -85,6 +85,7 @@ private static String serializeException(Exception e) {
return Base64.getEncoder().encodeToString(bo.toByteArray());
} catch (IOException e1) {
Exception newEx = new RuntimeException("IO error while serializing exception", e1);
//noinspection CallToPrintStackTrace
newEx.printStackTrace();
return serializeException(newEx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
@WebListener
public class ServletWebListener implements ServletContextListener {

private static final String ARQUILLIAN_SERVLET_NAME = "ArquillianServletRunner";
private static final String ARQUILLIAN_SERVLET_MAPPING = "/ArquillianServletRunner";
private static final String ARQUILLIAN_SERVLET_CLASS_NAME = "org.jboss.arquillian.protocol.servlet.runner." +
private static final String ARQUILLIAN_SERVLET_NAME = "ArquillianServletRunnerEE9";
private static final String ARQUILLIAN_SERVLET_MAPPING = "/ArquillianServletRunnerEE9";
private static final String ARQUILLIAN_SERVLET_CLASS_NAME = "org.jboss.arquillian.protocol.servlet5.runner." +
"ServletTestRunner";

@Override
Expand All @@ -55,9 +55,8 @@ public void contextDestroyed(ServletContextEvent servletContextEvent) {
// NO-OP
}

private boolean isClassPresent(String classname) {
private boolean isClassPresent(@SuppressWarnings("SameParameterValue") String classname) {
try {
System.out.println("Checking for class: " + classname);
Class.forName(classname);
return true;
} catch (ClassNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class AbstractDeployment {

private static final Logger LOG = Logger.getLogger(AbstractDeployment.class.getName());

private KumuluzEEContainerConfig containerConfig;
private final KumuluzEEContainerConfig containerConfig;

protected boolean shouldDelete;

Expand Down Expand Up @@ -122,8 +122,8 @@ public HTTPContext start() throws DeploymentException {

CountDownLatch serverReady = new CountDownLatch(1);

OutputProcessor stdoutProcessor = new OutputProcessor(process.getInputStream(), serverReady);
OutputProcessor stderrProcessor = new OutputProcessor(process.getErrorStream(), serverReady);
OutputProcessor stdoutProcessor = new OutputProcessor(process.getInputStream(), System.out, serverReady);
OutputProcessor stderrProcessor = new OutputProcessor(process.getErrorStream(), System.err, serverReady);
Thread outThread = new Thread(stdoutProcessor);
Thread errThread = new Thread(stderrProcessor);

Expand Down Expand Up @@ -157,7 +157,7 @@ public HTTPContext start() throws DeploymentException {
throw new DeploymentException("Could not retrieve HTTP context from server");
}

LOG.fine("Deployment started, context: " + context.toString());
LOG.fine("Deployment started, context: " + context);

return context;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class ArchiveUtils {
private static final Logger LOG = Logger.getLogger(ArchiveUtils.class.getName());

private ArchiveUtils() {
throw new IllegalStateException("Utility class");
}

/**
Expand Down Expand Up @@ -191,14 +190,15 @@ private static void explodeLoaderArchiveToRoot(JavaArchive javaArchive) {
* @param a Archive to fix
* @param parentDir Directory to scan for {@link ArchiveAsset}s
*/
private static void fixArchiveAssets(Archive<?> a, String parentDir) {
private static void fixArchiveAssets(Archive<?> a, @SuppressWarnings("SameParameterValue") String parentDir) {
Node n = a.get(parentDir);
Archive<?> tmp = ShrinkWrap.create(JavaArchive.class);
List<ArchivePath> pathsToDelete = new ArrayList<>();
for (Node child : n.getChildren()) {
Asset asset = child.getAsset();
if (asset instanceof ArchiveAsset archiveAsset && child.getPath().get().endsWith(".jar")) {
Asset childAsset = child.getAsset();
if (childAsset instanceof ArchiveAsset && child.getPath().get().endsWith(".jar")) {
LOG.fine("Converting archive " + child.getPath().get() + " to ByteArrayAsset");
ArchiveAsset archiveAsset = (ArchiveAsset) childAsset;
ByteArrayAsset bas = new ByteArrayAsset(archiveAsset.openStream());
pathsToDelete.add(child.getPath());
tmp.add(bas, child.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@
*/
public class OutputProcessor implements Runnable, Closeable {

private InputStream stream;
private CountDownLatch latch;
private final InputStream stream;
private final PrintStream forwardTo;
private final CountDownLatch latch;

private HTTPContext httpContext;
private Throwable processingError;
private Throwable deploymentError;

public OutputProcessor(InputStream stream, CountDownLatch latch) {
public OutputProcessor(InputStream stream, PrintStream forwardTo, CountDownLatch latch) {
this.stream = stream;
this.forwardTo = forwardTo;
this.latch = latch;
}

Expand All @@ -71,7 +73,7 @@ public void run() {
if (line.startsWith(MainWrapper.MSG_PREFIX)) {
processMessage(line.trim());
} else {
System.out.println(line);
this.forwardTo.println(line);
}
}
} catch (IOException | ParsingException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class RequiredLibraries {
private static final Logger LOG = Logger.getLogger(RequiredLibraries.class.getName());

private RequiredLibraries() {
throw new IllegalStateException("Utility class");
}

private static final String[] LIBS_DEFAULT = {
Expand Down Expand Up @@ -129,15 +128,21 @@ public static Archive<?>[] getRequiredLibraries(List<String> deploymentLibs) {
* @return A list of dependencies.
*/
private static List<String> getIncludedLibraries(String includeRequiredLibraries) {
return switch (includeRequiredLibraries) {
case KumuluzEEContainerConfig.INCLUDE_LIBS_FALSE, KumuluzEEContainerConfig.INCLUDE_LIBS_FROM_POM ->
Collections.emptyList();
case KumuluzEEContainerConfig.INCLUDE_LIBS_DEFAULT -> Arrays.asList(LIBS_DEFAULT);
case KumuluzEEContainerConfig.INCLUDE_LIBS_MP1_0 -> Arrays.asList(LIBS_MP1_0);
case KumuluzEEContainerConfig.INCLUDE_LIBS_MP1_1 -> Arrays.asList(LIBS_MP1_1);
case KumuluzEEContainerConfig.INCLUDE_LIBS_MP1_2 -> Arrays.asList(LIBS_MP1_2);
default -> throw new RuntimeException("Could not determine includeRequiredLibraries parameter: " +
includeRequiredLibraries);
};
switch (includeRequiredLibraries) {
case KumuluzEEContainerConfig.INCLUDE_LIBS_FALSE:
case KumuluzEEContainerConfig.INCLUDE_LIBS_FROM_POM:
return Collections.emptyList();
case KumuluzEEContainerConfig.INCLUDE_LIBS_DEFAULT:
return Arrays.asList(LIBS_DEFAULT);
case KumuluzEEContainerConfig.INCLUDE_LIBS_MP1_0:
return Arrays.asList(LIBS_MP1_0);
case KumuluzEEContainerConfig.INCLUDE_LIBS_MP1_1:
return Arrays.asList(LIBS_MP1_1);
case KumuluzEEContainerConfig.INCLUDE_LIBS_MP1_2:
return Arrays.asList(LIBS_MP1_2);
default:
throw new RuntimeException("Could not determine includeRequiredLibraries parameter: " +
includeRequiredLibraries);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
public class ShouldThrowExceptionTest {

@Deployment
@ShouldThrowException(DeploymentException.class)
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
.addClass(InvalidBean.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}

@Test
@ShouldThrowException(DeploymentException.class)
void ignored() {
// NO-OP, see @ShouldThrowException above
}
Expand Down
36 changes: 13 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@
<url>https://ee.kumuluz.com</url>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<kumuluzee.version>5.0.0-SNAPSHOT</kumuluzee.version>

<arquillian.version>1.8.0.Final</arquillian.version>
<shrinkwrap.version>1.2.6</shrinkwrap.version>
<shrinkwrap.resolver.version>3.2.1</shrinkwrap.resolver.version>
<shrinkwrap.resolver.version>3.3.0</shrinkwrap.resolver.version>

<junit.version>5.10.1</junit.version>
<rest-assured.version>5.3.2</rest-assured.version>

<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<nexus.staging.plugin.version>1.6.13</nexus.staging.plugin.version>
<gpg.plugin.version>3.1.0</gpg.plugin.version>
</properties>
Expand All @@ -53,10 +54,10 @@

<developers>
<developer>
<name>Tilen Faganel</name>
<id>tfaga</id>
<email>tilen.faganel@me.com</email>
<url>https://github.com/TFaga</url>
<name>KumuluzEE Development Team</name>
<id>kumuluz</id>
<email>info@kumuluz.com</email>
<url>https://github.com/kumuluz</url>
</developer>
</developers>

Expand Down Expand Up @@ -97,14 +98,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.jakarta</groupId>
<artifactId>arquillian-parent-jakarta</artifactId>
<version>${arquillian.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
Expand Down Expand Up @@ -139,14 +132,6 @@
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand All @@ -160,6 +145,11 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit ccb4e8c

Please sign in to comment.