use of com.coreos.jetcd.api.DeleteRangeResponse in project jetcd by coreos.
the class KVTest method testDelete.
@Test(dependsOnMethods = "testPut")
public void testDelete() throws Exception {
ByteString keyToDelete = ByteString.copyFrom("sample_key", "UTF-8");
try {
// count keys about to delete
ListenableFuture<RangeResponse> getFeature = kvClient.get(keyToDelete);
RangeResponse resp = getFeature.get();
// delete the keys
ListenableFuture<DeleteRangeResponse> deleteFuture = kvClient.delete(keyToDelete);
DeleteRangeResponse delResp = deleteFuture.get();
test.assertEquals(resp.getKvsList().size(), delResp.getDeleted());
} catch (Exception e) {
// empty
}
}
use of com.coreos.jetcd.api.DeleteRangeResponse in project jetcd by coreos.
the class KVTest method testGetAndDeleteWithPrefix.
@Test
public void testGetAndDeleteWithPrefix() throws Exception {
String prefix = randomString();
ByteString key = ByteString.copyFromUtf8(prefix);
int numPrefixes = 10;
putKeysWithPrefix(prefix, numPrefixes);
// verify get withPrefix.
ListenableFuture<RangeResponse> getFuture = kvClient.get(key, GetOption.newBuilder().withPrefix(key).build());
RangeResponse getResp = getFuture.get();
test.assertEquals(getResp.getCount(), numPrefixes);
// verify del withPrefix.
DeleteOption deleteOpt = DeleteOption.newBuilder().withPrefix(key).build();
ListenableFuture<DeleteRangeResponse> delFuture = kvClient.delete(key, deleteOpt);
DeleteRangeResponse delResp = delFuture.get();
test.assertEquals(delResp.getDeleted(), numPrefixes);
}
Aggregations