use of com.couchbase.client.java.Cluster in project tutorials by eugenp.
the class PersonServiceImplIntegrationTest method setupBeforeClass.
@BeforeClass
public static void setupBeforeClass() {
final Cluster cluster = CouchbaseCluster.create(MultiBucketCouchbaseConfig.NODE_LIST);
final Bucket bucket = cluster.openBucket(MultiBucketCouchbaseConfig.DEFAULT_BUCKET_NAME, MultiBucketCouchbaseConfig.DEFAULT_BUCKET_PASSWORD);
bucket.upsert(JsonDocument.create(johnSmithId, jsonJohnSmith));
bucket.upsert(JsonDocument.create(foobarId, jsonFooBar));
bucket.close();
cluster.disconnect();
}
use of com.couchbase.client.java.Cluster in project tutorials by eugenp.
the class StudentServiceImplIntegrationTest method setupBeforeClass.
@BeforeClass
public static void setupBeforeClass() {
Cluster cluster = CouchbaseCluster.create(MultiBucketCouchbaseConfig.NODE_LIST);
Bucket bucket = cluster.openBucket(MultiBucketCouchbaseConfig.DEFAULT_BUCKET_NAME, MultiBucketCouchbaseConfig.DEFAULT_BUCKET_PASSWORD);
bucket.upsert(JsonDocument.create(joeCollegeId, jsonJoeCollege));
bucket.upsert(JsonDocument.create(judyJetsonId, jsonJudyJetson));
bucket.close();
cluster.disconnect();
}
use of com.couchbase.client.java.Cluster in project samza by apache.
the class CouchbaseBucketRegistry method openCluster.
/**
* Helper method to open a cluster given cluster nodes and environment configurations.
*/
private Cluster openCluster(List<String> clusterNodes, CouchbaseEnvironmentConfigs configs) {
DefaultCouchbaseEnvironment.Builder envBuilder = new DefaultCouchbaseEnvironment.Builder();
if (configs.sslEnabled != null) {
envBuilder.sslEnabled(configs.sslEnabled);
}
if (configs.certAuthEnabled != null) {
envBuilder.certAuthEnabled(configs.certAuthEnabled);
}
if (configs.sslKeystoreFile != null) {
envBuilder.sslKeystoreFile(configs.sslKeystoreFile);
}
if (configs.sslKeystorePassword != null) {
envBuilder.sslKeystorePassword(configs.sslKeystorePassword);
}
if (configs.sslTruststoreFile != null) {
envBuilder.sslTruststoreFile(configs.sslTruststoreFile);
}
if (configs.sslTruststorePassword != null) {
envBuilder.sslTruststorePassword(configs.sslTruststorePassword);
}
if (configs.bootstrapCarrierDirectPort != null) {
envBuilder.bootstrapCarrierDirectPort(configs.bootstrapCarrierDirectPort);
}
if (configs.bootstrapCarrierSslPort != null) {
envBuilder.bootstrapCarrierSslPort(configs.bootstrapCarrierSslPort);
}
if (configs.bootstrapHttpDirectPort != null) {
envBuilder.bootstrapHttpDirectPort(configs.bootstrapHttpDirectPort);
}
if (configs.bootstrapHttpSslPort != null) {
envBuilder.bootstrapHttpSslPort(configs.bootstrapHttpSslPort);
}
CouchbaseEnvironment env = envBuilder.build();
Cluster cluster = CouchbaseCluster.create(env, clusterNodes);
if (configs.sslEnabled != null && configs.sslEnabled) {
cluster.authenticate(CertAuthenticator.INSTANCE);
} else if (configs.username != null) {
cluster.authenticate(configs.username, configs.password);
} else {
LOGGER.warn("No authentication is enabled for cluster: {}. This is not recommended except for test cases.", clusterNodes);
}
return cluster;
}
use of com.couchbase.client.java.Cluster in project spring-boot by spring-projects.
the class CouchbaseAutoConfigurationIntegrationTests method defaultConfiguration.
@Test
void defaultConfiguration() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(Cluster.class).hasSingleBean(ClusterEnvironment.class);
Cluster cluster = context.getBean(Cluster.class);
Bucket bucket = cluster.bucket(BUCKET_NAME);
bucket.waitUntilReady(Duration.ofMinutes(5));
DiagnosticsResult diagnostics = cluster.diagnostics();
assertThat(diagnostics.state()).isEqualTo(ClusterState.ONLINE);
});
}
use of com.couchbase.client.java.Cluster in project spring-boot by spring-projects.
the class CouchbaseAutoConfigurationIntegrationTests method whenCouchbaseIsUsingCustomObjectMapperThenJsonCanBeRoundTripped.
@Test
void whenCouchbaseIsUsingCustomObjectMapperThenJsonCanBeRoundTripped() {
this.contextRunner.withBean(ObjectMapper.class, ObjectMapper::new).run((context) -> {
Cluster cluster = context.getBean(Cluster.class);
Bucket bucket = cluster.bucket(BUCKET_NAME);
bucket.waitUntilReady(Duration.ofMinutes(5));
Collection collection = bucket.defaultCollection();
collection.insert("test-document", JsonObject.create().put("a", "alpha"));
assertThat(collection.get("test-document").contentAsObject().get("a")).isEqualTo("alpha");
});
}
Aggregations