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 2016/05/19 19:02:28 UTC
[13/35] curator git commit: moved test to better package
moved test to better package
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/30d83b87
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/30d83b87
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/30d83b87
Branch: refs/heads/CURATOR-3.0
Commit: 30d83b87e9ddcee78d21615d45995f13ef1832ff
Parents: e3ec920
Author: randgalt <ra...@apache.org>
Authored: Mon May 2 23:41:26 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon May 2 23:41:26 2016 -0500
----------------------------------------------------------------------
.../curator/framework/imps/TestSchema.java | 115 -------------------
.../curator/framework/schema/TestSchema.java | 111 ++++++++++++++++++
2 files changed, 111 insertions(+), 115 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/30d83b87/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
deleted file mode 100644
index c908fd5..0000000
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestSchema.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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 com.google.common.base.Charsets;
-import com.google.common.io.Resources;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.schema.SchemaKey;
-import org.apache.curator.framework.schema.SchemaSet;
-import org.apache.curator.framework.schema.SchemaSetLoader;
-import org.apache.curator.framework.schema.SchemaViolation;
-import org.apache.curator.retry.RetryOneTime;
-import org.apache.curator.test.BaseClassForTests;
-import org.apache.curator.utils.CloseableUtils;
-import org.apache.zookeeper.CreateMode;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-import java.io.IOException;
-
-public class TestSchema extends BaseClassForTests
-{
- @Test
- public void testBasics() throws Exception
- {
- SchemaSet schemaSet = loadSchemaSet("schema1.json");
- CuratorFramework client = newClient(schemaSet);
- try
- {
- client.start();
-
- try
- {
- client.create().creatingParentsIfNeeded().forPath(schemaSet.getNamedSchema(SchemaKey.named("test")).getRawPath());
- Assert.fail("Should've violated schema");
- }
- catch ( SchemaViolation dummy )
- {
- // expected
- }
-
- client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/a/b/c");
- }
- finally
- {
- CloseableUtils.closeQuietly(client);
- }
- }
-
- @Test
- public void testMulti() throws Exception
- {
- SchemaSet schemaSet = loadSchemaSet("schema2.json");
- CuratorFramework client = newClient(schemaSet);
- try
- {
- client.start();
-
- try
- {
- client.create().creatingParentsIfNeeded().forPath("/a/b/c");
- Assert.fail("Should've violated schema: test");
- }
- catch ( SchemaViolation dummy )
- {
- // expected
- }
-
- try
- {
- client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/a/b/c/d/e");
- Assert.fail("Should've violated schema: test2");
- }
- catch ( SchemaViolation dummy )
- {
- // expected
- }
- }
- finally
- {
- CloseableUtils.closeQuietly(client);
- }
- }
-
- private CuratorFramework newClient(SchemaSet schemaSet)
- {
- return CuratorFrameworkFactory.builder()
- .connectString(server.getConnectString())
- .retryPolicy(new RetryOneTime(1))
- .schemaSet(schemaSet)
- .build();
- }
-
- private SchemaSet loadSchemaSet(String name) throws IOException
- {
- String json = Resources.toString(Resources.getResource(name), Charsets.UTF_8);
- return new SchemaSetLoader(json, null).toSchemaSet(true);
- }
-}
http://git-wip-us.apache.org/repos/asf/curator/blob/30d83b87/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
new file mode 100644
index 0000000..7f29148
--- /dev/null
+++ b/curator-framework/src/test/java/org/apache/curator/framework/schema/TestSchema.java
@@ -0,0 +1,111 @@
+/**
+ * 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.schema;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.test.BaseClassForTests;
+import org.apache.curator.utils.CloseableUtils;
+import org.apache.zookeeper.CreateMode;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import java.io.IOException;
+
+public class TestSchema extends BaseClassForTests
+{
+ @Test
+ public void testBasics() throws Exception
+ {
+ SchemaSet schemaSet = loadSchemaSet("schema1.json");
+ CuratorFramework client = newClient(schemaSet);
+ try
+ {
+ client.start();
+
+ try
+ {
+ client.create().creatingParentsIfNeeded().forPath(schemaSet.getNamedSchema(SchemaKey.named("test")).getRawPath());
+ Assert.fail("Should've violated schema");
+ }
+ catch ( SchemaViolation dummy )
+ {
+ // expected
+ }
+
+ client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/a/b/c");
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+
+ @Test
+ public void testMulti() throws Exception
+ {
+ SchemaSet schemaSet = loadSchemaSet("schema2.json");
+ CuratorFramework client = newClient(schemaSet);
+ try
+ {
+ client.start();
+
+ try
+ {
+ client.create().creatingParentsIfNeeded().forPath("/a/b/c");
+ Assert.fail("Should've violated schema: test");
+ }
+ catch ( SchemaViolation dummy )
+ {
+ // expected
+ }
+
+ try
+ {
+ client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath("/a/b/c/d/e");
+ Assert.fail("Should've violated schema: test2");
+ }
+ catch ( SchemaViolation dummy )
+ {
+ // expected
+ }
+ }
+ finally
+ {
+ CloseableUtils.closeQuietly(client);
+ }
+ }
+
+ private CuratorFramework newClient(SchemaSet schemaSet)
+ {
+ return CuratorFrameworkFactory.builder()
+ .connectString(server.getConnectString())
+ .retryPolicy(new RetryOneTime(1))
+ .schemaSet(schemaSet)
+ .build();
+ }
+
+ private SchemaSet loadSchemaSet(String name) throws IOException
+ {
+ String json = Resources.toString(Resources.getResource(name), Charsets.UTF_8);
+ return new SchemaSetLoader(json, null).toSchemaSet(true);
+ }
+}