Repository: curator Updated Branches: refs/heads/master 716fb4aa4 -> 4a0e022ce
Fixed create mode for AsyncCuratorFramework.transactionOp().create(). It was being ignored. Added a test as well Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/4a0e022c Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/4a0e022c Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/4a0e022c Branch: refs/heads/master Commit: 4a0e022ce361e21b9f1751434166c5a90c4a8845 Parents: 716fb4a Author: randgalt <[email protected]> Authored: Thu Jul 13 23:51:43 2017 -0500 Committer: randgalt <[email protected]> Committed: Thu Jul 13 23:51:43 2017 -0500 ---------------------------------------------------------------------- .../x/async/details/AsyncTransactionOpImpl.java | 4 ++-- .../x/async/CompletableBaseClassForTests.java | 8 ++++++- .../curator/x/async/TestBasicOperations.java | 22 ++++++++++++++------ 3 files changed, 25 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/4a0e022c/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncTransactionOpImpl.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncTransactionOpImpl.java b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncTransactionOpImpl.java index 7b158f8..2a2c293 100644 --- a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncTransactionOpImpl.java +++ b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncTransactionOpImpl.java @@ -18,7 +18,7 @@ */ package org.apache.curator.x.async.details; -import org.apache.curator.framework.api.ACLCreateModePathAndBytesable; +import org.apache.curator.framework.api.ACLPathAndBytesable; import org.apache.curator.framework.api.PathAndBytesable; import org.apache.curator.framework.api.VersionPathAndBytesable; import org.apache.curator.framework.api.transaction.CuratorOp; @@ -115,7 +115,7 @@ class AsyncTransactionOpImpl implements AsyncTransactionOp private CuratorOp internalForPath(String path, byte[] data, boolean useData) { TransactionCreateBuilder2<CuratorOp> builder1 = (ttl > 0) ? client.transactionOp().create().withTtl(ttl) : client.transactionOp().create(); - ACLCreateModePathAndBytesable<CuratorOp> builder2 = compressed ? builder1.compressed() : builder1; + ACLPathAndBytesable<CuratorOp> builder2 = compressed ? builder1.compressed().withMode(createMode) : builder1.withMode(createMode); PathAndBytesable<CuratorOp> builder3 = builder2.withACL(aclList); try { http://git-wip-us.apache.org/repos/asf/curator/blob/4a0e022c/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java b/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java index 232d301..4a964b1 100644 --- a/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java +++ b/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java @@ -18,6 +18,7 @@ */ package org.apache.curator.x.async; +import com.google.common.base.Throwables; import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.Timing; import org.testng.Assert; @@ -33,7 +34,12 @@ public abstract class CompletableBaseClassForTests extends BaseClassForTests protected <T, U> void complete(CompletionStage<T> stage) { - complete(stage, (v, e) -> {}); + complete(stage, (v, e) -> { + if ( e != null ) + { + Throwables.propagate(e); + } + }); } protected <T, U> void complete(CompletionStage<T> stage, BiConsumer<? super T, Throwable> handler) http://git-wip-us.apache.org/repos/asf/curator/blob/4a0e022c/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java b/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java index 0274413..78f37c2 100644 --- a/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java +++ b/curator-x-async/src/test/java/org/apache/curator/x/async/TestBasicOperations.java @@ -20,10 +20,10 @@ package org.apache.curator.x.async; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.framework.api.transaction.CuratorOp; import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.Timing; import org.apache.curator.utils.CloseableUtils; +import org.apache.curator.x.async.modeled.ZPath; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.data.Stat; @@ -32,17 +32,15 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.IOException; +import java.util.Arrays; import java.util.concurrent.CompletionStage; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.function.BiConsumer; import static java.util.EnumSet.of; import static org.apache.curator.x.async.api.CreateOption.compress; import static org.apache.curator.x.async.api.CreateOption.setDataIfExists; import static org.apache.zookeeper.CreateMode.EPHEMERAL_SEQUENTIAL; +import static org.apache.zookeeper.CreateMode.PERSISTENT_SEQUENTIAL; public class TestBasicOperations extends CompletableBaseClassForTests { @@ -69,6 +67,18 @@ public class TestBasicOperations extends CompletableBaseClassForTests } @Test + public void testCreateTransactionWithMode() throws Exception + { + complete(AsyncWrappers.asyncEnsureContainers(client, ZPath.parse("/test"))); + + CuratorOp op1 = client.transactionOp().create().withMode(PERSISTENT_SEQUENTIAL).forPath("/test/node-"); + CuratorOp op2 = client.transactionOp().create().withMode(PERSISTENT_SEQUENTIAL).forPath("/test/node-"); + complete(client.transaction().forOperations(Arrays.asList(op1, op2))); + + Assert.assertEquals(client.unwrap().getChildren().forPath("/test").size(), 2); + } + + @Test public void testCrud() { AsyncStage<String> createStage = client.create().forPath("/test", "one".getBytes());
