more testing

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

Branch: refs/heads/CURATOR-3.0
Commit: 16364f3c48a5dda50ba46a7ce2bece93a1c55ccf
Parents: 88fe6b4
Author: randgalt <randg...@apache.org>
Authored: Fri Jan 6 14:15:52 2017 -0500
Committer: randgalt <randg...@apache.org>
Committed: Fri Jan 6 14:15:52 2017 -0500

----------------------------------------------------------------------
 .../curator/x/async/AsyncCreateBuilder.java     | 16 ++++----
 .../x/async/details/AsyncCreateBuilderImpl.java | 18 ++++----
 .../curator/x/async/TestBasicOperations.java    | 43 ++++++++++----------
 3 files changed, 38 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/16364f3c/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCreateBuilder.java
----------------------------------------------------------------------
diff --git 
a/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCreateBuilder.java
 
b/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCreateBuilder.java
index fbcf99c..b030fac 100644
--- 
a/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCreateBuilder.java
+++ 
b/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncCreateBuilder.java
@@ -33,19 +33,19 @@ public interface AsyncCreateBuilder extends
      * @param stat the stat to have filled in
      * @return this
      */
-    AsyncPathable<AsyncStage<String>> storingStatIn(Stat stat);
+    AsyncPathAndBytesable<AsyncStage<String>> storingStatIn(Stat stat);
 
-    AsyncPathable<AsyncStage<String>> withMode(CreateMode createMode);
+    AsyncPathAndBytesable<AsyncStage<String>> withMode(CreateMode createMode);
 
-    AsyncPathable<AsyncStage<String>> withACL(List<ACL> aclList);
+    AsyncPathAndBytesable<AsyncStage<String>> withACL(List<ACL> aclList);
 
-    AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> options);
+    AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> 
options);
 
-    AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> options, 
List<ACL> aclList);
+    AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, List<ACL> aclList);
 
-    AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> options, 
CreateMode createMode, List<ACL> aclList);
+    AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, CreateMode createMode, List<ACL> aclList);
 
-    AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> options, 
CreateMode createMode);
+    AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, CreateMode createMode);
 
-    AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> options, 
CreateMode createMode, List<ACL> aclList, Stat stat);
+    AsyncPathAndBytesable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, CreateMode createMode, List<ACL> aclList, Stat stat);
 }

http://git-wip-us.apache.org/repos/asf/curator/blob/16364f3c/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
----------------------------------------------------------------------
diff --git 
a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
 
b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
index fb52154..60483ef 100644
--- 
a/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
+++ 
b/curator-x-async/src/main/java/org/apache/curator/x/async/details/AsyncCreateBuilderImpl.java
@@ -22,7 +22,7 @@ import 
org.apache.curator.framework.api.UnhandledErrorListener;
 import org.apache.curator.framework.imps.CreateBuilderImpl;
 import org.apache.curator.framework.imps.CuratorFrameworkImpl;
 import org.apache.curator.x.async.AsyncCreateBuilder;
-import org.apache.curator.x.async.AsyncPathable;
+import org.apache.curator.x.async.AsyncPathAndBytesable;
 import org.apache.curator.x.async.AsyncStage;
 import org.apache.curator.x.async.CreateOption;
 import org.apache.zookeeper.CreateMode;
