You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by dr...@apache.org on 2015/08/19 01:18:29 UTC
[13/31] curator git commit: more tests
more tests
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ff8eb4b2
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ff8eb4b2
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ff8eb4b2
Branch: refs/heads/CURATOR-3.0
Commit: ff8eb4b2ec7c99258e62416453bef649fdc6220e
Parents: 49b2fd3
Author: randgalt <ra...@apache.org>
Authored: Mon May 11 20:48:16 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon May 11 20:48:16 2015 -0500
----------------------------------------------------------------------
.../imps/TestWatcherRemovalManager.java | 54 ++++++++++++++++++++
1 file changed, 54 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/ff8eb4b2/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 d951c57..9508f43 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
@@ -170,6 +170,60 @@ public class TestWatcherRemovalManager extends BaseClassForTests
}
}
+ @Test
+ public void testResetFromWatcher() throws Exception
+ {
+ Timing timing = new Timing();
+ CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+ try
+ {
+ client.start();
+
+ final WatcherRemovalFacade removerClient = (WatcherRemovalFacade)client.newWatcherRemoveCuratorFramework();
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ Watcher watcher = new Watcher()
+ {
+ @Override
+ public void process(WatchedEvent event)
+ {
+ if ( event.getType() == Event.EventType.NodeCreated )
+ {
+ try
+ {
+ removerClient.checkExists().usingWatcher(this).forPath("/yo");
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+ else if ( event.getType() == Event.EventType.NodeDeleted )
+ {
+ latch.countDown();
+ }
+ }
+ };
+
+ removerClient.checkExists().usingWatcher(watcher).forPath("/yo");
+ Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+ removerClient.create().forPath("/yo");
+
+ timing.sleepABit();
+ Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 1);
+
+ removerClient.delete().forPath("/yo");
+
+ Assert.assertTrue(timing.awaitLatch(latch));
+
+ Assert.assertEquals(removerClient.getRemovalManager().getEntries().size(), 0);
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+
private void internalTryBasic(CuratorFramework client) throws Exception
{
WatcherRemoveCuratorFramework removerClient = client.newWatcherRemoveCuratorFramework();