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 f85c8410fe87efe24393aa08383748e1f6cb3562
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Jun 11 09:31:03 2020 +0200

    [CAMEL-11807] Upgrade camel-olingo4 to junit5
---
 components/camel-olingo4/camel-olingo4-api/pom.xml |  2 +-
 .../camel/component/olingo4/Olingo4AppAPITest.java | 31 ++++++++++++----------
 .../camel-olingo4/camel-olingo4-component/pom.xml  |  2 +-
 .../olingo4/AbstractOlingo4TestSupport.java        | 10 +++----
 .../olingo4/Olingo4ComponentConsumerTest.java      | 15 ++++++-----
 .../olingo4/Olingo4ComponentProducerTest.java      | 28 +++++++++++--------
 .../camel/component/olingo4/Olingo4RouteTest.java  |  7 +++--
 7 files changed, 53 insertions(+), 42 deletions(-)

diff --git a/components/camel-olingo4/camel-olingo4-api/pom.xml 
b/components/camel-olingo4/camel-olingo4-api/pom.xml
index 222fc61..c38c646 100644
--- a/components/camel-olingo4/camel-olingo4-api/pom.xml
+++ b/components/camel-olingo4/camel-olingo4-api/pom.xml
@@ -86,7 +86,7 @@
         <!-- testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git 
a/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
 
