Added a test and moved to Java 8 - needed by ZK 3.5.4
Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1fa4bf6e Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1fa4bf6e Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1fa4bf6e Branch: refs/heads/master Commit: 1fa4bf6e5a3fedb996609154b3449fb916617b55 Parents: c097e4b Author: randgalt <[email protected]> Authored: Sun Jun 24 11:32:46 2018 -0500 Committer: randgalt <[email protected]> Committed: Sun Jun 24 11:32:46 2018 -0500 ---------------------------------------------------------------------- .../curator/framework/imps/TestFramework.java | 46 ++++++++++++++++++++ pom.xml | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/1fa4bf6e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java index 0539dbf..0a01679 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java @@ -35,19 +35,23 @@ import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.EnsurePath; import org.apache.curator.utils.ZKPaths; +import org.apache.curator.utils.ZookeeperFactory; import org.apache.zookeeper.CreateMode; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooDefs; +import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.ACL; import org.apache.zookeeper.data.Stat; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingQueue; @@ -71,6 +75,48 @@ public class TestFramework extends BaseClassForTests System.clearProperty("znode.container.checkIntervalMs"); super.teardown(); } + + @Test + public void testWaitForShutdownTimeoutMs() throws Exception + { + final BlockingQueue<Integer> timeoutQueue = new ArrayBlockingQueue<>(1); + ZookeeperFactory zookeeperFactory = new ZookeeperFactory() + { + @Override + public ZooKeeper newZooKeeper(String connectString, int sessionTimeout, Watcher watcher, boolean canBeReadOnly) throws IOException + { + return new ZooKeeper(connectString, sessionTimeout, watcher, canBeReadOnly) + { + @Override + public boolean close(int waitForShutdownTimeoutMs) throws InterruptedException + { + timeoutQueue.add(waitForShutdownTimeoutMs); + return super.close(waitForShutdownTimeoutMs); + } + }; + } + }; + + CuratorFramework client = CuratorFrameworkFactory.builder() + .connectString(server.getConnectString()) + .retryPolicy(new RetryOneTime(1)) + .zookeeperFactory(zookeeperFactory) + .waitForShutdownTimeoutMs(10064) + .build(); + try + { + client.start(); + client.checkExists().forPath("/foo"); + } + finally + { + CloseableUtils.closeQuietly(client); + } + + Integer polledValue = timeoutQueue.poll(new Timing().milliseconds(), TimeUnit.MILLISECONDS); + Assert.assertNotNull(polledValue); + Assert.assertEquals(10064, polledValue.intValue()); + } @Test public void testSessionLossWithLongTimeout() throws Exception http://git-wip-us.apache.org/repos/asf/curator/blob/1fa4bf6e/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index dd4abdd..74d015d 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <jdk-version>1.7</jdk-version> + <jdk-version>1.8</jdk-version> <!-- versions --> <zookeeper-version>3.5.4-beta</zookeeper-version>
