Search in sources :

Example 26 with IgnoreWhen

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

the class KeyValueIntegrationTest method touch.

/**
 * Right now the mock does not change the cas on touch, so we need to ignore the test
 * until https://github.com/couchbase/CouchbaseMock/issues/50 is resolved.
 */
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void touch() throws Exception {
    String id = UUID.randomUUID().toString();
    JsonObject expected = JsonObject.create().put("foo", true);
    MutationResult upsert = collection.upsert(id, expected, upsertOptions().expiry(Duration.ofSeconds(10)));
    assertTrue(upsert.cas() != 0);
    MutationResult touched = collection.touch(id, Duration.ofSeconds(1));
    assertNotEquals(touched.cas(), upsert.cas());
    Thread.sleep(300);
    GetResult r = collection.get(id);
    assertEquals(expected, r.contentAsObject());
    assertEquals(r.cas(), touched.cas());
    waitUntilCondition(() -> {
        try {
            Thread.sleep(100);
        } 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 27 with IgnoreWhen

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

the class KeyValueIntegrationTest method unlock.

/**
 * The mock returns TMPFAIL instead of LOCKED, so this test is ignored on the mock.
 */
@Test
@IgnoreWhen(clusterTypes = { ClusterType.MOCKED })
void unlock() {
    String id = UUID.randomUUID().toString();
    MutationResult upsert = collection.upsert(id, JsonObject.create().put("foo", true));
    assertTrue(upsert.cas() != 0);
    GetResult locked = collection.getAndLock(id, Duration.ofSeconds(30));
    TimeoutException exception = assertThrows(TimeoutException.class, () -> collection.upsert(id, JsonObject.create(), upsertOptions().timeout(Duration.ofMillis(100))));
    assertEquals(EnumSet.of(RetryReason.KV_LOCKED), exception.context().requestContext().retryReasons());
    assertThrows(CasMismatchException.class, () -> collection.unlock(id, locked.cas() + 1));
    collection.unlock(id, locked.cas());
    JsonObject expected = JsonObject.create().put("foo", false);
    MutationResult replaced = collection.replace(id, expected);
    assertTrue(replaced.cas() != 0);
    assertEquals(expected, collection.get(id).contentAsObject());
}
Also used : GetResult(com.couchbase.client.java.kv.GetResult) JsonObject(com.couchbase.client.java.json.JsonObject) MutationResult(com.couchbase.client.java.kv.MutationResult) TimeoutException(com.couchbase.client.core.error.TimeoutException) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 28 with IgnoreWhen

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

the class CreateAsDeletedIntegrationTest method upsertTombstone.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void upsertTombstone() {
    String id = docId();
    upsertTombstoneWithTxnXattr(coll, id, JsonObject.create());
    coll.upsert(id, JsonObject.create());
    LookupInResult r = assertIsRegularDoc(coll, id);
    // Make sure the transaction xattr's in the tombstone have been wiped
    // txn xattr
    assertFalse(r.exists(0));
    // body
    assertTrue(r.exists(1));
}
Also used : LookupInResult(com.couchbase.client.java.kv.LookupInResult) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 29 with IgnoreWhen

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

the class CreateAsDeletedIntegrationTest method getRegularTombstone.

@Test
@IgnoreWhen(clusterTypes = ClusterType.CAVES)
void getRegularTombstone() {
    String id = docId();
    coll.upsert(id, JsonObject.create());
    coll.remove(id);
    LookupInResult result = coll.lookupIn(id, Arrays.asList(LookupInSpec.get("txn.atr.id").xattr(), LookupInSpec.get("")), LookupInOptions.lookupInOptions().accessDeleted(true));
    assertFalse(result.exists(0));
    assertFalse(result.exists(1));
}
Also used : LookupInResult(com.couchbase.client.java.kv.LookupInResult) IgnoreWhen(com.couchbase.client.test.IgnoreWhen) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 30 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_lat.

@IgnoreWhen(clusterTypes = ClusterType.MOCKED)
@Test
void attributes_hobbies_1_details_location_lat() {
    JsonObject decoded = collection.get(DOC_ID, getOptions().project("attributes.hobbies[1].details.location.lat")).contentAsObject();
    JsonArray arr = decoded.getObject("attributes").getArray("hobbies");
    JsonObject obj = arr.getObject(0).getObject("details").getObject("location");
    assertEquals(1, arr.size());
    assertEquals(1, obj.size());
    assertEquals(49.282730, obj.getNumber("lat").doubleValue(), 0.1);
    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)

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