b/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
index d3b89d7..317016e 100644
--- 
a/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
+++ 
b/components/camel-olingo4/camel-olingo4-api/src/test/java/org/apache/camel/component/olingo4/Olingo4AppAPITest.java
@@ -73,13 +73,16 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Integration test for
@@ -132,12 +135,12 @@ public class Olingo4AppAPITest {
     private final ClientObjectFactory objFactory = 
odataClient.getObjectFactory();
     private final ODataReader reader = odataClient.getReader();
 
-    @BeforeClass
+    @BeforeAll
     public static void beforeClass() throws Exception {
         setupClient();
     }
 
-    @AfterClass
+    @AfterAll
     public static void afterClass() throws Exception {
         if (olingoApp != null) {
             olingoApp.close();
@@ -185,7 +188,7 @@ public class Olingo4AppAPITest {
         final ClientServiceDocument serviceDocument = responseHandler.await();
 
         final Map<String, URI> entitySets = serviceDocument.getEntitySets();
-        assertEquals("Service Entity Sets", 4, entitySets.size());
+        assertEquals(4, entitySets.size(), "Service Entity Sets");
         LOG.info("Service Document Entries:  {}", entitySets);
     }
 
@@ -197,7 +200,7 @@ public class Olingo4AppAPITest {
 
         final ClientEntitySet entitySet = responseHandler.await();
         assertNotNull(entitySet);
-        assertEquals("Entity set count", 20, entitySet.getEntities().size());
+        assertEquals(20, entitySet.getEntities().size(), "Entity set count");
         LOG.info("Entities:  {}", prettyPrint(entitySet));
     }
 
@@ -208,9 +211,9 @@ public class Olingo4AppAPITest {
         olingoApp.uread(edm, PEOPLE, null, null, responseHandler);
 
         final InputStream rawEntitySet = responseHandler.await();
-        assertNotNull("Data entity set", rawEntitySet);
+        assertNotNull(rawEntitySet, "Data entity set");
         final ClientEntitySet entitySet = reader.readEntitySet(rawEntitySet, 
TEST_FORMAT);
-        assertEquals("Entity set count", 20, entitySet.getEntities().size());
+        assertEquals(20, entitySet.getEntities().size(), "Entity set count");
         LOG.info("Entries:  {}", prettyPrint(entitySet));
     }
 
@@ -245,7 +248,7 @@ public class Olingo4AppAPITest {
 
         olingoApp.uread(edm, TEST_AIRLINE, null, null, responseHandler);
         InputStream rawEntity = responseHandler.await();
-        assertNotNull("Data entity", rawEntity);
+        assertNotNull(rawEntity, "Data entity");
         ClientEntity entity = reader.readEntity(rawEntity, TEST_FORMAT);
         assertEquals("Shanghai Airline", 
entity.getProperty("Name").getValue().toString());
         LOG.info("Single Entity:  {}", prettyPrint(entity));
@@ -530,7 +533,7 @@ public class Olingo4AppAPITest {
         olingoApp.batch(edm, null, batchParts, responseHandler);
 
         final List<Olingo4BatchResponse> responseParts = 
responseHandler.await(15, TimeUnit.MINUTES);
-        assertEquals("Batch responses expected", 8, responseParts.size());
+        assertEquals(8, responseParts.size(), "Batch responses expected");
 
         assertNotNull(responseParts.get(0).getBody());
 
@@ -739,11 +742,11 @@ public class Olingo4AppAPITest {
         }
 
         public T await(long timeout, TimeUnit unit) throws Exception {
-            assertTrue("Timeout waiting for response", latch.await(timeout, 
unit));
+            assertTrue(latch.await(timeout, unit), "Timeout waiting for 
response");
             if (error != null) {
                 throw error;
             }
-            assertNotNull("Response", response);
+            assertNotNull(response, "Response");
             return response;
         }
 
diff --git a/components/camel-olingo4/camel-olingo4-component/pom.xml 
b/components/camel-olingo4/camel-olingo4-component/pom.xml
index bc96f7b..e8e1207 100644
--- a/components/camel-olingo4/camel-olingo4-component/pom.xml
+++ b/components/camel-olingo4/camel-olingo4-component/pom.xml
@@ -83,7 +83,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/AbstractOlingo4TestSupport.java
 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/AbstractOlingo4TestSupport.java
index 6d6d813..9a58826 100644
--- 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/AbstractOlingo4TestSupport.java
+++ 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/AbstractOlingo4TestSupport.java
@@ -23,7 +23,7 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.support.PropertyBindingSupport;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.http.HttpHost;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.HttpGet;
@@ -36,11 +36,13 @@ import org.apache.http.protocol.HttpContext;
 import org.apache.olingo.client.api.ODataClient;
 import org.apache.olingo.client.api.domain.ClientObjectFactory;
 import org.apache.olingo.client.core.ODataClientFactory;
+import org.junit.jupiter.api.TestInstance;
 
 /**
  * Abstract base class for Olingo 4.0 Integration tests generated by Camel API
  * component maven plugin.
  */
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
 public class AbstractOlingo4TestSupport extends CamelTestSupport {
     protected static final String TEST_SERVICE_BASE_URL = 
"http://services.odata.org/TripPinRESTierService";;
     protected final ODataClient odataClient = ODataClientFactory.getClient();
@@ -86,12 +88,6 @@ public class AbstractOlingo4TestSupport extends 
CamelTestSupport {
         return currentUrl;
     }
 
-    @Override
-    public boolean isCreateCamelContextPerClass() {
-        // only create the context once for this class
-        return true;
-    }
-
     @SuppressWarnings("unchecked")
     protected <T> T requestBodyAndHeaders(String endpointUri, Object body, 
Map<String, Object> headers) throws CamelExecutionException {
         return (T)template().requestBodyAndHeaders(endpointUri, body, headers);
diff --git 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
index 1b509a0..d9432b8 100644
--- 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
+++ 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentConsumerTest.java
@@ -26,8 +26,16 @@ import org.apache.olingo.client.api.domain.ClientEntity;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
 import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
 import org.apache.olingo.client.api.domain.ClientProperty;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
 
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@TestInstance(TestInstance.Lifecycle.PER_METHOD)
 public class Olingo4ComponentConsumerTest extends AbstractOlingo4TestSupport {
 
     private static final String PEOPLE = "People";
@@ -38,11 +46,6 @@ public class Olingo4ComponentConsumerTest extends 
AbstractOlingo4TestSupport {
         setUseRouteBuilder(false);
     }
 
-    @Override
-    public boolean isCreateCamelContextPerClass() {
-        return false;
-    }
-
     private void addRouteAndStartContext(RouteBuilder builder) throws 
Exception {
         context().addRoutes(builder);
         startCamelContext();
diff --git 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
index 0aa24de..e524bf5 100644
--- 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
+++ 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4ComponentProducerTest.java
@@ -41,10 +41,16 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.ex.ODataError;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.apache.camel.test.junit5.TestSupport.assertStringContains;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
  * Test class for {@link org.apache.camel.component.olingo4.api.Olingo4App}
  * APIs.
@@ -143,14 +149,14 @@ public class Olingo4ComponentProducerTest extends 
AbstractOlingo4TestSupport {
         
clientEntity.getProperties().add(objFactory.newPrimitiveProperty("MiddleName", 
objFactory.newPrimitiveValueBuilder().buildString("Lewis")));
 
         HttpStatusCode status = requestBody("direct:update-entity", 
clientEntity);
-        assertNotNull("Update status", status);
-        assertEquals("Update status", 
HttpStatusCode.NO_CONTENT.getStatusCode(), status.getStatusCode());
+        assertNotNull(status, "Update status");
+        assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), 
status.getStatusCode(), "Update status");
         LOG.info("Update entity status: {}", status);
 
         // delete
         status = requestBody("direct:delete-entity", null);
-        assertNotNull("Delete status", status);
-        assertEquals("Delete status", 
HttpStatusCode.NO_CONTENT.getStatusCode(), status.getStatusCode());
+        assertNotNull(status, "Delete status");
+        assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), 
status.getStatusCode(), "Delete status");
         LOG.info("Delete status: {}", status);
 
         // check for delete
@@ -173,14 +179,14 @@ public class Olingo4ComponentProducerTest extends 
AbstractOlingo4TestSupport {
 
         // update
         HttpStatusCode status = requestBody("direct:update-entity", 
TEST_UPDATE_JSON);
-        assertNotNull("Update status", status);
-        assertEquals("Update status", 
HttpStatusCode.NO_CONTENT.getStatusCode(), status.getStatusCode());
+        assertNotNull(status, "Update status");
+        assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), 
status.getStatusCode(), "Update status");
         LOG.info("Update entity status: {}", status);
 
         // delete
         status = requestBody("direct:delete-entity", null);
-        assertNotNull("Delete status", status);
-        assertEquals("Delete status", 
HttpStatusCode.NO_CONTENT.getStatusCode(), status.getStatusCode());
+        assertNotNull(status, "Delete status");
+        assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), 
status.getStatusCode(), "Delete status");
         LOG.info("Delete status: {}", status);
 
         // check for delete
@@ -238,8 +244,8 @@ public class Olingo4ComponentProducerTest extends 
AbstractOlingo4TestSupport {
 
         // execute batch request
         final List<Olingo4BatchResponse> responseParts = 
requestBody("direct:batch", batchParts);
-        assertNotNull("Batch response", responseParts);
-        assertEquals("Batch responses expected", 8, responseParts.size());
+        assertNotNull(responseParts, "Batch response");
+        assertEquals(8, responseParts.size(), "Batch responses expected");
 
         final Edm edm = (Edm)responseParts.get(0).getBody();
         assertNotNull(edm);
diff --git 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
index bb7f268..00f7c85 100644
--- 
a/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
+++ 
b/components/camel-olingo4/camel-olingo4-component/src/test/java/org/apache/camel/component/olingo4/Olingo4RouteTest.java
@@ -18,9 +18,12 @@ package org.apache.camel.component.olingo4;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.olingo.client.api.domain.ClientEntitySet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class Olingo4RouteTest extends CamelTestSupport {
     protected static final String TEST_SERVICE_BASE_URL = 
"http://services.odata.org/TripPinRESTierService";;

Reply via email to