Search in sources :

Example 11 with ConnectionString

use of com.couchbase.client.core.util.ConnectionString in project couchbase-jvm-clients by couchbase.

the class ConnectionStringTest method shouldAcceptMultipleIPv6WithoutPort.

@Test
void shouldAcceptMultipleIPv6WithoutPort() {
    ConnectionString parsed = ConnectionString.create("couchbase://[::1], [::1]");
    assertEquals(ConnectionString.Scheme.COUCHBASE, parsed.scheme());
    assertEquals(2, parsed.hosts().size());
    assertEquals("::1", parsed.hosts().get(0).hostname());
    assertEquals("::1", parsed.hosts().get(1).hostname());
    assertTrue(parsed.params().isEmpty());
    parsed = ConnectionString.create("couchbase://[::1/128], [::1/128],[::1/128]");
    assertEquals(ConnectionString.Scheme.COUCHBASE, parsed.scheme());
    assertEquals(3, parsed.hosts().size());
    assertEquals("::1/128", parsed.hosts().get(0).hostname());
    assertEquals("::1/128", parsed.hosts().get(1).hostname());
    assertEquals("::1/128", parsed.hosts().get(2).hostname());
    assertTrue(parsed.params().isEmpty());
}
Also used : ConnectionStringUtil.asConnectionString(com.couchbase.client.core.util.ConnectionStringUtil.asConnectionString) ConnectionString(com.couchbase.client.core.util.ConnectionString) Test(org.junit.jupiter.api.Test)

Example 12 with ConnectionString

use of com.couchbase.client.core.util.ConnectionString in project couchbase-jvm-clients by couchbase.

the class ConnectionStringTest method shouldAcceptSingleIPv6WithoutPort.

@Test
void shouldAcceptSingleIPv6WithoutPort() {
    ConnectionString parsed = ConnectionString.create("couchbase://[::1]");
    assertEquals(ConnectionString.Scheme.COUCHBASE, parsed.scheme());
    assertEquals(1, parsed.hosts().size());
    assertEquals("::1", parsed.hosts().get(0).hostname());
    assertEquals(0, parsed.hosts().get(0).port());
    assertTrue(parsed.params().isEmpty());
    parsed = ConnectionString.create("couchbase://[::1/128]");
    assertEquals(ConnectionString.Scheme.COUCHBASE, parsed.scheme());
    assertEquals(1, parsed.hosts().size());
    assertEquals("::1/128", parsed.hosts().get(0).hostname());
    assertEquals(0, parsed.hosts().get(0).port());
    assertTrue(parsed.params().isEmpty());
}
Also used : ConnectionStringUtil.asConnectionString(com.couchbase.client.core.util.ConnectionStringUtil.asConnectionString) ConnectionString(com.couchbase.client.core.util.ConnectionString) Test(org.junit.jupiter.api.Test)

Example 13 with ConnectionString

use of com.couchbase.client.core.util.ConnectionString in project couchbase-jvm-clients by couchbase.

the class ConnectionStringTest method shouldAcceptIpv4WithNewPortType.

@Test
void shouldAcceptIpv4WithNewPortType() {
    ConnectionString parsed = ConnectionString.create("couchbase://foo:1234=manager,bar:5678=kv");
    assertEquals(2, parsed.hosts().size());
    assertEquals("foo", parsed.hosts().get(0).hostname());
    assertEquals(1234, parsed.hosts().get(0).port());
    assertEquals(ConnectionString.PortType.MANAGER, parsed.hosts().get(0).portType().get());
    assertEquals("bar", parsed.hosts().get(1).hostname());
    assertEquals(5678, parsed.hosts().get(1).port());
    assertEquals(ConnectionString.PortType.KV, parsed.hosts().get(1).portType().get());
}
Also used : ConnectionStringUtil.asConnectionString(com.couchbase.client.core.util.ConnectionStringUtil.asConnectionString) ConnectionString(com.couchbase.client.core.util.ConnectionString) Test(org.junit.jupiter.api.Test)

Example 14 with ConnectionString

use of com.couchbase.client.core.util.ConnectionString in project couchbase-jvm-clients by couchbase.

the class ConnectionStringTest method shouldAcceptIpv4WithLcbPortType.

@Test
void shouldAcceptIpv4WithLcbPortType() {
    ConnectionString parsed = ConnectionString.create("couchbase://foo:1234=http,bar:5678=mcd");
    assertEquals(2, parsed.hosts().size());
    assertEquals("foo", parsed.hosts().get(0).hostname());
    assertEquals(1234, parsed.hosts().get(0).port());
    assertEquals(ConnectionString.PortType.MANAGER, parsed.hosts().get(0).portType().get());
    assertEquals("bar", parsed.hosts().get(1).hostname());
    assertEquals(5678, parsed.hosts().get(1).port());
    assertEquals(ConnectionString.PortType.KV, parsed.hosts().get(1).portType().get());
}
Also used : ConnectionStringUtil.asConnectionString(com.couchbase.client.core.util.ConnectionStringUtil.asConnectionString) ConnectionString(com.couchbase.client.core.util.ConnectionString) Test(org.junit.jupiter.api.Test)

Aggregations

ConnectionString (com.couchbase.client.core.util.ConnectionString)14 ConnectionStringUtil.asConnectionString (com.couchbase.client.core.util.ConnectionStringUtil.asConnectionString)12 Test (org.junit.jupiter.api.Test)11 Authenticator (com.couchbase.client.core.env.Authenticator)1 CertificateAuthenticator (com.couchbase.client.core.env.CertificateAuthenticator)1 ConnectionStringPropertyLoader (com.couchbase.client.core.env.ConnectionStringPropertyLoader)1 OwnedSupplier (com.couchbase.client.core.env.OwnedSupplier)1 PasswordAuthenticator (com.couchbase.client.core.env.PasswordAuthenticator)1 ConnectionStringUtil.checkConnectionString (com.couchbase.client.core.util.ConnectionStringUtil.checkConnectionString)1 ClusterEnvironment (com.couchbase.client.java.env.ClusterEnvironment)1 Duration (java.time.Duration)1