add targeted unit test for bug/fix Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/8e4dba7a Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/8e4dba7a Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/8e4dba7a
Branch: refs/heads/master Commit: 8e4dba7a070beaf110267843ba0611ee7cae25fc Parents: 91e3a64 Author: nickhill <[email protected]> Authored: Mon Nov 5 09:57:29 2018 -0800 Committer: nickhill <[email protected]> Committed: Mon Nov 5 09:57:29 2018 -0800 ---------------------------------------------------------------------- .../recipes/nodes/TestPersistentNode.java | 33 ++++++++++++++++++++ 1 file changed, 33 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/8e4dba7a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java index 0fdd7c8..b157000 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java @@ -28,6 +28,8 @@ import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.CreateMode; import org.testng.Assert; import org.testng.annotations.Test; + +import java.util.List; import java.util.concurrent.TimeUnit; public class TestPersistentNode extends BaseClassForTests @@ -138,4 +140,35 @@ public class TestPersistentNode extends BaseClassForTests CloseableUtils.closeQuietly(client); } } + + @Test + public void testEphemeralSequentialWithProtectionReconnection() throws Exception + { + Timing timing = new Timing(); + PersistentNode pen = null; + CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); + try + { + client.start(); + client.create().creatingParentsIfNeeded().forPath("/test/one"); + + pen = new PersistentNode(client, CreateMode.EPHEMERAL_SEQUENTIAL, true, "/test/one/two", new byte[0]); + pen.start(); + List<String> children = client.getChildren().forPath("/test/one"); + System.out.println("children before restart: "+children); + Assert.assertEquals(1, children.size()); + server.stop(); + timing.sleepABit(); + server.restart(); + timing.sleepABit(); + List<String> childrenAfter = client.getChildren().forPath("/test/one"); + System.out.println("children after restart: "+childrenAfter); + Assert.assertEquals(children, childrenAfter, "unexpected znodes: "+childrenAfter); + } + finally + { + CloseableUtils.closeQuietly(pen); + CloseableUtils.closeQuietly(client); + } + } }
