diff --git a/kumuluzee-arquillian-container/pom.xml b/kumuluzee-arquillian-container/pom.xml index 2d33c15..223c559 100644 --- a/kumuluzee-arquillian-container/pom.xml +++ b/kumuluzee-arquillian-container/pom.xml @@ -20,27 +20,26 @@ kumuluzee-core provided - - com.kumuluz.ee - kumuluzee-cdi-weld - true - org.jboss.arquillian.protocol arquillian-protocol-servlet-jakarta + ${arquillian.version} org.jboss.arquillian.testenricher arquillian-testenricher-cdi-jakarta + ${arquillian.version} org.jboss.arquillian.testenricher arquillian-testenricher-resource-jakarta + ${arquillian.version} org.jboss.arquillian.testenricher arquillian-testenricher-initialcontext + ${arquillian.version} @@ -54,6 +53,11 @@ + + org.junit.jupiter + junit-jupiter + test + com.kumuluz.ee kumuluzee-jax-rs-jersey @@ -62,6 +66,7 @@ org.jboss.arquillian.junit5 arquillian-junit5-container + ${arquillian.version} test @@ -69,5 +74,10 @@ rest-assured test + + com.kumuluz.ee + kumuluzee-cdi-weld + test + \ No newline at end of file diff --git a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/MainWrapper.java b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/MainWrapper.java index d92c26d..c9b651c 100644 --- a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/MainWrapper.java +++ b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/MainWrapper.java @@ -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(); @@ -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 servlets = server.getRegisteredServlets(); + List servlets = ((ServletServer) server).getRegisteredServlets(); for (ServletWrapper s : servlets) { metadataSb.append(s.getName()).append(':').append(s.getContextPath()).append('\t'); } @@ -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); } diff --git a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/ServletWebListener.java b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/ServletWebListener.java index a39b81c..6251fc4 100644 --- a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/ServletWebListener.java +++ b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/assets/ServletWebListener.java @@ -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 @@ -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) { diff --git a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/deployment/AbstractDeployment.java b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/deployment/AbstractDeployment.java index e721d68..3aac6c0 100644 --- a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/deployment/AbstractDeployment.java +++ b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/deployment/AbstractDeployment.java @@ -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; @@ -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); @@ -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) { diff --git a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/ArchiveUtils.java b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/ArchiveUtils.java index 86b605a..914e5dd 100644 --- a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/ArchiveUtils.java +++ b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/ArchiveUtils.java @@ -46,7 +46,6 @@ public class ArchiveUtils { private static final Logger LOG = Logger.getLogger(ArchiveUtils.class.getName()); private ArchiveUtils() { - throw new IllegalStateException("Utility class"); } /** @@ -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 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()); diff --git a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/OutputProcessor.java b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/OutputProcessor.java index 9796271..3f22662 100644 --- a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/OutputProcessor.java +++ b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/OutputProcessor.java @@ -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; } @@ -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) { diff --git a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/RequiredLibraries.java b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/RequiredLibraries.java index f378f6d..4cd52f4 100644 --- a/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/RequiredLibraries.java +++ b/kumuluzee-arquillian-container/src/main/java/com/kumuluz/ee/testing/arquillian/utils/RequiredLibraries.java @@ -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 = { @@ -129,15 +128,21 @@ public static Archive[] getRequiredLibraries(List deploymentLibs) { * @return A list of dependencies. */ private static List 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); + } } } diff --git a/kumuluzee-arquillian-container/src/test/java/com/kumuluz/ee/testing/arquillian/ShouldThrowExceptionTest.java b/kumuluzee-arquillian-container/src/test/java/com/kumuluz/ee/testing/arquillian/ShouldThrowExceptionTest.java index 1158b99..e9091c7 100644 --- a/kumuluzee-arquillian-container/src/test/java/com/kumuluz/ee/testing/arquillian/ShouldThrowExceptionTest.java +++ b/kumuluzee-arquillian-container/src/test/java/com/kumuluz/ee/testing/arquillian/ShouldThrowExceptionTest.java @@ -41,6 +41,7 @@ public class ShouldThrowExceptionTest { @Deployment + @ShouldThrowException(DeploymentException.class) public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClass(InvalidBean.class) @@ -48,7 +49,6 @@ public static JavaArchive createDeployment() { } @Test - @ShouldThrowException(DeploymentException.class) void ignored() { // NO-OP, see @ShouldThrowException above } diff --git a/pom.xml b/pom.xml index 5386511..0aaff0e 100644 --- a/pom.xml +++ b/pom.xml @@ -22,20 +22,21 @@ https://ee.kumuluz.com - 21 - 21 + 11 + 11 UTF-8 5.0.0-SNAPSHOT 1.8.0.Final 1.2.6 - 3.2.1 + 3.3.0 5.10.1 5.3.2 3.11.0 + 3.2.5 1.6.13 3.1.0 @@ -53,10 +54,10 @@ - Tilen Faganel - tfaga - tilen.faganel@me.com - https://github.com/TFaga + KumuluzEE Development Team + kumuluz + info@kumuluz.com + https://github.com/kumuluz @@ -97,14 +98,6 @@ pom import - - org.jboss.arquillian.jakarta - arquillian-parent-jakarta - ${arquillian.version} - pom - import - - org.jboss.shrinkwrap.resolver shrinkwrap-resolver-depchain @@ -139,14 +132,6 @@ - - - org.junit.jupiter - junit-jupiter - test - - - @@ -160,6 +145,11 @@ true + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} +