This is an automated email from the ASF dual-hosted git repository.

hulee pushed a commit to branch rest0
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/rest0 by this push:
     new 881c1d1  add test for exists
881c1d1 is described below

commit 881c1d16c0767ab881e65afaae70fe954b821d8e
Author: Hunter Lee <[email protected]>
AuthorDate: Mon Jan 13 00:31:17 2020 -0800

    add test for exists
---
 .../helix/rest/server/TestZooKeeperAccessor.java      | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestZooKeeperAccessor.java
 
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestZooKeeperAccessor.java
index 175f0b2..fa08afd 100644
--- 
a/helix-rest/src/test/java/org/apache/helix/rest/server/TestZooKeeperAccessor.java
+++ 
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestZooKeeperAccessor.java
@@ -19,6 +19,10 @@ package org.apache.helix.rest.server;
  * under the License.
  */
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.I0Itec.zkclient.exception.ZkMarshallingError;
 import org.I0Itec.zkclient.serialize.ZkSerializer;
 import org.apache.helix.AccessOption;
@@ -58,18 +62,29 @@ public class TestZooKeeperAccessor extends 
AbstractTestClass {
   }
 
   @Test
-  public void testExists() {
+  public void testExists()
+      throws IOException {
     String path = "/path";
     Assert.assertFalse(_testBaseDataAccessor.exists(path, 
AccessOption.PERSISTENT));
+    Map<String, Boolean> result = new HashMap<>();
+    String data = new 
JerseyUriRequestBuilder("zookeeper{}?command=exists").format(path)
+        .isBodyReturnExpected(true).get(this);
+    result = OBJECT_MAPPER.readValue(data, HashMap.class);
+    Assert.assertTrue(result.containsKey("exists"));
+    Assert.assertEquals(result.get("exists"), Boolean.FALSE);
 
     // Create a ZNode and check again
     String content = "testExists";
     Assert.assertTrue(_testBaseDataAccessor.create(path, content.getBytes(), 
AccessOption.PERSISTENT));
     Assert.assertTrue(_testBaseDataAccessor.exists(path, 
AccessOption.PERSISTENT));
 
-    String data = new 
JerseyUriRequestBuilder("zookeeper{}?command=exists").format(path)
+    data = new 
JerseyUriRequestBuilder("zookeeper{}?command=exists").format(path)
         .isBodyReturnExpected(true).get(this);
 
+    result = OBJECT_MAPPER.readValue(data, HashMap.class);
+    Assert.assertTrue(result.containsKey("exists"));
+    Assert.assertEquals(result.get("exists"), Boolean.TRUE);
+
     // Clean up
     _testBaseDataAccessor.remove(path, AccessOption.PERSISTENT);
   }

Reply via email to