[
https://issues.apache.org/jira/browse/CURATOR-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14174701#comment-14174701
]
ASF GitHub Bot commented on CURATOR-145:
----------------------------------------
Github user cconroy commented on a diff in the pull request:
https://github.com/apache/curator/pull/42#discussion_r19000667
--- Diff:
curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java
---
@@ -68,6 +68,53 @@ public void testStartEmpty() throws Exception
}
@Test
+ public void testDepth0() throws Exception
+ {
+ client.create().forPath("/test");
+ client.create().forPath("/test/1", "one".getBytes());
+ client.create().forPath("/test/2", "two".getBytes());
+ client.create().forPath("/test/3", "three".getBytes());
+ client.create().forPath("/test/2/sub", "two-sub".getBytes());
+
+ cache = buildWithListeners(TreeCache.newBuilder(client,
"/test").setMaxDepth(0));
+ cache.start();
+ assertEvent(TreeCacheEvent.Type.NODE_ADDED, "/test");
+ assertEvent(TreeCacheEvent.Type.INITIALIZED);
+ assertNoMoreEvents();
+
+ Assert.assertEquals(cache.getCurrentChildren("/test").keySet(),
ImmutableSet.of());
+ Assert.assertNull(cache.getCurrentData("/test/1"));
+ Assert.assertNull(cache.getCurrentChildren("/test/1"));
+ Assert.assertNull(cache.getCurrentData("/test/non_exist"));
+ }
+
+ @Test
+ public void testDepth1() throws Exception
+ {
+ client.create().forPath("/test");
+ client.create().forPath("/test/1", "one".getBytes());
+ client.create().forPath("/test/2", "two".getBytes());
+ client.create().forPath("/test/3", "three".getBytes());
+ client.create().forPath("/test/2/sub", "two-sub".getBytes());
+
+ cache = buildWithListeners(TreeCache.newBuilder(client,
"/test").setMaxDepth(1));
--- End diff --
i'd like to see a test that exercises max depth from a starting point
deeper than the root or first node in the tree to ensure the null parent logic
plays correctly there.
> TreeCache should implement maxDepth
> -----------------------------------
>
> Key: CURATOR-145
> URL: https://issues.apache.org/jira/browse/CURATOR-145
> Project: Apache Curator
> Issue Type: Improvement
> Components: Recipes
> Reporter: Scott Blum
> Original Estimate: 48h
> Remaining Estimate: 48h
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)