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 e41435712fe9b95650c5994e022e6b09ac137d21
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Jun 24 10:16:24 2020 +0200

    [CAMEL-11807] Upgrade camel-couchbase to junit5
---
 components/camel-couchbase/pom.xml                 |  4 +-
 ...onsumeBeerMessagesWithLimitIntegrationTest.java |  4 +-
 .../couchbase/CouchbaseComponentTest.java          |  9 ++-
 .../component/couchbase/CouchbaseEndpointTest.java | 89 ++++++++++++----------
 .../component/couchbase/CouchbaseProducerTest.java | 50 ++++++------
 .../couchbase/ProduceMessagesSimpleTest.java       |  8 +-
 .../ProduceMessagesWithAutoIDIntegrationTest.java  |  4 +-
 .../couchbase/RemoveMessagesIntegrationTest.java   |  4 +-
 8 files changed, 92 insertions(+), 80 deletions(-)

diff --git a/components/camel-couchbase/pom.xml 
b/components/camel-couchbase/pom.xml
index b594940..fb5a552 100644
--- a/components/camel-couchbase/pom.xml
+++ b/components/camel-couchbase/pom.xml
@@ -60,13 +60,13 @@
 
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
+            <artifactId>camel-test-junit5</artifactId>
             <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
+            <artifactId>mockito-junit-jupiter</artifactId>
             <scope>test</scope>
         </dependency>
 
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
index e94b9cb..452cef3 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ConsumeBeerMessagesWithLimitIntegrationTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.couchbase;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
 
 public class ConsumeBeerMessagesWithLimitIntegrationTest extends 
