cammckenzie commented on a change in pull request #334: [CURATOR-549] Support ZooKeeper 3.6.0 Persistent Recursive Watchers URL: https://github.com/apache/curator/pull/334#discussion_r395346470
########## File path: curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatchesBuilder.java ########## @@ -610,6 +613,122 @@ public void pathAddedForGuaranteedOperation( } } + @Test(groups = CuratorTestBase.zk36Group) + public void testPersistentWatch() throws Exception + { + try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) ) + { + client.start(); + client.blockUntilConnected(); + + CountDownLatch latch = new CountDownLatch(3); + Watcher watcher = event -> latch.countDown(); + client.watchers().add().withMode(AddWatchMode.PERSISTENT).usingWatcher(watcher).forPath("/test/foo"); + + client.create().creatingParentsIfNeeded().forPath("/test/foo"); + client.setData().forPath("/test/foo", "hey".getBytes()); + client.delete().forPath("/test/foo"); + + Assert.assertTrue(timing.awaitLatch(latch)); + } + } + + @Test(groups = CuratorTestBase.zk36Group) + public void testPersistentWatchInBackground() throws Exception + { + try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) ) + { + client.start(); + client.blockUntilConnected(); + + CountDownLatch backgroundLatch = new CountDownLatch(1); + BackgroundCallback backgroundCallback = (__, ___) -> backgroundLatch.countDown(); + CountDownLatch latch = new CountDownLatch(3); + Watcher watcher = event -> latch.countDown(); + client.watchers().add().withMode(AddWatchMode.PERSISTENT).inBackground(backgroundCallback).usingWatcher(watcher).forPath("/test/foo"); + + client.create().creatingParentsIfNeeded().forPath("/test/foo"); + client.setData().forPath("/test/foo", "hey".getBytes()); + client.delete().forPath("/test/foo"); + + Assert.assertTrue(timing.awaitLatch(latch)); + } + } + + @Test(groups = CuratorTestBase.zk36Group) + public void testPersistentRecursiveWatch() throws Exception + { + try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) ) + { + client.start(); + client.blockUntilConnected(); + + CountDownLatch latch = new CountDownLatch(5); + Watcher watcher = event -> latch.countDown(); + client.watchers().add().withMode(AddWatchMode.PERSISTENT_RECURSIVE).usingWatcher(watcher).forPath("/test"); + + client.create().forPath("/test"); + client.create().forPath("/test/a"); + client.create().forPath("/test/a/b"); + client.create().forPath("/test/a/b/c"); + client.create().forPath("/test/a/b/c/d"); + + Assert.assertTrue(timing.awaitLatch(latch)); + } + } + + @Test(groups = CuratorTestBase.zk36Group) + public void testPersistentRecursiveWatchInBackground() throws Exception + { + try ( CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1)) ) + { + client.start(); + client.blockUntilConnected(); + + CountDownLatch backgroundLatch = new CountDownLatch(1); Review comment: As for previous backgroundLatch comment ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services