refactoring, added reconfig() support

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

Branch: refs/heads/CURATOR-3.0
Commit: 9a09b5df509886618829e8cf11d0bb587d5bced0
Parents: 7128332
Author: randgalt <randg...@apache.org>
Authored: Thu Jan 5 15:30:07 2017 -0500
Committer: randgalt <randg...@apache.org>
Committed: Thu Jan 5 15:30:07 2017 -0500

----------------------------------------------------------------------
 .../curator/x/crimps/async/AsyncCrimps.java     | 196 +++++++++++++++++++
 .../curator/x/crimps/async/BackgroundProc.java  |  18 ++
 .../crimps/async/CrimpedBackgroundCallback.java |  18 ++
 .../async/CrimpedConfigureEnsembleable.java     |  33 ++++
 .../x/crimps/async/CrimpedPathAndBytesable.java |  18 ++
 .../curator/x/crimps/async/CrimpedPathable.java |  18 ++
 .../apache/curator/x/crimps/async/Crimps.java   | 129 ++----------
 .../curator/x/crimps/async/TestCrimps.java      |  45 ++++-
 8 files changed, 360 insertions(+), 115 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCrimps.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCrimps.java
 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCrimps.java
new file mode 100644
index 0000000..69695bc
--- /dev/null
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/AsyncCrimps.java
@@ -0,0 +1,196 @@
+/**
+ * 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.x.crimps.async;
+
+import org.apache.curator.framework.api.*;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import java.util.List;
+import java.util.concurrent.CompletionStage;
+import java.util.function.Function;
+
+public class AsyncCrimps
+{
+    public static final BackgroundProc<String> nameSupplier = 
makeSupplier(CuratorEvent::getName);
+    public static final BackgroundProc<String> pathSupplier = 
makeSupplier(CuratorEvent::getPath);
+    public static final BackgroundProc<Void> voidSupplier = makeSupplier(e -> 
null);
+    public static final BackgroundProc<byte[]> dataSupplier = 
makeSupplier(CuratorEvent::getData);
+    public static final BackgroundProc<Stat> statSupplier = 
makeSupplier(CuratorEvent::getStat);
+    public static final BackgroundProc<List<String>> childrenSupplier = 
makeSupplier(CuratorEvent::getChildren);
+    public static final BackgroundProc<List<ACL>> aclSupplier = 
makeSupplier(CuratorEvent::getACLList);
+
+    private final UnhandledErrorListener unhandledErrorListener;
+
+    public static <T> BackgroundProc<T> makeSupplier(Function<CuratorEvent, T> 
proc)
+    {
+        return (event, future) -> {
+            if ( event.getResultCode() == 0 )
+            {
+                future.complete(proc.apply(event));
+            }
+            else
+            {
+                
future.completeExceptionally(KeeperException.create(KeeperException.Code.get(event.getResultCode())));
+            }
+            return null;
+        };
+    }
+
+    public AsyncCrimps withUnhandledErrorListener(UnhandledErrorListener 
unhandledErrorListener)
+    {
+        return new AsyncCrimps(unhandledErrorListener);
+    }
+
+    public CrimpedPathAndBytesable<String> 
name(BackgroundPathAndBytesable<String> builder)
+    {
+        return build(builder, nameSupplier);
+    }
+
+    public CrimpedPathAndBytesable<String> 
path(BackgroundPathAndBytesable<String> builder)
+    {
+        return build(builder, pathSupplier);
+    }
+
+    public CrimpedPathable<Void> ignored(BackgroundPathable<Void> builder)
+    {
+        return build(builder, voidSupplier);
+    }
+
+    public CrimpedPathable<byte[]> data(BackgroundPathable<byte[]> builder)
+    {
+        return build(builder, dataSupplier);
+    }
+
+    public CrimpedPathable<List<String>> 
children(BackgroundPathable<List<String>> builder)
+    {
+        return build(builder, childrenSupplier);
+    }
+
+    public CrimpedPathable<Stat> stat(BackgroundPathable<Stat> builder)
+    {
+        return build(builder, statSupplier);
+    }
+
+    public CrimpedPathable<List<ACL>> acls(BackgroundPathable<List<ACL>> 
builder)
+    {
+        return build(builder, aclSupplier);
+    }
+
+    public CrimpedPathAndBytesable<Stat> 
statBytes(BackgroundPathAndBytesable<Stat> builder)
+    {
+        return build(builder, statSupplier);
+    }
+
+    public CrimpedConfigureEnsembleable 
joiningLeaving(Backgroundable<ErrorListenerReconfigBuilderMain> builder, 
List<String> joining, List<String> leaving)
+    {
+        CrimpedBackgroundCallback<byte[]> callback = new 
CrimpedBackgroundCallback<>(dataSupplier);
+
+        ReconfigBuilderMain main;
+        if ( unhandledErrorListener != null )
+        {
+            main = 
builder.inBackground(callback).withUnhandledErrorListener(unhandledErrorListener);
+        }
+        else
+        {
+            main = builder.inBackground(callback);
+        }
+
+        ConfigureEnsembleable configBuilder;
+        if ( nonEmpty(joining) && nonEmpty(leaving) )
+        {
+            configBuilder = main.joining(joining).leaving(leaving);
+        }
+        else if ( nonEmpty(joining) )
+        {
+            configBuilder = main.joining(joining);
+        }
+        else if ( nonEmpty(leaving) )
+        {
+            configBuilder = main.leaving(leaving);
+        }
+        else
+        {
+            throw new IllegalArgumentException("leaving and joining cannot 
both be empty");
+        }
+
+        return new CrimpedConfigureEnsembleable()
+        {
+            private Ensembleable<byte[]> localEnsembleable = configBuilder;
+
+            @Override
+            public Ensembleable<CompletionStage<byte[]>> fromConfig(long 
config) throws Exception
+            {
+                localEnsembleable = configBuilder.fromConfig(config);
+                return this;
+            }
+
+            @Override
+            public CompletionStage<byte[]> forEnsemble() throws Exception
+            {
+                localEnsembleable.forEnsemble();
+                return callback;
+            }
+        };
+    }
+
+    public <T> CrimpedPathAndBytesable<T> build(BackgroundPathAndBytesable<T> 
builder, BackgroundProc<T> backgroundProc)
+    {
+        CrimpedBackgroundCallback<T> callback = new 
CrimpedBackgroundCallback<T>(backgroundProc);
+        ErrorListenerPathAndBytesable<T> localBuilder = 
builder.inBackground(callback);
+        PathAndBytesable<T> finalLocalBuilder = (unhandledErrorListener != 
null) ? localBuilder.withUnhandledErrorListener(unhandledErrorListener) : 
localBuilder;
+        return new CrimpedPathAndBytesable<T>()
+        {
+            @Override
+            public CompletionStage<T> forPath(String path) throws Exception
+            {
+                finalLocalBuilder.forPath(path);
+                return callback;
+            }
+
+            @Override
+            public CompletionStage<T> forPath(String path, byte[] data) throws 
Exception
+            {
+                finalLocalBuilder.forPath(path, data);
+                return callback;
+            }
+        };
+    }
+
+    public <T> CrimpedPathable<T> build(BackgroundPathable<T> builder, 
BackgroundProc<T> backgroundProc)
+    {
+        CrimpedBackgroundCallback<T> callback = new 
CrimpedBackgroundCallback<T>(backgroundProc);
+        ErrorListenerPathable<T> localBuilder = builder.inBackground(callback);
+        Pathable<T> finalLocalBuilder = (unhandledErrorListener != null) ? 
localBuilder.withUnhandledErrorListener(unhandledErrorListener) : localBuilder;
+        return path -> {
+            finalLocalBuilder.forPath(path);
+            return callback;
+        };
+    }
+
+    private static boolean nonEmpty(List<String> list)
+    {
+        return (list != null) && !list.isEmpty();
+    }
+
+    AsyncCrimps(UnhandledErrorListener unhandledErrorListener)
+    {
+        this.unhandledErrorListener = unhandledErrorListener;
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
index 69167c2..bad0fbe 100644
--- 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/BackgroundProc.java
@@ -1,3 +1,21 @@
+/**
+ * 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.x.crimps.async;
 
 import org.apache.curator.framework.api.CuratorEvent;

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
index 070e5f8..5fad73a 100644
--- 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedBackgroundCallback.java
@@ -1,3 +1,21 @@
+/**
+ * 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.x.crimps.async;
 
 import org.apache.curator.framework.CuratorFramework;

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigureEnsembleable.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigureEnsembleable.java
 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigureEnsembleable.java
new file mode 100644
index 0000000..d1211ce
--- /dev/null
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedConfigureEnsembleable.java
@@ -0,0 +1,33 @@
+/**
+ * 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.x.crimps.async;
+
+import org.apache.curator.framework.api.Ensembleable;
+import java.util.concurrent.CompletionStage;
+
+public interface CrimpedConfigureEnsembleable extends
+    Ensembleable<CompletionStage<byte[]>>
+{
+    /**
+     * Sets the configuration version to use.
+     * @param config The version of the configuration.
+     * @throws Exception errors
+     */
+    Ensembleable<CompletionStage<byte[]>> fromConfig(long config) throws 
Exception;
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathAndBytesable.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathAndBytesable.java
 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathAndBytesable.java
