You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2016/06/07 00:41:11 UTC
[4/4] curator git commit: #noissue - Added unit test with long
session timeout.
#noissue - Added unit test with long session timeout.
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1e07c779
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1e07c779
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1e07c779
Branch: refs/heads/long_session_timeout_issue
Commit: 1e07c779a682b15a1b2c604c55f80dcdaa21aef2
Parents: bc1960f
Author: Cam McKenzie <ca...@apache.org>
Authored: Tue Jun 7 10:40:16 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Tue Jun 7 10:40:16 2016 +1000
----------------------------------------------------------------------
.../curator/framework/imps/TestFramework.java | 53 ++++++++++++++++++++
1 file changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/1e07c779/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 5addcb7..7234088 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
@@ -70,6 +70,59 @@ public class TestFramework extends BaseClassForTests
System.clearProperty("znode.container.checkIntervalMs");
super.teardown();
}
+
+ @Test
+ public void testSessionLossWithLongTimeout() throws Exception
+ {
+
+ final Timing timing = new Timing();
+ //Change this to TRUE and the test will pass.
+ System.setProperty("curator-use-classic-connection-handling", Boolean.FALSE.toString());
+
+ try(final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.forWaiting().milliseconds(),
+ timing.connection(), new RetryOneTime(1)))
+ {
+
+ final CountDownLatch connectedLatch = new CountDownLatch(1);
+ final CountDownLatch lostLatch = new CountDownLatch(1);
+ final CountDownLatch restartedLatch = new CountDownLatch(1);
+ client.getConnectionStateListenable().addListener(new ConnectionStateListener()
+ {
+ @Override
+ public void stateChanged(CuratorFramework client, ConnectionState newState)
+ {
+ if ( newState == ConnectionState.CONNECTED )
+ {
+ connectedLatch.countDown();
+ }
+ else if ( newState == ConnectionState.LOST )
+ {
+ lostLatch.countDown();
+ }
+ else if ( newState == ConnectionState.RECONNECTED )
+ {
+ restartedLatch.countDown();
+ }
+ }
+ });
+
+ client.start();
+
+ Assert.assertTrue(timing.awaitLatch(connectedLatch));
+
+ server.stop();
+
+ timing.sleepABit();
+ Assert.assertTrue(timing.awaitLatch(lostLatch));
+
+ server.restart();
+ Assert.assertTrue(timing.awaitLatch(restartedLatch));
+ }
+ finally
+ {
+ System.clearProperty("curator-use-classic-connection-handling");
+ }
+ }
@Test
public void testConnectionState() throws Exception