You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2017/02/09 18:36:20 UTC

[21/47] curator git commit: testing watched

testing watched


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/88fe6b4f
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/88fe6b4f
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/88fe6b4f

Branch: refs/heads/CURATOR-3.0
Commit: 88fe6b4f436cc0731a7dcb0f1772991dd5897e09
Parents: 177cca6
Author: randgalt <ra...@apache.org>
Authored: Fri Jan 6 14:04:19 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri Jan 6 14:04:19 2017 -0500

----------------------------------------------------------------------
 .../x/async/AsyncCuratorFrameworkDsl.java       |  2 +-
 .../details/AsyncCuratorFrameworkImpl.java      |  2 +-
 .../curator/x/async/TestBasicOperations.java    | 20 ++++++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/88fe6b4f/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCuratorFrameworkDsl.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCuratorFrameworkDsl.java b/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCuratorFrameworkDsl.java
index 4a3880e..5927c22 100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCuratorFrameworkDsl.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCuratorFrameworkDsl.java
@@ -95,5 +95,5 @@ public interface AsyncCuratorFrameworkDsl extends WatchedAsyncCuratorFramework
      * Start a remove watches builder.
      * @return builder object
      */
-    AsyncRemoveWatchesBuilder watches();
+    AsyncRemoveWatchesBuilder removeWatches();
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/88fe6b4f/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCuratorFrameworkImpl.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCuratorFrameworkImpl.java b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCuratorFrameworkImpl.java
index 6111312..19b1b2e 100644
--- a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCuratorFrameworkImpl.java
+++ b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCuratorFrameworkImpl.java
@@ -138,7 +138,7 @@ public class AsyncCuratorFrameworkImpl implements AsyncCuratorFramework
     }
 
     @Override
-    public AsyncRemoveWatchesBuilder watches()
+    public AsyncRemoveWatchesBuilder removeWatches()
     {
         return new AsyncRemoveWatchesBuilderImpl(client, unhandledErrorListener);
     }

http://git-wip-us.apache.org/repos/asf/curator/blob/88fe6b4f/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java b/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
index a87b3f0..1ccd676 100644
--- a/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
+++ b/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java
@@ -25,11 +25,13 @@ import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.test.Timing;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.Watcher;
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 import java.util.function.BiFunction;
 
@@ -88,6 +90,24 @@ public class TestBasicOperations extends BaseClassForTests
         });
     }
 
+    @Test
+    public void testWatching()
+    {
+        CountDownLatch latch = new CountDownLatch(1);
+        client.watched().checkExists().forPath("/test").event().whenComplete((event, exception) -> {
+            Assert.assertNull(exception);
+            Assert.assertEquals(event.getType(), Watcher.Event.EventType.NodeCreated);
+            latch.countDown();
+        });
+        client.create().forPath("/test");
+        Assert.assertTrue(timing.awaitLatch(latch));
+    }
+
+    private <T, U> void complete(CompletionStage<T> stage)
+    {
+        complete(stage, (v, e) -> null);
+    }
+
     private <T, U> void complete(CompletionStage<T> stage, BiFunction<? super T, Throwable, ? extends U> handler)
     {
         try