You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2018/12/05 17:01:18 UTC

[4/4] curator git commit: expanded async-create-protected test to verify protectedId

expanded async-create-protected test to verify protectedId


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

Branch: refs/heads/master
Commit: 1720520f2be6b995dd562949f9e08053a748c5e8
Parents: 1bc21db
Author: josh gruenberg <jo...@gmail.com>
Authored: Wed Dec 5 08:27:30 2018 -0700
Committer: josh gruenberg <jo...@gmail.com>
Committed: Wed Dec 5 08:27:45 2018 -0700

----------------------------------------------------------------------
 .../org/apache/curator/framework/imps/TestFramework.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/1720520f/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
----------------------------------------------------------------------
diff --git a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
index e1e875b..27a84d0 100644
--- a/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
+++ b/curator-x-async/src/test/java/org/apache/curator/framework/imps/TestFramework.java
@@ -49,6 +49,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
+import java.util.UUID;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
@@ -408,6 +409,15 @@ public class TestFramework extends BaseClassForTests
             String path = async.create().withOptions(Collections.singleton(CreateOption.doProtected)).forPath("/yo").toCompletableFuture().get();
             String node = ZKPaths.getNodeFromPath(path);
             Assert.assertTrue(node.startsWith(CreateBuilderImpl.PROTECTED_PREFIX), node);
+
+            // CURATOR-489: confirm that the node contains a valid UUID, eg '_c_53345f98-9423-4e0c-a7b5-9f819e3ec2e1-yo'
+            int expectedProtectedIdLength = 36; // '53345f98-9423-4e0c-a7b5-9f819e3ec2e1'
+            int delimeterLength = 1; // '-'
+            int expectedNodeLength = CreateBuilderImpl.PROTECTED_PREFIX.length() + expectedProtectedIdLength + delimeterLength + "yo".length();
+            Assert.assertEquals(node.length(), expectedNodeLength);
+            int uuidStart = CreateBuilderImpl.PROTECTED_PREFIX.length();
+            String protectedId = node.substring(uuidStart, uuidStart + expectedProtectedIdLength);
+            UUID.fromString(protectedId); // will throw if token is not a UUID
         }
         finally
         {