You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/11/13 09:51:49 UTC

[camel] branch master updated: CAMEL-15789: camel-couchbase - Added test. Thanks to Otavio.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new b8712eb  CAMEL-15789: camel-couchbase - Added test. Thanks to Otavio.
b8712eb is described below

commit b8712eb866f044b9c3e042c9569ae6c4bb0da7f5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 13 10:51:10 2020 +0100

    CAMEL-15789: camel-couchbase - Added test. Thanks to Otavio.
---
 .../couchbase/CouchbaseComponentTest.java          | 58 +++++++++++++++++-----
 1 file changed, 46 insertions(+), 12 deletions(-)

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 17a5938..9bc1344 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
@@ -46,9 +46,10 @@ public class CouchbaseComponentTest extends CamelTestSupport {
     @Test
     public void testEndpointCreated() throws Exception {
         Map<String, Object> params = new HashMap<>();
+        params.put("bucket", "bucket");
 
-        String uri = "couchbase:http://localhost:9191/bucket";
-        String remaining = "http://localhost:9191/bucket";
+        String uri = "couchbase:http://localhost:9191?bucket=bucket";
+        String remaining = "http://localhost:9191";
 
         CouchbaseEndpoint endpoint = component.createEndpoint(uri, remaining, params);
         assertNotNull(endpoint);
@@ -62,6 +63,7 @@ public class CouchbaseComponentTest extends CamelTestSupport {
         params.put("additionalHosts", "127.0.0.1,example.com,another-host");
         params.put("persistTo", 2);
         params.put("replicateTo", 3);
+        params.put("bucket", "bucket");
 
         String uri = "couchdb:http://localhost:91234";
         String remaining = "http://localhost:91234";
@@ -81,8 +83,9 @@ public class CouchbaseComponentTest extends CamelTestSupport {
     @Test
     public void testCouchbaseURI() throws Exception {
         Map<String, Object> params = new HashMap<>();
-        String uri = "couchbase:http://localhost/bucket?param=true";
-        String remaining = "http://localhost/bucket?param=true";
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
 
         CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
         assertEquals(new URI("http://localhost:8091/pools"), endpoint.makeBootstrapURI()[0]);
@@ -92,8 +95,9 @@ public class CouchbaseComponentTest extends CamelTestSupport {
     public void testCouchbaseAdditionalHosts() throws Exception {
         Map<String, Object> params = new HashMap<>();
         params.put("additionalHosts", "127.0.0.1,example.com,another-host");
-        String uri = "couchbase:http://localhost/bucket?param=true";
-        String remaining = "http://localhost/bucket?param=true";
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
 
         CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
 
@@ -109,8 +113,9 @@ public class CouchbaseComponentTest extends CamelTestSupport {
     public void testCouchbaseAdditionalHostsWithSpaces() throws Exception {
         Map<String, Object> params = new HashMap<>();
         params.put("additionalHosts", " 127.0.0.1, example.com, another-host ");
-        String uri = "couchbase:http://localhost/bucket?param=true";
-        String remaining = "http://localhost/bucket?param=true";
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
 
         CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
 
@@ -126,8 +131,9 @@ public class CouchbaseComponentTest extends CamelTestSupport {
     public void testCouchbaseDuplicateAdditionalHosts() throws Exception {
         Map<String, Object> params = new HashMap<>();
         params.put("additionalHosts", "127.0.0.1,localhost, localhost");
-        String uri = "couchbase:http://localhost/bucket?param=true";
-        String remaining = "http://localhost/bucket?param=true";
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
 
         CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
         URI[] endpointArray = endpoint.makeBootstrapURI();
@@ -140,8 +146,9 @@ public class CouchbaseComponentTest extends CamelTestSupport {
     public void testCouchbaseNullAdditionalHosts() throws Exception {
         Map<String, Object> params = new HashMap<>();
         params.put("additionalHosts", null);
-        String uri = "couchbase:http://localhost/bucket?param=true";
-        String remaining = "http://localhost/bucket?param=true";
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
 
         CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
 
@@ -150,4 +157,31 @@ public class CouchbaseComponentTest extends CamelTestSupport {
         assertEquals(1, endpointArray.length);
     }
 
+    @Test
+    public void testCouchbaseURIWithBucket1() throws Exception {
+        Map<String, Object> params = new HashMap<>();
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
+
+        CouchbaseComponent couchbaseComponent = new CouchbaseComponent(context);
+        CouchbaseEndpoint endpoint = couchbaseComponent.createEndpoint(uri, remaining, params);
+
+        assertEquals(new URI("http://localhost:8091/pools"), endpoint.makeBootstrapURI()[0]);
+        assertEquals("bucket", endpoint.getBucket());
+    }
+
+    @Test
+    public void testCouchbaseURIWithBucket2() throws Exception {
+        Map<String, Object> params = new HashMap<>();
+        params.put("bucket", "bucket");
+        String uri = "couchbase:http://localhost";
+        String remaining = "http://localhost";
+
+        CouchbaseComponent couchbaseComponent = new CouchbaseComponent(context);
+        CouchbaseEndpoint endpoint = couchbaseComponent.createEndpoint(uri, remaining, params);
+
+        assertEquals(new URI("http://localhost:8091/pools"), endpoint.makeBootstrapURI()[0]);
+        assertEquals("bucket", endpoint.getBucket());
+    }
 }