curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject curator git commit: Don't exit test until watchers have hit so that the watcher removal code is stable
Date Tue, 31 May 2016 02:31:27 GMT
Repository: curator
Updated Branches:
  refs/heads/CURATOR-332 4fb089575 -> 44fd666a3


Don't exit test until watchers have hit so that the watcher removal code is stable


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

Branch: refs/heads/CURATOR-332
Commit: 44fd666a366999ae9503dff6866bb8aa37b2d604
Parents: 4fb0895
Author: randgalt <randgalt@apache.org>
Authored: Mon May 30 21:31:21 2016 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Mon May 30 21:31:21 2016 -0500

----------------------------------------------------------------------
 .../recipes/shared/TestSharedCount.java         | 37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/44fd666a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
index 16134ed..28df3f9 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
@@ -163,10 +163,29 @@ public class TestSharedCount extends BaseClassForTests
             client.start();
             count.start();
 
+            final CountDownLatch setLatch = new CountDownLatch(3);
+            SharedCountListener listener = new SharedCountListener()
+            {
+                @Override
+                public void countHasChanged(SharedCountReader sharedCount, int newCount)
throws Exception
+                {
+                    setLatch.countDown();
+                }
+
+                @Override
+                public void stateChanged(CuratorFramework client, ConnectionState newState)
+                {
+                    // nop
+                }
+            };
+            count.addListener(listener);
+
             Assert.assertTrue(count.trySetCount(1));
             Assert.assertTrue(count.trySetCount(2));
             Assert.assertTrue(count.trySetCount(10));
             Assert.assertEquals(count.getCount(), 10);
+
+            Assert.assertTrue(new Timing().awaitLatch(setLatch));
         }
         finally
         {
@@ -242,12 +261,30 @@ public class TestSharedCount extends BaseClassForTests
             Assert.assertTrue(count2.trySetCount(versionedValue, 20));
             timing.sleepABit();
 
+            final CountDownLatch setLatch = new CountDownLatch(2);
+            SharedCountListener listener = new SharedCountListener()
+            {
+                @Override
+                public void countHasChanged(SharedCountReader sharedCount, int newCount)
throws Exception
+                {
+                    setLatch.countDown();
+                }
+
+                @Override
+                public void stateChanged(CuratorFramework client, ConnectionState newState)
+                {
+                    // nop
+                }
+            };
+            count1.addListener(listener);
             VersionedValue<Integer> versionedValue1 = count1.getVersionedValue();
             VersionedValue<Integer> versionedValue2 = count2.getVersionedValue();
             Assert.assertTrue(count2.trySetCount(versionedValue2, 30));
             Assert.assertFalse(count1.trySetCount(versionedValue1, 40));
+
             versionedValue1 = count1.getVersionedValue();
             Assert.assertTrue(count1.trySetCount(versionedValue1, 40));
+            Assert.assertTrue(timing.awaitLatch(setLatch));
         }
         finally
         {


Mime
View raw message