You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2015/10/23 00:51:29 UTC
[2/5] curator git commit: Tests for EnsureContainers
Tests for EnsureContainers
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0f67e778
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0f67e778
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0f67e778
Branch: refs/heads/master
Commit: 0f67e77870fbffccc552af98346d454d4e4a4646
Parents: 3258898
Author: randgalt <ra...@apache.org>
Authored: Thu Oct 22 08:37:51 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Thu Oct 22 08:37:51 2015 -0500
----------------------------------------------------------------------
.../framework/imps/TestEnsureContainers.java | 73 ++++++++++++++++++++
1 file changed, 73 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/0f67e778/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java
new file mode 100644
index 0000000..a4397ab
--- /dev/null
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnsureContainers.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.curator.framework.imps;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.EnsureContainers;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
+import org.apache.curator.utils.CloseableUtils;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestEnsureContainers extends BaseClassForTests
+{
+ @Test
+ public void testBasic() throws Exception
+ {
+ CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+ try
+ {
+ client.start();
+
+ EnsureContainers ensureContainers = new EnsureContainers(client, "/one/two/three");
+ ensureContainers.ensure();
+
+ Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+
+ @Test
+ public void testSingleExecution() throws Exception
+ {
+ CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
+ try
+ {
+ client.start();
+
+ EnsureContainers ensureContainers = new EnsureContainers(client, "/one/two/three");
+ ensureContainers.ensure();
+
+ Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));
+
+ client.delete().forPath("/one/two/three");
+ ensureContainers.ensure();
+ Assert.assertNull(client.checkExists().forPath("/one/two/three"));
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+}