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/15 02:11:21 UTC

[16/19] curator git commit: #noissue - Fixed problem with test where the CHILD_ADDED event would fire for a non related zNode, causing the addedLatch to complete prematurely. This meant that the final assertion in the test would fail.

 #noissue - Fixed problem with test where the CHILD_ADDED event would fire for a non related zNode, causing the addedLatch to complete prematurely. This meant that the final assertion in the test would fail.


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/d55585fd
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/d55585fd
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/d55585fd

Branch: refs/heads/CURATOR-3.0
Commit: d55585fd4652ba01ec0768e37a7996585a2c55fc
Parents: bec1781
Author: Cam McKenzie <ca...@apache.org>
Authored: Wed Jun 15 11:09:31 2016 +1000
Committer: Cam McKenzie <ca...@apache.org>
Committed: Wed Jun 15 11:09:31 2016 +1000

----------------------------------------------------------------------
 .../recipes/cache/TestPathChildrenCache.java    | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/d55585fd/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
index 887df54..bf998ea 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java
@@ -23,6 +23,8 @@ import com.google.common.collect.Lists;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.CuratorFrameworkFactory;
 import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.state.ConnectionState;
+import org.apache.curator.framework.state.ConnectionStateListener;
 import org.apache.curator.retry.ExponentialBackoffRetry;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
@@ -79,7 +81,8 @@ public class TestPathChildrenCache extends BaseClassForTests
                 @Override
                 public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception
                 {
-                    if ( event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED )
+                    if ( event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED  &&
+                         event.getData().getPath().equals("/baz"))
                     {
                         addedLatch.countDown();
                     }
@@ -88,8 +91,24 @@ public class TestPathChildrenCache extends BaseClassForTests
             cache.getListenable().addListener(listener);
             cache.start();
             Assert.assertTrue(timing.awaitLatch(ensurePathLatch));
+            
+            final CountDownLatch connectedLatch = new CountDownLatch(1);
+            client.getConnectionStateListenable().addListener(new ConnectionStateListener()
+            {
+                
+                @Override
+                public void stateChanged(CuratorFramework client, ConnectionState newState)
+                {
+                    if(newState == ConnectionState.CONNECTED)
+                    {
+                        connectedLatch.countDown();
+                    }
+                }
+            });
 
             server = new TestingServer(serverPort, true);
+            
+            Assert.assertTrue(timing.awaitLatch(connectedLatch));
 
             client.create().creatingParentContainersIfNeeded().forPath("/baz", new byte[]{1, 2, 3});