Search in sources :

Example 31 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class GetProjectionIntegrationTest method attributes_hobbies_1_details_location.

@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
@Test
void attributes_hobbies_1_details_location() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes.hobbies[1].details.location")).contentAsObject();
    JsonArray arr = decoded.getObject("attributes").getArray("hobbies");
    JsonObject obj = arr.getObject(0).getObject("details").getObject("location");
    assertEquals(1, arr.size());
    assertEquals(2, obj.size());
    assertEquals(1, decoded.size());
}
Also used : JsonArray(com.couchbase.client.java.json.JsonArray) JsonObject(com.couchbase.client.java.json.JsonObject) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 32 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class KeyValueCollectionIntegrationTest method recognizesCollectionAfterCreation.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void recognizesCollectionAfterCreation() {
    String collId = UUID.randomUUID().toString().substring(0, 10);
    CollectionSpec collectionSpec = CollectionSpec.create(collId, CollectionIdentifier.DEFAULT_SCOPE);
    bucket.collections().createCollection(collectionSpec);
    Collection collection = bucket.collection(collId);
    String id = UUID.randomUUID().toString();
    String content = "bar";
    MutationResult upsertResult = collection.upsert(id, content);
    GetResult getResult = collection.get(id);
    assertEquals(upsertResult.cas(), getResult.cas());
    assertEquals(content, getResult.contentAs(String.class));
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) CollectionSpec(com.couchbase.client.java.manager.collection.CollectionSpec) MutationResult(com.couchbase.client.java.kv.MutationResult) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 33 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class KeyValueChannelIntegrationTest method failWithInvalidUsernameCredential.

@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void failWithInvalidUsernameCredential() throws Exception {
    TestNodeConfig node = config().nodes().get(0);
    Bootstrap bootstrap = new Bootstrap().remoteAddress(node.hostname(), node.ports().get(Services.KV)).group(eventLoopGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            new KeyValueEndpoint.KeyValuePipelineInitializer(endpointContext, Optional.of(config().bucketname()), PasswordAuthenticator.create("vfwmf42343rew", config().adminPassword())).init(null, ch.pipeline());
        }
    });
    assertAuthenticationFailure(bootstrap, "Authentication Failure");
}
Also used : NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.SocketChannel) NioSocketChannel(com.couchbase.client.core.deps.io.netty.channel.socket.nio.NioSocketChannel) TestNodeConfig(com.couchbase.client.test.TestNodeConfig) Bootstrap(com.couchbase.client.core.deps.io.netty.bootstrap.Bootstrap) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 34 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class ObserveIntegrationTest method failsFastIfTooManyReplicasRequested.

@Test
@IgnoreWhen(replicasGreaterThan = 1)
void failsFastIfTooManyReplicasRequested() {
    String id = UUID.randomUUID().toString();
    InsertResponse insertResponse = performInsert(id);
    assertTrue(insertResponse.mutationToken().isPresent());
    final ObserveContext ctx = new ObserveContext(core.context(), Observe.ObservePersistTo.THREE, Observe.ObserveReplicateTo.NONE, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    assertThrows(ReplicaNotConfiguredException.class, () -> Observe.poll(ctx).timeout(MAX_WAIT).block());
    final ObserveContext ctx2 = new ObserveContext(core.context(), Observe.ObservePersistTo.NONE, Observe.ObserveReplicateTo.TWO, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    assertThrows(ReplicaNotConfiguredException.class, () -> Observe.poll(ctx2).timeout(MAX_WAIT).block());
    final ObserveContext ctx3 = new ObserveContext(core.context(), Observe.ObservePersistTo.FOUR, Observe.ObserveReplicateTo.THREE, insertResponse.mutationToken(), 0, cid, id, false, env.timeoutConfig().kvTimeout(), null);
    assertThrows(ReplicaNotConfiguredException.class, () -> Observe.poll(ctx3).timeout(MAX_WAIT).block());
}
Also used : InsertResponse(com.couchbase.client.core.msg.kv.InsertResponse) ObserveContext(com.couchbase.client.core.service.kv.ObserveContext) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest)

Example 35 with IgnoreWhen

use of com.couchbase.client.test.IgnoreWhen in project couchbase-jvm-clients by couchbase.

the class SyncReplicationIntegrationTest method upsertSuccessfullyToMajority.

/**
 * This test works if a cluster has two or more nodes and one replica configured.
 */
@Test
@IgnoreWhen(nodesLessThan = 2, replicasLessThan = 1, replicasGreaterThan = 1, missesCapabilities = { Capabilities.SYNC_REPLICATION }, clusterTypes = ClusterType.CAVES)
void upsertSuccessfullyToMajority() throws Exception {
    String id = UUID.randomUUID().toString();
    byte[] content = "hello, world".getBytes(UTF_8);
    UpsertRequest upsertRequest = new UpsertRequest(id, content, 0, false, 0, kvTimeout, core.context(), CollectionIdentifier.fromDefault(config().bucketname()), env.retryStrategy(), Optional.of(DurabilityLevel.MAJORITY), null);
    core.send(upsertRequest);
    UpsertResponse upsertResponse = upsertRequest.response().get();
    assertTrue(upsertResponse.status().success());
    assertTrue(upsertResponse.cas() != 0);
}
Also used : UpsertResponse(com.couchbase.client.core.msg.kv.UpsertResponse) UpsertRequest(com.couchbase.client.core.msg.kv.UpsertRequest) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) CoreIntegrationTest(com.couchbase.client.core.util.CoreIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

IgnoreWhen (com.couchbase.client.test.IgnoreWhen)79 Test (org.junit.jupiter.api.Test)78 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)70 JsonObject (com.couchbase.client.java.json.JsonObject)41 GetResult (com.couchbase.client.java.kv.GetResult)15 MutationResult (com.couchbase.client.java.kv.MutationResult)13 CoreIntegrationTest (com.couchbase.client.core.util.CoreIntegrationTest)9 RateLimitedException (com.couchbase.client.core.error.RateLimitedException)8 TimeoutException (com.couchbase.client.core.error.TimeoutException)7 LookupInResult (com.couchbase.client.java.kv.LookupInResult)7 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)6 ReplaceBodyWithXattr (com.couchbase.client.java.kv.ReplaceBodyWithXattr)6 SearchIndex (com.couchbase.client.java.manager.search.SearchIndex)5 CasMismatchException (com.couchbase.client.core.error.CasMismatchException)4 MutateInResult (com.couchbase.client.java.kv.MutateInResult)4 TestNodeConfig (com.couchbase.client.test.TestNodeConfig)4 DocumentNotFoundException (com.couchbase.client.core.error.DocumentNotFoundException)3 FeatureNotAvailableException (com.couchbase.client.core.error.FeatureNotAvailableException)3 UnambiguousTimeoutException (com.couchbase.client.core.error.UnambiguousTimeoutException)3 Core (com.couchbase.client.core.Core)2