From a6fba871190f25750c282b04018c11a5a9df268f Mon Sep 17 00:00:00 2001 From: Radoslav Husar Date: Thu, 11 Jul 2024 11:36:27 +0200 Subject: [PATCH] Move WildFly integration tests from ear module to integration-tests module and introduce Arquillian and JUnit 5 (resolves #470) --- clusterbench-ee10-ear/pom.xml | 123 +------------ integration-tests/pom.xml | 13 +- .../wildfly}/jgroups.cli | 0 integration-tests/wildfly/pom.xml | 162 ++++++++++++++++++ .../it/wildfly/AbstractWildFlyIT.java | 33 ++++ .../it/wildfly}/DebugServletIT.java | 9 +- .../it/wildfly}/HttpResponseServletIT.java | 9 +- .../it/wildfly}/NodeNameServletIT.java | 13 +- .../wildfly/src/test/resources/arquillian.xml | 19 ++ 9 files changed, 247 insertions(+), 134 deletions(-) rename {clusterbench-ee10-ear => integration-tests/wildfly}/jgroups.cli (100%) create mode 100644 integration-tests/wildfly/pom.xml create mode 100644 integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/AbstractWildFlyIT.java rename {clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear => integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly}/DebugServletIT.java (85%) rename {clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear => integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly}/HttpResponseServletIT.java (87%) rename {clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear => integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly}/NodeNameServletIT.java (83%) create mode 100644 integration-tests/wildfly/src/test/resources/arquillian.xml diff --git a/clusterbench-ee10-ear/pom.xml b/clusterbench-ee10-ear/pom.xml index a34d4e1c..6122d7ba 100644 --- a/clusterbench-ee10-ear/pom.xml +++ b/clusterbench-ee10-ear/pom.xml @@ -1,4 +1,5 @@ + - - - testCompile - - testCompile - - - org.apache.maven.plugins @@ -75,26 +67,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - - failsafe-integration-test - integration-test - - integration-test - - - - failsafe-verify - verify - - verify - - - - @@ -126,85 +98,9 @@ granular war - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.apache.httpcomponents - httpclient - test - - - integration - - - !skipTests - - - - - - org.wildfly.plugins - wildfly-maven-plugin - - - standalone-ha.xml - - -Djboss.node.name=clusterbench-1 - - ${version.org.wildfly} - - - - integration-test-wildfly-deploy - pre-integration-test - - start - execute-commands - deploy - - - true - - - - - - - integration-test-wildfly-undeploy - post-integration-test - - undeploy - shutdown - - - - - - - - - integration-quickly - - - quickly - - - - true - - @@ -241,23 +137,6 @@ ROOT.ear - - integration-test-wildfly-deploy - none - - - integration-test-wildfly-undeploy - none - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - none - diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 5f5d766a..e32e4856 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -18,21 +18,26 @@ + + org.junit + junit-bom + ${version.org.junit.jupiter} + pom + import + org.jboss.arquillian arquillian-bom ${version.org.jboss.arquillian} - import pom + import - tomcat-10.1 + wildfly \ No newline at end of file diff --git a/clusterbench-ee10-ear/jgroups.cli b/integration-tests/wildfly/jgroups.cli similarity index 100% rename from clusterbench-ee10-ear/jgroups.cli rename to integration-tests/wildfly/jgroups.cli diff --git a/integration-tests/wildfly/pom.xml b/integration-tests/wildfly/pom.xml new file mode 100644 index 00000000..f6f0c3a9 --- /dev/null +++ b/integration-tests/wildfly/pom.xml @@ -0,0 +1,162 @@ + + + + + + 4.0.0 + + + org.jboss.test + clusterbench-it-parent + 10.0.0.Final-SNAPSHOT + + + clusterbench-it-wildfly + jar + + + ${project.build.directory}/wildfly + + + + + + org.junit + junit-bom + ${version.org.junit.jupiter} + pom + import + + + org.jboss.arquillian + arquillian-bom + ${version.org.jboss.arquillian} + import + pom + + + + + + + org.junit.jupiter + junit-jupiter + test + + + org.jboss.arquillian.junit5 + arquillian-junit5-core + test + + + org.jboss.arquillian.junit5 + arquillian-junit5-container + test + + + org.apache.httpcomponents + httpclient + test + + + org.wildfly.arquillian + wildfly-arquillian-container-managed + 5.1.0.Beta2 + test + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-war + generate-test-resources + + copy + + + + + org.jboss.test + clusterbench-ee10-ear + ${project.version} + ear + true + ${project.build.directory} + + + true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + smoke-test + integration-test + + integration-test + verify + + + + ${jboss.home} + + false + + org.jboss.arquillian.junit:arquillian-junit-container + org.jboss.arquillian.junit:arquillian-junit-core + + + + + + + + org.wildfly.plugins + wildfly-maven-plugin + ${version.org.wildfly.maven.plugin} + + ${jboss.home} + ${jboss.home} + + + org.wildfly + wildfly-ee-galleon-pack + ${version.org.wildfly} + + + + true + + + cloud-server + jsf + ejb + web-clustering + + + + + provision-server-for-testing + + provision + + process-test-classes + + + + + + + \ No newline at end of file diff --git a/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/AbstractWildFlyIT.java b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/AbstractWildFlyIT.java new file mode 100644 index 00000000..80ddc170 --- /dev/null +++ b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/AbstractWildFlyIT.java @@ -0,0 +1,33 @@ +/* + * Copyright The ClusterBench Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.jboss.test.clusterbench.it.wildfly; + +import java.io.File; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.importer.ZipImporter; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; + +/** + * Imports previously built enterprise archive (ear) for automatic deployment and allowing resource injection. + * + * TODO: move this to a suite scope, so it's only done once per execution. + * + * @author Radoslav Husar + */ +public abstract class AbstractWildFlyIT { + + @Deployment(testable = false) + public static Archive deployment() { + return ShrinkWrap + .create(ZipImporter.class, "clusterbench.ear") + .importFrom(new File("target/clusterbench-ee10-ear.ear")) + .as(EnterpriseArchive.class); + } + +} diff --git a/clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/DebugServletIT.java b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/DebugServletIT.java similarity index 85% rename from clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/DebugServletIT.java rename to integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/DebugServletIT.java index f709877c..ac1651cb 100644 --- a/clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/DebugServletIT.java +++ b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/DebugServletIT.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.test.clusterbench.ear; +package org.jboss.test.clusterbench.it.wildfly; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -17,12 +17,17 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.jboss.arquillian.container.test.api.RunAsClient; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.jboss.arquillian.junit5.ArquillianExtension; /** * @author Radoslav Husar */ -public class DebugServletIT { +@ExtendWith(ArquillianExtension.class) +@RunAsClient +public class DebugServletIT extends AbstractWildFlyIT { public static final String JBOSS_NODE_NAME = "clusterbench-1"; diff --git a/clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/HttpResponseServletIT.java b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/HttpResponseServletIT.java similarity index 87% rename from clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/HttpResponseServletIT.java rename to integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/HttpResponseServletIT.java index cab315b0..cd735a37 100644 --- a/clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/HttpResponseServletIT.java +++ b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/HttpResponseServletIT.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.test.clusterbench.ear; +package org.jboss.test.clusterbench.it.wildfly; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -17,14 +17,19 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit5.ArquillianExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * Test for {@link org.jboss.test.clusterbench.web.debug.HttpResponseServlet}. * * @author Radoslav Husar */ -public class HttpResponseServletIT { +@ExtendWith(ArquillianExtension.class) +@RunAsClient +public class HttpResponseServletIT extends AbstractWildFlyIT { @Test public void test() throws Exception { diff --git a/clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/NodeNameServletIT.java b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/NodeNameServletIT.java similarity index 83% rename from clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/NodeNameServletIT.java rename to integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/NodeNameServletIT.java index 6673a1a8..f8ba3ed4 100644 --- a/clusterbench-ee10-ear/src/test/java/org/jboss/test/clusterbench/ear/NodeNameServletIT.java +++ b/integration-tests/wildfly/src/test/java/org/jboss/test/clusterbench/it/wildfly/NodeNameServletIT.java @@ -3,10 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.jboss.test.clusterbench.ear; +package org.jboss.test.clusterbench.it.wildfly; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; @@ -18,12 +17,18 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * @author Radoslav Husar */ -public class NodeNameServletIT { +@ExtendWith(ArquillianExtension.class) +@RunAsClient +public class NodeNameServletIT extends AbstractWildFlyIT { @Test public void test() throws Exception { @@ -38,7 +43,7 @@ public void test() throws Exception { // Also ensure session is created with ?create=true Optional
header = Arrays.stream(response.getAllHeaders()).filter(h -> Arrays.stream(h.getElements()).anyMatch(e -> e.getName().equals("JSESSIONID"))).findAny(); - assertFalse(header.isPresent()); + Assertions.assertFalse(header.isPresent()); } httpGet = new HttpGet("http://localhost:8080/clusterbench/jboss-node-name?create=true"); diff --git a/integration-tests/wildfly/src/test/resources/arquillian.xml b/integration-tests/wildfly/src/test/resources/arquillian.xml new file mode 100644 index 00000000..f8115c95 --- /dev/null +++ b/integration-tests/wildfly/src/test/resources/arquillian.xml @@ -0,0 +1,19 @@ + + + + + + + + + + -Djboss.node.name=clusterbench-1 + ${jboss.home} + + + + +