Skip to content

Commit

Permalink
Merge pull request #533 from jamezp/WFARQ-149-open-rewrite
Browse files Browse the repository at this point in the history
[WFARQ-149] Migrate to using JUnit 5 for testing
  • Loading branch information
jamezp authored Jan 10, 2025
2 parents 992116d + e8b604e commit 6661e1a
Show file tree
Hide file tree
Showing 85 changed files with 687 additions and 675 deletions.
7 changes: 0 additions & 7 deletions bom/project-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<version.org.wildfly.full>31.0.1.Final</version.org.wildfly.full>
<version.org.wildfly.launcher>1.0.0.Final</version.org.wildfly.launcher>
<version.io.smallrye.jandex>3.1.6</version.io.smallrye.jandex>
<version.junit>4.13.2</version.junit>
<version.org.junit>5.11.3</version.org.junit>
<version.org.jboss.arquillian.core>1.9.2.Final</version.org.jboss.arquillian.core>
<version.org.jboss.arquillian.jakarta>10.0.0.Final</version.org.jboss.arquillian.jakarta>
Expand Down Expand Up @@ -128,12 +127,6 @@
<version>${version.jakarta.ws.rs-api}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>${version.junit}</version>
</dependency>

<dependency>
<groupId>org.jboss</groupId>
Expand Down
8 changes: 4 additions & 4 deletions common-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,58 @@
*/
package org.jboss.as.arquillian.container;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.util.List;

import org.jboss.as.arquillian.container.domain.ParameterUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* TestCases for {@link ParameterUtils}.
*
*/
public class ParameterUtilsTest {
class ParameterUtilsTest {

private static final String PARAM_WITH_WHITESPACE = "-Djboss.server.base.dir=Does contain whitespaces";
private static final String QUOTED_PARAM_WITH_WHITESPACE = "\"" + PARAM_WITH_WHITESPACE + "\"";
private static final String PARAM_WITHOUT_WHITESPACE = "-Djboss.http.port=8080";

@Test
public void mixedParams() {
void mixedParams() {
List<String> splitParams = ParameterUtils
.splitParams(QUOTED_PARAM_WITH_WHITESPACE.concat(" ").concat(PARAM_WITHOUT_WHITESPACE).concat(" ")
.concat(QUOTED_PARAM_WITH_WHITESPACE).concat(" ").concat(QUOTED_PARAM_WITH_WHITESPACE).concat(" ")
.concat(PARAM_WITHOUT_WHITESPACE).concat(" ").concat(QUOTED_PARAM_WITH_WHITESPACE));
Assert.assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITH_WHITESPACE,
assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITH_WHITESPACE,
PARAM_WITH_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITH_WHITESPACE }, splitParams.toArray(new String[0]));
}

@Test
public void singleParamWithWS() {
void singleParamWithWS() {
List<String> splitParams = ParameterUtils.splitParams(QUOTED_PARAM_WITH_WHITESPACE);
Assert.assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE }, splitParams.toArray(new String[0]));
assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE }, splitParams.toArray(new String[0]));
}

@Test
public void singleParamWithoutWS() {
void singleParamWithoutWS() {
List<String> splitParams = ParameterUtils.splitParams(PARAM_WITHOUT_WHITESPACE);
Assert.assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE }, splitParams.toArray(new String[0]));
assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE }, splitParams.toArray(new String[0]));
}

@Test
public void onlyParamsWithWhitespaces() {
void onlyParamsWithWhitespaces() {
List<String> splitParams = ParameterUtils.splitParams(QUOTED_PARAM_WITH_WHITESPACE.concat(" ")
.concat(QUOTED_PARAM_WITH_WHITESPACE).concat(QUOTED_PARAM_WITH_WHITESPACE));
Assert.assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE },
assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE },
splitParams.toArray(new String[0]));
}

