Search in sources :

Example 1 with Authenticator

use of com.couchbase.client.core.env.Authenticator in project couchbase-jvm-clients by couchbase.

the class CoreContextTest method getAndExportProperties.

@Test
void getAndExportProperties() {
    long id = 12345;
    CoreEnvironment env = mock(CoreEnvironment.class);
    Core core = mock(Core.class);
    Authenticator authenticator = mock(Authenticator.class);
    CoreContext ctx = new CoreContext(core, id, env, authenticator);
    assertEquals(core, ctx.core());
    assertEquals(id, ctx.id());
    assertEquals(env, ctx.environment());
    assertEquals(authenticator, ctx.authenticator());
    String result = ctx.exportAsString(Context.ExportFormat.JSON);
    assertEquals("{\"coreId\":\"0x3039\"}", result);
}
Also used : CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) Authenticator(com.couchbase.client.core.env.Authenticator) Test(org.junit.jupiter.api.Test)

Example 2 with Authenticator

use of com.couchbase.client.core.env.Authenticator in project couchbase-elasticsearch-connector by couchbase.

the class CouchbaseHelper method createCluster.

public static Cluster createCluster(CouchbaseConfig config, ClusterEnvironment env) {
    List<String> hosts = config.hosts();
    // For compatibility with previous 4.2.x versions of the connector,
    // interpret unqualified ports as MANAGER ports instead of KV ports.
    hosts = qualifyPorts(hosts, ConnectionString.PortType.MANAGER);
    String connectionString = String.join(",", hosts);
    Authenticator authenticator = authenticator(config);
    return Cluster.connect(connectionString, clusterOptions(authenticator).environment(env));
}
Also used : ConnectionString(com.couchbase.client.core.util.ConnectionString) PasswordAuthenticator(com.couchbase.client.core.env.PasswordAuthenticator) CertificateAuthenticator(com.couchbase.client.core.env.CertificateAuthenticator) Authenticator(com.couchbase.client.core.env.Authenticator)

Aggregations

Authenticator (com.couchbase.client.core.env.Authenticator)2 CertificateAuthenticator (com.couchbase.client.core.env.CertificateAuthenticator)1 CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)1 PasswordAuthenticator (com.couchbase.client.core.env.PasswordAuthenticator)1 ConnectionString (com.couchbase.client.core.util.ConnectionString)1 Test (org.junit.jupiter.api.Test)1