curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cammcken...@apache.org
Subject [3/4] git commit: Add unit test for setting node data in InterProcessReadWriteLock.
Date Mon, 03 Nov 2014 23:33:59 GMT
Add unit test for setting node data in InterProcessReadWriteLock.


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

Branch: refs/heads/CURATOR-140
Commit: b468f42382ab2d4813137215c20de9c36ef117c1
Parents: 77a1afb
Author: Brien Wheeler <brien@Briens-MacBook-Pro.local>
Authored: Mon Nov 3 14:46:17 2014 -0500
Committer: Brien Wheeler <brien@Briens-MacBook-Pro.local>
Committed: Mon Nov 3 14:46:17 2014 -0500

----------------------------------------------------------------------
 .../locks/TestInterProcessReadWriteLock.java    | 33 ++++++++++++++++++++
 1 file changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/b468f423/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
index 23c9eca..f7636ed 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessReadWriteLock.java
@@ -261,6 +261,39 @@ public class TestInterProcessReadWriteLock extends BaseClassForTests
         Assert.assertTrue(maxConcurrentCount.get() > 1);
     }
 
+    @Test
+    public void     testSetNodeData() throws Exception
+    {
+        CuratorFramework        client = CuratorFrameworkFactory.newClient(server.getConnectString(),
new RetryOneTime(1));
+
+        try
+        {
+            client.start();
+
+            final byte[] nodeData = new byte[] { 1, 2, 3, 4 };
+
+            InterProcessReadWriteLock   lock = new InterProcessReadWriteLock(client, "/lock",
nodeData);
+
+            // mutate passed-in node data, lock has made copy
+            nodeData[0] = 5;
+
+            lock.writeLock().acquire();
+
+            List<String> children = client.getChildren().forPath("/lock");
+            Assert.assertEquals(1, children.size());
+
+            byte dataInZk[] = client.getData().forPath("/lock/" + children.get(0));
+            Assert.assertNotNull(dataInZk);
+            Assert.assertEquals(new byte[] { 1, 2, 3, 4 }, dataInZk);
+
+            lock.writeLock().release();
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(client);
+        }
+    }
+
     private void doLocking(InterProcessLock lock, AtomicInteger concurrentCount, AtomicInteger
maxConcurrentCount, Random random, int maxAllowed) throws Exception
     {
         try


Mime
View raw message