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;
}
});
}
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());
}
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));
}
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));
}
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());
}
Aggregations