@Test
public void onlyParamsWithoutWhitespaces() {
void onlyParamsWithoutWhitespaces() {
List<String> splitParams = ParameterUtils.splitParams(PARAM_WITHOUT_WHITESPACE.concat(" ")
.concat(PARAM_WITHOUT_WHITESPACE).concat(" ").concat(PARAM_WITHOUT_WHITESPACE));
Assert.assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE },
assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE },
splitParams.toArray(new String[0]));
}
}
12 changes: 5 additions & 7 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,13 @@
<artifactId>wildfly-plugin-tools</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
<artifactId>shrinkwrap-descriptors-impl-base</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
<artifactId>shrinkwrap-descriptors-impl-base</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@
*/
package org.jboss.as.arquillian.container;

import org.junit.Assert;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ManagementClientTest {
import org.junit.jupiter.api.Test;

class ManagementClientTest {

@Test
public void shouldParseBindAllAsLocalhost() {
void shouldParseBindAllAsLocalhost() {
String sourceIp = "0.0.0.0";
String parsedIp = ManagementClient.formatIP(sourceIp);
Assert.assertEquals("127.0.0.1", parsedIp);
assertEquals("127.0.0.1", parsedIp);
}

@Test
public void shouldParseLocalIPAsNormalIP() {
void shouldParseLocalIPAsNormalIP() {
String sourceIp = "10.1.2.3";
String formattedIp = ManagementClient.formatIP(sourceIp);
Assert.assertEquals(sourceIp, formattedIp);
assertEquals(sourceIp, formattedIp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,57 @@
*/
package org.jboss.as.arquillian.container;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;

import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* TestCases for {@link ParameterUtils}.
*
*/
public class ParameterUtilsTest {
class ParameterUtilsTest {

private static final String PARAM_WITH_WHITESPACE = "-Djboss.server.base.dir=Does contain whitespaces";
private static final String QUOTED_PARAM_WITH_WHITESPACE = "\"" + PARAM_WITH_WHITESPACE + "\"";
private static final String PARAM_WITHOUT_WHITESPACE = "-Djboss.http.port=8080";

@Test
public void mixedParams() {
void mixedParams() {
List<String> splitParams = ParameterUtils
.splitParams(QUOTED_PARAM_WITH_WHITESPACE.concat(" ").concat(PARAM_WITHOUT_WHITESPACE).concat(" ")
.concat(QUOTED_PARAM_WITH_WHITESPACE).concat(" ").concat(QUOTED_PARAM_WITH_WHITESPACE).concat(" ")
.concat(PARAM_WITHOUT_WHITESPACE).concat(" ").concat(QUOTED_PARAM_WITH_WHITESPACE));
Assert.assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITH_WHITESPACE,
assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITH_WHITESPACE,
PARAM_WITH_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITH_WHITESPACE }, splitParams.toArray(new String[0]));
}

@Test
public void singleParamWithWS() {
void singleParamWithWS() {
List<String> splitParams = ParameterUtils.splitParams(QUOTED_PARAM_WITH_WHITESPACE);
Assert.assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE }, splitParams.toArray(new String[0]));
assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE }, splitParams.toArray(new String[0]));
}

@Test
public void singleParamWithoutWS() {
void singleParamWithoutWS() {
List<String> splitParams = ParameterUtils.splitParams(PARAM_WITHOUT_WHITESPACE);
Assert.assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE }, splitParams.toArray(new String[0]));
assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE }, splitParams.toArray(new String[0]));
}

@Test
public void onlyParamsWithWhitespaces() {
void onlyParamsWithWhitespaces() {
List<String> splitParams = ParameterUtils.splitParams(QUOTED_PARAM_WITH_WHITESPACE.concat(" ")
.concat(QUOTED_PARAM_WITH_WHITESPACE).concat(QUOTED_PARAM_WITH_WHITESPACE));
Assert.assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE },
assertArrayEquals(new String[] { PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE, PARAM_WITH_WHITESPACE },
splitParams.toArray(new String[0]));
}

@Test
public void onlyParamsWithoutWhitespaces() {
void onlyParamsWithoutWhitespaces() {
List<String> splitParams = ParameterUtils.splitParams(PARAM_WITHOUT_WHITESPACE.concat(" ")
.concat(PARAM_WITHOUT_WHITESPACE).concat(" ").concat(PARAM_WITHOUT_WHITESPACE));
Assert.assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE },
assertArrayEquals(new String[] { PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE, PARAM_WITHOUT_WHITESPACE },
splitParams.toArray(new String[0]));
}
}
20 changes: 12 additions & 8 deletions container-bootable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,19 @@
<groupId>org.wildfly.launcher</groupId>
<artifactId>wildfly-launcher</artifactId>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -112,7 +116,7 @@
<phase>compile</phase>
<configuration>
<bootable-jar>true</bootable-jar>
<skip-deployment>true</skip-deployment>
<skipDeployment>true</skipDeployment>
<bootable-jar-name>test-wildfly.jar</bootable-jar-name>
</configuration>
</execution>
Expand Down Expand Up @@ -145,7 +149,7 @@
<include>**/*TestCase.java</include>
<include>**/*TestSuite.java</include>
</includes>
<excludedGroups>org.jboss.as.arquillian.container.managed.manual.ManualMode</excludedGroups>
<excludedGroups>ManualMode</excludedGroups>
<excludes>
<exclude>**/ThreadContextClassloaderTest.java</exclude>
<!-- These run as part of test suites -->
Expand Down Expand Up @@ -183,7 +187,7 @@
</goals>
<configuration>
<skip>false</skip>
<groups>org.jboss.as.arquillian.container.managed.manual.ManualMode</groups>
<groups>ManualMode</groups>
<systemPropertyVariables>
<arquillian.xml>manual-arquillian.xml</arquillian.xml>
<install.dir>${jboss.home}</install.dir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* @author <a href="[email protected]">Kabir Khan</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.container.ArchiveDeployer;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Test deploying through an injected {@link ArchiveDeployer}.
*
* @author <a href="mailto:[email protected]">James R. Perkins</a>
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public class ClientDeploymentTestCase {

Expand All @@ -37,29 +37,29 @@ public static WebArchive create() {

@Test
public void globalDeploymentTest(@ArquillianResource ManagementClient client) throws Exception {
Assert.assertNotNull("Expected the ArchiveDeployer to be injected", deployer);
Assertions.assertNotNull(deployer, "Expected the ArchiveDeployer to be injected");
testDeploy(deployer, client);
}

@Test
public void parameterDeploymentTest(@ArquillianResource ManagementClient client,
@ArquillianResource ArchiveDeployer deployer) throws Exception {
Assert.assertNotNull("Expected the ArchiveDeployer to be injected", deployer);
Assertions.assertNotNull(deployer, "Expected the ArchiveDeployer to be injected");
testDeploy(deployer, client);
}

private void testDeploy(final ArchiveDeployer deployer, final ManagementClient client) throws Exception {
final WebArchive deployment = createDeployment("test-client-deployment.war");
Assert.assertEquals(deployment.getName(), deployer.deploy(deployment));
Assertions.assertEquals(deployment.getName(), deployer.deploy(deployment));

// Check the server for the deployment
final ModelNode address = Operations.createAddress("deployment", deployment.getName());
final ModelNode result = client.getControllerClient()
.execute(Operations.createReadAttributeOperation(address, "status"));
if (!Operations.isSuccessfulOutcome(result)) {
Assert.fail(Operations.getFailureDescription(result).asString());
Assertions.fail(Operations.getFailureDescription(result).asString());
}
Assert.assertEquals("OK", Operations.readResult(result).asString());
Assertions.assertEquals("OK", Operations.readResult(result).asString());
deployer.undeploy(deployment.getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
package org.jboss.as.arquillian.container.managed;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.msc.service.ServiceActivator;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Tests basic deployment
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
public class DeploymentTestCase {

@Deployment
Expand All @@ -29,7 +29,7 @@ public static JavaArchive create() {

@Test
public void testSystemPropSet() throws Exception {
Assert.assertEquals(SystemPropertyServiceActivator.VALUE,
Assertions.assertEquals(SystemPropertyServiceActivator.VALUE,
System.getProperty(SystemPropertyServiceActivator.TEST_PROPERTY));
}
}
Loading

0 comments on commit 6661e1a

Please sign in to comment.