curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [2/2] curator git commit: more tests
Date Tue, 12 May 2015 01:48:24 GMT
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-217
Commit: ff8eb4b2ec7c99258e62416453bef649fdc6220e
Parents: 49b2fd3
Author: randgalt <randgalt@apache.org>
Authored: Mon May 11 20:48:16 2015 -0500
Committer: randgalt <randgalt@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();


Mime
View raw message