curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsi...@apache.org
Subject [24/31] curator git commit: make test more rational by using a latch
Date Tue, 18 Aug 2015 23:18:40 GMT
make test more rational by using a latch


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

Branch: refs/heads/CURATOR-3.0
Commit: 4ad09e7d1d71acebba97bb5594205d96f76eba3c
Parents: 115611e
Author: randgalt <randgalt@apache.org>
Authored: Tue May 19 19:38:24 2015 -0700
Committer: randgalt <randgalt@apache.org>
Committed: Tue May 19 19:38:24 2015 -0700

----------------------------------------------------------------------
 .../curator/framework/imps/TestWatcherRemovalManager.java    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/4ad09e7d/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
index 9508f43..bf690fd 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java
@@ -228,12 +228,16 @@ public class TestWatcherRemovalManager extends BaseClassForTests
     {
         WatcherRemoveCuratorFramework removerClient = client.newWatcherRemoveCuratorFramework();
 
+        final CountDownLatch latch = new CountDownLatch(1);
         Watcher watcher = new Watcher()
         {
             @Override
             public void process(WatchedEvent event)
             {
-                // NOP
+                if ( event.getType() == Event.EventType.DataWatchRemoved )
+                {
+                    latch.countDown();
+                }
             }
         };
         removerClient.checkExists().usingWatcher(watcher).forPath("/hey");
@@ -243,7 +247,7 @@ public class TestWatcherRemovalManager extends BaseClassForTests
 
         removerClient.removeWatchers();
 
-        new Timing().sleepABit();
+        Assert.assertTrue(new Timing().awaitLatch(latch));
 
         existWatches = WatchersDebug.getExistWatches(client.getZookeeperClient().getZooKeeper());
         Assert.assertEquals(existWatches.size(), 0);


Mime
View raw message