curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsi...@apache.org
Subject [25/31] curator git commit: make test more rational by using a latch
Date Tue, 18 Aug 2015 23:18:41 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/ff2ed849
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ff2ed849
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ff2ed849

Branch: refs/heads/CURATOR-3.0
Commit: ff2ed8490660a3ea8caa046ecc5f80664cb0d8bd
Parents: 4ad09e7
Author: randgalt <randgalt@apache.org>
Authored: Tue May 19 19:40:46 2015 -0700
Committer: randgalt <randgalt@apache.org>
Committed: Tue May 19 19:40:46 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/curator/blob/ff2ed849/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 bf690fd..e20c450 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
@@ -181,7 +181,8 @@ public class TestWatcherRemovalManager extends BaseClassForTests
 
             final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
 
-            final CountDownLatch latch = new CountDownLatch(1);
+            final CountDownLatch createdLatch = new CountDownLatch(1);
+            final CountDownLatch deletedLatch = new CountDownLatch(1);
             Watcher watcher = new Watcher()
             {
                 @Override
@@ -197,10 +198,11 @@ public class TestWatcherRemovalManager extends BaseClassForTests
                         {
                             e.printStackTrace();
                         }
+                        createdLatch.countDown();
                     }
                     else if ( event.getType() == Event.EventType.NodeDeleted )
                     {
-                        latch.countDown();
+                        deletedLatch.countDown();
                     }
                 }
             };
@@ -209,12 +211,12 @@ public class TestWatcherRemovalManager extends BaseClassForTests
             Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
             removerClient.create().forPath("/yo");
 
-            timing.sleepABit();
+            Assert.assertTrue(timing.awaitLatch(createdLatch));
             Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
 
             removerClient.delete().forPath("/yo");
 
-            Assert.assertTrue(timing.awaitLatch(latch));
+            Assert.assertTrue(timing.awaitLatch(deletedLatch));
 
             Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
         }


Mime
View raw message