use of com.ibm.etcd.client.watch.WatchCreateException in project etcd-java by IBM.
the class WatchTest method testCreateFail.
@Test
public void testCreateFail() throws Exception {
KvStoreClient client = EtcdClient.forEndpoint("localhost", 2379).withPlainText().build();
try {
KvClient kvc = client.getKvClient();
// range end before start => should fail
Watch watch2 = kvc.watch(ByteString.copyFromUtf8("/watchtest2")).rangeEnd(ByteString.copyFromUtf8("/watchtest1")).startRevision(-5000L).start((ListenerObserver<WatchUpdate>) (c, v, t) -> {
});
try {
watch2.get(1000, TimeUnit.SECONDS);
fail("watch future should fail");
} catch (ExecutionException e) {
System.out.println("watch creation failed with exception: " + e);
assertTrue(e.getCause() instanceof WatchCreateException);
}
} finally {
client.close();
}
}
Aggregations