Skip to content

Commit

Permalink
Merge pull request #4103 from jamezp/RESTEASY-3388-6.2
Browse files Browse the repository at this point in the history
[RESTEASY-3388] Final migrations of JUnit 4 to JUnit 5
  • Loading branch information
jamezp authored Mar 22, 2024
2 parents 719214c + f1244be commit 2284d84
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 159 deletions.
23 changes: 10 additions & 13 deletions docbook/reference/en/en-US/modules/RESTEasy_Embedded_Container.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import io.undertow.servlet.api.DeploymentInfo;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
import org.jboss.resteasy.test.TestPortProvider;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.GET;
Expand All @@ -30,7 +30,6 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;
/**
Expand Down Expand Up @@ -58,19 +57,17 @@ public class UndertowTest
@Override
public Set<Class<?>> getClasses()
{
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(Resource.class);
return classes;
return Set.of(Resource.class);
}
}
@BeforeClass
@BeforeAll
public static void init() throws Exception
{
server = new UndertowJaxrsServer().start();
}
@AfterClass
@AfterAll
public static void stop() throws Exception
{
server.stop();
Expand All @@ -83,7 +80,7 @@ public class UndertowTest
Client client = ClientBuilder.newClient();
String val = client.target(TestPortProvider.generateURL("/base/test"))
.request().get(String.class);
Assert.assertEquals("hello world", val);
Assertions.assertEquals("hello world", val);
client.close();
}
Expand All @@ -94,7 +91,7 @@ public class UndertowTest
Client client = ClientBuilder.newClient();
String val = client.target(TestPortProvider.generateURL("/root/test"))
.request().get(String.class);
Assert.assertEquals("hello world", val);
Assertions.assertEquals("hello world", val);
client.close();
}
Expand All @@ -108,7 +105,7 @@ public class UndertowTest
Client client = ClientBuilder.newClient();
String val = client.target(TestPortProvider.generateURL("/di/base/test"))
.request().get(String.class);
Assert.assertEquals("hello world", val);
Assertions.assertEquals("hello world", val);
client.close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions providers/jaxb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import org.jboss.logging.Logger;
import org.jboss.resteasy.plugins.providers.jaxb.i18n.Messages;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
*
Expand All @@ -29,11 +29,11 @@ public void testLocale() throws Exception {
return;
}

Assert.assertEquals(getExpected(BASE + "05", "collectionWrappingFailedNamespace", "xyz", "http://localhost"),
Assertions.assertEquals(getExpected(BASE + "05", "collectionWrappingFailedNamespace", "xyz", "http://localhost"),
Messages.MESSAGES.collectionWrappingFailedNamespace("xyz", "http://localhost"));
Assert.assertEquals(getExpected(BASE + "10", "couldNotFindJAXBContextFinder", "xx/yy"),
Assertions.assertEquals(getExpected(BASE + "10", "couldNotFindJAXBContextFinder", "xx/yy"),
Messages.MESSAGES.couldNotFindJAXBContextFinder(new MediaType("xx", "yy")));
Assert.assertEquals(getExpected(BASE + "55", "validXmlRegistryCouldNotBeLocated", getClass()),
Assertions.assertEquals(getExpected(BASE + "55", "validXmlRegistryCouldNotBeLocated", getClass()),
Messages.MESSAGES.validXmlRegistryCouldNotBeLocated());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.Properties;

import org.jboss.logging.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

/**
*
Expand All @@ -20,12 +20,12 @@ public abstract class TestMessagesParent {
protected static Locale savedLocale;
protected Properties properties = new Properties();

@BeforeClass
@BeforeAll
public static void beforeClass() {
savedLocale = Locale.getDefault();
}

@AfterClass
@AfterAll
public static void afterClass() {
Locale.setDefault(savedLocale);
LOG.info("Reset default locale to: " + savedLocale);
Expand Down
4 changes: 2 additions & 2 deletions providers/resteasy-atom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</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 @@ -6,8 +6,8 @@

import org.jboss.logging.Logger;
import org.jboss.resteasy.plugins.providers.resteasy_atom.i18n.Messages;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
*
Expand All @@ -30,12 +30,12 @@ public void testLocale() throws Exception {
return;
}

Assert.assertEquals(getExpected(BASE + "00", "consructorMustBeCalled"), Messages.MESSAGES.consructorMustBeCalled());
Assert.assertEquals(getExpected(BASE + "05", "unableToFindJAXBContext", "xx/yy"),
Assertions.assertEquals(getExpected(BASE + "00", "consructorMustBeCalled"), Messages.MESSAGES.consructorMustBeCalled());
Assertions.assertEquals(getExpected(BASE + "05", "unableToFindJAXBContext", "xx/yy"),
Messages.MESSAGES.unableToFindJAXBContext(new MediaType("xx", "yy")));
Assert.assertEquals(getExpected(BASE + "10", "unableToMarshal", "xx/yy"),
Assertions.assertEquals(getExpected(BASE + "10", "unableToMarshal", "xx/yy"),
Messages.MESSAGES.unableToMarshal(new MediaType("xx", "yy")));
Assert.assertEquals(getExpected(BASE + "15", "unableToUnmarshal", "xx/yy"),
Assertions.assertEquals(getExpected(BASE + "15", "unableToUnmarshal", "xx/yy"),
Messages.MESSAGES.unableToUnmarshal(new MediaType("xx", "yy")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.Properties;

import org.jboss.logging.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

/**
*
Expand All @@ -20,12 +20,12 @@ public abstract class TestMessagesParent {
protected static Locale savedLocale;
protected Properties properties = new Properties();

@BeforeClass
@BeforeAll
public static void beforeClass() {
savedLocale = Locale.getDefault();
}

@AfterClass
@AfterAll
public static void afterClass() {
Locale.setDefault(savedLocale);
LOG.info("Reset default locale to: " + savedLocale);
Expand Down
4 changes: 2 additions & 2 deletions providers/resteasy-html/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</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,8 +4,8 @@

import org.jboss.logging.Logger;
import org.jboss.resteasy.plugins.providers.html.i18n.Messages;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
*
Expand All @@ -27,7 +27,8 @@ public void testLocale() throws Exception {
return;
}

Assert.assertEquals(getExpected(BASE + "00", "noDispatcherFound", "path"), Messages.MESSAGES.noDispatcherFound("path"));
Assertions.assertEquals(getExpected(BASE + "00", "noDispatcherFound", "path"),
Messages.MESSAGES.noDispatcherFound("path"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import java.util.Properties;

import org.jboss.logging.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

/**
*
Expand All @@ -20,12 +20,12 @@ public abstract class TestMessagesParent {
protected static Locale savedLocale;
protected Properties properties = new Properties();

@BeforeClass
@BeforeAll
public static void beforeClass() {
savedLocale = Locale.getDefault();
}

@AfterClass
@AfterAll
public static void afterClass() {
Locale.setDefault(savedLocale);
LOG.info("Reset default locale to: " + savedLocale);
Expand Down
66 changes: 0 additions & 66 deletions providers/resteasy-validator-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,71 +79,5 @@
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>i18n</id>
<activation>
<property>
<name>i18n</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/resources/org/jboss/resteasy/plugins/validation/i18n</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/test/resources/i18n</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>i18</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<reuseForks>false</reuseForks>
<includes>
<include>**/I18nTestMessages_*.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
7 changes: 0 additions & 7 deletions resteasy-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<version.jakarta.json.bind-api>3.0.0</version.jakarta.json.bind-api>
<version.jakarta.validation-api>3.0.2</version.jakarta.validation-api>
<version.org.junit>5.10.2</version.org.junit>
<version.junit>4.13.2</version.junit>
<version.stephenc.jcip.jcip-annotations>1.0-1</version.stephenc.jcip.jcip-annotations>
<version.org.apache.httpcomponents.httpclient>4.5.14</version.org.apache.httpcomponents.httpclient>
<version.org.apache.httpcomponents.httpcore>4.4.16</version.org.apache.httpcomponents.httpcore>
Expand Down Expand Up @@ -629,12 +628,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
9 changes: 4 additions & 5 deletions server-adapters/resteasy-netty4-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@
</dependency>

<!-- Test dependencies -->
<!-- Have to stay on Junit4 for this module due to arquillian dependency. see issue https://issues.redhat.com/browse/RESTEASY-3398-->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -73,8 +72,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit 2284d84

Please sign in to comment.