Return-Path: X-Original-To: apmail-curator-commits-archive@minotaur.apache.org Delivered-To: apmail-curator-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2E090106E1 for ; Wed, 12 Mar 2014 03:14:05 +0000 (UTC) Received: (qmail 46949 invoked by uid 500); 12 Mar 2014 03:14:04 -0000 Delivered-To: apmail-curator-commits-archive@curator.apache.org Received: (qmail 46907 invoked by uid 500); 12 Mar 2014 03:14:01 -0000 Mailing-List: contact commits-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list commits@curator.apache.org Received: (qmail 46619 invoked by uid 99); 12 Mar 2014 03:13:58 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Mar 2014 03:13:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E0C84941255; Wed, 12 Mar 2014 03:13:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: randgalt@apache.org To: commits@curator.apache.org Date: Wed, 12 Mar 2014 03:13:57 -0000 Message-Id: <896bc82d34024d9fbc690690f0ba55a1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: testing continues 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 Authored: Mon Mar 10 17:04:08 2014 -0500 Committer: randgalt 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 events = new LinkedBlockingQueue(); + 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 listeners = new ListenerContainer(); + + 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 getListenable() + { + return listeners; + } + + public List getCurrentData() + { + return null; + } +}