You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/06/01 00:06:42 UTC
[4/5] curator git commit: Don't exit test until watchers have hit so
that the watcher removal code is stable
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-3.0
Commit: 44fd666a366999ae9503dff6866bb8aa37b2d604
Parents: 4fb0895
Author: randgalt <ra...@apache.org>
Authored: Mon May 30 21:31:21 2016 -0500
Committer: randgalt <ra...@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
{