CamelTestSupport {
 
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseComponentTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseComponentTest.java
index a2b0222..b5189e3 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseComponentTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseComponentTest.java
@@ -20,13 +20,18 @@ import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class CouchbaseComponentTest extends CamelTestSupport {
 
     private CouchbaseComponent component;
 
+    @BeforeEach
     @Override
     public void setUp() throws Exception {
         super.setUp();
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseEndpointTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseEndpointTest.java
index 90294a3..677996d 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseEndpointTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseEndpointTest.java
@@ -18,11 +18,12 @@ package org.apache.camel.component.couchbase;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static 
org.apache.camel.component.couchbase.CouchbaseConstants.DEFAULT_COUCHBASE_PORT;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class CouchbaseEndpointTest {
 
@@ -32,9 +33,10 @@ public class CouchbaseEndpointTest {
         assertTrue(endpoint.isSingleton());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testBucketRequired() throws Exception {
-        new CouchbaseEndpoint("couchbase:http://localhost:80";, 
"http://localhost:80";, new CouchbaseComponent());
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseEndpoint("couchbase:http://localhost:80";, 
"http://localhost:80";, new CouchbaseComponent()));
     }
 
     @Test
@@ -43,14 +45,16 @@ public class CouchbaseEndpointTest {
         assertEquals(DEFAULT_COUCHBASE_PORT, endpoint.getPort());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testHostnameRequired() throws Exception {
-        new CouchbaseEndpoint("couchbase:http://:80/bucket";, 
"couchbase://:80/bucket", new CouchbaseComponent());
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseEndpoint("couchbase:http://:80/bucket";, 
"couchbase://:80/bucket", new CouchbaseComponent()));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSchemeRequired() throws Exception {
-        new CouchbaseEndpoint("couchbase:localhost:80/bucket", 
"localhost:80/bucket", new CouchbaseComponent());
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseEndpoint("couchbase:localhost:80/bucket", 
"localhost:80/bucket", new CouchbaseComponent()));
     }
 
     @Test
@@ -58,9 +62,10 @@ public class CouchbaseEndpointTest {
         new CouchbaseEndpoint();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testCouchbaseEndpointWithoutProtocol() throws Exception {
-        new CouchbaseEndpoint("localhost:80/bucket", "localhost:80/bucket", 
new CouchbaseComponent());
+        assertThrows(IllegalArgumentException.class, 
+            () -> new CouchbaseEndpoint("localhost:80/bucket", 
"localhost:80/bucket", new CouchbaseComponent()));
     }
 
     @Test
@@ -68,19 +73,19 @@ public class CouchbaseEndpointTest {
         new CouchbaseEndpoint("couchbase:localhost:80/bucket", new 
CouchbaseComponent());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testCouchbaseEndpointCreateProducer() throws Exception {
-        new CouchbaseEndpoint("couchbase:localhost:80/bucket", new 
CouchbaseComponent()).createProducer();
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseEndpoint("couchbase:localhost:80/bucket", new 
CouchbaseComponent()).createProducer());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testCouchbaseEndpointCreateConsumer() throws Exception {
-        new CouchbaseEndpoint("couchbase:localhost:80/bucket", new 
CouchbaseComponent()).createConsumer(new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                // Nothing to do
-            }
-        });
+        Processor p = exchange -> {
+            // Nothing to do
+        };
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseEndpoint("couchbase:localhost:80/bucket", new 
CouchbaseComponent()).createConsumer(p));
     }
 
     @Test
@@ -88,73 +93,73 @@ public class CouchbaseEndpointTest {
         CouchbaseEndpoint endpoint = new CouchbaseEndpoint();
 
         endpoint.setProtocol("couchbase");
-        assertTrue(endpoint.getProtocol().equals("couchbase"));
+        assertEquals("couchbase", endpoint.getProtocol());
 
         endpoint.setBucket("bucket");
-        assertTrue(endpoint.getBucket().equals("bucket"));
+        assertEquals("bucket", endpoint.getBucket());
 
         endpoint.setHostname("localhost");
-        assertTrue(endpoint.getHostname().equals("localhost"));
+        assertEquals("localhost", endpoint.getHostname());
 
         endpoint.setPort(80);
-        assertTrue(endpoint.getPort() == 80);
+        assertEquals(80, endpoint.getPort());
 
         endpoint.setOperation("PUT");
-        assertTrue(endpoint.getOperation().equals("PUT"));
+        assertEquals("PUT", endpoint.getOperation());
 
         endpoint.setStartingIdForInsertsFrom(1L);
-        assertTrue(endpoint.getStartingIdForInsertsFrom() == 1L);
+        assertEquals(1L, endpoint.getStartingIdForInsertsFrom());
 
         endpoint.setProducerRetryAttempts(5);
-        assertTrue(endpoint.getProducerRetryAttempts() == 5);
+        assertEquals(5, endpoint.getProducerRetryAttempts());
 
         endpoint.setProducerRetryPause(1);
-        assertTrue(endpoint.getProducerRetryPause() == 1);
+        assertEquals(1, endpoint.getProducerRetryPause());
 
         endpoint.setDesignDocumentName("beer");
-        assertTrue(endpoint.getDesignDocumentName().equals("beer"));
+        assertEquals("beer", endpoint.getDesignDocumentName());
 
         endpoint.setViewName("brewery_beers");
-        assertTrue(endpoint.getViewName().equals("brewery_beers"));
+        assertEquals("brewery_beers", endpoint.getViewName());
 
         endpoint.setLimit(1);
-        assertTrue(endpoint.getLimit() == 1);
+        assertEquals(1, endpoint.getLimit());
 
         endpoint.setSkip(1);
-        assertTrue(endpoint.getSkip() == 1);
+        assertEquals(1, endpoint.getSkip());
 
         endpoint.setRangeStartKey("");
-        assertTrue(endpoint.getRangeStartKey().equals(""));
+        assertEquals("", endpoint.getRangeStartKey());
 
         endpoint.setRangeEndKey("");
-        assertTrue(endpoint.getRangeEndKey().equals(""));
+        assertEquals("", endpoint.getRangeEndKey());
 
         endpoint.setConsumerProcessedStrategy("delete");
-        assertTrue(endpoint.getConsumerProcessedStrategy().equals("delete"));
+        assertEquals("delete", endpoint.getConsumerProcessedStrategy());
 
         endpoint.setOpTimeOut(1L);
-        assertTrue(endpoint.getOpTimeOut() == 1L);
+        assertEquals(1L, endpoint.getOpTimeOut());
 
         endpoint.setTimeoutExceptionThreshold(1);
-        assertTrue(endpoint.getTimeoutExceptionThreshold() == 1);
+        assertEquals(1, endpoint.getTimeoutExceptionThreshold());
 
         endpoint.setReadBufferSize(1);
-        assertTrue(endpoint.getReadBufferSize() == 1);
+        assertEquals(1, endpoint.getReadBufferSize());
 
         endpoint.setShouldOptimize(true);
         assertTrue(endpoint.isShouldOptimize());
 
         endpoint.setMaxReconnectDelay(1L);
-        assertTrue(endpoint.getMaxReconnectDelay() == 1L);
+        assertEquals(1L, endpoint.getMaxReconnectDelay());
 
         endpoint.setOpQueueMaxBlockTime(1L);
-        assertTrue(endpoint.getOpQueueMaxBlockTime() == 1L);
+        assertEquals(1L, endpoint.getOpQueueMaxBlockTime());
 
         endpoint.setObsPollInterval(1L);
-        assertTrue(endpoint.getObsPollInterval() == 1L);
+        assertEquals(1L, endpoint.getObsPollInterval());
 
         endpoint.setObsTimeout(1L);
-        assertTrue(endpoint.getObsTimeout() == 1L);
+        assertEquals(1L, endpoint.getObsTimeout());
 
         endpoint.setDescending(false);
     }
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseProducerTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseProducerTest.java
index 6dbeb72..b64316e 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseProducerTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/CouchbaseProducerTest.java
@@ -23,25 +23,26 @@ import com.couchbase.client.CouchbaseClient;
 import net.spy.memcached.internal.OperationFuture;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.invocation.InvocationOnMock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.stubbing.Answer;
 
 import static 
org.apache.camel.component.couchbase.CouchbaseConstants.HEADER_TTL;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.lenient;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
 public class CouchbaseProducerTest {
 
     @Mock
@@ -64,45 +65,46 @@ public class CouchbaseProducerTest {
 
     private CouchbaseProducer producer;
 
-    @Before
+    @BeforeEach
     public void before() throws Exception {
-        
when(endpoint.getProducerRetryAttempts()).thenReturn(CouchbaseConstants.DEFAULT_PRODUCER_RETRIES);
+        
lenient().when(endpoint.getProducerRetryAttempts()).thenReturn(CouchbaseConstants.DEFAULT_PRODUCER_RETRIES);
         producer = new CouchbaseProducer(endpoint, client, 0, 0);
-        when(exchange.getIn()).thenReturn(msg);
+        lenient().when(exchange.getIn()).thenReturn(msg);
     }
 
-    @Test(expected = CouchbaseException.class)
+    @Test
     public void testBodyMandatory() throws Exception {
-        producer.process(exchange);
+        assertThrows(CouchbaseException.class,
+            () -> producer.process(exchange));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testPersistToLowerThanSupported() throws Exception {
-        producer = new CouchbaseProducer(endpoint, client, -1, 0);
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseProducer(endpoint, client, -1, 0));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testPersistToHigherThanSupported() throws Exception {
-        producer = new CouchbaseProducer(endpoint, client, 5, 0);
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseProducer(endpoint, client, 5, 0));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testReplicateToLowerThanSupported() throws Exception {
-        producer = new CouchbaseProducer(endpoint, client, 0, -1);
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseProducer(endpoint, client, 0, -1));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testReplicateToHigherThanSupported() throws Exception {
-        producer = new CouchbaseProducer(endpoint, client, 0, 4);
+        assertThrows(IllegalArgumentException.class,
+            () -> new CouchbaseProducer(endpoint, client, 0, 4));
     }
 
     @Test
     public void testMaximumValuesForPersistToAndRepicateTo() throws Exception {
-        try {
-            producer = new CouchbaseProducer(endpoint, client, 4, 3);
-        } catch (IllegalArgumentException e) {
-            Assert.fail("Exception was thrown while testing maximum values for 
persistTo and replicateTo parameters " + e.getMessage());
-        }
+        producer = new CouchbaseProducer(endpoint, client, 4, 3);
     }
 
     @Test
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesSimpleTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesSimpleTest.java
index 5dcb808..d5d3bdc 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesSimpleTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesSimpleTest.java
@@ -18,14 +18,14 @@ package org.apache.camel.component.couchbase;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 public class ProduceMessagesSimpleTest extends CamelTestSupport {
 
     // Ignore test since build environment does not have any couchbase instance
-    @Ignore
+    @Disabled
     @Test
     public void testInsert() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesWithAutoIDIntegrationTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesWithAutoIDIntegrationTest.java
index f67868b..d509240 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesWithAutoIDIntegrationTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/ProduceMessagesWithAutoIDIntegrationTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.couchbase;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
 
 public class ProduceMessagesWithAutoIDIntegrationTest extends CamelTestSupport 
{
 
diff --git 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/RemoveMessagesIntegrationTest.java
 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/RemoveMessagesIntegrationTest.java
index bf03b3d..452dd24 100644
--- 
a/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/RemoveMessagesIntegrationTest.java
+++ 
b/components/camel-couchbase/src/test/java/org/apache/camel/component/couchbase/RemoveMessagesIntegrationTest.java
@@ -18,8 +18,8 @@ package org.apache.camel.component.couchbase;
 
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
 
 public class RemoveMessagesIntegrationTest extends CamelTestSupport {
 

Reply via email to