Search in sources :

Example 66 with IgnoreWhen

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

the class SubdocMutateIntegrationTest method reviveDocumentOnAlreadyAliveDocument.

@IgnoreWhen(missesCapabilities = { Capabilities.SUBDOC_REVIVE_DOCUMENT })
@Test
void reviveDocumentOnAlreadyAliveDocument() {
    String docId = docId();
    JsonObject body = JsonObject.create().put("foo", "bar");
    coll.insert(docId, body);
    try {
        coll.mutateIn(docId, Collections.singletonList(upsert("foo", "bar").xattr()), MutateInOptions.mutateInOptions().accessDeleted(true).storeSemantics(StoreSemantics.REVIVE));
        fail();
    } catch (DocumentAlreadyAliveException ignored) {
        assertEquals(CAN_ONLY_REVIVE_DELETED_DOCUMENTS.name(), ignored.context().exportAsMap().get("subdocStatus"));
    }
}
Also used : DocumentAlreadyAliveException(com.couchbase.client.core.error.subdoc.DocumentAlreadyAliveException) 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 67 with IgnoreWhen

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

the class KeyValueIntegrationTest method getAndTouch.

/**
 * This test is ignored against the mock because right now it does not bump the CAS like
 * the server does when getAndTouch is called.
 *
 * <p>Remove the ignore as soon as https://github.com/couchbase/CouchbaseMock/issues/49 is
 * fixed.</p>
 */
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void getAndTouch() {
    String id = UUID.randomUUID().toString();
    JsonObject expected = JsonObject.create().put("foo", true);
    MutationResult insert = collection.insert(id, expected, insertOptions().expiry(Duration.ofSeconds(10)));
    assertTrue(insert.cas() != 0);
    GetResult getAndTouch = collection.getAndTouch(id, Duration.ofSeconds(1));
    assertTrue(getAndTouch.cas() != 0);
    assertNotEquals(insert.cas(), getAndTouch.cas());
    assertEquals(expected, getAndTouch.contentAsObject());
    waitUntilCondition(() -> {
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
        // ignored.
        }
        try {
            collection.get(id);
            return false;
        } catch (DocumentNotFoundException knf) {
            return true;
        }
    });
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) DocumentNotFoundException(com.couchbase.client.core.error.DocumentNotFoundException) JsonObject(com.couchbase.client.java.json.JsonObject) 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 68 with IgnoreWhen

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

the class KeyValueIntegrationTest method fullDocWithExpirationAndCustomTranscoder.

@Test
@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
void fullDocWithExpirationAndCustomTranscoder() {
    String id = UUID.randomUUID().toString();
    JsonObject content = JsonObject.create().put("foo", "bar").put("created", true).put("age", 12);
    MutationResult mutationResult = collection.upsert(id, content.toBytes(), upsertOptions().expiry(Duration.ofSeconds(5)).transcoder(RawBinaryTranscoder.INSTANCE));
    assertTrue(mutationResult.cas() != 0);
    GetResult getResult = collection.get(id, getOptions().withExpiry(true).transcoder(RawBinaryTranscoder.INSTANCE));
    assertTrue(getResult.expiryTime().isPresent());
    assertTrue(getResult.expiryTime().get().toEpochMilli() > 0);
    assertEquals(content, JsonObject.fromJson(getResult.contentAs(byte[].class)));
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) JsonObject(com.couchbase.client.java.json.JsonObject) 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 69 with IgnoreWhen

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

the class KeyValueIntegrationTest method fullDocWithExpiration.

/**
 * Right now the mock does not support xattr/macro expansion so this test is
 * ignored on the mock. Once the mock supports it, please remove the ignore
 * annotation.
 *
 * <p>See https://github.com/couchbase/CouchbaseMock/issues/46</p>
 */
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void fullDocWithExpiration() {
    String id = UUID.randomUUID().toString();
    JsonObject content = JsonObject.create().put("foo", "bar").put("created", true).put("age", 12);
    MutationResult mutationResult = collection.upsert(id, content, upsertOptions().expiry(Duration.ofSeconds(5)));
    assertTrue(mutationResult.cas() != 0);
    GetResult getResult = collection.get(id, getOptions().withExpiry(true));
    assertTrue(getResult.expiryTime().isPresent());
    assertTrue(getResult.expiryTime().get().toEpochMilli() > 0);
    assertEquals(content, getResult.contentAsObject());
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) JsonObject(com.couchbase.client.java.json.JsonObject) 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 70 with IgnoreWhen

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

the class KeyValueIntegrationTest method decrement.

/**
 * Right now the mock allows the value to be decremented below zero, which is against the server
 * spec/protocol. Once https://github.com/couchbase/CouchbaseMock/issues/51 is fixed, this
 * ignore annotation can be removed.
 */
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void decrement() {
    String id = UUID.randomUUID().toString();
    assertThrows(DocumentNotFoundException.class, () -> collection.binary().decrement(id));
    CounterResult result = collection.binary().decrement(id, decrementOptions().initial(2L));
    assertTrue(result.cas() != 0);
    assertEquals(2L, result.content());
    result = collection.binary().decrement(id);
    assertTrue(result.cas() != 0);
    assertEquals(1L, result.content());
    result = collection.binary().decrement(id);
    assertTrue(result.cas() != 0);
    assertEquals(0L, result.content());
    result = collection.binary().decrement(id);
    assertTrue(result.cas() != 0);
    assertEquals(0L, result.content());
}
Also used : CounterResult(com.couchbase.client.java.kv.CounterResult) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) 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