Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RESTEASY-3388] code changes supporting junit5 (integration-tests-emb… #4089

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions testsuite/integration-tests-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<name>RESTEasy Main testsuite: Embedded Server tests</name>

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

<dependency>
<groupId>org.jboss.resteasy</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import jakarta.ws.rs.core.Application;

import org.jboss.resteasy.core.se.ConfigurationOption;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

/**
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
Expand All @@ -42,12 +42,12 @@ public abstract class AbstractBootstrapTest {
protected Client client;
protected SeBootstrap.Instance instance;

@Before
@BeforeEach
public void createClient() {
client = ClientBuilder.newClient();
}

@After
@AfterEach
public void shutdown() throws Exception {
if (client != null) {
client.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import org.jboss.resteasy.embedded.test.core.basic.resource.ApplicationTestSingletonA;
import org.jboss.resteasy.embedded.test.core.basic.resource.ApplicationTestSingletonB;
import org.jboss.resteasy.spi.HttpResponseCodes;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

/**
* @tpChapter Embedded Containers
Expand All @@ -32,7 +32,7 @@ public class ApplicationTest extends AbstractBootstrapTest {
private static final String CONTENT_ERROR_MESSAGE = "Wrong content of response";
private static Index INDEX;

@BeforeClass
@BeforeAll
public static void configureIndex() throws Exception {
INDEX = Index.of(ApplicationTestResourceA.class,
ApplicationTestResourceB.class,
Expand All @@ -52,16 +52,16 @@ public void testExplicitA() throws Exception {
WebTarget base = client.target(generateURL("/a/explicit"));

String value = base.path("resources/a").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "a", value);
Assertions.assertEquals("a", value, CONTENT_ERROR_MESSAGE);

Response response = base.path("resources/b").request().get();
Assert.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());

value = base.path("singletons/a").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "a", value);
Assertions.assertEquals("a", value, CONTENT_ERROR_MESSAGE);

response = base.path("singletons/b").request().get();
Assert.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());
client.close();
}

Expand All @@ -77,16 +77,16 @@ public void testExplicitB() throws Exception {
WebTarget base = client.target(generateURL("/b/explicit"));

String value = base.path("resources/b").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "b", value);
Assertions.assertEquals("b", value, CONTENT_ERROR_MESSAGE);

Response response = base.path("resources/a").request().get();
Assert.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());

value = base.path("singletons/b").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "b", value);
Assertions.assertEquals("b", value, CONTENT_ERROR_MESSAGE);

response = base.path("singletons/a").request().get();
Assert.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_NOT_FOUND, response.getStatus());
client.close();
}

Expand All @@ -104,16 +104,16 @@ public void testScanned() throws Exception {
WebTarget base = client.target(generateURL("/scanned"));

String value = base.path("resources/a").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "a", value);
Assertions.assertEquals("a", value, CONTENT_ERROR_MESSAGE);

value = base.path("resources/b").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "b", value);
Assertions.assertEquals("b", value, CONTENT_ERROR_MESSAGE);

value = base.path("singletons/a").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "a", value);
Assertions.assertEquals("a", value, CONTENT_ERROR_MESSAGE);

value = base.path("singletons/b").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "b", value);
Assertions.assertEquals("b", value, CONTENT_ERROR_MESSAGE);
client.close();
}

Expand All @@ -135,16 +135,16 @@ public void testMapped() throws Exception {
WebTarget base = client.target(generateURL("/mapped"));

String value = base.path("resources/a").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "a", value);
Assertions.assertEquals("a", value, CONTENT_ERROR_MESSAGE);

value = base.path("resources/b").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "b", value);
Assertions.assertEquals("b", value, CONTENT_ERROR_MESSAGE);

value = base.path("singletons/a").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "a", value);
Assertions.assertEquals("a", value, CONTENT_ERROR_MESSAGE);

value = base.path("singletons/b").request().get(String.class);
Assert.assertEquals(CONTENT_ERROR_MESSAGE, "b", value);
Assertions.assertEquals("b", value, CONTENT_ERROR_MESSAGE);
client.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import org.jboss.resteasy.embedded.test.core.interceptors.resource.ReaderContextLinkedListEntityProvider;
import org.jboss.resteasy.embedded.test.core.interceptors.resource.ReaderContextResource;
import org.jboss.resteasy.embedded.test.core.interceptors.resource.ReaderContextSecondReaderInterceptor;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* @tpSubChapter
Expand All @@ -30,7 +30,7 @@
*/
public class ReaderContextTest extends AbstractBootstrapTest {

@Before
@BeforeEach
public void before() throws Exception {
start(new TestApplication(ReaderContextResource.class,
ReaderContextArrayListEntityProvider.class,
Expand Down Expand Up @@ -59,13 +59,12 @@ public void readerContextOnClientTest() {
ReaderContextFirstReaderInterceptor.class.getName());
@SuppressWarnings("unchecked")
List<String> list = response.readEntity(List.class);
Assert.assertTrue("Returned list in not instance of ArrayList", ArrayList.class.isInstance(list));
Assertions.assertTrue(ArrayList.class.isInstance(list), "Returned list in not instance of ArrayList");
String entity = list.get(0);
Assert.assertTrue("Wrong interceptor type in response",
entity.contains(ReaderContextSecondReaderInterceptor.class.getName()));
Assert.assertTrue("Wrong interceptor annotation in response",
entity.contains(ReaderContextSecondReaderInterceptor.class.getAnnotations()[0]
.annotationType().getName()));
Assertions.assertTrue(entity.contains(ReaderContextSecondReaderInterceptor.class.getName()),
"Wrong interceptor type in response");
Assertions.assertTrue(entity.contains(ReaderContextSecondReaderInterceptor.class.getAnnotations()[0]
.annotationType().getName()), "Wrong interceptor annotation in response");

client.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import org.jboss.resteasy.embedded.test.AbstractBootstrapTest;
import org.jboss.resteasy.spi.HttpResponseCodes;
import org.jboss.resteasy.utils.TestUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* @tpSubChapter Verify ValidatorFactory is found in absence of CDI
Expand Down Expand Up @@ -49,7 +49,7 @@ public Response string(@Size(min = 3) String s) {
}

//////////////////////////////////////////////////////////////////////////////
@Before
@BeforeEach
public void before() throws Exception {
start(new TestApp());
}
Expand All @@ -60,10 +60,10 @@ public void before() throws Exception {
public void testValidate() throws Exception {
Invocation.Builder request = client.target("http://localhost:8081/test/validate/x").request();
Response response = request.get();
Assert.assertEquals(HttpResponseCodes.SC_BAD_REQUEST, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_BAD_REQUEST, response.getStatus());
String header = response.getHeaderString(Validation.VALIDATION_HEADER);
Assert.assertNotNull("Validation header is missing", header);
Assert.assertTrue("Wrong validation header", Boolean.valueOf(header));
Assertions.assertNotNull(header, "Validation header is missing");
Assertions.assertTrue(Boolean.valueOf(header), "Wrong validation header");
String entity = response.readEntity(String.class);
ViolationReport r = new ViolationReport(entity);
TestUtil.countViolations(r, 0, 0, 1, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.jboss.resteasy.embedded.test.TestApplication;
import org.jboss.resteasy.embedded.test.interceptor.resource.ClientRequestFilterImpl;
import org.jboss.resteasy.embedded.test.interceptor.resource.ClientResource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* @tpSubChapter
Expand All @@ -21,7 +21,7 @@
*/
public class ClientRequestFilterRegistrationTest extends AbstractBootstrapTest {

@Before
@BeforeEach
public void before() throws Exception {
start(new TestApplication(ClientResource.class, ClientRequestFilterImpl.class));
}
Expand All @@ -30,7 +30,7 @@ public void before() throws Exception {
public void filterRegisteredTest() throws Exception {
WebTarget base = client.target(generateURL("/") + "testIt");
Response response = base.request().get();
Assert.assertEquals(456, response.getStatus());
Assertions.assertEquals(456, response.getStatus());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.jboss.resteasy.embedded.test.interceptor.resource.PriorityExecutionContainerResponseFilterMin;
import org.jboss.resteasy.embedded.test.interceptor.resource.PriorityExecutionResource;
import org.jboss.resteasy.spi.HttpResponseCodes;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* @tpSubChapter
Expand All @@ -49,7 +49,7 @@ public class PriorityExecutionTest extends AbstractBootstrapTest {
public static Logger logger = Logger.getLogger(PriorityExecutionTest.class);
private static final String WRONG_ORDER_ERROR_MSG = "Wrong order of interceptor execution";

@Before
@BeforeEach
public void setup() throws Exception {
Set<Class<?>> actualProviderClassList = new LinkedHashSet<>();
actualProviderClassList.add(PriorityExecutionResource.class);
Expand Down Expand Up @@ -93,33 +93,33 @@ public void testPriority() throws Exception {
Response response = client.target(generateURL("/test")).request().get();
response.bufferEntity();
logger.info(response.readEntity(String.class));
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assert.assertEquals("Wrong content of response", "test", response.getEntity());
Assertions.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assertions.assertEquals("test", response.getEntity(), "Wrong content of response");

// client filters
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientRequestFilterMin", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientRequestFilter1", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientRequestFilter2", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientRequestFilter3", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientRequestFilterMax", interceptors.poll());
Assertions.assertEquals("PriorityExecutionClientRequestFilterMin", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientRequestFilter1", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientRequestFilter2", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientRequestFilter3", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientRequestFilterMax", interceptors.poll(), WRONG_ORDER_ERROR_MSG);

// server filters
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerRequestFilterMin", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerRequestFilter1", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerRequestFilter2", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerRequestFilter3", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerRequestFilterMax", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerResponseFilterMax", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerResponseFilter3", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerResponseFilter2", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerResponseFilter1", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionContainerResponseFilterMin", interceptors.poll());
Assertions.assertEquals("PriorityExecutionContainerRequestFilterMin", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerRequestFilter1", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerRequestFilter2", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerRequestFilter3", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerRequestFilterMax", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerResponseFilterMax", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerResponseFilter3", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerResponseFilter2", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerResponseFilter1", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionContainerResponseFilterMin", interceptors.poll(), WRONG_ORDER_ERROR_MSG);

// client filters
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientResponseFilterMax", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientResponseFilter3", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientResponseFilter2", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientResponseFilter1", interceptors.poll());
Assert.assertEquals(WRONG_ORDER_ERROR_MSG, "PriorityExecutionClientResponseFilterMin", interceptors.poll());
Assertions.assertEquals("PriorityExecutionClientResponseFilterMax", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientResponseFilter3", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientResponseFilter2", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientResponseFilter1", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
Assertions.assertEquals("PriorityExecutionClientResponseFilterMin", interceptors.poll(), WRONG_ORDER_ERROR_MSG);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.jboss.resteasy.embedded.test.providers.custom.resource.ReaderWriterResource;
import org.jboss.resteasy.embedded.test.providers.custom.resource.WriterNotBuiltinTestWriter;
import org.jboss.resteasy.spi.HttpResponseCodes;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* @tpSubChapter
Expand All @@ -23,7 +23,7 @@
*/
public class WriterNotBuiltinTest extends AbstractBootstrapTest {

@Before
@BeforeEach
public void setup() throws Exception {
start(new TestApplication(ReaderWriterResource.class, WriterNotBuiltinTestWriter.class),
SeBootstrap.Configuration.builder()
Expand All @@ -41,9 +41,9 @@ public void setup() throws Exception {
@Test
public void test1New() throws Exception {
Response response = client.target(generateURL("/string")).request().get();
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assert.assertEquals("text/plain;charset=UTF-8", response.getStringHeaders().getFirst("content-type"));
Assert.assertEquals("Response contains wrong content", "hello world", response.readEntity(String.class));
Assert.assertTrue("Wrong MessageBodyWriter was used", WriterNotBuiltinTestWriter.used);
Assertions.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assertions.assertEquals("text/plain;charset=UTF-8", response.getStringHeaders().getFirst("content-type"));
Assertions.assertEquals("hello world", response.readEntity(String.class), "Response contains wrong content");
Assertions.assertTrue(WriterNotBuiltinTestWriter.used, "Wrong MessageBodyWriter was used");
}
}