curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsi...@apache.org
Subject [2/3] curator git commit: Fix TestTreeCache pollution; more tearDown() checks.
Date Tue, 09 Feb 2016 23:13:55 GMT
Fix TestTreeCache pollution; more tearDown() checks.


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

Branch: refs/heads/CURATOR-3.0
Commit: 33c19d6279ca6b0e614cda82b29fb6bdf789e7b5
Parents: 3d5970f
Author: Scott Blum <dragonsinth@apache.org>
Authored: Tue Feb 9 18:05:19 2016 -0500
Committer: Scott Blum <dragonsinth@apache.org>
Committed: Tue Feb 9 18:09:08 2016 -0500

----------------------------------------------------------------------
 .../recipes/cache/BaseTestTreeCache.java        |  3 +-
 .../framework/recipes/cache/TestTreeCache.java  | 37 +++++++++-----------
 2 files changed, 19 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/33c19d62/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
index ab37785..1b9a0b0 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/BaseTestTreeCache.java
@@ -119,6 +119,7 @@ public class BaseTestTreeCache extends BaseClassForTests
             try
             {
                 Assert.assertFalse(hadBackgroundException.get(), "Background exceptions were
thrown, see stderr for details");
+                assertNoMoreEvents();
             }
             finally
             {
@@ -138,7 +139,7 @@ public class BaseTestTreeCache extends BaseClassForTests
     void assertNoMoreEvents() throws InterruptedException
     {
         timing.sleepABit();
-        Assert.assertTrue(events.isEmpty());
+        Assert.assertTrue(events.isEmpty(), String.format("Expected no events, found %d;
first event: %s", events.size(), events.peek()));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/curator/blob/33c19d62/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
index 712e41b..2cf9e70 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
@@ -56,25 +56,17 @@ public class TestTreeCache extends BaseTestTreeCache
                 return !fullPath.equals("/root/n1-c");
             }
         };
-        TreeCache treeCache = TreeCache.newBuilder(client, "/root").setSelector(selector).build();
-        try
-        {
-            treeCache.getListenable().addListener(eventListener);
-            treeCache.start();
-
-            assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root");
-            assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-a");
-            assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-b");
-            assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-d");
-            assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-b/n2-a");
-            assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-b/n2-b");
-            assertEvent(TreeCacheEvent.Type.INITIALIZED);
-            assertNoMoreEvents();
-        }
-        finally
-        {
-            CloseableUtils.closeQuietly(treeCache);
-        }
+        cache = buildWithListeners(TreeCache.newBuilder(client, "/root").setSelector(selector));
+        cache.start();
+
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root");
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-a");
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-b");
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-d");
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-b/n2-a");
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/root/n1-b/n2-b");
+        assertEvent(TreeCacheEvent.Type.INITIALIZED);
+        assertNoMoreEvents();
     }
 
     @Test
@@ -107,11 +99,16 @@ public class TestTreeCache extends BaseTestTreeCache
     {
         cache = newTreeCacheWithListeners(client, "/one/two/three");
         cache.start();
+        assertEvent(TreeCacheEvent.Type.INITIALIZED);
+        assertNoMoreEvents();
         Assert.assertNull(client.checkExists().forPath("/one/two/three"));
         cache.close();
 
-        cache = TreeCache.newBuilder(client, "/one/two/three").setCreateParentNodes(true).build();
+        cache = buildWithListeners(TreeCache.newBuilder(client, "/one/two/three").setCreateParentNodes(true));
         cache.start();
+        assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/one/two/three");
+        assertEvent(TreeCacheEvent.Type.INITIALIZED);
+        assertNoMoreEvents();
         Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
     }
 


Mime
View raw message