CouchbaseComponent extends DefaultComponent { @Override protected CouchbaseEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { CouchbaseEndpoint endpoint = new CouchbaseEndpoint(uri, remaining, this); setProperties(endpoint, parameters); return endpoint; } CouchbaseComponent();  CouchbaseComponent(CamelContext context);   }
@Test public void testEndpointCreated() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); String uri = "couchbase:http: String remaining = "http: Endpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); assertNotNull(endpoint); }
@Test public void testPropertiesSet() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("username", "ugol"); params.put("password", "pwd"); params.put("additionalHosts", "127.0.0.1,example.com,another-host"); params.put("persistTo", 2); params.put("replicateTo", 3); String uri = "couchdb:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); assertEquals("http", endpoint.getProtocol()); assertEquals("localhost", endpoint.getHostname()); assertEquals("bucket", endpoint.getBucket()); assertEquals(91234, endpoint.getPort()); assertEquals("ugol", endpoint.getUsername()); assertEquals("pwd", endpoint.getPassword()); assertEquals("127.0.0.1,example.com,another-host", endpoint.getAdditionalHosts()); assertEquals(2, endpoint.getPersistTo()); assertEquals(3, endpoint.getReplicateTo()); }
@Test public void testCouchbaseURI() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); String uri = "couchbase:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); assertEquals(new URI("http: }
@Test public void testCouchbaseAdditionalHosts() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("additionalHosts", "127.0.0.1,example.com,another-host"); String uri = "couchbase:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); URI[] endpointArray = endpoint.makeBootstrapURI(); assertEquals(new URI("http: assertEquals(new URI("http: assertEquals(new URI("http: assertEquals(new URI("http: assertEquals(4, endpointArray.length); }
@Test public void testCouchbaseAdditionalHostsWithSpaces() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("additionalHosts", " 127.0.0.1, example.com, another-host "); String uri = "couchbase:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); URI[] endpointArray = endpoint.makeBootstrapURI(); assertEquals(new URI("http: assertEquals(new URI("http: assertEquals(new URI("http: assertEquals(new URI("http: assertEquals(4, endpointArray.length); }
@Test public void testCouchbaseDuplicateAdditionalHosts() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("additionalHosts", "127.0.0.1,localhost, localhost"); String uri = "couchbase:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); URI[] endpointArray = endpoint.makeBootstrapURI(); assertEquals(2, endpointArray.length); assertEquals(new URI("http: assertEquals(new URI("http: }
@Test public void testCouchbaseNullAdditionalHosts() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("additionalHosts", null); String uri = "couchbase:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); URI[] endpointArray = endpoint.makeBootstrapURI(); assertEquals(1, endpointArray.length); }
@Test public void testCouchbasePersistToAndReplicateToParameters() throws Exception { Map<String, Object> params = new HashMap<String, Object>(); params.put("persistTo", "1"); params.put("replicateTo", "2"); String uri = "couchbase:http: String remaining = "http: CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params); assertEquals(1, endpoint.getPersistTo()); assertEquals(2, endpoint.getReplicateTo()); }