index aa90507..b62ceec 100644
--- 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathAndBytesable.java
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathAndBytesable.java
@@ -1,3 +1,21 @@
+/**
+ * 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.x.crimps.async;
 
 import org.apache.curator.framework.api.PathAndBytesable;

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
index 49b096a..aa28797 100644
--- 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/CrimpedPathable.java
@@ -1,3 +1,21 @@
+/**
+ * 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.x.crimps.async;
 
 import org.apache.curator.framework.api.Pathable;

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimps.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimps.java 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimps.java
index 128e195..519a7c5 100644
--- 
a/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimps.java
+++ 
b/curator-x-crimps/src/main/java/org/apache/curator/x/crimps/async/Crimps.java
@@ -1,117 +1,28 @@
+/**
+ * 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.x.crimps.async;
 
-import org.apache.curator.framework.api.BackgroundPathAndBytesable;
-import org.apache.curator.framework.api.BackgroundPathable;
-import org.apache.curator.framework.api.CuratorEvent;
-import org.apache.curator.framework.api.ErrorListenerPathAndBytesable;
-import org.apache.curator.framework.api.ErrorListenerPathable;
-import org.apache.curator.framework.api.PathAndBytesable;
-import org.apache.curator.framework.api.Pathable;
-import org.apache.curator.framework.api.UnhandledErrorListener;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.ACL;
-import org.apache.zookeeper.data.Stat;
-import java.util.List;
-import java.util.concurrent.CompletionStage;
-import java.util.function.Function;
-
 public class Crimps
 {
-    public static final BackgroundProc<String> nameSupplier = 
makeSupplier(CuratorEvent::getName);
-    public static final BackgroundProc<String> pathSupplier = 
makeSupplier(CuratorEvent::getPath);
-    public static final BackgroundProc<Void> voidSupplier = makeSupplier(e -> 
null);
-    public static final BackgroundProc<byte[]> dataSupplier = 
makeSupplier(CuratorEvent::getData);
-    public static final BackgroundProc<Stat> statSupplier = 
makeSupplier(CuratorEvent::getStat);
-    public static final BackgroundProc<List<String>> childrenSupplier = 
makeSupplier(CuratorEvent::getChildren);
-    public static final BackgroundProc<List<ACL>> aclSupplier = 
makeSupplier(CuratorEvent::getACLList);
-
-    private static <T> BackgroundProc<T> makeSupplier(Function<CuratorEvent, 
T> proc)
-    {
-        return (event, future) -> {
-            if ( event.getResultCode() == 0 )
-            {
-                future.complete(proc.apply(event));
-            }
-            else
-            {
-                
future.completeExceptionally(KeeperException.create(KeeperException.Code.get(event.getResultCode())));
-            }
-            return null;
-        };
-    }
-
-    public static CrimpedPathAndBytesable<String> 
nameInBackground(BackgroundPathAndBytesable<String> builder)
-    {
-        return build(builder, null, nameSupplier);
-    }
-
-    public static CrimpedPathAndBytesable<String> 
pathInBackground(BackgroundPathAndBytesable<String> builder)
-    {
-        return build(builder, null, pathSupplier);
-    }
-
-    public static CrimpedPathable<Void> 
voidInBackground(BackgroundPathable<Void> builder)
-    {
-        return build(builder, null, voidSupplier);
-    }
-
-    public static CrimpedPathable<byte[]> 
dataInBackground(BackgroundPathable<byte[]> builder)
-    {
-        return build(builder, null, dataSupplier);
-    }
-
-    public static CrimpedPathable<List<String>> 
childrenInBackground(BackgroundPathable<List<String>> builder)
-    {
-        return build(builder, null, childrenSupplier);
-    }
-
-    public static CrimpedPathable<Stat> 
statInBackground(BackgroundPathable<Stat> builder)
-    {
-        return build(builder, null, statSupplier);
-    }
-
-    public static CrimpedPathable<List<ACL>> 
aclsInBackground(BackgroundPathable<List<ACL>> builder)
-    {
-        return build(builder, null, aclSupplier);
-    }
-
-    public static CrimpedPathAndBytesable<Stat> 
statBytesInBackground(BackgroundPathAndBytesable<Stat> builder)
-    {
-        return build(builder, null, statSupplier);
-    }
-
-    public static <T> CrimpedPathAndBytesable<T> 
build(BackgroundPathAndBytesable<T> builder, UnhandledErrorListener 
unhandledErrorListener, BackgroundProc<T> backgroundProc)
-    {
-        CrimpedBackgroundCallback<T> callback = new 
CrimpedBackgroundCallback<T>(backgroundProc);
-        ErrorListenerPathAndBytesable<T> localBuilder = 
builder.inBackground(callback);
-        PathAndBytesable<T> finalLocalBuilder = (unhandledErrorListener != 
null) ? localBuilder.withUnhandledErrorListener(unhandledErrorListener) : 
localBuilder;
-        return new CrimpedPathAndBytesable<T>()
-        {
-            @Override
-            public CompletionStage<T> forPath(String path) throws Exception
-            {
-                finalLocalBuilder.forPath(path);
-                return callback;
-            }
-
-            @Override
-            public CompletionStage<T> forPath(String path, byte[] data) throws 
Exception
-            {
-                finalLocalBuilder.forPath(path, data);
-                return callback;
-            }
-        };
-    }
-
-    public static <T> CrimpedPathable<T> build(BackgroundPathable<T> builder, 
UnhandledErrorListener unhandledErrorListener, BackgroundProc<T> backgroundProc)
+    public static AsyncCrimps async()
     {
-        CrimpedBackgroundCallback<T> callback = new 
CrimpedBackgroundCallback<T>(backgroundProc);
-        ErrorListenerPathable<T> localBuilder = builder.inBackground(callback);
-        Pathable<T> finalLocalBuilder = (unhandledErrorListener != null) ? 
localBuilder.withUnhandledErrorListener(unhandledErrorListener) : localBuilder;
-        return path -> {
-            finalLocalBuilder.forPath(path);
-            return callback;
-        };
+        return new AsyncCrimps(null);
     }
 
     private Crimps()

http://git-wip-us.apache.org/repos/asf/curator/blob/9a09b5df/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
----------------------------------------------------------------------
diff --git 
a/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
 
b/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
index 0bee0cf..428cb78 100644
--- 
a/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
+++ 
b/curator-x-crimps/src/test/java/org/apache/curator/x/crimps/async/TestCrimps.java
@@ -1,3 +1,21 @@
+/**
+ * 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.x.crimps.async;
 
 import org.apache.curator.framework.CuratorFramework;
@@ -9,27 +27,30 @@ import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.data.Stat;
 import org.testng.Assert;
 import org.testng.annotations.Test;
+import java.util.Arrays;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.ExecutionException;
 
 public class TestCrimps extends BaseClassForTests
 {
+    private final AsyncCrimps async = Crimps.async();
+
     @Test
     public void testCreateAndSet() throws Exception
     {
         try ( CuratorFramework client = 
CuratorFrameworkFactory.newClient(server.getConnectString(), new 
RetryOneTime(1)) )
         {
             client.start();
-            CompletionStage<String> f = 
Crimps.nameInBackground(client.create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL)).forPath("/a/b/c");
+            CompletionStage<String> f = 
async.name(client.create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL)).forPath("/a/b/c");
             complete(f.handle((path, e) -> {
                 Assert.assertEquals(path, "/a/b/c0000000000");
                 return null;
             }));
 
-            f = Crimps.nameInBackground(client.create()).forPath("/foo/bar");
+            f = async.name(client.create()).forPath("/foo/bar");
             assertException(f, KeeperException.Code.NONODE);
 
-            CompletionStage<Stat> statFuture = 
Crimps.statBytesInBackground(client.setData()).forPath("/a/b/c0000000000", 
"hey".getBytes());
+            CompletionStage<Stat> statFuture = 
async.statBytes(client.setData()).forPath("/a/b/c0000000000", "hey".getBytes());
             complete(statFuture.handle((stat, e) -> {
                 Assert.assertNotNull(stat);
                 return null;
@@ -45,14 +66,14 @@ public class TestCrimps extends BaseClassForTests
             client.start();
             client.create().forPath("/test");
 
-            CompletionStage<Void> f = 
Crimps.voidInBackground(client.delete()).forPath("/test");
+            CompletionStage<Void> f = 
async.ignored(client.delete()).forPath("/test");
             complete(f.handle((v, e) -> {
                 Assert.assertEquals(v, null);
                 Assert.assertEquals(e, null);
                 return null;
             }));
 
-            f = Crimps.voidInBackground(client.delete()).forPath("/test");
+            f = async.ignored(client.delete()).forPath("/test");
             assertException(f, KeeperException.Code.NONODE);
         }
     }
@@ -65,7 +86,7 @@ public class TestCrimps extends BaseClassForTests
             client.start();
             client.create().forPath("/test", "foo".getBytes());
 
-            CompletionStage<byte[]> f = 
Crimps.dataInBackground(client.getData()).forPath("/test");
+            CompletionStage<byte[]> f = 
async.data(client.getData()).forPath("/test");
             complete(f.handle((data, e) -> {
                 Assert.assertEquals(data, "foo".getBytes());
                 return null;
@@ -73,6 +94,18 @@ public class TestCrimps extends BaseClassForTests
         }
     }
 
+    @Test
+    public void testReconfig() throws Exception
+    {
+        try ( CuratorFramework client = 
CuratorFrameworkFactory.newClient(server.getConnectString(), new 
RetryOneTime(1)) )
+        {
+            client.start();
+
+            CompletionStage<byte[]> f = 
async.joiningLeaving(client.reconfig(), Arrays.asList("1", "2"), 
Arrays.asList("3", "4")).forEnsemble();
+            assertException(f, KeeperException.Code.UNIMPLEMENTED);
+        }
+    }
+
     public void assertException(CompletionStage<?> f, KeeperException.Code 
code) throws Exception
     {
         complete(f.handle((value, e) -> {

Reply via email to