Bladeren bron

Fixed ZOOKEEPER-75, addressed some license issues and also removed the cobertura library (gpl). Moved from junit 4.1 to junit 4.4 at the same time (tests still pass).

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@677109 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 17 jaren geleden
bovenliggende
commit
31d99a300a
36 gewijzigde bestanden met toevoegingen van 625 en 329 verwijderingen
  1. 3 0
      src/java/lib/cobertura/README.txt
  2. BIN
      src/java/lib/cobertura/cobertura.jar
  3. BIN
      src/java/lib/cobertura/lib/asm-2.2.1.jar
  4. BIN
      src/java/lib/cobertura/lib/asm-tree-2.2.1.jar
  5. BIN
      src/java/lib/cobertura/lib/jakarta-oro-2.0.8.jar
  6. 0 53
      src/java/lib/cobertura/lib/jakarta-oro-license.txt
  7. BIN
      src/java/lib/junit-4.1.jar
  8. 27 0
      src/java/lib/junit-4.4.LICENSE.txt
  9. BIN
      src/java/lib/junit-4.4.jar
  10. 0 0
      src/java/lib/log4j-1.2.15.LICENSE.txt
  11. 0 0
      src/java/lib/log4j-1.2.15.NOTICE.txt
  12. 0 0
      src/java/lib/svnant/README.txt
  13. 0 0
      src/java/lib/svnant/ganymed.LICENSE.txt
  14. 0 0
      src/java/lib/svnant/javasvn.LICENSE.txt
  15. 0 0
      src/java/lib/svnant/svnClientAdapter.LICENSE.txt
  16. 0 0
      src/java/lib/svnant/svnant.LICENSE.txt
  17. 55 55
      src/java/lib/svnant/svnjavahl.LICENSE.txt
  18. 18 0
      src/java/main/org/apache/zookeeper/server/quorum/Election.java
  19. 21 3
      src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java
  20. 25 7
      src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
  21. 27 9
      src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java
  22. 91 73
      src/java/test/org/apache/zookeeper/test/AsyncTest.java
  23. 20 2
      src/java/test/org/apache/zookeeper/test/ClientBase.java
  24. 44 26
      src/java/test/org/apache/zookeeper/test/ClientTest.java
  25. 3 2
      src/java/test/org/apache/zookeeper/test/DataTreeTest.java
  26. 32 14
      src/java/test/org/apache/zookeeper/test/GenerateLoad.java
  27. 22 4
      src/java/test/org/apache/zookeeper/test/IntegrityCheck.java
  28. 18 3
      src/java/test/org/apache/zookeeper/test/OOMTest.java
  29. 20 2
      src/java/test/org/apache/zookeeper/test/QuorumTest.java
  30. 24 9
      src/java/test/org/apache/zookeeper/test/RecoveryTest.java
  31. 29 11
      src/java/test/org/apache/zookeeper/test/SessionTest.java
  32. 19 1
      src/java/test/org/apache/zookeeper/test/SledgeHammer.java
  33. 19 1
      src/java/test/org/apache/zookeeper/test/TestHammer.java
  34. 64 46
      src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java
  35. 26 8
      src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java
  36. 18 0
      src/zookeeper.jute

+ 3 - 0
src/java/lib/cobertura/README.txt

@@ -0,0 +1,3 @@
+Download the cobertura binary from the following location and unpack it into this directory. Run "cobertura-report" target from build.xml to generate coverage report.
+
+http://cobertura.sourceforge.net/download.html

BIN
src/java/lib/cobertura/cobertura.jar


BIN
src/java/lib/cobertura/lib/asm-2.2.1.jar


BIN
src/java/lib/cobertura/lib/asm-tree-2.2.1.jar


BIN
src/java/lib/cobertura/lib/jakarta-oro-2.0.8.jar


+ 0 - 53
src/java/lib/cobertura/lib/jakarta-oro-license.txt

@@ -1,53 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation", "Jakarta-Oro" 
- *    must not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache" 
- *    or "Jakarta-Oro", nor may "Apache" or "Jakarta-Oro" appear in their 
- *    name, without prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */

BIN
src/java/lib/junit-4.1.jar


+ 27 - 0
src/java/lib/junit-4.4.LICENSE.txt

@@ -0,0 +1,27 @@
+BSD License
+
+Copyright (c) 2000-2006, www.hamcrest.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of Hamcrest nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.

BIN
src/java/lib/junit-4.4.jar


+ 0 - 0
src/java/lib/log4j-LICENSE → src/java/lib/log4j-1.2.15.LICENSE.txt


+ 0 - 0
src/java/lib/log4j-NOTICE → src/java/lib/log4j-1.2.15.NOTICE.txt


+ 0 - 0
src/java/lib/README.svnant → src/java/lib/svnant/README.txt


+ 0 - 0
src/java/lib/svnant/GANYMED-LICENSE → src/java/lib/svnant/ganymed.LICENSE.txt


+ 0 - 0
src/java/lib/svnant/JAVASVN-LICENSE → src/java/lib/svnant/javasvn.LICENSE.txt


+ 0 - 0
src/java/lib/svnant/SVNCLIENTADAPTER-LICENSE → src/java/lib/svnant/svnClientAdapter.LICENSE.txt


+ 0 - 0
src/java/lib/svnant/license.txt → src/java/lib/svnant/svnant.LICENSE.txt


+ 55 - 55
src/java/lib/svnant/JAVAHL-LICENSE → src/java/lib/svnant/svnjavahl.LICENSE.txt

