Repository: curator
Updated Branches:
  refs/heads/CURATOR-421 f7e728b99 -> 9385d0490


more tests


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

Branch: refs/heads/CURATOR-421
Commit: 75118e43b165d2e99a432161cee6a3dab55e3e4e
Parents: f7e728b
Author: randgalt <[email protected]>
Authored: Fri Jul 14 17:15:32 2017 -0500
Committer: randgalt <[email protected]>
Committed: Fri Jul 14 17:15:32 2017 -0500

----------------------------------------------------------------------
 .../async/migrations/TestMigrationManager.java  | 50 ++++++++++++++++++--
 1 file changed, 46 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/75118e43/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
----------------------------------------------------------------------
diff --git 
a/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
 
b/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
index 3522911..80a03bb 100644
--- 
a/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
+++ 
b/curator-x-async/src/test/java/org/apache/curator/x/async/migrations/TestMigrationManager.java
@@ -33,6 +33,7 @@ import 
org.apache.curator.x.async.modeled.JacksonModelSerializer;
 import org.apache.curator.x.async.modeled.ModelSpec;
 import org.apache.curator.x.async.modeled.ModeledFramework;
 import org.apache.curator.x.async.modeled.ZPath;
+import org.apache.zookeeper.KeeperException;
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -94,7 +95,7 @@ public class TestMigrationManager extends 
CompletableBaseClassForTests
     }
 
     @Test
-    public void testBasic() throws Exception
+    public void testBasic()
     {
         Migration m1 = () -> Arrays.asList(v1opA, v1opB);
         Migration m2 = () -> Collections.singletonList(v2op);
@@ -116,7 +117,7 @@ public class TestMigrationManager extends 
CompletableBaseClassForTests
     }
 
     @Test
-    public void testStaged() throws Exception
+    public void testStaged()
     {
         Migration m1 = () -> Arrays.asList(v1opA, v1opB);
         MigrationSet migrationSet = MigrationSet.build("1", 
Collections.singletonList(m1));
@@ -174,7 +175,7 @@ public class TestMigrationManager extends 
CompletableBaseClassForTests
     }
 
     @Test
-    public void testChecksumDataError() throws Exception
+    public void testChecksumDataError()
     {
         CuratorOp op1 = client.transactionOp().create().forPath("/test");
         CuratorOp op2 = client.transactionOp().create().forPath("/test/bar", 
"first".getBytes());
@@ -197,7 +198,7 @@ public class TestMigrationManager extends 
CompletableBaseClassForTests
     }
 
     @Test
-    public void testChecksumPathError() throws Exception
+    public void testChecksumPathError()
     {
         CuratorOp op1 = client.transactionOp().create().forPath("/test2");
         CuratorOp op2 = client.transactionOp().create().forPath("/test2/bar");
@@ -218,4 +219,45 @@ public class TestMigrationManager extends 
CompletableBaseClassForTests
             Assert.assertTrue(Throwables.getRootCause(e) instanceof 
MigrationException);
         }
     }
+
+    @Test
+    public void testPartialApplyForBadOps() throws Exception
+    {
+        CuratorOp op1 = client.transactionOp().create().forPath("/test", 
"something".getBytes());
+        CuratorOp op2 = client.transactionOp().create().forPath("/a/b/c");
+        Migration m1 = () -> Collections.singletonList(op1);
+        Migration m2 = () -> Collections.singletonList(op2);
+        MigrationSet migrationSet = MigrationSet.build("1", Arrays.asList(m1, 
m2));
+        try
+        {
+            complete(manager.migrate(migrationSet));
+            Assert.fail("Should throw");
+        }
+        catch ( Throwable e )
+        {
+            Assert.assertTrue(Throwables.getRootCause(e) instanceof 
KeeperException.NoNodeException);
+        }
+
+        Assert.assertEquals(client.unwrap().getData().forPath("/test"), 
"something".getBytes());
+    }
+
+    @Test
+    public void testTransactionForBadOps() throws Exception
+    {
+        CuratorOp op1 = client.transactionOp().create().forPath("/test2", 
"something".getBytes());
+        CuratorOp op2 = client.transactionOp().create().forPath("/a/b/c/d");
+        Migration migration = () -> Arrays.asList(op1, op2);
+        MigrationSet migrationSet = MigrationSet.build("1", 
Collections.singletonList(migration));
+        try
+        {
+            complete(manager.migrate(migrationSet));
+            Assert.fail("Should throw");
+        }
+        catch ( Throwable e )
+        {
+            Assert.assertTrue(Throwables.getRootCause(e) instanceof 
KeeperException.NoNodeException);
+        }
+
+        Assert.assertNull(client.unwrap().checkExists().forPath("/test"));
+    }
 }

Reply via email to