Repository: curator
Updated Branches:
  refs/heads/CURATOR-3.0 537156db4 -> df949e7a2


CURATOR-270 createContainers does not work correctly with usingNamespace


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

Branch: refs/heads/CURATOR-3.0
Commit: 1556a2fcb8fd0d43669b057eb51290e3bf5ee5a2
Parents: f8f05be
Author: Alexey Serba <ase...@gmail.com>
Authored: Tue Oct 6 00:11:35 2015 +0300
Committer: Alexey Serba <ase...@gmail.com>
Committed: Tue Oct 6 00:11:35 2015 +0300

----------------------------------------------------------------------
 .../curator/framework/imps/NamespaceFacade.java |  1 +
 .../curator/framework/imps/TestFramework.java   | 42 ++++++++++++++++++++
 2 files changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/1556a2fc/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
----------------------------------------------------------------------
diff --git 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
index 60ef647..a4bb2e5 100644
--- 
a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
+++ 
b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceFacade.java
@@ -45,6 +45,7 @@ class NamespaceFacade extends CuratorFrameworkImpl
     @Override
     public void createContainers(String path) throws Exception
     {
+        path = fixForNamespace(path);
         client.createContainers(path);
     }
 

http://git-wip-us.apache.org/repos/asf/curator/blob/1556a2fc/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 811631c..b6a0a40 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
@@ -592,6 +592,48 @@ public class TestFramework extends BaseClassForTests
             CloseableUtils.closeQuietly(client);
         }
     }
+    
+    @Test
+    public void testCreateContainersWithNamespace() throws Exception
+    {
+        final String namespace = "container1";
+        CuratorFrameworkFactory.Builder builder = 
CuratorFrameworkFactory.builder();
+        CuratorFramework client = 
builder.connectString(server.getConnectString()).retryPolicy(new 
RetryOneTime(1)).namespace(namespace).build();
+        client.start();
+        try
+        {
+            String path = "/path1/path2";
+            client.createContainers(path);
+            Assert.assertNotNull(client.checkExists().forPath(path));
+            
Assert.assertNotNull(client.getZookeeperClient().getZooKeeper().exists("/" + 
namespace + path, false));
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(client);
+        }
+    }
+    
+    
+    @Test
+    public void testCreateContainersUsingNamespace() throws Exception
+    {
+        final String namespace = "container2";
+        CuratorFrameworkFactory.Builder builder = 
CuratorFrameworkFactory.builder();
+        CuratorFramework client = 
builder.connectString(server.getConnectString()).retryPolicy(new 
RetryOneTime(1)).build();
+        client.start();
+        CuratorFramework nsClient = client.usingNamespace(namespace);
+        try
+        {
+            String path = "/path1/path2";
+            nsClient.createContainers(path);
+            Assert.assertNotNull(nsClient.checkExists().forPath(path));
+            
Assert.assertNotNull(nsClient.getZookeeperClient().getZooKeeper().exists("/" + 
namespace + path, false));
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(client);
+        }
+    }
 
     @Test
     public void testNamespace() throws Exception

Reply via email to