You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/07/22 16:59:08 UTC
[camel] 02/18: [CAMEL-11807] Upgrade camel-resteasy to junit5
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 11bbdda2285c5ec0a9eba186a7b2afc187e5a79a
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Jul 22 13:36:22 2020 +0200
[CAMEL-11807] Upgrade camel-resteasy to junit5
---
components/camel-resteasy/pom.xml | 11 +-
.../test/ResteasyConsumerMatchUriOnPrefix.java | 20 +-
.../resteasy/test/ResteasyConsumerProxyTest.java | 32 ++--
.../resteasy/test/ResteasyConsumerTest.java | 69 ++++---
.../test/ResteasyConsumerTwoServletsTest.java | 26 ++-
.../resteasy/test/ResteasyMethodRestrictTest.java | 22 +--
.../resteasy/test/ResteasyProducerProxyTest.java | 68 +++----
.../resteasy/test/ResteasyProducerTest.java | 72 ++++----
.../test/ResteasyRestDSLProxyCamelTest.java | 20 +-
.../resteasy/test/ResteasyRestDSLProxyTest.java | 21 ++-
.../resteasy/test/ResteasyRestDSLTest.java | 20 +-
.../resteasy/test/ResteasySetHttpBindingTest.java | 16 +-
.../resteasy/test/ResteasySimpleConsumerTest.java | 30 +--
.../resteasy/test/ServletInitializerTest.java | 20 +-
.../camel/component/resteasy/test/WebTest.java | 203 +++++++++++++++++++++
.../camel-resteasy/src/test/resources/pom.xml | 4 +-
16 files changed, 428 insertions(+), 226 deletions(-)
diff --git a/components/camel-resteasy/pom.xml b/components/camel-resteasy/pom.xml
index 5c03de3..245e899 100644
--- a/components/camel-resteasy/pom.xml
+++ b/components/camel-resteasy/pom.xml
@@ -118,8 +118,8 @@
<!-- test dependencies -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -135,7 +135,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -270,6 +270,11 @@
<version>${jboss-el-api_3.0_spec-version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerMatchUriOnPrefix.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerMatchUriOnPrefix.java
index c39ecbf..c79c4ca 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerMatchUriOnPrefix.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerMatchUriOnPrefix.java
@@ -21,26 +21,22 @@ import java.net.URI;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.SimpleService;
-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.test.api.ArquillianResource;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(Arquillian.class)
-@RunAsClient
+@WebTest
public class ResteasyConsumerMatchUriOnPrefix {
- @ArquillianResource
+
+ @Resource
URI baseUri;
@Deployment
@@ -69,6 +65,6 @@ public class ResteasyConsumerMatchUriOnPrefix {
.request().get();
String entity = response.readEntity(String.class);
assertEquals(200, response.getStatus());
- Assert.assertEquals("Body set from camel route", entity);
+ assertEquals("Body set from camel route", entity);
}
}
\ No newline at end of file
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerProxyTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerProxyTest.java
index 552e1b6..6453078 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerProxyTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerProxyTest.java
@@ -26,27 +26,25 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.Customer;
import org.apache.camel.component.resteasy.test.beans.ProxyBean;
import org.apache.camel.component.resteasy.test.beans.ProxyServiceInterface;
-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.test.api.ArquillianResource;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
-@RunAsClient
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasyConsumerProxyTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -71,16 +69,16 @@ public class ResteasyConsumerProxyTest {
WebTarget target = client.target(baseUri.toString() + "camel/address");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Proxy address only from Camel", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Proxy address only from Camel", response.readEntity(String.class));
}
@Test
public void testProxyFromInterface() throws Exception {
Response response = ResteasyClientBuilder.newClient().target(baseUri.toString() + "proxy/get").request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Address from ProxyInterface", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Address from ProxyInterface", response.readEntity(String.class));
}
@@ -94,8 +92,8 @@ public class ResteasyConsumerProxyTest {
WebTarget target = client.target(baseUri.toString() + "proxy/createCustomer");
Response response = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(customer, MediaType.APPLICATION_JSON_TYPE));
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Customer added : {\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":1}", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Customer added : {\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":1}", response.readEntity(String.class));
}
@@ -105,7 +103,7 @@ public class ResteasyConsumerProxyTest {
WebTarget target = client.target(baseUri.toString() + "proxy/createCustomer");
Response response = target.request().get();
- Assert.assertEquals(405, response.getStatus());
+ assertEquals(405, response.getStatus());
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTest.java
index b5f9067..84af74e 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTest.java
@@ -27,27 +27,26 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.Customer;
import org.apache.camel.component.resteasy.test.beans.CustomerList;
import org.apache.camel.component.resteasy.test.beans.CustomerService;
-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.junit.InSequence;
-import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
-@RunAsClient
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+
+@WebTest
public class ResteasyConsumerTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -70,7 +69,7 @@ public class ResteasyConsumerTest {
Response response = target.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(customer, MediaType.APPLICATION_JSON_TYPE));
- Assert.assertEquals(200, response.getStatus());
+ assertEquals(200, response.getStatus());
return response;
}
@@ -79,7 +78,7 @@ public class ResteasyConsumerTest {
WebTarget target = client.target(baseUri.toString() + "customer/deleteCustomer?id=" + id);
Response response = target.request().delete();
- Assert.assertEquals(200, response.getStatus());
+ assertEquals(200, response.getStatus());
return response;
}
@@ -89,13 +88,13 @@ public class ResteasyConsumerTest {
WebTarget target = client.target(baseUri.toString() + "customer/getCustomer?id=" + id);
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
+ assertEquals(200, response.getStatus());
return response.readEntity(Customer.class);
}
@Test
- @InSequence(1)
+ @Order(1)
public void testGetAll() throws Exception {
String expectedUser1 = "{\"name\":\"Roman\",\"surname\":\"Jakubco\",\"id\":1}";
String expectedUser2 = "{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2}";
@@ -104,31 +103,31 @@ public class ResteasyConsumerTest {
WebTarget target = client.target(baseUri.toString() + "customer/getAll");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
+ assertEquals(200, response.getStatus());
String users = response.readEntity(String.class);
- Assert.assertTrue(users.contains(expectedUser1));
- Assert.assertTrue(users.contains(expectedUser2));
+ assertTrue(users.contains(expectedUser1));
+ assertTrue(users.contains(expectedUser2));
File file = new File("target/test/consumerTest/all.txt");
byte[] encoded = Files.readAllBytes(file.toPath());
String responseBody = new String(encoded);
- Assert.assertTrue(responseBody.contains(expectedUser1));
- Assert.assertTrue(responseBody.contains(expectedUser2));
+ assertTrue(responseBody.contains(expectedUser1));
+ assertTrue(responseBody.contains(expectedUser2));
}
@Test
public void testGet() throws Exception {
Customer customer = getCustomer(2);
- Assert.assertEquals(new Customer("Camel", "Rider", 2), customer);
+ assertEquals(new Customer("Camel", "Rider", 2), customer);
File file = new File("target/test/consumerTest/get.txt");
byte[] encoded = Files.readAllBytes(file.toPath());
String responseBody = new String(encoded);
- Assert.assertEquals("{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2}", responseBody);
+ assertEquals("{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2}", responseBody);
}
@Test
@@ -139,15 +138,15 @@ public class ResteasyConsumerTest {
Customer customer = new Customer("TestCreate", "TestCreate", customerId);
Response response = createCustomer(customer);
- // Assert.assertEquals(expectedResponse,
+ // assertEquals(expectedResponse,
// response.readEntity(String.class));
File file = new File("target/test/consumerTest/create.txt");
byte[] encoded = Files.readAllBytes(file.toPath());
String responseBody = new String(encoded);
- Assert.assertEquals(expectedResponse, responseBody);
+ assertEquals(expectedResponse, responseBody);
- Assert.assertEquals(customer, getCustomer(customerId));
+ assertEquals(customer, getCustomer(customerId));
deleteCustomer(customerId);
}
@@ -162,20 +161,20 @@ public class ResteasyConsumerTest {
createCustomer(customer);
Response responseDelete = deleteCustomer(customerId);
- Assert.assertEquals(200, responseDelete.getStatus());
- Assert.assertEquals(expectedResponse, responseDelete.readEntity(String.class));
+ assertEquals(200, responseDelete.getStatus());
+ assertEquals(expectedResponse, responseDelete.readEntity(String.class));
File file = new File("target/test/consumerTest/delete.txt");
byte[] encoded = Files.readAllBytes(file.toPath());
String responseBody = new String(encoded);
- Assert.assertEquals(expectedResponse, responseBody);
+ assertEquals(expectedResponse, responseBody);
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target(baseUri.toString() + "customer/getCustomer?id=" + customerId);
Response response = target.request().get();
- Assert.assertEquals(404, response.getStatus());
- Assert.assertEquals("Customer with given id doesn't exist", response.readEntity(String.class));
+ assertEquals(404, response.getStatus());
+ assertEquals("Customer with given id doesn't exist", response.readEntity(String.class));
}
@Test
@@ -195,16 +194,16 @@ public class ResteasyConsumerTest {
Response response = target.request(MediaType.APPLICATION_JSON_TYPE)
.put(Entity.entity(customer, MediaType.APPLICATION_JSON_TYPE));
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals(expectedResponse, response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals(expectedResponse, response.readEntity(String.class));
File file = new File("target/test/consumerTest/update.txt");
byte[] encoded = Files.readAllBytes(file.toPath());
String responseBody = new String(encoded);
- Assert.assertEquals(expectedResponse, responseBody);
+ assertEquals(expectedResponse, responseBody);
Customer updatedCustomer = getCustomer(customerId);
- Assert.assertEquals(customer, updatedCustomer);
+ assertEquals(customer, updatedCustomer);
deleteCustomer(customerId);
}
@@ -215,7 +214,7 @@ public class ResteasyConsumerTest {
WebTarget target = client.target(baseUri.toString() + "customer/createCustomer");
Response response = target.request().get();
- Assert.assertEquals(405, response.getStatus());
+ assertEquals(405, response.getStatus());
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTwoServletsTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTwoServletsTest.java
index d18c5c0..d703bbb 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTwoServletsTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyConsumerTwoServletsTest.java
@@ -24,25 +24,23 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.ServletOneService;
import org.apache.camel.component.resteasy.test.beans.ServletTwoService;
-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.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
-@RunAsClient
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasyConsumerTwoServletsTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -64,14 +62,14 @@ public class ResteasyConsumerTwoServletsTest {
WebTarget target = client.target(baseUri.toString() + "numberOne/simpleServiceSecure/getMsg");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Message from camel-servlet-1", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Message from camel-servlet-1", response.readEntity(String.class));
Client client2 = ClientBuilder.newBuilder().build();
WebTarget target2 = client2.target(baseUri.toString() + "numberTwo/simpleServiceSecure/getMsg");
Response response2 = target2.request().get();
- Assert.assertEquals(200, response2.getStatus());
- Assert.assertEquals("Message from camel-servlet-2", response2.readEntity(String.class));
+ assertEquals(200, response2.getStatus());
+ assertEquals("Message from camel-servlet-2", response2.readEntity(String.class));
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyMethodRestrictTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyMethodRestrictTest.java
index c3b7575..0916126 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyMethodRestrictTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyMethodRestrictTest.java
@@ -24,21 +24,21 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasyMethodRestrictTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -59,12 +59,12 @@ public class ResteasyMethodRestrictTest {
WebTarget target = client.target(baseUri.toString() + "method/restrict");
Response response = target.request().get();
- Assert.assertEquals(405, response.getStatus());
+ assertEquals(405, response.getStatus());
Client client2 = ClientBuilder.newBuilder().build();
WebTarget target2 = client2.target(baseUri.toString() + "method/restrict");
Response response2 = target2.request().delete();
- Assert.assertEquals(200, response2.getStatus());
- Assert.assertEquals("Response from httpMethodRestrict", response2.readEntity(String.class));
+ assertEquals(200, response2.getStatus());
+ assertEquals("Response from httpMethodRestrict", response2.readEntity(String.class));
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerProxyTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerProxyTest.java
index 89d4093..0a53d86 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerProxyTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerProxyTest.java
@@ -29,28 +29,30 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.component.resteasy.ResteasyComponent;
import org.apache.camel.component.resteasy.ResteasyConstants;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.Customer;
import org.apache.camel.component.resteasy.test.beans.CustomerList;
import org.apache.camel.component.resteasy.test.beans.CustomerService;
import org.apache.camel.component.resteasy.test.beans.ProxyProducerInterface;
import org.apache.camel.component.resteasy.test.beans.ResteasyProducerProxyTestApp;
import org.apache.camel.spi.DataFormat;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.junit.InSequence;
-import org.jboss.arquillian.test.api.ArquillianResource;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+
+@WebTest
public class ResteasyProducerProxyTest extends CamelTestSupport {
- @ArquillianResource
+
+ @Resource
URI baseUri;
@Deployment
@@ -117,19 +119,19 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:delete", null, headers, String.class);
- Assert.assertTrue(response.contains(String.valueOf(id)));
- Assert.assertTrue(response.contains("Customer deleted :"));
+ assertTrue(response.contains(String.valueOf(id)));
+ assertTrue(response.contains("Customer deleted :"));
}
@Test
- @InSequence(1)
+ @Order(1)
public void testProxyGetAll() throws Exception {
String expectedUser1 = "{\"name\":\"Roman\",\"surname\":\"Jakubco\",\"id\":1}";
String expectedUser2 = "{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2}";
String response = template.requestBody("direct:getAll", null, String.class);
- Assert.assertTrue(response.contains(expectedUser1));
- Assert.assertTrue(response.contains(expectedUser2));
+ assertTrue(response.contains(expectedUser1));
+ assertTrue(response.contains(expectedUser2));
}
@Test
@@ -144,7 +146,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
exchange.getIn().getHeaders().put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
}
});
- Assert.assertEquals(expectedBody, response.getMessage().getBody(String.class));
+ assertEquals(expectedBody, response.getMessage().getBody(String.class));
}
@@ -161,7 +163,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
exchange.getIn().getHeaders().put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
}
});
- Assert.assertEquals(expectedCustomer, response.getMessage().getBody(Customer.class));
+ assertEquals(expectedCustomer, response.getMessage().getBody(Customer.class));
}
@@ -176,7 +178,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
deleteCustomer(customerId);
}
@@ -192,7 +194,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
@@ -204,7 +206,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:put", null, headers, String.class);
- Assert.assertEquals("Customer updated : " + expectedCustomer, response);
+ assertEquals("Customer updated : " + expectedCustomer, response);
deleteCustomer(customerId);
}
@@ -220,7 +222,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
params.clear();
headers.clear();
@@ -228,7 +230,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:delete", null, headers, String.class);
- Assert.assertEquals("Customer deleted : " + expectedCustomer, response);
+ assertEquals("Customer deleted : " + expectedCustomer, response);
}
@@ -243,7 +245,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
String expectedCustomers = "[{\"name\":\"Test\",\"surname\":\"Test\",\"id\":6},{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2},{\"name\":\"Roman\",\"surname\":\"Jakubco\",\"id\":1}]";
@@ -254,7 +256,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
params.add(1);
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:moreAttributes", null, headers, String.class);
- Assert.assertEquals(expectedCustomers, response);
+ assertEquals(expectedCustomers, response);
deleteCustomer(customerId);
}
@@ -271,7 +273,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
headers.clear();
@@ -280,7 +282,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
params.add(expectedCustomer);
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:differentType", null, headers, String.class);
- Assert.assertEquals("Customers are equal", response);
+ assertEquals("Customers are equal", response);
headers.clear();
params.clear();
@@ -288,7 +290,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
params.add(expectedCustomer);
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:differentType", null, headers, String.class);
- Assert.assertEquals("Customers are not equal", response);
+ assertEquals("Customers are not equal", response);
Customer testCustomer = new Customer("Camel", "Rider", 2);
headers.clear();
@@ -297,7 +299,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
params.add(testCustomer);
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:differentType", null, headers, String.class);
- Assert.assertEquals("Customers are equal", response);
+ assertEquals("Customers are equal", response);
deleteCustomer(customerId);
@@ -315,7 +317,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
@@ -330,8 +332,8 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
}
});
- Assert.assertTrue(exchange.getMessage().getBody() instanceof NoSuchMethodException);
- Assert.assertTrue(exchange.getMessage().getHeaders().containsKey(ResteasyConstants.RESTEASY_PROXY_PRODUCER_EXCEPTION));
+ assertTrue(exchange.getMessage().getBody() instanceof NoSuchMethodException);
+ assertTrue(exchange.getMessage().getHeaders().containsKey(ResteasyConstants.RESTEASY_PROXY_PRODUCER_EXCEPTION));
deleteCustomer(customerId);
}
@@ -347,7 +349,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
String response = template.requestBodyAndHeaders("direct:post", null, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
headers.clear();
@@ -356,7 +358,7 @@ public class ResteasyProducerProxyTest extends CamelTestSupport {
headers.put(ResteasyConstants.RESTEASY_PROXY_METHOD_PARAMS, params);
response = template.requestBodyAndHeaders("direct:notResponseType", null, headers, String.class);
- Assert.assertEquals(expectedCustomer.toString(), response);
+ assertEquals(expectedCustomer.toString(), response);
deleteCustomer(customerId);
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerTest.java
index 41b8e30..8b9b23e 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyProducerTest.java
@@ -32,27 +32,30 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jackson.JacksonDataFormat;
import org.apache.camel.component.resteasy.ResteasyComponent;
import org.apache.camel.component.resteasy.ResteasyConstants;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.Customer;
import org.apache.camel.component.resteasy.test.beans.CustomerList;
import org.apache.camel.component.resteasy.test.beans.CustomerService;
import org.apache.camel.component.resteasy.test.beans.TestBean;
import org.apache.camel.spi.DataFormat;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+
+@WebTest
public class ResteasyProducerTest extends CamelTestSupport {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -111,8 +114,8 @@ public class ResteasyProducerTest extends CamelTestSupport {
String expectedUser1 = "{\"name\":\"Roman\",\"surname\":\"Jakubco\",\"id\":1}";
String expectedUser2 = "{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2}";
String response = template.requestBody("direct:getAll", null, String.class);
- Assert.assertTrue(response.contains(expectedUser1));
- Assert.assertTrue(response.contains(expectedUser2));
+ assertTrue(response.contains(expectedUser1));
+ assertTrue(response.contains(expectedUser2));
}
@Test
@@ -120,7 +123,7 @@ public class ResteasyProducerTest extends CamelTestSupport {
String expectedBody = "{\"name\":\"Camel\",\"surname\":\"Rider\",\"id\":2}";
String response = template.requestBodyAndHeader("direct:get", null, Exchange.HTTP_QUERY, "id=2", String.class);
- Assert.assertEquals(expectedBody, response);
+ assertEquals(expectedBody, response);
}
@@ -129,7 +132,7 @@ public class ResteasyProducerTest extends CamelTestSupport {
Integer customerId = 2;
Customer expectedCustomer = new Customer("Camel", "Rider", customerId);
Customer customer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(expectedCustomer, customer);
+ assertEquals(expectedCustomer, customer);
}
@Test
@@ -137,10 +140,10 @@ public class ResteasyProducerTest extends CamelTestSupport {
Integer customerId = 3;
Customer expectedCustomer = new Customer("TestPost", "TestPost", customerId);
String response = template.requestBodyAndHeader("direct:post", "{\"name\":\"TestPost\",\"surname\":\"TestPost\",\"id\":3}", Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
Customer customer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(expectedCustomer, customer);
+ assertEquals(expectedCustomer, customer);
template.sendBodyAndHeader("direct:delete", null, Exchange.HTTP_QUERY, "id=" + customerId);
}
@@ -151,10 +154,10 @@ public class ResteasyProducerTest extends CamelTestSupport {
Customer expectedCustomer = new Customer("TestPostMarshal", "TestPostMarshal", customerId);
String response = template.requestBodyAndHeader("direct:postMarshal", expectedCustomer, Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
Customer customer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(expectedCustomer, customer);
+ assertEquals(expectedCustomer, customer);
template.sendBodyAndHeader("direct:delete", null, Exchange.HTTP_QUERY, "id=" + customerId);
}
@@ -165,21 +168,21 @@ public class ResteasyProducerTest extends CamelTestSupport {
Customer customer = new Customer("TestPut", "TestPut", customerId);
String response = template.requestBodyAndHeader("direct:postMarshal", customer, Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON, String.class);
- Assert.assertEquals("Customer added : " + customer, response);
+ assertEquals("Customer added : " + customer, response);
Customer oldCustomer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(customer, oldCustomer);
+ assertEquals(customer, oldCustomer);
oldCustomer.setName("Updated");
oldCustomer.setSurname("updated");
response = template.requestBodyAndHeader("direct:put", oldCustomer, Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON, String.class);
- Assert.assertEquals("Customer updated : " + oldCustomer, response);
+ assertEquals("Customer updated : " + oldCustomer, response);
Customer updatedCustomer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(oldCustomer, updatedCustomer);
- Assert.assertNotEquals(customer, updatedCustomer);
+ assertEquals(oldCustomer, updatedCustomer);
+ assertNotEquals(customer, updatedCustomer);
template.sendBodyAndHeader("direct:delete", null, Exchange.HTTP_QUERY, "id=" + customerId);
}
@@ -190,15 +193,15 @@ public class ResteasyProducerTest extends CamelTestSupport {
Customer expectedCustomer = new Customer("TestDelete", "TestDelete", customerId);
String response = template.requestBodyAndHeader("direct:postMarshal", expectedCustomer, Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
Customer customer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(expectedCustomer, customer);
+ assertEquals(expectedCustomer, customer);
template.sendBodyAndHeader("direct:delete", null, Exchange.HTTP_QUERY, "id=" + customerId);
response = template.requestBodyAndHeader("direct:get", null, Exchange.HTTP_QUERY, "id=" + customerId, String.class);
- Assert.assertEquals("Customer with given id doesn't exist", response);
+ assertEquals("Customer with given id doesn't exist", response);
}
@@ -216,7 +219,7 @@ public class ResteasyProducerTest extends CamelTestSupport {
}
});
- Assert.assertEquals(405, exchange.getMessage().getHeaders().get("CamelHttpResponseCode"));
+ assertEquals(405, exchange.getMessage().getHeaders().get("CamelHttpResponseCode"));
Map<String, Object> headers = new HashMap<>();
@@ -224,18 +227,19 @@ public class ResteasyProducerTest extends CamelTestSupport {
headers.put(Exchange.CONTENT_TYPE, MediaType.APPLICATION_JSON);
String response = template.requestBodyAndHeaders("direct:postInHeader", expectedCustomer, headers, String.class);
- Assert.assertEquals("Customer added : " + expectedCustomer, response);
+ assertEquals("Customer added : " + expectedCustomer, response);
Customer customer = template.requestBodyAndHeader("direct:getUnmarshal", null, Exchange.HTTP_QUERY, "id=" + customerId, Customer.class);
- Assert.assertEquals(expectedCustomer, customer);
+ assertEquals(expectedCustomer, customer);
template.sendBodyAndHeader("direct:delete", null, Exchange.HTTP_QUERY, "id=" + customerId);
}
- @Test(expected = CamelExecutionException.class)
+ @Test
public void testSettingNotExistingHttpMethod() throws Exception {
- template.requestBodyAndHeader("direct:getAll", null, ResteasyConstants.RESTEASY_HTTP_METHOD, "GAT");
+ assertThrows(CamelExecutionException.class,
+ () -> template.requestBodyAndHeader("direct:getAll", null, ResteasyConstants.RESTEASY_HTTP_METHOD, "GAT"));
}
@@ -255,10 +259,10 @@ public class ResteasyProducerTest extends CamelTestSupport {
ArrayList contentLength = (ArrayList) headers.get("Content-Length");
Integer responseCode = (Integer) headers.get("CamelHttpResponseCode");
- Assert.assertEquals("application/json", contentType.get(0));
- //Assert.assertEquals("WildFly/8", server.get(0));
- Assert.assertEquals("87", contentLength.get(0));
- Assert.assertEquals(new Integer(200), responseCode);
+ assertEquals("application/json", contentType.get(0));
+ //assertEquals("WildFly/8", server.get(0));
+ assertEquals("87", contentLength.get(0));
+ assertEquals(new Integer(200), responseCode);
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyCamelTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyCamelTest.java
index cb3e4f9..ac76ac4 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyCamelTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyCamelTest.java
@@ -24,21 +24,21 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasyRestDSLProxyCamelTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -61,8 +61,8 @@ public class ResteasyRestDSLProxyCamelTest {
WebTarget target = client.target(baseUri.toString() + "say/hello");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Only message from Camel", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Only message from Camel", response.readEntity(String.class));
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyTest.java
index 3c651ff..3b2ffb8 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLProxyTest.java
@@ -24,22 +24,23 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.Customer;
import org.apache.camel.component.resteasy.test.beans.ProxyServiceInterface;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasyRestDSLProxyTest {
- @ArquillianResource
+
+ @Resource
URI baseUri;
@Deployment
@@ -63,8 +64,8 @@ public class ResteasyRestDSLProxyTest {
WebTarget target = client.target(baseUri.toString() + "proxy/get");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Address from ProxyInterface", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Address from ProxyInterface", response.readEntity(String.class));
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLTest.java
index cf970a3..4139ba7 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasyRestDSLTest.java
@@ -24,22 +24,22 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.SimpleService;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasyRestDSLTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -63,8 +63,8 @@ public class ResteasyRestDSLTest {
WebTarget target = client.target(baseUri.toString() + "simpleService/getMsg");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Text from camel. Response from REST : Message1 from Rest service", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Text from camel. Response from REST : Message1 from Rest service", response.readEntity(String.class));
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySetHttpBindingTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySetHttpBindingTest.java
index 981ad64..51cdf683 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySetHttpBindingTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySetHttpBindingTest.java
@@ -22,22 +22,22 @@ import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.resteasy.ResteasyComponent;
import org.apache.camel.component.resteasy.ResteasyHttpBinding;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
import org.apache.camel.component.resteasy.test.beans.TestHttpBinding;
import org.apache.camel.spi.Registry;
import org.apache.camel.support.DefaultRegistry;
import org.apache.camel.support.SimpleRegistry;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasySetHttpBindingTest extends CamelTestSupport {
@Deployment
@@ -78,7 +78,7 @@ public class ResteasySetHttpBindingTest extends CamelTestSupport {
@Test
public void testSettingResteasyHttpBinding() throws Exception {
String response = template.requestBody("direct:start", null, String.class);
- Assert.assertEquals("Test from custom HttpBinding", response);
+ assertEquals("Test from custom HttpBinding", response);
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySimpleConsumerTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySimpleConsumerTest.java
index 9b2934f..6e22108 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySimpleConsumerTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ResteasySimpleConsumerTest.java
@@ -25,23 +25,23 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.apache.camel.component.resteasy.test.beans.SimpleService;
import org.apache.camel.component.resteasy.test.beans.TestBean;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
-@RunWith(Arquillian.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+@WebTest
public class ResteasySimpleConsumerTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -63,8 +63,8 @@ public class ResteasySimpleConsumerTest {
WebTarget target = client.target(baseUri.toString() + "simpleService/getMsg");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Added this message from bean to original message from Rest Service -> Message1 from Rest service", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Added this message from bean to original message from Rest Service -> Message1 from Rest service", response.readEntity(String.class));
}
@Test
@@ -73,8 +73,8 @@ public class ResteasySimpleConsumerTest {
WebTarget target = client.target(baseUri.toString() + "simpleService/getMsg2");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals("Overriding output from Rest service", response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals("Overriding output from Rest service", response.readEntity(String.class));
}
@Test
@@ -85,14 +85,14 @@ public class ResteasySimpleConsumerTest {
WebTarget target = client.target(baseUri.toString() + "simpleService/getMsg3");
Response response = target.request().get();
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals(expectedResponse, response.readEntity(String.class));
+ assertEquals(200, response.getStatus());
+ assertEquals(expectedResponse, response.readEntity(String.class));
File file = new File("target/messageTest/response.txt");
byte[] encoded = Files.readAllBytes(file.toPath());
String responseBody = new String(encoded);
- Assert.assertEquals(expectedResponse, responseBody);
+ assertEquals(expectedResponse, responseBody);
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ServletInitializerTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ServletInitializerTest.java
index 500f135..937e998 100644
--- a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ServletInitializerTest.java
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/ServletInitializerTest.java
@@ -21,20 +21,17 @@ import java.net.URI;
import javax.ws.rs.core.Response;
-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.test.api.ArquillianResource;
+import org.apache.camel.component.resteasy.test.WebTest.Deployment;
+import org.apache.camel.component.resteasy.test.WebTest.Resource;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.Assert.assertEquals;
/**
See the Servlet 3.0 spec, section 8.2.4 for implementation and processing the details
@@ -50,11 +47,10 @@ import static org.junit.Assert.assertEquals;
resource and provider classes as well as no web.xml file.
*/
-@RunWith(Arquillian.class)
-@RunAsClient
+@WebTest
public class ServletInitializerTest {
- @ArquillianResource
+ @Resource
URI baseUri;
@Deployment
@@ -80,6 +76,6 @@ public class ServletInitializerTest {
.target(baseUri.toString() + "test/17").request().get();
String entity = response.readEntity(String.class);
assertEquals(200, response.getStatus());
- Assert.assertEquals("17", entity);
+ assertEquals("17", entity);
}
}
diff --git a/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/WebTest.java b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/WebTest.java
new file mode 100644
index 0000000..325325c
--- /dev/null
+++ b/components/camel-resteasy/src/test/java/org/apache/camel/component/resteasy/test/WebTest.java
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.resteasy.test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.servlet.ServletContext;
+
+import org.eclipse.jetty.deploy.App;
+import org.jboss.arquillian.container.jetty.embedded_9.JettyEmbeddedConfiguration;
+import org.jboss.arquillian.container.jetty.embedded_9.JettyEmbeddedContainer;
+import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
+import org.jboss.arquillian.container.test.impl.enricher.resource.URIResourceProvider;
+import org.jboss.arquillian.container.test.impl.enricher.resource.URLResourceProvider;
+import org.jboss.arquillian.core.api.InstanceProducer;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.arquillian.test.spi.enricher.resource.ResourceProvider;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Retention(RUNTIME)
+@Target(ElementType.TYPE)
+@ExtendWith(WebTest.WebTestExtension.class)
+public @interface WebTest {
+
+ @Retention(RUNTIME)
+ @Target({ElementType.FIELD, ElementType.PARAMETER})
+ @interface Resource {
+ }
+
+ @Retention(RUNTIME)
+ @Target(ElementType.METHOD)
+ @interface Deployment {
+ }
+
+ class WebTestExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback, AfterAllCallback {
+
+ @ArquillianResource
+ private static final Object DUMMY = null;
+ private static final ArquillianResource ARQUILLIAN_RESOURCE;
+
+ static {
+ try {
+ ARQUILLIAN_RESOURCE = WebTestExtension.class.getDeclaredField("DUMMY").getAnnotation(ArquillianResource.class);
+ } catch (NoSuchFieldException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private List<ResourceProvider> providers;
+
+ @Override
+ public void beforeAll(ExtensionContext context) throws Exception {
+ Class<?> testClass = context.getRequiredTestClass();
+ List<Method> methods = Stream.of(testClass.getMethods())
+ .filter(m -> m.getAnnotation(Deployment.class) != null)
+ .collect(Collectors.toList());
+ if (methods.size() != 1) {
+ throw new IllegalStateException("Expecting a single method annotated with @Deployment");
+ }
+ Method method = methods.iterator().next();
+ method.setAccessible(true);
+ Object value = method.invoke(null);
+ if (!(value instanceof Archive)) {
+ throw new IllegalStateException("Method " + method.getName() + " returned an object which is not an Archive");
+ }
+ ExtensionContext.Store store = getStore(context);
+
+ JettyEmbeddedConfiguration config = new JettyEmbeddedConfiguration();
+ config.setBindHttpPort(0);
+ JettyEmbeddedContainer container = new JettyEmbeddedContainer();
+ inject(container, "webAppContextProducer", new Instance<>(store, App.class));
+ inject(container, "servletContextInstanceProducer", new Instance<>(store, ServletContext.class));
+
+ container.setup(config);
+ container.start();
+ ProtocolMetaData metaData = container.deploy((Archive) value);
+ new Instance<>(store, ProtocolMetaData.class).set(metaData);
+ new Instance<>(store, JettyEmbeddedContainer.class).set(container);
+
+ URLResourceProvider url = new URLResourceProvider();
+ inject(url, "protocolMetadata", new Instance<>(getStore(context), ProtocolMetaData.class));
+ URIResourceProvider uri = new URIResourceProvider();
+ inject(uri, "protocolMetadata", new Instance<>(getStore(context), ProtocolMetaData.class));
+ providers = Arrays.asList(url, uri);
+ }
+
+ private void inject(Object instance, String fieldName, Object value) {
+ try {
+ Field f = null;
+ Class<?> clazz = instance.getClass();
+ while (f == null && clazz != null) {
+ try {
+ f = clazz.getDeclaredField(fieldName);
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ if (f == null) {
+ throw new NoSuchFieldException(fieldName);
+ }
+ inject(instance, f, value);
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to inject field", e);
+ }
+ }
+
+ private void inject(Object instance, Field f, Object value) {
+ try {
+ f.setAccessible(true);
+ f.set(instance, value);
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to inject field", e);
+ }
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext context) throws Exception {
+ Class<?> testClass = context.getRequiredTestClass();
+ List<Field> fields = Stream.of(testClass.getDeclaredFields())
+ .filter(f -> f.isAnnotationPresent(Resource.class))
+ .collect(Collectors.toList());
+ if (!fields.isEmpty()) {
+ for (Field field : fields) {
+ List<ResourceProvider> matching = providers.stream()
+ .filter(p -> p.canProvide(field.getType()))
+ .collect(Collectors.toList());
+ if (matching.size() == 0) {
+ throw new IllegalStateException("No matching resource provider for " + field.getType());
+ } else if (matching.size() > 1) {
+ throw new IllegalStateException("Ambiguous resource provider for " + field.getType());
+ } else {
+ ResourceProvider rp = matching.iterator().next();
+ Object value = rp.lookup(ARQUILLIAN_RESOURCE);
+ inject(context.getRequiredTestInstance(), field, value);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void afterEach(ExtensionContext context) throws Exception {
+ }
+
+ @Override
+ public void afterAll(ExtensionContext context) throws Exception {
+ JettyEmbeddedContainer container = getStore(context).get(JettyEmbeddedContainer.class, JettyEmbeddedContainer.class);
+ container.stop();
+ }
+
+ private ExtensionContext.Store getStore(ExtensionContext context) {
+ return context.getStore(ExtensionContext.Namespace.create(WebTestExtension.class));
+ }
+
+ private static class Instance<T> implements InstanceProducer<T> {
+ final ExtensionContext.Store store;
+ final Class<T> type;
+
+ public Instance(ExtensionContext.Store store, Class<T> type) {
+ this.store = store;
+ this.type = type;
+ }
+
+ public T get() {
+ return store.get(type, type);
+ }
+ public void set(T value) {
+ store.put(type, value);
+ }
+ }
+
+ }
+}
+
diff --git a/components/camel-resteasy/src/test/resources/pom.xml b/components/camel-resteasy/src/test/resources/pom.xml
index ca243e3..b91885e 100644
--- a/components/camel-resteasy/src/test/resources/pom.xml
+++ b/components/camel-resteasy/src/test/resources/pom.xml
@@ -35,8 +35,8 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>