Skip to content

Commit

Permalink
[RESTEASY-3388] code changes supporting junit5 (integration-tests).
Browse files Browse the repository at this point in the history
  • Loading branch information
rsearls committed Feb 15, 2024
1 parent 31441ed commit 9632435
Show file tree
Hide file tree
Showing 734 changed files with 12,510 additions and 11,768 deletions.
10 changes: 10 additions & 0 deletions testsuite/integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,16 @@
<artifactId>jboss-logging-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,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.resteasy.test.asynch.resource.AsyncGenericEntityMessageBodyWriter;
import org.jboss.resteasy.test.asynch.resource.AsyncGenericEntityResource;
import org.jboss.resteasy.utils.PortProviderUtil;
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
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;

/**
* @tpSubChapter Asynchronous RESTEasy
* @tpChapter Integration tests
* @tpTestCaseDetails Test getting GenericType from return entity.
* @tpSince RESTEasy 3.7.0
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public class AsyncGenericEntityTest {

Expand All @@ -49,8 +49,8 @@ public void testCalls() {
Client client = ClientBuilder.newClient();
Builder request = client.target(generateURL("/test")).request();
Response response = request.get();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("ok", response.readEntity(String.class));
Assertions.assertEquals(200, response.getStatus());
Assertions.assertEquals("ok", response.readEntity(String.class));
response.close();
client.close();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.resteasy.test.asynch;

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

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
Expand All @@ -9,7 +9,7 @@

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.logging.Logger;
import org.jboss.resteasy.test.asynch.resource.AsyncInjectionBooleanInjector;
import org.jboss.resteasy.test.asynch.resource.AsyncInjectionByteInjector;
Expand All @@ -34,16 +34,16 @@
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* @tpSubChapter CDI
* @tpChapter Integration tests
* @tpTestCaseDetails Async Request Filter test.
* @tpSince RESTEasy 4.0.0
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public class AsyncInjectionTest {
protected static final Logger log = Logger.getLogger(AsyncInjectionTest.class.getName());
Expand Down Expand Up @@ -80,7 +80,7 @@ public void testAsyncInjection() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-200 result: " + response.readEntity(String.class), 200, response.getStatus());
assertEquals(200, response.getStatus(), "Non-200 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -97,7 +97,7 @@ public void testAsyncInjectionInterface() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-200 result: " + response.readEntity(String.class), 200, response.getStatus());
assertEquals(200, response.getStatus(), "Non-200 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -114,7 +114,7 @@ public void testAsyncInjectionResolved() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-200 result: " + response.readEntity(String.class), 200, response.getStatus());
assertEquals(200, response.getStatus(), "Non-200 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -131,7 +131,7 @@ public void testAsyncInjectionSuspended() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-200 result: " + response.readEntity(String.class), 200, response.getStatus());
assertEquals(200, response.getStatus(), "Non-200 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -148,7 +148,7 @@ public void testAsyncInjectionException() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-202 result: " + response.readEntity(String.class), 202, response.getStatus());
assertEquals(202, response.getStatus(), "Non-202 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -165,7 +165,7 @@ public void testAsyncInjectionExceptionAsync() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-202 result: " + response.readEntity(String.class), 202, response.getStatus());
assertEquals(202, response.getStatus(), "Non-202 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -182,7 +182,7 @@ public void testAsyncInjectionExceptionLate() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-200 result: " + response.readEntity(String.class), 200, response.getStatus());
assertEquals(200, response.getStatus(), "Non-200 result: " + response.readEntity(String.class));

client.close();
}
Expand All @@ -199,7 +199,7 @@ public void testAsyncInjectionPrimitives() throws Exception {

Response response = base.request()
.get();
assertEquals("Non-200 result: " + response.readEntity(String.class), 200, response.getStatus());
assertEquals(200, response.getStatus(), "Non-200 result: " + response.readEntity(String.class));

client.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import jakarta.ws.rs.core.Response;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.logging.Logger;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.spi.HttpResponseCodes;
Expand All @@ -21,19 +21,19 @@
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* @tpSubChapter Asynchronous RESTEasy
* @tpChapter Integration tests
* @tpTestCaseDetails Regression test for RESTEASY-767
* @tpSince RESTEasy 3.0.16
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
public class AsyncPostProcessingTest {

private static Logger logger = Logger.getLogger(AsyncPostProcessingTest.class);
Expand Down Expand Up @@ -64,12 +64,12 @@ private String generateURL(String path) {
return PortProviderUtil.generateURL(path, AsyncPostProcessingTest.class.getSimpleName());
}

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

@After
@AfterEach
public void after() throws Exception {
client.close();
}
Expand All @@ -83,15 +83,17 @@ public void testSync() throws Exception {
reset();
Response response = client.target(generateURL("/sync")).request().get();
logger.info("Status: " + response.getStatus());
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
logger.info("TestMessageBodyWriterInterceptor.called: " + AsyncPostProcessingMsgBodyWriterInterceptor.called);
logger.info("TestPostProcessInterceptor.called: " + AsyncPostProcessingInterceptor.called);
response.bufferEntity();
logger.info("returned entity: " + response.readEntity(String.class));
Assert.assertTrue("AsyncPostProcessingMsgBodyWriterInterceptor interceptor was not called",
AsyncPostProcessingMsgBodyWriterInterceptor.called);
Assert.assertTrue("AsyncPostProcessingInterceptor interceptor was not called", AsyncPostProcessingInterceptor.called);
Assert.assertEquals("Entity has wrong content", "sync", response.readEntity(String.class));
Assertions.assertTrue(AsyncPostProcessingMsgBodyWriterInterceptor.called,
"AsyncPostProcessingMsgBodyWriterInterceptor interceptor was not called");
Assertions.assertTrue(AsyncPostProcessingInterceptor.called,
"AsyncPostProcessingInterceptor interceptor was not called");
Assertions.assertEquals("sync", response.readEntity(String.class),
"Entity has wrong content");
}

/**
Expand All @@ -103,15 +105,17 @@ public void testAsyncWithDelay() throws Exception {
reset();
Response response = client.target(generateURL("/async/delay")).request().get();
logger.info("Status: " + response.getStatus());
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
logger.info("TestMessageBodyWriterInterceptor.called: " + AsyncPostProcessingMsgBodyWriterInterceptor.called);
logger.info("TestPostProcessInterceptor.called: " + AsyncPostProcessingInterceptor.called);
response.bufferEntity();
logger.info("returned entity: " + response.readEntity(String.class));
Assert.assertTrue("AsyncPostProcessingMsgBodyWriterInterceptor interceptor was not called",
AsyncPostProcessingMsgBodyWriterInterceptor.called);
Assert.assertTrue("AsyncPostProcessingInterceptor interceptor was not called", AsyncPostProcessingInterceptor.called);
Assert.assertEquals("Entity has wrong content", "async/delay", response.readEntity(String.class));
Assertions.assertTrue(AsyncPostProcessingMsgBodyWriterInterceptor.called,
"AsyncPostProcessingMsgBodyWriterInterceptor interceptor was not called");
Assertions.assertTrue(AsyncPostProcessingInterceptor.called,
"AsyncPostProcessingInterceptor interceptor was not called");
Assertions.assertEquals("async/delay", response.readEntity(String.class),
"Entity has wrong content");
}

/**
Expand All @@ -123,15 +127,17 @@ public void testAsyncWithNoDelay() throws Exception {
reset();
Response response = client.target(generateURL("/async/nodelay")).request().get();
logger.info("Status: " + response.getStatus());
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
logger.info("TestMessageBodyWriterInterceptor.called: " + AsyncPostProcessingMsgBodyWriterInterceptor.called);
logger.info("TestPostProcessInterceptor.called: " + AsyncPostProcessingInterceptor.called);
response.bufferEntity();
logger.info("returned entity: " + response.readEntity(String.class));
Assert.assertTrue("AsyncPostProcessingMsgBodyWriterInterceptor interceptor was not called",
AsyncPostProcessingMsgBodyWriterInterceptor.called);
Assert.assertTrue("AsyncPostProcessingInterceptor interceptor was not called", AsyncPostProcessingInterceptor.called);
Assert.assertEquals("Entity has wrong content", "async/nodelay", response.readEntity(String.class));
Assertions.assertTrue(AsyncPostProcessingMsgBodyWriterInterceptor.called,
"AsyncPostProcessingMsgBodyWriterInterceptor interceptor was not called");
Assertions.assertTrue(AsyncPostProcessingInterceptor.called,
"AsyncPostProcessingInterceptor interceptor was not called");
Assertions.assertEquals("async/nodelay", response.readEntity(String.class),
"Entity has wrong content");
}

private void reset() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jboss.resteasy.test.asynch;

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

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
Expand All @@ -10,7 +10,7 @@

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.logging.Logger;
import org.jboss.resteasy.test.asynch.resource.AsyncFilterException;
import org.jboss.resteasy.test.asynch.resource.AsyncFilterExceptionMapper;
Expand All @@ -30,16 +30,16 @@
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* @tpSubChapter CDI
* @tpChapter Integration tests
* @tpTestCaseDetails Async Request Filter test.
* @tpSince RESTEasy 4.0.0
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public class AsyncRequestFilterTest {
protected static final Logger log = Logger.getLogger(AsyncRequestFilterTest.class.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@

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.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.spi.HttpResponseCodes;
import org.jboss.resteasy.test.asynch.resource.AsyncServletResource;
import org.jboss.resteasy.utils.PortProviderUtil;
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* @tpSubChapter Asynchronous RESTEasy
* @tpChapter Integration tests
* @tpTestCaseDetails Test for asyncHttpServlet module
* @tpSince RESTEasy 3.0.16
*/
@RunWith(Arquillian.class)
@ExtendWith(ArquillianExtension.class)
@RunAsClient
public class AsyncServletTest {

static ResteasyClient client;

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

@After
@AfterEach
public void after() throws Exception {
client.close();
}
Expand All @@ -58,8 +58,9 @@ private String generateURL(String path) {
@Test
public void testAsync() throws Exception {
Response response = client.target(generateURL("/async")).request().get();
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assert.assertEquals("Wrong response content", "hello", response.readEntity(String.class));
Assertions.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Assertions.assertEquals("hello", response.readEntity(String.class),
"Wrong response content");
}

/**
Expand All @@ -69,6 +70,6 @@ public void testAsync() throws Exception {
@Test
public void testTimeout() throws Exception {
Response response = client.target(generateURL("/async/timeout")).request().get();
Assert.assertEquals(HttpResponseCodes.SC_SERVICE_UNAVAILABLE, response.getStatus());
Assertions.assertEquals(HttpResponseCodes.SC_SERVICE_UNAVAILABLE, response.getStatus());
}
}

0 comments on commit 9632435

Please sign in to comment.