@@ -1,55 +1,55 @@
-This license applies to all portions of Subversion which are not
-externally-maintained libraries (e.g. apr/, apr-util/, and neon/).
-Such libraries have their own licenses; we recommend you read them, as
-their terms may differ from the terms below.
-
-This is version 1 of this license.  It is also available online at
-http://subversion.tigris.org/license-1.html.  If newer versions of
-this license are posted there (the same URL, but with the version
-number incremented: .../license-2.html, .../license-3.html, and so
-on), you may use a newer version instead, at your option.
-
-====================================================================
-Copyright (c) 2000-2005 CollabNet.  All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
-
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-
-3. The end-user documentation included with the redistribution, if
-any, must include the following acknowledgment: "This product includes
-software developed by CollabNet (http://www.Collab.Net/)."
-Alternately, this acknowledgment may appear in the software itself, if
-and wherever such third-party acknowledgments normally appear.
-
-4. The hosted project names must not be used to endorse or promote
-products derived from this software without prior written
-permission. For written permission, please contact info@collab.net.
-
-5. Products derived from this software may not use the "Tigris" name
-nor may "Tigris" appear in their names without prior written
-permission of CollabNet.
-
-THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-====================================================================
-
-This software consists of voluntary contributions made by many
-individuals on behalf of CollabNet.
-
+This license applies to all portions of Subversion which are not
+externally-maintained libraries (e.g. apr/, apr-util/, and neon/).
+Such libraries have their own licenses; we recommend you read them, as
+their terms may differ from the terms below.
+
+This is version 1 of this license.  It is also available online at
+http://subversion.tigris.org/license-1.html.  If newer versions of
+this license are posted there (the same URL, but with the version
+number incremented: .../license-2.html, .../license-3.html, and so
+on), you may use a newer version instead, at your option.
+
+====================================================================
+Copyright (c) 2000-2005 CollabNet.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+3. The end-user documentation included with the redistribution, if
+any, must include the following acknowledgment: "This product includes
+software developed by CollabNet (http://www.Collab.Net/)."
+Alternately, this acknowledgment may appear in the software itself, if
+and wherever such third-party acknowledgments normally appear.
+
+4. The hosted project names must not be used to endorse or promote
+products derived from this software without prior written
+permission. For written permission, please contact info@collab.net.
+
+5. Products derived from this software may not use the "Tigris" name
+nor may "Tigris" appear in their names without prior written
+permission of CollabNet.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+====================================================================
+
+This software consists of voluntary contributions made by many
+individuals on behalf of CollabNet.
+

+ 18 - 0
src/java/main/org/apache/zookeeper/server/quorum/Election.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.server.quorum;
 
 

+ 21 - 3
src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.server;
 
 import java.io.ByteArrayInputStream;
@@ -24,7 +42,7 @@ public class DeserializationPerfTest extends TestCase {
             BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
             tree.serialize(oa, "test");
             baos.flush();
-    
+
             ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
             ia = BinaryInputArchive.getArchive(bais);
         }
@@ -37,9 +55,9 @@ public class DeserializationPerfTest extends TestCase {
         long end = System.nanoTime();
         long durationms = (end - start) / 1000000L;
         long pernodeus = ((end - start) / 1000L) / count;
-        
+
         assertEquals(count, dserTree.getNodeCount());
-        
+
         System.out.println("Deserialized " + count + " nodes in " + durationms
                 + " ms (" + pernodeus + "us/node), depth=" + depth + " width="
                 + width + " datalen=" + len);

+ 25 - 7
src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.server;
 
 import java.io.IOException;
@@ -22,14 +40,14 @@ public class SerializationPerfTest extends TestCase {
         if (--depth == 0) {
             return 1;
         }
-        
+
         path += "/";
-        
+
         int count = 1;
         for (int i = 0; i < childcount; i++) {
             count += createNodes(tree, path + i, depth, childcount, data);
         }
-        
+
         return count;
     }
 
@@ -38,8 +56,8 @@ public class SerializationPerfTest extends TestCase {
         DataTree tree = new DataTree();
         createNodes(tree, "/", depth, width, new byte[len]);
         int count = tree.getNodeCount();
-        
-        BinaryOutputArchive oa = 
+
+        BinaryOutputArchive oa =
             BinaryOutputArchive.getArchive(new NullOutputStream());
         System.gc();
         long start = System.nanoTime();
@@ -48,7 +66,7 @@ public class SerializationPerfTest extends TestCase {
         long durationms = (end - start)/1000000L;
         long pernodeus = ((end - start)/1000L)/count;
         System.out.println("Serialized " + count + " nodes in "
-                + durationms + " ms (" + pernodeus + "us/node), depth=" 
+                + durationms + " ms (" + pernodeus + "us/node), depth="
                 + depth + " width=" + width + " datalen=" + len);
     }
 
@@ -66,7 +84,7 @@ public class SerializationPerfTest extends TestCase {
             throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
         serializeTree(1000, 1, 20);
     }
-    
+
     public void test10Wide5DeepSerialize()
             throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
         serializeTree(5, 10, 20);

+ 27 - 9
src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.server;
 
 import java.io.File;
@@ -8,17 +26,17 @@ import junit.framework.TestCase;
 public class ZooKeeperServerTest extends TestCase {
     public void testSortDataDirAscending() {
         File[] files = new File[5];
-        
+
         files[0] = new File("foo.10027c6de");
         files[1] = new File("foo.10027c6df");
         files[2] = new File("bar.10027c6dd");
         files[3] = new File("foo.10027c6dc");
         files[4] = new File("foo.20027c6dc");
-        
+
         File[] orig = files.clone();
 
         List<File> filelist = ZooKeeperServer.sortDataDir(files, "foo", true);
-        
+
         assertEquals(orig[2], filelist.get(0));
         assertEquals(orig[3], filelist.get(1));
         assertEquals(orig[0], filelist.get(2));
@@ -28,7 +46,7 @@ public class ZooKeeperServerTest extends TestCase {
 
     public void testSortDataDirDescending() {
         File[] files = new File[5];
-        
+
         files[0] = new File("foo.10027c6de");
         files[1] = new File("foo.10027c6df");
         files[2] = new File("bar.10027c6dd");
@@ -38,17 +56,17 @@ public class ZooKeeperServerTest extends TestCase {
         File[] orig = files.clone();
 
         List<File> filelist = ZooKeeperServer.sortDataDir(files, "foo", false);
-        
+
         assertEquals(orig[4], filelist.get(0));
         assertEquals(orig[1], filelist.get(1));
         assertEquals(orig[0], filelist.get(2));
         assertEquals(orig[3], filelist.get(3));
         assertEquals(orig[2], filelist.get(4));
     }
-    
+
     public void testGetLogFiles() {
         File[] files = new File[5];
-        
+
         files[0] = new File("log.10027c6de");
         files[1] = new File("log.10027c6df");
         files[2] = new File("snapshot.10027c6dd");
@@ -57,10 +75,10 @@ public class ZooKeeperServerTest extends TestCase {
 
         File[] orig = files.clone();
 
-        File[] filelist = 
+        File[] filelist =
             ZooKeeperServer.getLogFiles(files,
                 Long.parseLong("10027c6de", 16));
-        
+
         assertEquals(3, filelist.length);
         assertEquals(orig[0], filelist[0]);
         assertEquals(orig[1], filelist[1]);

+ 91 - 73
src/java/test/org/apache/zookeeper/test/AsyncTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -47,29 +65,29 @@ public class AsyncTest extends TestCase implements Watcher, StringCallback, Void
     protected void restart() throws Exception {
         qt.startServers();
     }
-    
+
     @After
     protected void tearDown() throws Exception {
         qt.tearDown();
-    	LOG.error("Client test shutdown");
+        LOG.error("Client test shutdown");
         if (f != null) {
             f.shutdown();
         }
         clientConnected=null;
         LOG.error("Client test shutdown finished");
     }
-    
+
     private ZooKeeper createClient() throws IOException,InterruptedException{
         clientConnected=new CountDownLatch(1);
-		ZooKeeper zk = new ZooKeeper(hostPort, 30000, this);
-		if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
-			fail("Unable to connect to server");
-		}
-		return zk;
+        ZooKeeper zk = new ZooKeeper(hostPort, 30000, this);
+        if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
+            fail("Unable to connect to server");
+        }
+        return zk;
     }
 
     boolean bang;
-    
+
     class HammerThread extends Thread implements Watcher, StringCallback, VoidCallback {
         ZooKeeper zk;
         public void run() {
@@ -110,78 +128,78 @@ public class AsyncTest extends TestCase implements Watcher, StringCallback, Void
         public void processResult(int rc, String path, Object ctx) {
         }
     }
-    
+
     @Test
     public void testHammer() throws Exception {
-		Thread.sleep(1000);
-		bang = true;
-		for (int i = 0; i < 100; i++) {
-			new HammerThread().start();
-		}
-		Thread.sleep(5000);
-		tearDown();
-		bang = false;
-		restart();
-		Thread.sleep(5000);
-		String parts[] = hostPort.split(",");
-		String prevList[] = null;
-		for (String hp : parts) {
-			ZooKeeper zk = createClient();
-			String list[] = zk.getChildren("/", false).toArray(new String[0]);
-			if (prevList != null) {
-				assertEquals(prevList.length, list.length);
-				for (int i = 0; i < list.length; i++) {
-					assertEquals(prevList[i], list[i]);
-				}
-			}
-			prevList = list;
-		}
-	}
-    
+        Thread.sleep(1000);
+        bang = true;
+        for (int i = 0; i < 100; i++) {
+            new HammerThread().start();
+        }
+        Thread.sleep(5000);
+        tearDown();
+        bang = false;
+        restart();
+        Thread.sleep(5000);
+        String parts[] = hostPort.split(",");
+        String prevList[] = null;
+        for (String hp : parts) {
+            ZooKeeper zk = createClient();
+            String list[] = zk.getChildren("/", false).toArray(new String[0]);
+            if (prevList != null) {
+                assertEquals(prevList.length, list.length);
+                for (int i = 0; i < list.length; i++) {
+                    assertEquals(prevList[i], list[i]);
+                }
+            }
+            prevList = list;
+        }
+    }
+
     LinkedList<Integer> results = new LinkedList<Integer>();
     @Test
     public void testAsync() throws IOException,
             InterruptedException, KeeperException {
-		ZooKeeper zk = null;
-		zk = createClient();
-		zk.addAuthInfo("digest", "ben:passwd".getBytes());
-		zk.create("/ben", new byte[0], Ids.READ_ACL_UNSAFE, 0, this, results);
-		zk.create("/ben/2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
-		zk.delete("/ben", -1, this, results);
-		zk.create("/ben2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
-		zk.getData("/ben2", false, this, results);
-		synchronized (results) {
-			while (results.size() < 5) {
-				results.wait();
-			}
-		}
-		assertEquals(0, (int) results.get(0));
-		assertEquals(Code.NoAuth, (int) results.get(1));
-		assertEquals(0, (int) results.get(2));
-		assertEquals(0, (int) results.get(3));
-		assertEquals(0, (int) results.get(4));
-		zk.close();
-
-		zk =createClient();
-		zk.addAuthInfo("digest", "ben:passwd2".getBytes());
-		try {
-			zk.getData("/ben2", false, new Stat());
-			fail("Should have received a permission error");
-		} catch (KeeperException e) {
-			assertEquals(Code.NoAuth, e.getCode());
-		}
-		zk.close();
-
-		zk =createClient();
-		zk.addAuthInfo("digest", "ben:passwd".getBytes());
-		zk.getData("/ben2", false, new Stat());
-		zk.close();
-	}
+        ZooKeeper zk = null;
+        zk = createClient();
+        zk.addAuthInfo("digest", "ben:passwd".getBytes());
+        zk.create("/ben", new byte[0], Ids.READ_ACL_UNSAFE, 0, this, results);
+        zk.create("/ben/2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
+        zk.delete("/ben", -1, this, results);
+        zk.create("/ben2", new byte[0], Ids.CREATOR_ALL_ACL, 0, this, results);
+        zk.getData("/ben2", false, this, results);
+        synchronized (results) {
+            while (results.size() < 5) {
+                results.wait();
+            }
+        }
+        assertEquals(0, (int) results.get(0));
+        assertEquals(Code.NoAuth, (int) results.get(1));
+        assertEquals(0, (int) results.get(2));
+        assertEquals(0, (int) results.get(3));
+        assertEquals(0, (int) results.get(4));
+        zk.close();
+
+        zk =createClient();
+        zk.addAuthInfo("digest", "ben:passwd2".getBytes());
+        try {
+            zk.getData("/ben2", false, new Stat());
+            fail("Should have received a permission error");
+        } catch (KeeperException e) {
+            assertEquals(Code.NoAuth, e.getCode());
+        }
+        zk.close();
+
+        zk =createClient();
+        zk.addAuthInfo("digest", "ben:passwd".getBytes());
+        zk.getData("/ben2", false, new Stat());
+        zk.close();
+    }
 
     public void process(WatcherEvent event) {
-    	if(event.getState()==Event.KeeperStateSyncConnected){
-    		clientConnected.countDown();
-    	}
+        if(event.getState()==Event.KeeperStateSyncConnected){
+            clientConnected.countDown();
+        }
     }
 
     public void processResult(int rc, String path, Object ctx, String name) {

+ 20 - 2
src/java/test/org/apache/zookeeper/test/ClientBase.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -21,7 +39,7 @@ public abstract class ClientBase extends TestCase {
     protected static final int CONNECTION_TIMEOUT = 30000;
     protected NIOServerCnxn.Factory f = null;
     protected File tmpDir = null;
-    protected static File baseTest = 
+    protected static File baseTest =
         new File(System.getProperty("build.test.dir", "build"));
 
     public ClientBase() {
@@ -56,7 +74,7 @@ public abstract class ClientBase extends TestCase {
         ServerStats.unregister();
         LOG.info("Client test shutdown finished");
     }
-    
+
     private static void recursiveDelete(File d) {
         if (d.isDirectory()) {
             File children[] = d.listFiles();

+ 44 - 26
src/java/test/org/apache/zookeeper/test/ClientTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -19,23 +37,23 @@ import org.apache.zookeeper.ZooDefs.CreateFlags;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.proto.WatcherEvent;
-    
+
 public class ClientTest extends ClientBase implements Watcher {
-    LinkedBlockingQueue<WatcherEvent> events = 
+    LinkedBlockingQueue<WatcherEvent> events =
         new LinkedBlockingQueue<WatcherEvent>();
     protected volatile CountDownLatch clientConnected;
 
-    protected ZooKeeper createClient(Watcher watcher) 
+    protected ZooKeeper createClient(Watcher watcher)
         throws IOException, InterruptedException
     {
         clientConnected=new CountDownLatch(1);
         ZooKeeper zk = new ZooKeeper(hostPort, 20000, watcher);
-		if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
-			fail("Unable to connect to server");
-		}
-		return zk;
+        if(!clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)){
+            fail("Unable to connect to server");
+        }
+        return zk;
     }
-    
+
     protected void tearDown() throws Exception {
         clientConnected = null;
         super.tearDown();
@@ -88,14 +106,14 @@ public class ClientTest extends ClientBase implements Watcher {
             InterruptedException, KeeperException {
         ZooKeeper zk = null;
         try {
-    		zk =createClient(this);
+            zk =createClient(this);
             //System.out.println("Created client: " + zk.describeCNXN());
             System.out.println("Before create /benwashere");
             zk.create("/benwashere", "".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
             System.out.println("After create /benwashere");
             try {
-            	zk.setData("/benwashere", "hi".getBytes(), 57);
-        		fail("Should have gotten BadVersion exception");
+                zk.setData("/benwashere", "hi".getBytes(), 57);
+                fail("Should have gotten BadVersion exception");
             } catch(KeeperException.BadVersionException e) {
                 // expected that
             } catch (KeeperException e) {
@@ -110,7 +128,7 @@ public class ClientTest extends ClientBase implements Watcher {
             zk = createClient(this);
             //System.out.println("Created a new client: " + zk.describeCNXN());
             System.out.println("Before delete /");
-            
+
             try {
                 zk.delete("/", -1);
                 fail("deleted root!");
@@ -194,7 +212,7 @@ public class ClientTest extends ClientBase implements Watcher {
             //} catch(KeeperException e) {
             //    assertEquals(KeeperException.Code.BadArguments, e.getCode());
             //}
-            
+
             zk.create("/duplicate", "".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
             try {
                 zk.create("/duplicate", "".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
@@ -301,12 +319,12 @@ public class ClientTest extends ClientBase implements Watcher {
             LOG.error("******************* Connected to ZooKeeper" + new Date());
             for (int i = 0; i < threadCount; i++) {
                 System.err.println("Doing thread: " + i + " " + new Date());
-                List<String> children = 
+                List<String> children =
                     zk.getChildren("/test-" + i, false);
                 assertEquals(childCount, children.size());
             }
             for (int i = 0; i < threadCount; i++) {
-                List<String> children = 
+                List<String> children =
                     zk.getChildren("/test-" + i, false);
                 assertEquals(childCount, children.size());
             }
@@ -322,15 +340,15 @@ public class ClientTest extends ClientBase implements Watcher {
     }
 
     public void process(WatcherEvent event) {
-		if (event.getState() == Event.KeeperStateSyncConnected) {
-			clientConnected.countDown();
-		}
-		if (event.getType() != Event.EventNone) {
-			try {
-				events.put(event);
-			} catch (InterruptedException e) {
-				e.printStackTrace();
-			}
-		}
-	}
+        if (event.getState() == Event.KeeperStateSyncConnected) {
+            clientConnected.countDown();
+        }
+        if (event.getType() != Event.EventNone) {
+            try {
+                events.put(event);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 }

+ 3 - 2
src/java/test/org/apache/zookeeper/test/DataTreeTest.java

@@ -15,6 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.zookeeper.test;
 
 import static org.junit.Assert.*;
@@ -31,7 +32,7 @@ import junit.framework.TestCase;
 
 public class DataTreeTest extends TestCase {
     DataTree dt;
-    
+
     public void setUp() throws Exception {
         dt=new DataTree();
     }
@@ -40,7 +41,7 @@ public class DataTreeTest extends TestCase {
         dt=null;
     }
 
-   
+
     public void testRootWatchTriggered() throws Exception {
         class MyWatcher implements Watcher{
             boolean fired=false;

+ 32 - 14
src/java/test/org/apache/zookeeper/test/GenerateLoad.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.BufferedReader;
@@ -31,7 +49,7 @@ import org.apache.zookeeper.proto.WatcherEvent;
 
 public class GenerateLoad {
     static ServerSocket ss;
-    
+
     static Set<SlaveThread> slaves = Collections
             .synchronizedSet(new HashSet<SlaveThread>());
 
@@ -50,9 +68,9 @@ public class GenerateLoad {
             e.printStackTrace();
         }
     }
-    
+
     static final int INTERVAL = 6000;
-    
+
     synchronized static void add(long time, int count, Socket s) {
         long interval = time / INTERVAL;
         if (currentInterval == 0 || currentInterval > interval) {
@@ -236,23 +254,23 @@ public class GenerateLoad {
     static String host;
 
         static Socket s;
-    
+
         static int errors;
-      
+
         static final Object statSync = new Object();
-        
+
         static int finished;
-        
+
         static int reads;
-        
+
         static int writes;
-        
+
         static int rlatency;
-        
+
         static int wlatency;
 
         static int outstanding;
-        
+
     static class ZooKeeperThread extends Thread implements Watcher, DataCallback,
             StatCallback {
         ZooKeeperThread() {
@@ -397,13 +415,13 @@ public class GenerateLoad {
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            
+
         }
     }
-    
+
     /**
      * @param args
-     * @throws InterruptedException 
+     * @throws InterruptedException
      */
     public static void main(String[] args) throws InterruptedException {
         if (args.length == 1) {

+ 22 - 4
src/java/test/org/apache/zookeeper/test/IntegrityCheck.java

@@ -1,10 +1,28 @@
+/**
+ * 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.zookeeper.test;
 
 /**
  * This is a simple test to check the integrity of ZooKeeper servers. The client
  * simply cycles through blasting changes to ZooKeeper and the checking what it
  * gets back.
- * 
+ *
  * The check is very simple. The value of the last successful read or write is
  * stored in lastValue. When we issue a request, that value becomes a possible
  * value. The difficulty is that when a communication error happens, the client
@@ -81,7 +99,7 @@ public class IntegrityCheck implements Watcher, StatCallback, DataCallback {
                 waitOutstanding();
             }
         }finally{
-            LOG.warn("Test loop terminated for "+path);            
+            LOG.warn("Test loop terminated for "+path);
         }
     }
 
@@ -145,7 +163,7 @@ public class IntegrityCheck implements Watcher, StatCallback, DataCallback {
             }
         }
     }
-    
+
     /**
      * @param args
      */
@@ -175,7 +193,7 @@ public class IntegrityCheck implements Watcher, StatCallback, DataCallback {
                     ctest.run();
                 } catch (Exception e) {
                     e.printStackTrace();
-                }                
+                }
             }
         } catch (Exception e) {
             e.printStackTrace();

+ 18 - 3
src/java/test/org/apache/zookeeper/test/OOMTest.java

@@ -1,6 +1,21 @@
 /**
- * 
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -20,7 +35,7 @@ import org.apache.zookeeper.server.ZooKeeperServer;
 
 /**
  * @author breed
- * 
+ *
  */
 public class OOMTest extends TestCase implements Watcher {
     public void testOOM() throws IOException, InterruptedException, KeeperException {
@@ -114,7 +129,7 @@ public class OOMTest extends TestCase implements Watcher {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.proto.WatcherEvent)
      */
     public void process(WatcherEvent event) {

+ 20 - 2
src/java/test/org/apache/zookeeper/test/QuorumTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -40,7 +58,7 @@ public class QuorumTest extends ClientTest {
         LOG.warn("Setup finished");
     }
     void startServers() throws IOException, InterruptedException {
-		QuorumStats.registerAsConcrete();
+        QuorumStats.registerAsConcrete();
         int tickTime = 2000;
         int initLimit = 3;
         int syncLimit = 3;
@@ -83,6 +101,6 @@ public class QuorumTest extends ClientTest {
         s4.shutdown();
         s5.shutdown();
         Thread.sleep(5000);
-		QuorumStats.unregister();
+        QuorumStats.unregister();
     }
 }

+ 24 - 9
src/java/test/org/apache/zookeeper/test/RecoveryTest.java

@@ -1,6 +1,21 @@
 /**
- * 
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -21,18 +36,18 @@ import org.apache.zookeeper.server.ZooKeeperServer;
 
 /**
  * @author breed
- * 
+ *
  */
 public class RecoveryTest extends TestCase implements Watcher {
-	static File baseTest = new File(System.getProperty("build.test.dir",
+    static File baseTest = new File(System.getProperty("build.test.dir",
             "build"));
     protected void setUp() throws Exception {
-    	ServerStats.registerAsConcrete();
+        ServerStats.registerAsConcrete();
+    }
+    protected void tearDown() throws Exception {
+        ServerStats.unregister();
     }
-	protected void tearDown() throws Exception {
-    	ServerStats.unregister();
-	}
-    
+
     @Test
     public void testRecovery() throws Exception {
         File tmpDir = File.createTempFile("test", ".junit", baseTest);
@@ -119,7 +134,7 @@ public class RecoveryTest extends TestCase implements Watcher {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.proto.WatcherEvent)
      */
     public void process(WatcherEvent event) {

+ 29 - 11
src/java/test/org/apache/zookeeper/test/SessionTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.File;
@@ -19,15 +37,15 @@ public class SessionTest extends TestCase implements Watcher {
     static File baseTest = new File(System.getProperty("build.test.dir",
             "build"));
 
-	protected void setUp() throws Exception {
-    	ServerStats.registerAsConcrete();
-	}
-	protected void tearDown() throws Exception {
-		ServerStats.unregister();
-	}
-	/**
-     * this test checks to see if the sessionid that was created for the 
-     * first zookeeper client can be reused for the second one immidiately 
+    protected void setUp() throws Exception {
+        ServerStats.registerAsConcrete();
+    }
+    protected void tearDown() throws Exception {
+        ServerStats.unregister();
+    }
+    /**
+     * this test checks to see if the sessionid that was created for the
+     * first zookeeper client can be reused for the second one immidiately
      * after the first client closes and the new client resues them.
      * @throws IOException
      * @throws InterruptedException
@@ -42,7 +60,7 @@ public class SessionTest extends TestCase implements Watcher {
         f.startup(zs);
         Thread.sleep(4000);
         ZooKeeper zk = new ZooKeeper("127.0.0.1:33299", 3000, this);
-        
+
         long sessionId = zk.getSessionId();
         byte[] passwd = zk.getSessionPasswd();
         zk.close();
@@ -51,7 +69,7 @@ public class SessionTest extends TestCase implements Watcher {
         zk.close();
         zs.shutdown();
         f.shutdown();
-        
+
     }
     @Test
     public void testSession() throws IOException, InterruptedException, KeeperException {

+ 19 - 1
src/java/test/org/apache/zookeeper/test/SledgeHammer.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.IOException;
@@ -44,7 +62,7 @@ public class SledgeHammer extends Thread implements Watcher {
             for (int i = 0; i < count; i++) {
                 try {
                     System.out.print(i + "\r");
-                    List<String> childs = 
+                    List<String> childs =
                         zk.getChildren("/hammers", false);
                     Collections.shuffle(childs);
                     for (String s : childs) {

+ 19 - 1
src/java/test/org/apache/zookeeper/test/TestHammer.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.IOException;
@@ -37,7 +55,7 @@ public class TestHammer implements VoidCallback {
 
     public void processResult(int rc, String path, Object ctx) {
         // TODO Auto-generated method stub
-        
+
     }
 
 }

+ 64 - 46
src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.IOException;
@@ -15,10 +33,10 @@ import org.apache.zookeeper.proto.WatcherEvent;
 
 public class WatcherFuncTest extends ClientBase {
     private static class SimpleWatcher implements Watcher {
-        private LinkedBlockingQueue<WatcherEvent> events = 
+        private LinkedBlockingQueue<WatcherEvent> events =
             new LinkedBlockingQueue<WatcherEvent>();
         private CountDownLatch latch;
-        
+
         public SimpleWatcher(CountDownLatch latch) {
             this.latch = latch;
         }
@@ -43,7 +61,7 @@ public class WatcherFuncTest extends ClientBase {
             WatcherEvent event;
             int count = 0;
             while (count < expected.size()
-                    && (event = events.poll(30, TimeUnit.SECONDS)) != null) 
+                    && (event = events.poll(30, TimeUnit.SECONDS)) != null)
             {
                 assertEquals(expected.get(count).intValue(), event.getType());
                 count++;
@@ -58,20 +76,20 @@ public class WatcherFuncTest extends ClientBase {
     private SimpleWatcher lsnr_dwatch;
     private volatile CountDownLatch lsnr_latch;
     private ZooKeeper lsnr;
-    
+
     private List<Integer> expected;
-    
+
     protected void setUp() throws Exception {
         super.setUp();
-        
+
         client_latch = new CountDownLatch(1);
-        client_dwatch = new SimpleWatcher(client_latch);    
+        client_dwatch = new SimpleWatcher(client_latch);
         client = createClient(client_dwatch, client_latch);
 
         lsnr_latch = new CountDownLatch(1);
         lsnr_dwatch = new SimpleWatcher(lsnr_latch);
         lsnr = createClient(lsnr_dwatch, lsnr_latch);
-        
+
         expected = new ArrayList<Integer>();
     }
     protected void tearDown() throws Exception {
@@ -80,8 +98,8 @@ public class WatcherFuncTest extends ClientBase {
         Thread.sleep(5000);
         super.tearDown();
     }
-    
-    protected ZooKeeper createClient(Watcher watcher, CountDownLatch latch) 
+
+    protected ZooKeeper createClient(Watcher watcher, CountDownLatch latch)
         throws IOException, InterruptedException
     {
         ZooKeeper zk = new ZooKeeper(hostPort, 20000, watcher);
@@ -95,7 +113,7 @@ public class WatcherFuncTest extends ClientBase {
         lsnr_dwatch.verify(expected);
         expected.clear();
     }
-    public void testExistsSync() 
+    public void testExistsSync()
         throws IOException, InterruptedException, KeeperException
     {
         assertNull(lsnr.exists("/foo", true));
@@ -107,7 +125,7 @@ public class WatcherFuncTest extends ClientBase {
         expected.add(Watcher.Event.EventNodeCreated);
 
         verify();
-        
+
         assertNotNull(lsnr.exists("/foo", true));
         assertNotNull(lsnr.exists("/foo/bar", true));
 
@@ -118,7 +136,7 @@ public class WatcherFuncTest extends ClientBase {
         } catch (KeeperException e) {
             assertEquals(KeeperException.Code.NoNode, e.getCode());
         }
-        
+
         try {
             assertNull(lsnr.exists("/foo/car", true));
             client.setData("/foo/car", "missing".getBytes(), -1);
@@ -126,7 +144,7 @@ public class WatcherFuncTest extends ClientBase {
         } catch (KeeperException e) {
             assertEquals(KeeperException.Code.NoNode, e.getCode());
         }
-        
+
         client.setData("/foo", "parent".getBytes(), -1);
         expected.add(Watcher.Event.EventNodeDataChanged);
         client.setData("/foo/bar", "child".getBytes(), -1);
@@ -144,7 +162,7 @@ public class WatcherFuncTest extends ClientBase {
 
         verify();
     }
-    
+
     public void testGetDataSync()
         throws IOException, InterruptedException, KeeperException
     {
@@ -183,7 +201,7 @@ public class WatcherFuncTest extends ClientBase {
 
         verify();
     }
-    
+
     public void testGetChildrenSync()
         throws IOException, InterruptedException, KeeperException
     {
@@ -211,7 +229,7 @@ public class WatcherFuncTest extends ClientBase {
         client.setData("/foo", "parent".getBytes(), -1);
         client.setData("/foo/bar", "child".getBytes(), -1);
 
-        
+
         assertNotNull(lsnr.exists("/foo", true));
 
         assertNotNull(lsnr.getChildren("/foo", true));
@@ -226,16 +244,16 @@ public class WatcherFuncTest extends ClientBase {
         verify();
     }
 
-    public void testExistsSyncWObj() 
+    public void testExistsSyncWObj()
         throws IOException, InterruptedException, KeeperException
     {
         SimpleWatcher w1 = new SimpleWatcher(null);
         SimpleWatcher w2 = new SimpleWatcher(null);
         SimpleWatcher w3 = new SimpleWatcher(null);
         SimpleWatcher w4 = new SimpleWatcher(null);
-        
+
         List<Integer> e2 = new ArrayList<Integer>();
-        
+
         assertNull(lsnr.exists("/foo", true));
         assertNull(lsnr.exists("/foo", w1));
 
@@ -243,12 +261,12 @@ public class WatcherFuncTest extends ClientBase {
         assertNull(lsnr.exists("/foo/bar", w3));
         assertNull(lsnr.exists("/foo/bar", w3));
         assertNull(lsnr.exists("/foo/bar", w4));
-    
+
         client.create("/foo", "parent".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
         expected.add(Watcher.Event.EventNodeCreated);
         client.create("/foo/bar", "child".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
         e2.add(Watcher.Event.EventNodeCreated);
-    
+
         lsnr_dwatch.verify(expected);
         w1.verify(expected);
         w2.verify(e2);
@@ -256,7 +274,7 @@ public class WatcherFuncTest extends ClientBase {
         w4.verify(e2);
         expected.clear();
         e2.clear();
-        
+
         // default not registered
         assertNotNull(lsnr.exists("/foo", w1));
 
@@ -264,12 +282,12 @@ public class WatcherFuncTest extends ClientBase {
         assertNotNull(lsnr.exists("/foo/bar", w3));
         assertNotNull(lsnr.exists("/foo/bar", w4));
         assertNotNull(lsnr.exists("/foo/bar", w4));
-    
+
         client.setData("/foo", "parent".getBytes(), -1);
         expected.add(Watcher.Event.EventNodeDataChanged);
         client.setData("/foo/bar", "child".getBytes(), -1);
         e2.add(Watcher.Event.EventNodeDataChanged);
-    
+
         lsnr_dwatch.verify(new ArrayList<Integer>()); // not reg so should = 0
         w1.verify(expected);
         w2.verify(e2);
@@ -277,7 +295,7 @@ public class WatcherFuncTest extends ClientBase {
         w4.verify(e2);
         expected.clear();
         e2.clear();
-    
+
         assertNotNull(lsnr.exists("/foo", true));
         assertNotNull(lsnr.exists("/foo", w1));
         assertNotNull(lsnr.exists("/foo", w1));
@@ -286,12 +304,12 @@ public class WatcherFuncTest extends ClientBase {
         assertNotNull(lsnr.exists("/foo/bar", w2));
         assertNotNull(lsnr.exists("/foo/bar", w3));
         assertNotNull(lsnr.exists("/foo/bar", w4));
-    
+
         client.delete("/foo/bar", -1);
         expected.add(Watcher.Event.EventNodeDeleted);
         client.delete("/foo", -1);
         e2.add(Watcher.Event.EventNodeDeleted);
-    
+
         lsnr_dwatch.verify(expected);
         w1.verify(expected);
         w2.verify(e2);
@@ -309,7 +327,7 @@ public class WatcherFuncTest extends ClientBase {
         SimpleWatcher w2 = new SimpleWatcher(null);
         SimpleWatcher w3 = new SimpleWatcher(null);
         SimpleWatcher w4 = new SimpleWatcher(null);
-        
+
         List<Integer> e2 = new ArrayList<Integer>();
 
         try {
@@ -324,7 +342,7 @@ public class WatcherFuncTest extends ClientBase {
         } catch (KeeperException e) {
             assertEquals(KeeperException.Code.NoNode, e.getCode());
         }
-    
+
         client.create("/foo", "parent".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
         assertNotNull(lsnr.getData("/foo", true, null));
         assertNotNull(lsnr.getData("/foo", w1, null));
@@ -333,12 +351,12 @@ public class WatcherFuncTest extends ClientBase {
         assertNotNull(lsnr.getData("/foo/bar", w3, null));
         assertNotNull(lsnr.getData("/foo/bar", w4, null));
         assertNotNull(lsnr.getData("/foo/bar", w4, null));
-    
+
         client.setData("/foo", "parent".getBytes(), -1);
         expected.add(Watcher.Event.EventNodeDataChanged);
         client.setData("/foo/bar", "child".getBytes(), -1);
         e2.add(Watcher.Event.EventNodeDataChanged);
-    
+
         lsnr_dwatch.verify(expected);
         w1.verify(expected);
         w2.verify(e2);
@@ -346,19 +364,19 @@ public class WatcherFuncTest extends ClientBase {
         w4.verify(e2);
         expected.clear();
         e2.clear();
-    
+
         assertNotNull(lsnr.getData("/foo", true, null));
         assertNotNull(lsnr.getData("/foo", w1, null));
         assertNotNull(lsnr.getData("/foo/bar", w2, null));
         assertNotNull(lsnr.getData("/foo/bar", w3, null));
         assertNotNull(lsnr.getData("/foo/bar", w3, null));
         assertNotNull(lsnr.getData("/foo/bar", w4, null));
-    
+
         client.delete("/foo/bar", -1);
         expected.add(Watcher.Event.EventNodeDeleted);
         client.delete("/foo", -1);
         e2.add(Watcher.Event.EventNodeDeleted);
-    
+
         lsnr_dwatch.verify(expected);
         w1.verify(expected);
         w2.verify(e2);
@@ -367,7 +385,7 @@ public class WatcherFuncTest extends ClientBase {
         expected.clear();
         e2.clear();
     }
-    
+
     public void testGetChildrenSyncWObj()
         throws IOException, InterruptedException, KeeperException
     {
@@ -375,7 +393,7 @@ public class WatcherFuncTest extends ClientBase {
         SimpleWatcher w2 = new SimpleWatcher(null);
         SimpleWatcher w3 = new SimpleWatcher(null);
         SimpleWatcher w4 = new SimpleWatcher(null);
-        
+
         List<Integer> e2 = new ArrayList<Integer>();
 
         try {
@@ -390,41 +408,41 @@ public class WatcherFuncTest extends ClientBase {
         } catch (KeeperException e) {
             assertEquals(KeeperException.Code.NoNode, e.getCode());
         }
-    
+
         client.create("/foo", "parent".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
         assertNotNull(lsnr.getChildren("/foo", true));
         assertNotNull(lsnr.getChildren("/foo", w1));
-    
+
         client.create("/foo/bar", "child".getBytes(), Ids.OPEN_ACL_UNSAFE, 0);
         expected.add(Watcher.Event.EventNodeChildrenChanged); // /foo
         assertNotNull(lsnr.getChildren("/foo/bar", w2));
         assertNotNull(lsnr.getChildren("/foo/bar", w2));
         assertNotNull(lsnr.getChildren("/foo/bar", w3));
         assertNotNull(lsnr.getChildren("/foo/bar", w4));
-    
-    
+
+
         client.setData("/foo", "parent".getBytes(), -1);
         client.setData("/foo/bar", "child".getBytes(), -1);
-    
-        
+
+
         assertNotNull(lsnr.exists("/foo", true));
         assertNotNull(lsnr.exists("/foo", w1));
         assertNotNull(lsnr.exists("/foo", true));
         assertNotNull(lsnr.exists("/foo", w1));
-    
+
         assertNotNull(lsnr.getChildren("/foo", true));
         assertNotNull(lsnr.getChildren("/foo", w1));
         assertNotNull(lsnr.getChildren("/foo/bar", w2));
         assertNotNull(lsnr.getChildren("/foo/bar", w3));
         assertNotNull(lsnr.getChildren("/foo/bar", w4));
         assertNotNull(lsnr.getChildren("/foo/bar", w4));
-    
+
         client.delete("/foo/bar", -1);
         e2.add(Watcher.Event.EventNodeDeleted); // /foo/bar childwatch
         expected.add(Watcher.Event.EventNodeChildrenChanged); // /foo
         client.delete("/foo", -1);
         expected.add(Watcher.Event.EventNodeDeleted);
-    
+
         lsnr_dwatch.verify(expected);
         w1.verify(expected);
         w2.verify(e2);

+ 26 - 8
src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java

@@ -1,3 +1,21 @@
+/**
+ * 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.zookeeper.test;
 
 import java.io.IOException;
@@ -240,18 +258,18 @@ public class ZooKeeperTestClient extends TestCase implements Watcher {
     System.out.println("session id of zk: " + zk.getSessionId());
     System.out.println("session id of zk_1: " + zk_1.getSessionId());
     zk.close();
-  
+
     stat = zk_1.exists("nosuchnode", false);
-    
+
     event = this.getEvent(10);
     if (event == null) {
       fail("First event was not delivered promptly");
     }
-    if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged && 
+    if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged &&
            event.getPath().equalsIgnoreCase(parentName)) ||
-         (event.getType() == Watcher.Event.EventNodeDeleted && 
+         (event.getType() == Watcher.Event.EventNodeDeleted &&
            event.getPath().equalsIgnoreCase(nodeName)))) {
-      System.out.print(parentName + " " 
+      System.out.print(parentName + " "
           + Watcher.Event.EventNodeChildrenChanged + " " + nodeName + " " + Watcher.Event.EventNodeDeleted);
       fail("Unexpected first event was delivered: " + event.toString());
     }
@@ -261,11 +279,11 @@ public class ZooKeeperTestClient extends TestCase implements Watcher {
     if (event == null) {
       fail("Second event was not delivered promptly");
     }
-    if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged && 
+    if (!((event.getType() == Watcher.Event.EventNodeChildrenChanged &&
         event.getPath().equalsIgnoreCase(parentName)) ||
-      (event.getType() == Watcher.Event.EventNodeDeleted && 
+      (event.getType() == Watcher.Event.EventNodeDeleted &&
         event.getPath().equalsIgnoreCase(nodeName)))) {
-      System.out.print(parentName + " " 
+      System.out.print(parentName + " "
           + Watcher.Event.EventNodeChildrenChanged + " " + nodeName + " " + Watcher.Event.EventNodeDeleted);
       fail("Unexpected second event was delivered: " + event.toString());
     }

+ 18 - 0
src/zookeeper.jute

@@ -1,3 +1,21 @@
+/**
+ * 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.
+ */
+
 module org.apache.zookeeper.data {
     class Id {
     	ustring scheme;