use of com.coreos.jetcd.api.PutResponse in project jetcd by coreos.
the class KVTest method testGetWithRev.
@Test
public void testGetWithRev() throws Exception {
ByteString sampleKey = ByteString.copyFrom("sample_key3", "UTF-8");
ByteString sampleValue = ByteString.copyFrom("sample_value", "UTF-8");
ByteString sampleValueTwo = ByteString.copyFrom("sample_value2", "UTF-8");
ListenableFuture<PutResponse> feature = kvClient.put(sampleKey, sampleValue);
try {
PutResponse putResp = feature.get();
kvClient.put(sampleKey, sampleValueTwo).get();
GetOption option = GetOption.newBuilder().withRevision(putResp.getHeader().getRevision()).build();
ListenableFuture<RangeResponse> getFeature = kvClient.get(sampleKey, option);
RangeResponse response = getFeature.get();
test.assertEquals(response.getKvsCount(), 1);
test.assertEquals(response.getKvs(0).getValue().toStringUtf8(), "sample_value");
} catch (Exception e) {
// empty
}
}
use of com.coreos.jetcd.api.PutResponse in project jetcd by coreos.
the class KVTest method testPut.
@Test
public void testPut() throws Exception {
ByteString sampleKey = ByteString.copyFrom("sample_key", "UTF-8");
ByteString sampleValue = ByteString.copyFrom("sample_value", "UTF-8");
ListenableFuture<PutResponse> feature = kvClient.put(sampleKey, sampleValue);
try {
PutResponse response = feature.get();
test.assertTrue(response.hasHeader());
test.assertTrue(!response.hasPrevKv());
} catch (Exception e) {
// empty
e.printStackTrace();
}
}
use of com.coreos.jetcd.api.PutResponse in project jetcd by coreos.
the class KVTest method testPutWithNotExistLease.
@Test
public void testPutWithNotExistLease() throws Exception {
ByteString sampleKey = ByteString.copyFrom("sample_key", "UTF-8");
ByteString sampleValue = ByteString.copyFrom("sample_value", "UTF-8");
PutOption option = PutOption.newBuilder().withLeaseId(99999).build();
ListenableFuture<PutResponse> feature = kvClient.put(sampleKey, sampleValue, option);
try {
PutResponse response = feature.get();
test.assertTrue(response.hasHeader());
} catch (Exception e) {
// empty
}
}
Aggregations