@@ -52,35 +52,35 @@ class AsyncCreateBuilderImpl implements AsyncCreateBuilder
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> storingStatIn(Stat stat)
+    public AsyncPathAndBytesable<AsyncStage<String>> storingStatIn(Stat stat)
     {
         this.stat = stat;
         return this;
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withMode(CreateMode createMode)
+    public AsyncPathAndBytesable<AsyncStage<String>> withMode(CreateMode 
createMode)
     {
         this.createMode = Objects.requireNonNull(createMode, "createMode 
cannot be null");
         return this;
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withACL(List<ACL> aclList)
+    public AsyncPathAndBytesable<AsyncStage<String>> withACL(List<ACL> aclList)
     {
         this.aclList = aclList;
         return this;
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> 
options)
+    public AsyncPathAndBytesable<AsyncStage<String>> 
withOptions(Set<CreateOption> options)
     {
         this.options = Objects.requireNonNull(options, "options cannot be 
null");
         return this;
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, List<ACL> aclList)
+    public AsyncPathAndBytesable<AsyncStage<String>> 
withOptions(Set<CreateOption> options, List<ACL> aclList)
     {
         this.options = Objects.requireNonNull(options, "options cannot be 
null");
         this.aclList = aclList;
@@ -88,7 +88,7 @@ class AsyncCreateBuilderImpl implements AsyncCreateBuilder
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, CreateMode createMode, List<ACL> aclList)
+    public AsyncPathAndBytesable<AsyncStage<String>> 
withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> aclList)
     {
         this.options = Objects.requireNonNull(options, "options cannot be 
null");
         this.aclList = aclList;
@@ -97,7 +97,7 @@ class AsyncCreateBuilderImpl implements AsyncCreateBuilder
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, CreateMode createMode)
+    public AsyncPathAndBytesable<AsyncStage<String>> 
withOptions(Set<CreateOption> options, CreateMode createMode)
     {
         this.options = Objects.requireNonNull(options, "options cannot be 
null");
         this.createMode = Objects.requireNonNull(createMode, "createMode 
cannot be null");
@@ -105,7 +105,7 @@ class AsyncCreateBuilderImpl implements AsyncCreateBuilder
     }
 
     @Override
-    public AsyncPathable<AsyncStage<String>> withOptions(Set<CreateOption> 
options, CreateMode createMode, List<ACL> aclList, Stat stat)
+    public AsyncPathAndBytesable<AsyncStage<String>> 
withOptions(Set<CreateOption> options, CreateMode createMode, List<ACL> 
aclList, Stat stat)
     {
         this.options = Objects.requireNonNull(options, "options cannot be 
null");
         this.aclList = aclList;

http://git-wip-us.apache.org/repos/asf/curator/blob/16364f3c/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 1ccd676..eca679e 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
@@ -24,7 +24,6 @@ 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.zookeeper.CreateMode;
 import org.apache.zookeeper.Watcher;
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
@@ -33,7 +32,12 @@ import org.testng.annotations.Test;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
-import java.util.function.BiFunction;
+import java.util.function.BiConsumer;
+
+import static java.util.EnumSet.of;
+import static org.apache.curator.x.async.CreateOption.compress;
+import static org.apache.curator.x.async.CreateOption.setDataIfExists;
+import static org.apache.zookeeper.CreateMode.EPHEMERAL_SEQUENTIAL;
 
 public class TestBasicOperations extends BaseClassForTests
 {
@@ -64,30 +68,22 @@ public class TestBasicOperations extends BaseClassForTests
     public void testCrud()
     {
         AsyncStage<String> createStage = client.create().forPath("/test", 
"one".getBytes());
-        complete(createStage, (path, e) -> {
-            Assert.assertEquals(path, "/test");
-            return null;
-        });
+        complete(createStage, (path, e) -> Assert.assertEquals(path, "/test"));
 
         AsyncStage<byte[]> getStage = client.getData().forPath("/test");
-        complete(getStage, (data, e) -> {
-            Assert.assertEquals(data, "one".getBytes());
-            return null;
-        });
+        complete(getStage, (data, e) -> Assert.assertEquals(data, 
"one".getBytes()));
 
         CompletionStage<byte[]> combinedStage = 
client.setData().forPath("/test", "new".getBytes()).thenCompose(
             __ -> client.getData().forPath("/test"));
-        complete(combinedStage, (data, e) -> {
-            Assert.assertEquals(data, "new".getBytes());
-            return null;
-        });
+        complete(combinedStage, (data, e) -> Assert.assertEquals(data, 
"new".getBytes()));
 
-        CompletionStage<Void> combinedDelete = 
client.create().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath("/deleteme").thenCompose(
+        CompletionStage<Void> combinedDelete = 
client.create().withMode(EPHEMERAL_SEQUENTIAL).forPath("/deleteme").thenCompose(
             path -> client.delete().forPath(path));
-        complete(combinedDelete, (v, e) -> {
-            Assert.assertNull(e);
-            return null;
-        });
+        complete(combinedDelete, (v, e) -> Assert.assertNull(e));
+
+        CompletionStage<byte[]> setDataIfStage = 
client.create().withOptions(of(compress, setDataIfExists)).forPath("/test", 
"last".getBytes())
+            .thenCompose(__ -> 
client.getData().decompressed().forPath("/test"));
+        complete(setDataIfStage, (data, e) -> Assert.assertEquals(data, 
"last".getBytes()));
     }
 
     @Test
@@ -105,14 +101,17 @@ public class TestBasicOperations extends BaseClassForTests
 
     private <T, U> void complete(CompletionStage<T> stage)
     {
-        complete(stage, (v, e) -> null);
+        complete(stage, (v, e) -> {});
     }
 
-    private <T, U> void complete(CompletionStage<T> stage, BiFunction<? super 
T, Throwable, ? extends U> handler)
+    private <T, U> void complete(CompletionStage<T> stage, BiConsumer<? super 
T, Throwable> handler)
     {
         try
         {
-            stage.handle(handler).toCompletableFuture().get();
+            stage.handle((v, e) -> {
+                handler.accept(v, e);
+                return null;
+            }).toCompletableFuture().get();
         }
         catch ( InterruptedException e )
         {

Reply via email to