hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r920619 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/test/org/apache/zookeeper/test/ClientTest.java
Date Tue, 09 Mar 2010 02:09:16 GMT
Author: mahadev
Date: Tue Mar  9 02:09:15 2010
New Revision: 920619

URL: http://svn.apache.org/viewvc?rev=920619&view=rev
Log:
ZOOKEEPER-543. Tests for ZooKeeper examples (steven via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=920619&r1=920618&r2=920619&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Mar  9 02:09:15 2010
@@ -333,6 +333,8 @@ IMPROVEMENTS:
 
   ZOOKEEPER-663. hudson failure in ZKDatabaseCorruptionTest (mahadev via henryr)
 
+  ZOOKEEPER-543. Tests for ZooKeeper examples (steven via mahadev)
+
 NEW FEATURES:
   ZOOKEEPER-539. generate eclipse project via ant target. (phunt via mahadev)
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java?rev=920619&r1=920618&r2=920619&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java Tue Mar
 9 02:09:15 2010
@@ -438,7 +438,7 @@ public class ClientTest extends ClientBa
             }
         }
     }
-
+    
     // Test that sequential filenames are being created correctly,
     // with 0-padding in the filename
     @Test
@@ -484,6 +484,48 @@ public class ClientTest extends ClientBa
                 zk.close();
         }
     }
+    
+    // Test that data provided when 
+    // creating sequential nodes is stored properly
+    @Test
+    public void testSequentialNodeData() throws Exception {
+        ZooKeeper zk= null;
+        String queue_handle = "/queue";
+        try {
+            zk = createClient();
+
+            zk.create(queue_handle, new byte[0], Ids.OPEN_ACL_UNSAFE,
+                    CreateMode.PERSISTENT);
+            zk.create(queue_handle + "/element", "0".getBytes(),
+                    Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
+            zk.create(queue_handle + "/element", "1".getBytes(),
+                    Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
+            List<String> children = zk.getChildren(queue_handle, true);
+            assertEquals(children.size(), 2);
+            String child1 = children.get(0);
+            String child2 = children.get(1);
+            int compareResult = child1.compareTo(child2);
+            assertNotSame(compareResult, 0);
+            if (compareResult < 0) {
+            } else {
+                String temp = child1;
+                child1 = child2;
+                child2 = temp;
+            }
+            String child1data = new String(zk.getData(queue_handle
+                    + "/" + child1, false, null));
+            String child2data = new String(zk.getData(queue_handle
+                    + "/" + child2, false, null));
+            assertEquals(child1data, "0");
+            assertEquals(child2data, "1");
+        } finally {
+            if (zk != null) {
+                zk.close();
+            }
+        }
+
+    }
+
 
     private void verifyCreateFails(String path, ZooKeeper zk) throws Exception {
         try {



Mime
View raw message