curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [1/2] git commit: testing continues
Date Wed, 12 Mar 2014 03:13:57 GMT
Repository: curator
Updated Branches:
  refs/heads/CURATOR-88 05fb0b873 -> 656ecdedc


testing continues


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

Branch: refs/heads/CURATOR-88
Commit: 78b5022ac550f3a7cbd4264493cc238a3b2738ff
Parents: 05fb0b8
Author: randgalt <randgalt@apache.org>
Authored: Mon Mar 10 17:04:08 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Mon Mar 10 17:04:08 2014 -0500

----------------------------------------------------------------------
 .../x/rest/entities/OptionalNodeData.java       | 49 ++++++++++++
 .../curator/x/rest/api/TestPathCache.java       | 81 ++++++++++++++++++++
 .../x/rest/support/PathChildrenCacheBridge.java | 70 +++++++++++++++++
 3 files changed, 200 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/78b5022a/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/OptionalNodeData.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/OptionalNodeData.java
b/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/OptionalNodeData.java
new file mode 100644
index 0000000..398308c
--- /dev/null
+++ b/curator-x-rest/src/main/java/org/apache/curator/x/rest/entities/OptionalNodeData.java
@@ -0,0 +1,49 @@
+/**
+ * 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.rest.entities;
+
+import org.apache.zookeeper.data.Stat;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class OptionalNodeData
+{
+    private NodeData nodeData;
+
+    public OptionalNodeData()
+    {
+        this(null);
+    }
+
+    public OptionalNodeData(NodeData nodeData)
+    {
+        this.nodeData = nodeData;
+    }
+
+    public NodeData getNodeData()
+    {
+        return nodeData;
+    }
+
+    public void setNodeData(NodeData nodeData)
+    {
+        this.nodeData = nodeData;
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/78b5022a/curator-x-rest/src/test/java/org/apache/curator/x/rest/api/TestPathCache.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/test/java/org/apache/curator/x/rest/api/TestPathCache.java
b/curator-x-rest/src/test/java/org/apache/curator/x/rest/api/TestPathCache.java
new file mode 100644
index 0000000..619713c
--- /dev/null
+++ b/curator-x-rest/src/test/java/org/apache/curator/x/rest/api/TestPathCache.java
@@ -0,0 +1,81 @@
+/**
+ * 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.rest.api;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.recipes.cache.PathChildrenCache;
+import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
+import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
+import org.apache.curator.retry.RetryOneTime;
+import org.apache.curator.utils.CloseableUtils;
+import org.apache.curator.x.rest.support.BaseClassForTests;
+import org.apache.curator.x.rest.support.PathChildrenCacheBridge;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class TestPathCache extends BaseClassForTests
+{
+    @Test
+    public void testBasics() throws Exception
+    {
+/*
+        client.create().forPath("/test");
+
+        final BlockingQueue<PathChildrenCacheEvent.Type> events = new LinkedBlockingQueue<PathChildrenCacheEvent.Type>();
+        PathChildrenCacheBridge cache = new PathChildrenCacheBridge(restClient, sessionManager,
uriMaker, "/test", true, false);
+        try
+        {
+            cache.getListenable().addListener
+                (
+                    new PathChildrenCacheListener()
+                    {
+                        @Override
+                        public void childEvent(CuratorFramework client, PathChildrenCacheEvent
event) throws Exception
+                        {
+                            if ( event.getData().getPath().equals("/test/one") )
+                            {
+                                events.offer(event.getType());
+                            }
+                        }
+                    }
+                );
+            cache.start();
+
+            client.create().forPath("/test/one", "hey there".getBytes());
+            Assert.assertEquals(events.poll(10, TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_ADDED);
+
+            client.setData().forPath("/test/one", "sup!".getBytes());
+            Assert.assertEquals(events.poll(10, TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_UPDATED);
+            Assert.assertEquals(new String(cache.getCurrentData("/test/one").getData()),
"sup!");
+
+            client.delete().forPath("/test/one");
+            Assert.assertEquals(events.poll(10, TimeUnit.SECONDS), PathChildrenCacheEvent.Type.CHILD_REMOVED);
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(cache);
+        }
+*/
+    }
+}

http://git-wip-us.apache.org/repos/asf/curator/blob/78b5022a/curator-x-rest/src/test/java/org/apache/curator/x/rest/support/PathChildrenCacheBridge.java
----------------------------------------------------------------------
diff --git a/curator-x-rest/src/test/java/org/apache/curator/x/rest/support/PathChildrenCacheBridge.java
b/curator-x-rest/src/test/java/org/apache/curator/x/rest/support/PathChildrenCacheBridge.java
new file mode 100644
index 0000000..b593839
--- /dev/null
+++ b/curator-x-rest/src/test/java/org/apache/curator/x/rest/support/PathChildrenCacheBridge.java
@@ -0,0 +1,70 @@
+/**
+ * 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.rest.support;
+
+import com.sun.jersey.api.client.Client;
+import org.apache.curator.framework.listen.ListenerContainer;
+import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
+import org.apache.curator.x.rest.entities.NodeData;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.List;
+
+public class PathChildrenCacheBridge implements Closeable
+{
+    private final Client restClient;
+    private final SessionManager sessionManager;
+    private final UriMaker uriMaker;
+    private final String path;
+    private final boolean cacheData;
+    private final boolean dataIsCompressed;
+    private final ListenerContainer<PathChildrenCacheListener> listeners = new ListenerContainer<PathChildrenCacheListener>();
+
+    public PathChildrenCacheBridge(Client restClient, SessionManager sessionManager, UriMaker
uriMaker, String path, boolean cacheData, boolean dataIsCompressed)
+    {
+        this.restClient = restClient;
+        this.sessionManager = sessionManager;
+        this.uriMaker = uriMaker;
+        this.path = path;
+        this.cacheData = cacheData;
+        this.dataIsCompressed = dataIsCompressed;
+    }
+
+    public void start() throws Exception
+    {
+
+    }
+
+    @Override
+    public void close() throws IOException
+    {
+
+    }
+
+    public ListenerContainer<PathChildrenCacheListener> getListenable()
+    {
+        return listeners;
+    }
+
+    public List<NodeData> getCurrentData()
+    {
+        return null;
+    }
+}


Mime
View raw message