Examples of EtcdResult


Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void setAndGet() throws Exception {
    String key = prefix + "/message";

    EtcdResult result;

    result = this.client.set(key, "hello");
    Assert.assertEquals("set", result.action);
    Assert.assertEquals("hello", result.node.value);
    Assert.assertNull(result.prevNode);
View Full Code Here

Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void getNonExistentKey() throws Exception {
    String key = prefix + "/doesnotexist";

    EtcdResult result;

    result = this.client.get(key);
    Assert.assertNull(result);
  }
View Full Code Here

Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void testDelete() throws Exception {
    String key = prefix + "/testDelete";

    EtcdResult result;

    result = this.client.set(key, "hello");

    result = this.client.get(key);
    Assert.assertEquals("hello", result.node.value);
View Full Code Here

Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void testTtl() throws Exception {
    String key = prefix + "/ttl";

    EtcdResult result;

    result = this.client.set(key, "hello", 2);
    Assert.assertNotNull(result.node.expiration);
    Assert.assertTrue(result.node.ttl == 2 || result.node.ttl == 1);
View Full Code Here

Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void testCAS() throws Exception {
    String key = prefix + "/cas";

    EtcdResult result;

    result = this.client.set(key, "hello");
    result = this.client.get(key);
    Assert.assertEquals("hello", result.node.value);

    result = this.client.cas(key, "world", "world");
    Assert.assertEquals(true, result.isError());
    result = this.client.get(key);
    Assert.assertEquals("hello", result.node.value);

    result = this.client.cas(key, "hello", "world");
    Assert.assertEquals(false, result.isError());
    result = this.client.get(key);
    Assert.assertEquals("world", result.node.value);
  }
View Full Code Here

Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void testWatchPrefix() throws Exception {
    String key = prefix + "/watch";

    EtcdResult result = this.client.set(key + "/f2", "f2");
    Assert.assertTrue(!result.isError());
    Assert.assertNotNull(result.node);
    Assert.assertEquals("f2", result.node.value);

    ListenableFuture<EtcdResult> watchFuture = this.client.watch(key,
        result.node.modifiedIndex + 1,
        true);
    try {
      EtcdResult watchResult = watchFuture
          .get(100, TimeUnit.MILLISECONDS);
      Assert.fail("Subtree watch fired unexpectedly: " + watchResult);
    } catch (TimeoutException e) {
      // Expected
    }

    Assert.assertFalse(watchFuture.isDone());

    result = this.client.set(key + "/f1", "f1");
    Assert.assertTrue(!result.isError());
    Assert.assertNotNull(result.node);
    Assert.assertEquals("f1", result.node.value);

    EtcdResult watchResult = watchFuture.get(100, TimeUnit.MILLISECONDS);

    Assert.assertNotNull(watchResult);
    Assert.assertTrue(!watchResult.isError());
    Assert.assertNotNull(watchResult.node);

    {
      Assert.assertEquals(key + "/f1", watchResult.node.key);
      Assert.assertEquals("f1", watchResult.node.value);
View Full Code Here

Examples of com.justinsb.etcd.EtcdResult

  @Test
  public void testList() throws Exception {
    String key = prefix + "/dir";

    EtcdResult result;

    result = this.client.set(key + "/f1", "f1");
    Assert.assertEquals("f1", result.node.value);
    result = this.client.set(key + "/f2", "f2");
    Assert.assertEquals("f2", result.node.value);
    result = this.client.set(key + "/f3", "f3");
    Assert.assertEquals("f3", result.node.value);
    result = this.client.set(key + "/subdir1/f", "f");
    Assert.assertEquals("f", result.node.value);

    EtcdResult listing = this.client.listChildren(key);
    Assert.assertEquals(4, listing.node.nodes.size());
    Assert.assertEquals("get", listing.action);

    {
      EtcdNode child = listing.node.nodes.get(0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.