You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by an...@apache.org on 2018/10/24 09:32:43 UTC

[27/36] zookeeper git commit: ZOOKEEPER-3032: MAVEN MIGRATION - branch-3.4 - zookeeper-server

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientBase.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientBase.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientBase.java
deleted file mode 100644
index 7de4f3c..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientBase.java
+++ /dev/null
@@ -1,757 +0,0 @@
-/**
- * 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 static org.apache.zookeeper.client.FourLetterWordMain.send4LetterWord;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-
-import junit.framework.TestCase;
-
-import org.apache.zookeeper.common.Time;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.common.IOUtils;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ServerCnxnFactoryAccessor;
-import org.apache.zookeeper.server.ZKDatabase;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.persistence.FilePadding;
-import org.apache.zookeeper.server.persistence.FileTxnLog;
-import org.apache.zookeeper.server.quorum.QuorumPeer;
-import org.apache.zookeeper.server.util.OSMXBean;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class ClientBase extends ZKTestCase {
-    protected static final Logger LOG = LoggerFactory.getLogger(ClientBase.class);
-
-    public static int CONNECTION_TIMEOUT = 30000;
-    static final File BASETEST =
-        new File(System.getProperty("build.test.dir", "build"));
-
-    protected int port = PortAssignment.unique();
-    protected String hostPort = "127.0.0.1:" + port;
-    protected String ipv6HostPort = "[0:0:0:0:0:0:0:1]:" + port;
-    protected int maxCnxns = 0;
-    protected ServerCnxnFactory serverFactory = null;
-    protected File tmpDir = null;
-    
-    long initialFdCount;
-    
-    public ClientBase() {
-        super();
-    }
-
-    /**
-     * In general don't use this. Only use in the special case that you
-     * want to ignore results (for whatever reason) in your test. Don't
-     * use empty watchers in real code!
-     *
-     */
-    protected class NullWatcher implements Watcher {
-        public void process(WatchedEvent event) { /* nada */ }
-    }
-
-    public static class CountdownWatcher implements Watcher {
-        // XXX this doesn't need to be volatile! (Should probably be final)
-        volatile CountDownLatch clientConnected;
-        // Set to true when connected to a read-only server, or a read-write (quorum) server.
-        volatile boolean connected;
-        // Set to true when connected to a quorum server.
-        volatile boolean syncConnected;
-        // Set to true when connected to a quorum server in read-only mode
-        volatile boolean readOnlyConnected;
-
-        public CountdownWatcher() {
-            reset();
-        }
-        synchronized public void reset() {
-            clientConnected = new CountDownLatch(1);
-            connected = false;
-            syncConnected = false;
-            readOnlyConnected = false;
-        }
-        synchronized public void process(WatchedEvent event) {
-            KeeperState state = event.getState();
-            if (state == KeeperState.SyncConnected) {
-                connected = true;
-                syncConnected = true;
-                readOnlyConnected = false;
-            } else if (state == KeeperState.ConnectedReadOnly) {
-                connected = true;
-                syncConnected = false;
-                readOnlyConnected = true;
-            } else {
-                connected = false;
-                syncConnected = false;
-                readOnlyConnected = false;
-            }
-
-            notifyAll();
-            if (connected) {
-                clientConnected.countDown();
-            }
-        }
-        synchronized public boolean isConnected() {
-            return connected;
-        }
-        synchronized public void waitForConnected(long timeout)
-            throws InterruptedException, TimeoutException
-        {
-            long expire = Time.currentElapsedTime() + timeout;
-            long left = timeout;
-            while(!connected && left > 0) {
-                wait(left);
-                left = expire - Time.currentElapsedTime();
-            }
-            if (!connected) {
-                throw new TimeoutException("Did not connect");
-
-            }
-        }
-        synchronized public void waitForSyncConnected(long timeout)
-                throws InterruptedException, TimeoutException
-        {
-            long expire = System.currentTimeMillis() + timeout;
-            long left = timeout;
-            while(!syncConnected && left > 0) {
-                wait(left);
-                left = expire - System.currentTimeMillis();
-            }
-            if (!syncConnected) {
-                throw new TimeoutException("Failed to connect to read-write ZooKeeper server.");
-            }
-        }
-        synchronized public void waitForReadOnlyConnected(long timeout)
-                throws InterruptedException, TimeoutException
-        {
-            long expire = System.currentTimeMillis() + timeout;
-            long left = timeout;
-            while(!readOnlyConnected && left > 0) {
-                wait(left);
-                left = expire - System.currentTimeMillis();
-            }
-            if (!readOnlyConnected) {
-                throw new TimeoutException("Failed to connect in read-only mode to ZooKeeper server.");
-            }
-        }
-        synchronized public void waitForDisconnected(long timeout)
-            throws InterruptedException, TimeoutException
-        {
-            long expire = Time.currentElapsedTime() + timeout;
-            long left = timeout;
-            while(connected && left > 0) {
-                wait(left);
-                left = expire - Time.currentElapsedTime();
-            }
-            if (connected) {
-                throw new TimeoutException("Did not disconnect");
-
-            }
-        }
-    }
-
-    protected TestableZooKeeper createClient()
-        throws IOException, InterruptedException
-    {
-        return createClient(hostPort);
-    }
-
-    protected TestableZooKeeper createClient(String hp)
-        throws IOException, InterruptedException
-    {
-        CountdownWatcher watcher = new CountdownWatcher();
-        return createClient(watcher, hp);
-    }
-
-    protected TestableZooKeeper createClient(CountdownWatcher watcher)
-        throws IOException, InterruptedException
-    {
-        return createClient(watcher, hostPort);
-    }
-
-    private LinkedList<ZooKeeper> allClients;
-    private boolean allClientsSetup = false;
-
-    protected TestableZooKeeper createClient(CountdownWatcher watcher, String hp)
-        throws IOException, InterruptedException
-    {
-        return createClient(watcher, hp, CONNECTION_TIMEOUT);
-    }
-
-    protected TestableZooKeeper createClient(CountdownWatcher watcher,
-            String hp, int timeout)
-        throws IOException, InterruptedException
-    {
-        watcher.reset();
-        TestableZooKeeper zk = new TestableZooKeeper(hp, timeout, watcher);
-        if (!watcher.clientConnected.await(timeout, TimeUnit.MILLISECONDS))
-        {
-            Assert.fail("Unable to connect to server");
-        }
-        synchronized(this) {
-            if (!allClientsSetup) {
-                LOG.error("allClients never setup");
-                Assert.fail("allClients never setup");
-            }
-            if (allClients != null) {
-                allClients.add(zk);
-                JMXEnv.ensureAll(getHexSessionId(zk.getSessionId()));
-            } else {
-                // test done - close the zk, not needed
-                zk.close();
-            }
-        }
-
-        return zk;
-    }
-
-    public static class HostPort {
-        String host;
-        int port;
-        public HostPort(String host, int port) {
-            this.host = host;
-            this.port = port;
-        }
-    }
-    public static List<HostPort> parseHostPortList(String hplist) {
-        ArrayList<HostPort> alist = new ArrayList<HostPort>();
-        for (String hp: hplist.split(",")) {
-            int idx = hp.lastIndexOf(':');
-            String host = hp.substring(0, idx);
-            int port;
-            try {
-                port = Integer.parseInt(hp.substring(idx + 1));
-            } catch(RuntimeException e) {
-                throw new RuntimeException("Problem parsing " + hp + e.toString());
-            }
-            alist.add(new HostPort(host,port));
-        }
-        return alist;
-    }
-
-    public static boolean waitForServerUp(String hp, long timeout) {
-        long start = Time.currentElapsedTime();
-        while (true) {
-            try {
-                // if there are multiple hostports, just take the first one
-                HostPort hpobj = parseHostPortList(hp).get(0);
-                String result = send4LetterWord(hpobj.host, hpobj.port, "stat");
-                if (result.startsWith("Zookeeper version:") &&
-                        !result.contains("READ-ONLY")) {
-                    return true;
-                }
-            } catch (IOException e) {
-                // ignore as this is expected
-                LOG.info("server " + hp + " not up " + e);
-            }
-
-            if (Time.currentElapsedTime() > start + timeout) {
-                break;
-            }
-            try {
-                Thread.sleep(250);
-            } catch (InterruptedException e) {
-                // ignore
-            }
-        }
-        return false;
-    }
-    public static boolean waitForServerDown(String hp, long timeout) {
-        long start = Time.currentElapsedTime();
-        while (true) {
-            try {
-                HostPort hpobj = parseHostPortList(hp).get(0);
-                send4LetterWord(hpobj.host, hpobj.port, "stat");
-            } catch (IOException e) {
-                return true;
-            }
-
-            if (Time.currentElapsedTime() > start + timeout) {
-                break;
-            }
-            try {
-                Thread.sleep(250);
-            } catch (InterruptedException e) {
-                // ignore
-            }
-        }
-        return false;
-    }
-
-    public static boolean waitForServerState(QuorumPeer qp, int timeout,
-            String serverState) {
-        long start = Time.currentElapsedTime();
-        while (true) {
-            try {
-                Thread.sleep(250);
-            } catch (InterruptedException e) {
-                // ignore
-            }
-            if (qp.getServerState().equals(serverState))
-                return true;
-            if (Time.currentElapsedTime() > start + timeout) {
-                return false;
-            }
-        }
-    }
-
-    static void verifyThreadTerminated(Thread thread, long millis)
-        throws InterruptedException
-    {
-        thread.join(millis);
-        if (thread.isAlive()) {
-            LOG.error("Thread " + thread.getName() + " : "
-                    + Arrays.toString(thread.getStackTrace()));
-            Assert.assertFalse("thread " + thread.getName()
-                    + " still alive after join", true);
-        }
-    }
-
-    public static File createEmptyTestDir() throws IOException {
-        return createTmpDir(BASETEST, false);
-    }
-
-    public static File createTmpDir() throws IOException {
-        return createTmpDir(BASETEST, true);
-    }
-
-    static File createTmpDir(File parentDir, boolean createInitFile) throws IOException {
-        File tmpFile = File.createTempFile("test", ".junit", parentDir);
-        // don't delete tmpFile - this ensures we don't attempt to create
-        // a tmpDir with a duplicate name
-        File tmpDir = new File(tmpFile + ".dir");
-        Assert.assertFalse(tmpDir.exists()); // never true if tmpfile does it's job
-        Assert.assertTrue(tmpDir.mkdirs());
-
-        // todo not every tmp directory needs this file
-        if (createInitFile) {
-            createInitializeFile(tmpDir);
-        }
-
-        return tmpDir;
-    }
-
-    public static void createInitializeFile(File dir) throws IOException {
-        File initFile = new File(dir, "initialize");
-        if (!initFile.exists()) {
-            Assert.assertTrue(initFile.createNewFile());
-        }
-    }
-
-    private static int getPort(String hostPort) {
-        String[] split = hostPort.split(":");
-        String portstr = split[split.length-1];
-        String[] pc = portstr.split("/");
-        if (pc.length > 1) {
-            portstr = pc[0];
-        }
-        return Integer.parseInt(portstr);
-    }
-
-    /**
-     * Starting the given server instance
-     */
-    public static void startServerInstance(File dataDir,
-            ServerCnxnFactory factory, String hostPort) throws IOException,
-            InterruptedException {
-        final int port = getPort(hostPort);
-        LOG.info("STARTING server instance 127.0.0.1:{}", port);
-        ZooKeeperServer zks = new ZooKeeperServer(dataDir, dataDir, 3000);
-        factory.startup(zks);
-        Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
-                "127.0.0.1:" + port, CONNECTION_TIMEOUT));
-    }
-
-    /**
-     * This method instantiates a new server. Starting of the server
-     * instance has been moved to a separate method
-     * {@link ClientBase#startServerInstance(File, ServerCnxnFactory, String)}.
-     * Because any exception on starting the server would leave the server
-     * running and the caller would not be able to shutdown the instance. This
-     * may affect other test cases.
-     * 
-     * @return newly created server instance
-     * 
-     * @see <a
-     *      href="https://issues.apache.org/jira/browse/ZOOKEEPER-1852">ZOOKEEPER-1852</a>
-     *      for more information.
-     */
-    public static ServerCnxnFactory createNewServerInstance(
-            ServerCnxnFactory factory, String hostPort, int maxCnxns)
-            throws IOException, InterruptedException {
-        final int port = getPort(hostPort);
-        LOG.info("CREATING server instance 127.0.0.1:{}", port);
-        if (factory == null) {
-            factory = ServerCnxnFactory.createFactory(port, maxCnxns);
-        }
-        return factory;
-    }
-
-    static void shutdownServerInstance(ServerCnxnFactory factory,
-            String hostPort)
-    {
-        if (factory != null) {
-            ZKDatabase zkDb = null;
-            {
-                ZooKeeperServer zs = getServer(factory);
-                if (zs != null) {
-                    zkDb = zs.getZKDatabase();
-                }
-            }
-            factory.shutdown();
-            try {
-                if (zkDb != null) {
-                    zkDb.close();
-                }
-            } catch (IOException ie) {
-                LOG.warn("Error closing logs ", ie);
-            }
-            final int PORT = getPort(hostPort);
-
-            Assert.assertTrue("waiting for server down",
-                       ClientBase.waitForServerDown("127.0.0.1:" + PORT,
-                                                    CONNECTION_TIMEOUT));
-        }
-    }
-
-    /**
-     * Test specific setup
-     */
-    public static void setupTestEnv() {
-        // during the tests we run with 100K prealloc in the logs.
-        // on windows systems prealloc of 64M was seen to take ~15seconds
-        // resulting in test Assert.failure (client timeout on first session).
-        // set env and directly in order to handle static init/gc issues
-        System.setProperty("zookeeper.preAllocSize", "100");
-        FilePadding.setPreallocSize(100 * 1024);
-    }
-
-    protected void setUpAll() throws Exception {
-        allClients = new LinkedList<ZooKeeper>();
-        allClientsSetup = true;
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        /* some useful information - log the number of fds used before
-         * and after a test is run. Helps to verify we are freeing resources
-         * correctly. Unfortunately this only works on unix systems (the
-         * only place sun has implemented as part of the mgmt bean api.
-         */
-        OSMXBean osMbean = new OSMXBean();
-        if (osMbean.getUnix() == true) {
-            initialFdCount = osMbean.getOpenFileDescriptorCount();  	
-            LOG.info("Initial fdcount is: "
-                    + initialFdCount);
-        }
-
-        setupTestEnv();
-
-        JMXEnv.setUp();
-
-        setUpAll();
-
-        tmpDir = createTmpDir(BASETEST, true);
-
-        startServer();
-
-        LOG.info("Client test setup finished");
-    }
-
-    protected void startServer() throws Exception {
-        LOG.info("STARTING server");
-        serverFactory = createNewServerInstance(serverFactory, hostPort,
-                maxCnxns);
-        startServerInstance(tmpDir, serverFactory, hostPort);
-        // ensure that server and data bean are registered
-        Set<ObjectName> children = JMXEnv.ensureParent("InMemoryDataTree",
-                "StandaloneServer_port");
-        // Remove beans which are related to zk client sessions. Strong
-        // assertions cannot be done for these client sessions because
-        // registeration of these beans with server will happen only on their
-        // respective reconnection interval
-        verifyUnexpectedBeans(children);
-    }
-
-    private void verifyUnexpectedBeans(Set<ObjectName> children) {
-        if (allClients != null) {
-            for (ZooKeeper zkc : allClients) {
-                Iterator<ObjectName> childItr = children.iterator();
-                while (childItr.hasNext()) {
-                    ObjectName clientBean = childItr.next();
-                    if (clientBean.toString().contains(
-                            getHexSessionId(zkc.getSessionId()))) {
-                        LOG.info("found name:" + zkc.getSessionId()
-                                + " client bean:" + clientBean.toString());
-                        childItr.remove();
-                    }
-                }
-            }
-        }
-        for (ObjectName bean : children) {
-            LOG.info("unexpected:" + bean.toString());
-        }
-        TestCase.assertEquals("Unexpected bean exists!", 0, children.size());
-    }
-
-    /**
-     * Returns a string representation of the given long value session id
-     * 
-     * @param sessionId
-     *            long value of session id
-     * @return string representation of session id
-     */
-    protected static String getHexSessionId(long sessionId) {
-        return "0x" + Long.toHexString(sessionId);
-    }
-
-    protected void stopServer() throws Exception {
-        LOG.info("STOPPING server");
-        shutdownServerInstance(serverFactory, hostPort);
-        serverFactory = null;
-        // ensure no beans are leftover
-        JMXEnv.ensureOnly();
-    }
-
-
-    protected static ZooKeeperServer getServer(ServerCnxnFactory fac) {
-        ZooKeeperServer zs = ServerCnxnFactoryAccessor.getZkServer(fac);
-
-        return zs;
-    }
-
-    protected void tearDownAll() throws Exception {
-        synchronized (this) {
-            if (allClients != null) for (ZooKeeper zk : allClients) {
-                try {
-                    if (zk != null)
-                        zk.close();
-                } catch (InterruptedException e) {
-                    LOG.warn("ignoring interrupt", e);
-                }
-            }
-            allClients = null;
-        }
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        LOG.info("tearDown starting");
-
-        tearDownAll();
-
-        stopServer();
-
-        if (tmpDir != null) {
-            Assert.assertTrue("delete " + tmpDir.toString(), recursiveDelete(tmpDir));
-        }
-
-        // This has to be set to null when the same instance of this class is reused between test cases
-        serverFactory = null;
-
-        JMXEnv.tearDown();
-
-        /* some useful information - log the number of fds used before
-         * and after a test is run. Helps to verify we are freeing resources
-         * correctly. Unfortunately this only works on unix systems (the
-         * only place sun has implemented as part of the mgmt bean api.
-         */
-        OSMXBean osMbean = new OSMXBean();
-        if (osMbean.getUnix() == true) {
-            long fdCount = osMbean.getOpenFileDescriptorCount();     
-            String message = "fdcount after test is: "
-                    + fdCount + " at start it was " + initialFdCount;
-            LOG.info(message);
-            if (fdCount > initialFdCount) {
-                LOG.info("sleeping for 20 secs");
-                //Thread.sleep(60000);
-                //assertTrue(message, fdCount <= initialFdCount);
-            }
-        }
-    }
-
-    public static MBeanServerConnection jmxConn() throws IOException {
-        return JMXEnv.conn();
-    }
-
-    public static boolean recursiveDelete(File d) {
-        if (d.isDirectory()) {
-            File children[] = d.listFiles();
-            for (File f : children) {
-                Assert.assertTrue("delete " + f.toString(), recursiveDelete(f));
-            }
-        }
-        return d.delete();
-    }
-
-    public static void logAllStackTraces() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("Starting logAllStackTraces()\n");
-        Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces();
-        for (Entry<Thread, StackTraceElement[]> e: threads.entrySet()) {
-            sb.append("Thread " + e.getKey().getName() + "\n");
-            for (StackTraceElement elem: e.getValue()) {
-                sb.append("\tat " + elem + "\n");
-            }
-        }
-        sb.append("Ending logAllStackTraces()\n");
-        LOG.error(sb.toString());
-    }
-
-    /*
-     * Verify that all of the servers see the same number of nodes
-     * at the root
-     */
-    void verifyRootOfAllServersMatch(String hostPort)
-        throws InterruptedException, KeeperException, IOException
-    {
-        String parts[] = hostPort.split(",");
-
-        // run through till the counts no longer change on each server
-        // max 15 tries, with 2 second sleeps, so approx 30 seconds
-        int[] counts = new int[parts.length];
-        int failed = 0;
-        for (int j = 0; j < 100; j++) {
-            int newcounts[] = new int[parts.length];
-            int i = 0;
-            for (String hp : parts) {
-                try {
-                    ZooKeeper zk = createClient(hp);
-
-                    try {
-                        newcounts[i++] = zk.getChildren("/", false).size();
-                    } finally {
-                        zk.close();
-                    }
-                } catch (Throwable t) {
-                    failed++;
-                    // if session creation Assert.fails dump the thread stack
-                    // and try the next server
-                    logAllStackTraces();
-                }
-            }
-
-            if (Arrays.equals(newcounts, counts)) {
-                LOG.info("Found match with array:"
-                        + Arrays.toString(newcounts));
-                counts = newcounts;
-                break;
-            } else {
-                counts = newcounts;
-                Thread.sleep(10000);
-            }
-
-            // don't keep this up too long, will Assert.assert false below
-            if (failed > 10) {
-                break;
-            }
-        }
-
-        // verify all the servers reporting same number of nodes
-        String logmsg = "node count not consistent{} {}";
-        for (int i = 1; i < parts.length; i++) {
-            if (counts[i-1] != counts[i]) {            	
-                LOG.error(logmsg, Integer.valueOf(counts[i-1]), Integer.valueOf(counts[i]));
-            } else {
-                LOG.info(logmsg, Integer.valueOf(counts[i-1]), Integer.valueOf(counts[i]));
-            }
-        }
-    }
-
-    public static String readFile(File file) throws IOException {
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
-        try {
-            IOUtils.copyBytes(is, os, 1024, true);
-        } finally {
-            is.close();
-        }
-        return os.toString();
-    }
-
-    public static String join(String separator, Object[] parts) {
-        StringBuilder sb = new StringBuilder();
-        boolean first = true;
-        for (Object part : parts) {
-            if (!first) {
-                sb.append(separator);
-                first = false;
-            }
-            sb.append(part);
-        }
-        return sb.toString();
-    }
-
-    public static ZooKeeper createZKClient(String cxnString) throws Exception {
-        return createZKClient(cxnString, CONNECTION_TIMEOUT);
-    }
-
-    /**
-     * Returns ZooKeeper client after connecting to ZooKeeper Server. Session
-     * timeout is {@link #CONNECTION_TIMEOUT}
-     *
-     * @param cxnString
-     *            connection string in the form of host:port
-     * @param sessionTimeout
-     * @throws IOException
-     *             in cases of network failure
-     */
-    public static ZooKeeper createZKClient(String cxnString, int sessionTimeout) throws IOException {
-        CountdownWatcher watcher = new CountdownWatcher();
-        ZooKeeper zk = new ZooKeeper(cxnString, sessionTimeout, watcher);
-        try {
-            watcher.waitForConnected(CONNECTION_TIMEOUT);
-        } catch (InterruptedException e) {
-            Assert.fail("ZooKeeper client can not connect to " + cxnString);
-        }
-        catch (TimeoutException e) {
-            Assert.fail("ZooKeeper client can not connect to " + cxnString);
-        }
-        return zk;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientHammerTest.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientHammerTest.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientHammerTest.java
deleted file mode 100644
index 025ccbe..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientHammerTest.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/**
- * 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;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.zookeeper.common.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ClientHammerTest extends ClientBase {
-    protected static final Logger LOG = LoggerFactory.getLogger(ClientHammerTest.class);
-
-    private static final long HAMMERTHREAD_LATENCY = 5;
-
-    private static abstract class HammerThread extends Thread {
-        protected final int count;
-        protected volatile int current = 0;
-
-        HammerThread(String name, int count) {
-            super(name);
-            this.count = count;
-        }
-    }
-
-    private static class BasicHammerThread extends HammerThread {
-        private final ZooKeeper zk;
-        private final String prefix;
-
-        BasicHammerThread(String name, ZooKeeper zk, String prefix, int count) {
-            super(name, count);
-            this.zk = zk;
-            this.prefix = prefix;
-        }
-
-        public void run() {
-            byte b[] = new byte[256];
-            try {
-                for (; current < count; current++) {
-                    // Simulate a bit of network latency...
-                    Thread.sleep(HAMMERTHREAD_LATENCY);
-                    zk.create(prefix + current, b, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-                }
-            } catch (Throwable t) {
-                LOG.error("Client create operation Assert.failed", t);
-            } finally {
-                try {
-                    zk.close();
-                } catch (InterruptedException e) {
-                    LOG.warn("Unexpected", e);
-                }
-            }
-        }
-    }
-
-    private static class SuperHammerThread extends HammerThread {
-        private final ClientHammerTest parent;
-        private final String prefix;
-
-        SuperHammerThread(String name, ClientHammerTest parent, String prefix,
-                int count)
-        {
-            super(name, count);
-            this.parent = parent;
-            this.prefix = prefix;
-        }
-
-        public void run() {
-            byte b[] = new byte[256];
-            try {
-                for (; current < count; current++) {
-                    ZooKeeper zk = parent.createClient();
-                    try {
-                        zk.create(prefix + current, b, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-                    } finally {
-                        try {
-                            zk.close();
-                        } catch (InterruptedException e) {
-                            LOG.warn("Unexpected", e);
-                        }
-                    }
-                }
-            } catch (Throwable t) {
-                LOG.error("Client create operation Assert.failed", t);
-            }
-        }
-    }
-
-    /**
-     * Separate threads each creating a number of nodes. Each thread
-     * is using a non-shared (owned by thread) client for all node creations.
-     * @throws Throwable
-     */
-    @Test
-    public void testHammerBasic() throws Throwable {
-        runHammer(10, 1000);
-    }
-
-    public void runHammer(final int threadCount, final int childCount)
-        throws Throwable
-    {
-        try {
-            HammerThread[] threads = new HammerThread[threadCount];
-            long start = Time.currentElapsedTime();
-            for (int i = 0; i < threads.length; i++) {
-                ZooKeeper zk = createClient();
-                String prefix = "/test-" + i;
-                zk.create(prefix, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-                prefix += "/";
-                HammerThread thread =
-                    new BasicHammerThread("BasicHammerThread-" + i, zk, prefix,
-                            childCount);
-                thread.start();
-
-                threads[i] = thread;
-            }
-
-            verifyHammer(start, threads, childCount);
-        } catch (Throwable t) {
-            LOG.error("test Assert.failed", t);
-            throw t;
-        }
-    }
-
-    /**
-     * Separate threads each creating a number of nodes. Each thread
-     * is creating a new client for each node creation.
-     * @throws Throwable
-     */
-    @Test
-    public void testHammerSuper() throws Throwable {
-        try {
-            final int threadCount = 5;
-            final int childCount = 10;
-
-            HammerThread[] threads = new HammerThread[threadCount];
-            long start = Time.currentElapsedTime();
-            for (int i = 0; i < threads.length; i++) {
-                String prefix = "/test-" + i;
-                {
-                    ZooKeeper zk = createClient();
-                    try {
-                        zk.create(prefix, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-                    } finally {
-                        zk.close();
-                    }
-                }
-                prefix += "/";
-                HammerThread thread =
-                    new SuperHammerThread("SuperHammerThread-" + i, this,
-                            prefix, childCount);
-                thread.start();
-
-                threads[i] = thread;
-            }
-
-            verifyHammer(start, threads, childCount);
-        } catch (Throwable t) {
-            LOG.error("test Assert.failed", t);
-            throw t;
-        }
-    }
-
-    public void verifyHammer(long start, HammerThread[] threads, int childCount)
-        throws IOException, InterruptedException, KeeperException
-    {
-        // look for the clients to finish their create operations
-        LOG.info("Starting check for completed hammers");
-        int workingCount = threads.length;
-        for (int i = 0; i < 120; i++) {
-            Thread.sleep(10000);
-            for (HammerThread h : threads) {
-                if (!h.isAlive() || h.current == h.count) {
-                    workingCount--;
-                }
-            }
-            if (workingCount == 0) {
-                break;
-            }
-            workingCount = threads.length;
-        }
-        if (workingCount > 0) {
-            for (HammerThread h : threads) {
-                LOG.warn(h.getName() + " never finished creation, current:"
-                        + h.current);
-            }
-        } else {
-            LOG.info("Hammer threads completed creation operations");
-        }
-
-        for (HammerThread h : threads) {
-            final int safetyFactor = 3;
-            verifyThreadTerminated(h,
-                    threads.length * childCount
-                    * HAMMERTHREAD_LATENCY * safetyFactor);
-        }
-        LOG.info(new Date() + " Total time "
-                + (Time.currentElapsedTime() - start));
-
-        ZooKeeper zk = createClient();
-        try {
-            LOG.info("******************* Connected to ZooKeeper" + new Date());
-            for (int i = 0; i < threads.length; i++) {
-                LOG.info("Doing thread: " + i + " " + new Date());
-                List<String> children =
-                    zk.getChildren("/test-" + i, false);
-                Assert.assertEquals(childCount, children.size());
-                children = zk.getChildren("/test-" + i, false, null);
-                Assert.assertEquals(childCount, children.size());
-            }
-            for (int i = 0; i < threads.length; i++) {
-                List<String> children =
-                    zk.getChildren("/test-" + i, false);
-                Assert.assertEquals(childCount, children.size());
-                children = zk.getChildren("/test-" + i, false, null);
-                Assert.assertEquals(childCount, children.size());
-            }
-        } finally {
-            zk.close();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientPortBindTest.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientPortBindTest.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientPortBindTest.java
deleted file mode 100644
index 95c55e2..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientPortBindTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * 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 static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Enumeration;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ClientPortBindTest extends ZKTestCase implements Watcher {
-    protected static final Logger LOG = 
-        LoggerFactory.getLogger(ClientPortBindTest.class);
-
-    private volatile CountDownLatch startSignal;
-
-    /**
-     * Verify that the server binds to the specified address
-     */
-    @Test
-    public void testBindByAddress() throws Exception {
-        String bindAddress = null;
-        Enumeration<NetworkInterface> intfs =
-            NetworkInterface.getNetworkInterfaces();
-        // if we have a loopback and it has an address use it
-        while(intfs.hasMoreElements()) {
-            NetworkInterface i = intfs.nextElement();
-            try {
-                if (i.isLoopback()) {
-                  Enumeration<InetAddress> addrs = i.getInetAddresses();
-                  while (addrs.hasMoreElements()) {
-                    InetAddress a = addrs.nextElement();
-                    if(a.isLoopbackAddress()) {
-                      bindAddress = a.getHostAddress();
-                      break;
-                    }
-                  }
-                }
-            } catch (SocketException se) {
-                LOG.warn("Couldn't find  loopback interface: " + se.getMessage());
-            }
-        }
-        if (bindAddress == null) {
-            LOG.warn("Unable to determine loop back address, skipping test");
-            return;
-        }
-        final int PORT = PortAssignment.unique();
-
-        LOG.info("Using " + bindAddress + " as the bind address");
-        final String HOSTPORT = bindAddress + ":" + PORT;
-        LOG.info("Using " + HOSTPORT + " as the host/port");
-
-
-        File tmpDir = ClientBase.createTmpDir();
-
-        ClientBase.setupTestEnv();
-        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
-
-        ServerCnxnFactory f = ServerCnxnFactory.createFactory(
-                new InetSocketAddress(bindAddress, PORT), -1);
-        f.startup(zks);
-        LOG.info("starting up the the server, waiting");
-
-        Assert.assertTrue("waiting for server up",
-                   ClientBase.waitForServerUp(HOSTPORT,
-                                   CONNECTION_TIMEOUT));
-
-        startSignal = new CountDownLatch(1);
-        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
-        try {
-            boolean isZero = startSignal.await(CONNECTION_TIMEOUT,
-                    TimeUnit.MILLISECONDS);
-            Assert.assertTrue("count == " + startSignal.getCount(), isZero);
-            zk.close();
-        } finally {
-            f.shutdown();
-            zks.shutdown();
-
-            Assert.assertTrue("waiting for server down",
-                       ClientBase.waitForServerDown(HOSTPORT,
-                                                    CONNECTION_TIMEOUT));
-        }
-    }
-
-    public void process(WatchedEvent event) {
-        LOG.info("Event:" + event.getState() + " " + event.getType() + " " + event.getPath());
-        if (event.getState() == KeeperState.SyncConnected
-                && startSignal != null && startSignal.getCount() > 0)
-        {
-            startSignal.countDown();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientRetry.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientRetry.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientRetry.java
deleted file mode 100644
index d0b6b43..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientRetry.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * 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;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.ZooKeeper.States;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ClientRetry extends ClientBase {
-
-    @Override
-    public void setUp() throws Exception {
-        maxCnxns = 1;
-        super.setUp();
-    }
-    /*
-     * This is a simple test - try to connect two clients to a server
-     * accepting a maximum of one connection from each address. Check that
-     * only one is accepted. Close that connection, and check that the other
-     * eventually connects.
-     *
-     * There is a possibility of a false positive here, as when zk2 is tested
-     * for having connected it might not have been given enough time, and finish
-     * connecting after the test is done. Since the
-     * server doesn't tell the client why it hasn't connected, there's no
-     * obvious way to detect the difference.
-     */
-    @Test
-    public void testClientRetry() throws IOException, InterruptedException, TimeoutException{
-        CountdownWatcher cdw1 = new CountdownWatcher();
-        CountdownWatcher cdw2 = new CountdownWatcher();
-        ZooKeeper zk = new ZooKeeper(hostPort, 10000, cdw1);
-        try {
-            cdw1.waitForConnected(CONNECTION_TIMEOUT);
-            ZooKeeper zk2 = new ZooKeeper(hostPort, 10000, cdw2);
-            try {
-                States s1 = zk.getState();
-                States s2 = zk2.getState();
-                Assert.assertSame(s1,States.CONNECTED);
-                Assert.assertSame(s2,States.CONNECTING);
-                cdw1.reset();
-                cdw1.waitForDisconnected(CONNECTION_TIMEOUT);
-                cdw2.waitForConnected(CONNECTION_TIMEOUT);
-                Assert.assertSame(zk2.getState(),States.CONNECTED);
-            } finally {
-                zk2.close();
-            }
-        } finally {
-            zk.close();
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientTest.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientTest.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientTest.java
deleted file mode 100644
index 9dc4861..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ClientTest.java
+++ /dev/null
@@ -1,805 +0,0 @@
-/**
- * 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;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.Code;
-import org.apache.zookeeper.KeeperException.InvalidACLException;
-import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.Watcher.Event.EventType;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooDefs.Perms;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.ACL;
-import org.apache.zookeeper.data.Id;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.proto.ExistsRequest;
-import org.apache.zookeeper.proto.ExistsResponse;
-import org.apache.zookeeper.proto.ReplyHeader;
-import org.apache.zookeeper.proto.RequestHeader;
-import org.apache.zookeeper.server.PrepRequestProcessor;
-import org.apache.zookeeper.server.util.OSMXBean;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ClientTest extends ClientBase {
-    protected static final Logger LOG = LoggerFactory.getLogger(ClientTest.class);
-
-    /** Verify that pings are sent, keeping the "idle" client alive */
-    @Test
-    public void testPing() throws Exception {
-        ZooKeeper zkIdle = null;
-        ZooKeeper zkWatchCreator = null;
-        try {
-            CountdownWatcher watcher = new CountdownWatcher();
-            zkIdle = createClient(watcher, hostPort, 10000);
-
-            zkWatchCreator = createClient();
-
-            for (int i = 0; i < 10; i++) {
-                zkWatchCreator.create("/" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
-                        CreateMode.PERSISTENT);
-            }
-            for (int i = 0; i < 10; i++) {
-                zkIdle.exists("/" + i, true);
-            }
-            for (int i = 0; i < 10; i++) {
-                Thread.sleep(1000);
-                zkWatchCreator.delete("/" + i, -1);
-            }
-            // The bug will manifest itself here because zkIdle will expire
-            zkIdle.exists("/0", false);
-        } finally {
-            if (zkIdle != null) {
-                zkIdle.close();
-            }
-            if (zkWatchCreator != null) {
-                zkWatchCreator.close();
-            }
-        }
-    }
-
-    @Test
-    public void testClientwithoutWatcherObj() throws IOException,
-            InterruptedException, KeeperException
-    {
-        performClientTest(false, hostPort);
-    }
-
-    @Test
-    public void testClientWithWatcherObj() throws IOException,
-            InterruptedException, KeeperException
-    {
-        performClientTest(true, hostPort);
-    }
-
-    @Test
-    public void testClientWithIPv6Address() throws IOException,
-            InterruptedException, KeeperException
-    {
-        assumeIPv6Available();
-        performClientTest(true, ipv6HostPort);
-    }
-
-    /** Exercise the testable functions, verify tostring, etc... */
-    @Test
-    public void testTestability() throws Exception {
-        TestableZooKeeper zk = createClient();
-        try {
-            LOG.info("{}",zk.testableLocalSocketAddress());
-            LOG.info("{}",zk.testableRemoteSocketAddress());
-            LOG.info("{}",zk.toString());
-        } finally {
-            zk.close();
-            zk.testableWaitForShutdown(CONNECTION_TIMEOUT);
-            LOG.info("{}",zk.testableLocalSocketAddress());
-            LOG.info("{}",zk.testableRemoteSocketAddress());
-            LOG.info("{}",zk.toString());
-        }
-    }
-
-    @Test
-    public void testACLs() throws Exception {
-        ZooKeeper zk = null;
-        try {
-            zk = createClient();
-            try {
-                zk.create("/acltest", new byte[0], Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
-                Assert.fail("Should have received an invalid acl error");
-            } catch(InvalidACLException e) {
-                LOG.info("Test successful, invalid acl received : "
-                        + e.getMessage());
-            }
-            try {
-                ArrayList<ACL> testACL = new ArrayList<ACL>();
-                testACL.add(new ACL(Perms.ALL | Perms.ADMIN, Ids.AUTH_IDS));
-                testACL.add(new ACL(Perms.ALL | Perms.ADMIN, new Id("ip", "127.0.0.1/8")));
-                zk.create("/acltest", new byte[0], testACL, CreateMode.PERSISTENT);
-                Assert.fail("Should have received an invalid acl error");
-            } catch(InvalidACLException e) {
-                LOG.info("Test successful, invalid acl received : "
-                        + e.getMessage());
-            }
-            zk.addAuthInfo("digest", "ben:passwd".getBytes());
-            zk.create("/acltest", new byte[0], Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
-            zk.close();
-            zk = createClient();
-            zk.addAuthInfo("digest", "ben:passwd2".getBytes());
-            try {
-                zk.getData("/acltest", false, new Stat());
-                Assert.fail("Should have received a permission error");
-            } catch (KeeperException e) {
-                Assert.assertEquals(Code.NOAUTH, e.code());
-            }
-            zk.addAuthInfo("digest", "ben:passwd".getBytes());
-            zk.getData("/acltest", false, new Stat());
-            zk.setACL("/acltest", Ids.OPEN_ACL_UNSAFE, -1);
-            zk.close();
-            zk = createClient();
-            zk.getData("/acltest", false, new Stat());
-            List<ACL> acls = zk.getACL("/acltest", new Stat());
-            Assert.assertEquals(1, acls.size());
-            Assert.assertEquals(Ids.OPEN_ACL_UNSAFE, acls);
-
-            // The stat parameter should be optional.
-            acls = zk.getACL("/acltest", null);
-            Assert.assertEquals(1, acls.size());
-            Assert.assertEquals(Ids.OPEN_ACL_UNSAFE, acls);
-
-            zk.close();
-        } finally {
-            if (zk != null) {
-                zk.close();
-            }
-        }
-    }
-
-    private class MyWatcher extends CountdownWatcher {
-        LinkedBlockingQueue<WatchedEvent> events =
-            new LinkedBlockingQueue<WatchedEvent>();
-
-        public void process(WatchedEvent event) {
-            super.process(event);
-            if (event.getType() != EventType.None) {
-                try {
-                    events.put(event);
-                } catch (InterruptedException e) {
-                    LOG.warn("ignoring interrupt during event.put");
-                }
-            }
-        }
-    }
-
-    /**
-     * Register multiple watchers and verify that they all get notified and
-     * in the right order.
-     */
-    @Test
-    public void testMutipleWatcherObjs()
-        throws IOException, InterruptedException, KeeperException
-    {
-        ZooKeeper zk = createClient(new CountdownWatcher(), hostPort);
-        try {
-            MyWatcher watchers[] = new MyWatcher[100];
-            MyWatcher watchers2[] = new MyWatcher[watchers.length];
-            for (int i = 0; i < watchers.length; i++) {
-                watchers[i] = new MyWatcher();
-                watchers2[i] = new MyWatcher();
-                zk.create("/foo-" + i, ("foodata" + i).getBytes(),
-                        Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-            }
-            Stat stat = new Stat();
-
-            //
-            // test get/exists with single set of watchers
-            //   get all, then exists all
-            //
-            for (int i = 0; i < watchers.length; i++) {
-                Assert.assertNotNull(zk.getData("/foo-" + i, watchers[i], stat));
-            }
-            for (int i = 0; i < watchers.length; i++) {
-                Assert.assertNotNull(zk.exists("/foo-" + i, watchers[i]));
-            }
-            // trigger the watches
-            for (int i = 0; i < watchers.length; i++) {
-                zk.setData("/foo-" + i, ("foodata2-" + i).getBytes(), -1);
-                zk.setData("/foo-" + i, ("foodata3-" + i).getBytes(), -1);
-            }
-            for (int i = 0; i < watchers.length; i++) {
-                WatchedEvent event =
-                    watchers[i].events.poll(10, TimeUnit.SECONDS);
-                Assert.assertEquals("/foo-" + i, event.getPath());
-                Assert.assertEquals(EventType.NodeDataChanged, event.getType());
-                Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-
-                // small chance that an unexpected message was delivered
-                //  after this check, but we would catch that next time
-                //  we check events
-                Assert.assertEquals(0, watchers[i].events.size());
-            }
-
-            //
-            // test get/exists with single set of watchers
-            //  get/exists together
-            //
-            for (int i = 0; i < watchers.length; i++) {
-                Assert.assertNotNull(zk.getData("/foo-" + i, watchers[i], stat));
-                Assert.assertNotNull(zk.exists("/foo-" + i, watchers[i]));
-            }
-            // trigger the watches
-            for (int i = 0; i < watchers.length; i++) {
-                zk.setData("/foo-" + i, ("foodata4-" + i).getBytes(), -1);
-                zk.setData("/foo-" + i, ("foodata5-" + i).getBytes(), -1);
-            }
-            for (int i = 0; i < watchers.length; i++) {
-                WatchedEvent event =
-                    watchers[i].events.poll(10, TimeUnit.SECONDS);
-                Assert.assertEquals("/foo-" + i, event.getPath());
-                Assert.assertEquals(EventType.NodeDataChanged, event.getType());
-                Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-
-                // small chance that an unexpected message was delivered
-                //  after this check, but we would catch that next time
-                //  we check events
-                Assert.assertEquals(0, watchers[i].events.size());
-            }
-
-            //
-            // test get/exists with two sets of watchers
-            //
-            for (int i = 0; i < watchers.length; i++) {
-                Assert.assertNotNull(zk.getData("/foo-" + i, watchers[i], stat));
-                Assert.assertNotNull(zk.exists("/foo-" + i, watchers2[i]));
-            }
-            // trigger the watches
-            for (int i = 0; i < watchers.length; i++) {
-                zk.setData("/foo-" + i, ("foodata6-" + i).getBytes(), -1);
-                zk.setData("/foo-" + i, ("foodata7-" + i).getBytes(), -1);
-            }
-            for (int i = 0; i < watchers.length; i++) {
-                WatchedEvent event =
-                    watchers[i].events.poll(10, TimeUnit.SECONDS);
-                Assert.assertEquals("/foo-" + i, event.getPath());
-                Assert.assertEquals(EventType.NodeDataChanged, event.getType());
-                Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-
-                // small chance that an unexpected message was delivered
-                //  after this check, but we would catch that next time
-                //  we check events
-                Assert.assertEquals(0, watchers[i].events.size());
-
-                // watchers2
-                WatchedEvent event2 =
-                    watchers2[i].events.poll(10, TimeUnit.SECONDS);
-                Assert.assertEquals("/foo-" + i, event2.getPath());
-                Assert.assertEquals(EventType.NodeDataChanged, event2.getType());
-                Assert.assertEquals(KeeperState.SyncConnected, event2.getState());
-
-                // small chance that an unexpected message was delivered
-                //  after this check, but we would catch that next time
-                //  we check events
-                Assert.assertEquals(0, watchers2[i].events.size());
-            }
-
-        } finally {
-            if (zk != null) {
-                zk.close();
-            }
-        }
-    }
-
-    private void performClientTest(boolean withWatcherObj, String hostPort)
-        throws IOException, InterruptedException, KeeperException
-    {
-        ZooKeeper zk = null;
-        try {
-            MyWatcher watcher = new MyWatcher();
-            zk = createClient(watcher, hostPort);
-            LOG.info("Before create /benwashere");
-            zk.create("/benwashere", "".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            LOG.info("After create /benwashere");
-            try {
-                zk.setData("/benwashere", "hi".getBytes(), 57);
-                Assert.fail("Should have gotten BadVersion exception");
-            } catch(KeeperException.BadVersionException e) {
-                // expected that
-            } catch (KeeperException e) {
-                Assert.fail("Should have gotten BadVersion exception");
-            }
-            LOG.info("Before delete /benwashere");
-            zk.delete("/benwashere", 0);
-            LOG.info("After delete /benwashere");
-            zk.close();
-            //LOG.info("Closed client: " + zk.describeCNXN());
-            Thread.sleep(2000);
-
-            zk = createClient(watcher, hostPort);
-            //LOG.info("Created a new client: " + zk.describeCNXN());
-            LOG.info("Before delete /");
-
-            try {
-                zk.delete("/", -1);
-                Assert.fail("deleted root!");
-            } catch(KeeperException.BadArgumentsException e) {
-                // good, expected that
-            }
-            Stat stat = new Stat();
-            // Test basic create, ls, and getData
-            zk.create("/pat", "Pat was here".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            LOG.info("Before create /ben");
-            zk.create("/pat/ben", "Ben was here".getBytes(),
-                    Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-            LOG.info("Before getChildren /pat");
-            List<String> children = zk.getChildren("/pat", false);
-            Assert.assertEquals(1, children.size());
-            Assert.assertEquals("ben", children.get(0));
-            List<String> children2 = zk.getChildren("/pat", false, null);
-            Assert.assertEquals(children, children2);
-            String value = new String(zk.getData("/pat/ben", false, stat));
-            Assert.assertEquals("Ben was here", value);
-            // Test stat and watch of non existent node
-
-            try {
-                if (withWatcherObj) {
-                    Assert.assertEquals(null, zk.exists("/frog", watcher));
-                } else {
-                    Assert.assertEquals(null, zk.exists("/frog", true));
-                }
-                LOG.info("Comment: asseting passed for frog setting /");
-            } catch (KeeperException.NoNodeException e) {
-                // OK, expected that
-            }
-            zk.create("/frog", "hi".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            // the first poll is just a session delivery
-            LOG.info("Comment: checking for events length "
-                     + watcher.events.size());
-            WatchedEvent event = watcher.events.poll(10, TimeUnit.SECONDS);
-            Assert.assertEquals("/frog", event.getPath());
-            Assert.assertEquals(EventType.NodeCreated, event.getType());
-            Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-            // Test child watch and create with sequence
-            zk.getChildren("/pat/ben", true);
-            for (int i = 0; i < 10; i++) {
-                zk.create("/pat/ben/" + i + "-", Integer.toString(i).getBytes(),
-                        Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
-            }
-            children = zk.getChildren("/pat/ben", false);
-            Collections.sort(children);
-            Assert.assertEquals(10, children.size());
-            for (int i = 0; i < 10; i++) {
-                final String name = children.get(i);
-                Assert.assertTrue("starts with -", name.startsWith(i + "-"));
-                byte b[];
-                if (withWatcherObj) {
-                    b = zk.getData("/pat/ben/" + name, watcher, stat);
-                } else {
-                    b = zk.getData("/pat/ben/" + name, true, stat);
-                }
-                Assert.assertEquals(Integer.toString(i), new String(b));
-                zk.setData("/pat/ben/" + name, "new".getBytes(),
-                        stat.getVersion());
-                if (withWatcherObj) {
-                    stat = zk.exists("/pat/ben/" + name, watcher);
-                } else {
-                stat = zk.exists("/pat/ben/" + name, true);
-                }
-                zk.delete("/pat/ben/" + name, stat.getVersion());
-            }
-            event = watcher.events.poll(10, TimeUnit.SECONDS);
-            Assert.assertEquals("/pat/ben", event.getPath());
-            Assert.assertEquals(EventType.NodeChildrenChanged, event.getType());
-            Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-            for (int i = 0; i < 10; i++) {
-                event = watcher.events.poll(10, TimeUnit.SECONDS);
-                final String name = children.get(i);
-                Assert.assertEquals("/pat/ben/" + name, event.getPath());
-                Assert.assertEquals(EventType.NodeDataChanged, event.getType());
-                Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-                event = watcher.events.poll(10, TimeUnit.SECONDS);
-                Assert.assertEquals("/pat/ben/" + name, event.getPath());
-                Assert.assertEquals(EventType.NodeDeleted, event.getType());
-                Assert.assertEquals(KeeperState.SyncConnected, event.getState());
-            }
-            zk.create("/good\u0040path", "".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-
-            zk.create("/duplicate", "".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            try {
-                zk.create("/duplicate", "".getBytes(), Ids.OPEN_ACL_UNSAFE,
-                        CreateMode.PERSISTENT);
-                Assert.fail("duplicate create allowed");
-            } catch(KeeperException.NodeExistsException e) {
-                // OK, expected that
-            }
-        } finally {
-            if (zk != null) {
-                zk.close();
-            }
-        }
-    }
-    
-    // Test that sequential filenames are being created correctly,
-    // with 0-padding in the filename
-    @Test
-    public void testSequentialNodeNames()
-        throws IOException, InterruptedException, KeeperException
-    {
-        String path = "/SEQUENCE";
-        String file = "TEST";
-        String filepath = path + "/" + file;
-
-        ZooKeeper zk = null;
-        try {
-            zk = createClient();
-            zk.create(path, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-            zk.create(filepath, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
-            List<String> children = zk.getChildren(path, false);
-            Assert.assertEquals(1, children.size());
-            Assert.assertEquals(file + "0000000000", children.get(0));
-
-            zk.create(filepath, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
-            children = zk.getChildren(path, false);
-            Assert.assertEquals(2, children.size());
-            Assert.assertTrue("contains child 1",  children.contains(file + "0000000001"));
-
-            zk.create(filepath, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
-            children = zk.getChildren(path, false);
-            Assert.assertEquals(3, children.size());
-            Assert.assertTrue("contains child 2",
-                       children.contains(file + "0000000002"));
-
-            // The pattern is holding so far.  Let's run the counter a bit
-            // to be sure it continues to spit out the correct answer
-            for(int i = children.size(); i < 105; i++)
-               zk.create(filepath, new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
-
-            children = zk.getChildren(path, false);
-            Assert.assertTrue("contains child 104",
-                       children.contains(file + "0000000104"));
-
-        }
-        finally {
-            if(zk != null)
-                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);
-            Assert.assertEquals(children.size(), 2);
-            String child1 = children.get(0);
-            String child2 = children.get(1);
-            int compareResult = child1.compareTo(child2);
-            Assert.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));
-            Assert.assertEquals(child1data, "0");
-            Assert.assertEquals(child2data, "1");
-        } finally {
-            if (zk != null) {
-                zk.close();
-            }
-        }
-
-    }
-
-    @Test
-    public void testLargeNodeData() throws Exception {
-        ZooKeeper zk= null;
-        String queue_handle = "/large";
-        try {
-            zk = createClient();
-
-            zk.create(queue_handle, new byte[500000], Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-        } finally {
-            if (zk != null) {
-                zk.close();
-            }
-        }
-
-    }
-
-    private void verifyCreateFails(String path, ZooKeeper zk) throws Exception {
-        try {
-            zk.create(path, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        } catch (IllegalArgumentException e) {
-            // this is good
-            return;
-        }
-        Assert.fail("bad path \"" + path + "\" not caught");
-    }
-
-    // Test that the path string is validated
-    @Test
-    public void testPathValidation() throws Exception {
-        ZooKeeper zk = createClient();
-
-        verifyCreateFails(null, zk);
-        verifyCreateFails("", zk);
-        verifyCreateFails("//", zk);
-        verifyCreateFails("///", zk);
-        verifyCreateFails("////", zk);
-        verifyCreateFails("/.", zk);
-        verifyCreateFails("/..", zk);
-        verifyCreateFails("/./", zk);
-        verifyCreateFails("/../", zk);
-        verifyCreateFails("/foo/./", zk);
-        verifyCreateFails("/foo/../", zk);
-        verifyCreateFails("/foo/.", zk);
-        verifyCreateFails("/foo/..", zk);
-        verifyCreateFails("/./.", zk);
-        verifyCreateFails("/../..", zk);
-        verifyCreateFails("/\u0001foo", zk);
-        verifyCreateFails("/foo/bar/", zk);
-        verifyCreateFails("/foo//bar", zk);
-        verifyCreateFails("/foo/bar//", zk);
-
-        verifyCreateFails("foo", zk);
-        verifyCreateFails("a", zk);
-
-        zk.create("/createseqpar", null, Ids.OPEN_ACL_UNSAFE,
-                CreateMode.PERSISTENT);
-        // next two steps - related to sequential processing
-        // 1) verify that empty child name Assert.fails if not sequential
-        try {
-            zk.create("/createseqpar/", null, Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT);
-            Assert.assertTrue(false);
-        } catch(IllegalArgumentException be) {
-            // catch this.
-        }
-
-        // 2) verify that empty child name success if sequential 
-        zk.create("/createseqpar/", null, Ids.OPEN_ACL_UNSAFE,
-                CreateMode.PERSISTENT_SEQUENTIAL);
-        zk.create("/createseqpar/.", null, Ids.OPEN_ACL_UNSAFE,
-                CreateMode.PERSISTENT_SEQUENTIAL);
-        zk.create("/createseqpar/..", null, Ids.OPEN_ACL_UNSAFE,
-                CreateMode.PERSISTENT_SEQUENTIAL);
-        try {
-            zk.create("/createseqpar//", null, Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT_SEQUENTIAL);
-            Assert.assertTrue(false);
-        } catch(IllegalArgumentException be) {
-            // catch this.
-        }
-        try {
-            zk.create("/createseqpar/./", null, Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT_SEQUENTIAL);
-            Assert.assertTrue(false);
-        } catch(IllegalArgumentException be) {
-            // catch this.
-        }
-        try {
-            zk.create("/createseqpar/../", null, Ids.OPEN_ACL_UNSAFE,
-                    CreateMode.PERSISTENT_SEQUENTIAL);
-            Assert.assertTrue(false);
-        } catch(IllegalArgumentException be) {
-            // catch this.
-        }
-
-        
-        //check for the code path that throws at server
-        PrepRequestProcessor.setFailCreate(true);
-        try {
-            zk.create("/m", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-            Assert.assertTrue(false);
-        } catch(KeeperException.BadArgumentsException be) {
-            // catch this.
-        }
-        PrepRequestProcessor.setFailCreate(false);
-        zk.create("/.foo", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/.f.", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/..f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/..f..", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f.c", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f\u0040f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f/.f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f/f.", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f/..f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f/f..", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f/.f/f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/f/f./f", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-    }
-
-//    private void notestConnections()
-//        throws IOException, InterruptedException, KeeperException
-//    {
-//        ZooKeeper zk;
-//        for(int i = 0; i < 2000; i++) {
-//            if (i % 100 == 0) {
-//                LOG.info("Testing " + i + " connections");
-//            }
-//            // We want to make sure socket descriptors are going away
-//            zk = new ZooKeeper(hostPort, 30000, this);
-//            zk.getData("/", false, new Stat());
-//            zk.close();
-//        }
-//    }
-
-    @Test
-    public void testDeleteWithChildren() throws Exception {
-        ZooKeeper zk = createClient();
-        zk.create("/parent", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        zk.create("/parent/child", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        try {
-            zk.delete("/parent", -1);
-            Assert.fail("Should have received a not equals message");
-        } catch (KeeperException e) {
-            Assert.assertEquals(KeeperException.Code.NOTEMPTY, e.code());
-        }
-        zk.delete("/parent/child", -1);
-        zk.delete("/parent", -1);
-        zk.close();
-    }
-
-    private class VerifyClientCleanup extends Thread {
-        int count;
-        int current = 0;
-
-        VerifyClientCleanup(String name, int count) {
-            super(name);
-            this.count = count;
-        }
-
-        public void run() {
-            try {
-                for (; current < count; current++) {
-                    TestableZooKeeper zk = createClient();
-                    zk.close();
-                    // we've asked to close, wait for it to finish closing
-                    // all the sub-threads otw the selector may not be
-                    // closed when we check (false positive on test Assert.failure
-                    zk.testableWaitForShutdown(CONNECTION_TIMEOUT);
-                }
-            } catch (Throwable t) {
-                LOG.error("test Assert.failed", t);
-            }
-        }
-    }
-
-    /**
-     * Verify that the client is cleaning up properly. Open/close a large
-     * number of sessions. Essentially looking to see if sockets/selectors
-     * are being cleaned up properly during close.
-     *
-     * @throws Throwable
-     */
-    @Test
-    public void testClientCleanup() throws Throwable {
-        OSMXBean osMbean = new OSMXBean();
-        if (osMbean.getUnix() == false) {
-            LOG.warn("skipping testClientCleanup, only available on Unix");
-            return;
-        }
-
-        final int threadCount = 3;
-        final int clientCount = 10;
-
-        /* Log the number of fds used before and after a test is run. Verifies
-         * we are freeing resources correctly. Unfortunately this only works
-         * on unix systems (the only place sun has implemented as part of the
-         * mgmt bean api).
-         */
-        long initialFdCount = osMbean.getOpenFileDescriptorCount();
-
-        VerifyClientCleanup threads[] = new VerifyClientCleanup[threadCount];
-
-        for (int i = 0; i < threads.length; i++) {
-            threads[i] = new VerifyClientCleanup("VCC" + i, clientCount);
-            threads[i].start();
-        }
-
-        for (int i = 0; i < threads.length; i++) {
-            threads[i].join(CONNECTION_TIMEOUT);
-            Assert.assertTrue(threads[i].current == threads[i].count);
-        }
-
-        // if this Assert.fails it means we are not cleaning up after the closed
-        // sessions.
-        long currentCount = osMbean.getOpenFileDescriptorCount();
-        final String logmsg = "open fds after test ({}) are not significantly higher than before ({})";
-        
-        if (currentCount > initialFdCount + 10) {
-            // consider as error
-        	LOG.error(logmsg,Long.valueOf(currentCount),Long.valueOf(initialFdCount));
-        } else {
-        	LOG.info(logmsg,Long.valueOf(currentCount),Long.valueOf(initialFdCount));
-        }
-    }
-
-
-    /**
-     * We create a perfectly valid 'exists' request, except that the opcode is wrong.
-     * @return
-     * @throws Exception
-     */
-    @Test
-    public void testNonExistingOpCode() throws Exception  {
-        final CountDownLatch clientDisconnected = new CountDownLatch(1);
-        Watcher watcher = new Watcher() {
-            @Override
-            public synchronized void process(WatchedEvent event) {
-                if (event.getState() == KeeperState.Disconnected) {
-                    clientDisconnected.countDown();
-                }
-            }
-        };
-        TestableZooKeeper zk = new TestableZooKeeper(hostPort, CONNECTION_TIMEOUT, watcher);
-
-        final String path = "/m1";
-
-        RequestHeader h = new RequestHeader();
-        h.setType(888);  // This code does not exists
-        ExistsRequest request = new ExistsRequest();
-        request.setPath(path);
-        request.setWatch(false);
-        ExistsResponse response = new ExistsResponse();
-
-        ReplyHeader r = zk.submitRequest(h, request, response, null);
-
-        Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());
-
-        // Sending a nonexisting opcode should cause the server to disconnect
-        Assert.assertTrue("failed to disconnect",
-                clientDisconnected.await(5000, TimeUnit.MILLISECONDS));
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/ConnectStringParserTest.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ConnectStringParserTest.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/ConnectStringParserTest.java
deleted file mode 100644
index a169b7b..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/ConnectStringParserTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 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 org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.client.ConnectStringParser;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ConnectStringParserTest extends ZKTestCase{
-
-    @Test
-    public void testSingleServerChrootPath(){
-        String chrootPath = "/hallo/welt";
-        String servers = "10.10.10.1";
-        assertChrootPath(chrootPath,
-                new ConnectStringParser(servers+chrootPath));
-    }
-
-    @Test
-    public void testMultipleServersChrootPath(){
-        String chrootPath = "/hallo/welt";
-        String servers = "10.10.10.1,10.10.10.2";
-        assertChrootPath(chrootPath,
-                new ConnectStringParser(servers+chrootPath));
-    }
-
-    @Test
-    public void testParseServersWithoutPort(){
-        String servers = "10.10.10.1,10.10.10.2";
-        ConnectStringParser parser = new ConnectStringParser(servers);
-
-        Assert.assertEquals("10.10.10.1", parser.getServerAddresses().get(0).getHostName());
-        Assert.assertEquals("10.10.10.2", parser.getServerAddresses().get(1).getHostName());
-    }
-
-    @Test
-    public void testParseServersWithPort(){
-        String servers = "10.10.10.1:112,10.10.10.2:110";
-        ConnectStringParser parser = new ConnectStringParser(servers);
-
-        Assert.assertEquals("10.10.10.1", parser.getServerAddresses().get(0).getHostName());
-        Assert.assertEquals("10.10.10.2", parser.getServerAddresses().get(1).getHostName());
-
-        Assert.assertEquals(112, parser.getServerAddresses().get(0).getPort());
-        Assert.assertEquals(110, parser.getServerAddresses().get(1).getPort());
-    }
-
-    private void assertChrootPath(String expected, ConnectStringParser parser){
-        Assert.assertEquals(expected, parser.getChrootPath());
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/7291e47c/zookeeper-common/src/test/java/org/apache/zookeeper/test/CreateModeTest.java
----------------------------------------------------------------------
diff --git a/zookeeper-common/src/test/java/org/apache/zookeeper/test/CreateModeTest.java b/zookeeper-common/src/test/java/org/apache/zookeeper/test/CreateModeTest.java
deleted file mode 100644
index a3b838a..0000000
--- a/zookeeper-common/src/test/java/org/apache/zookeeper/test/CreateModeTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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.util.EnumSet;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.KeeperException.Code;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CreateModeTest extends ZKTestCase {
-    
-    @Test
-    public void testBasicCreateMode() {
-        CreateMode cm = CreateMode.PERSISTENT;
-        Assert.assertEquals(cm.toFlag(), 0);
-        Assert.assertFalse(cm.isEphemeral());
-        Assert.assertFalse(cm.isSequential());
-        
-        cm = CreateMode.EPHEMERAL;
-        Assert.assertEquals(cm.toFlag(), 1);
-        Assert.assertTrue(cm.isEphemeral());
-        Assert.assertFalse(cm.isSequential());
-        
-        cm = CreateMode.PERSISTENT_SEQUENTIAL;
-        Assert.assertEquals(cm.toFlag(), 2);
-        Assert.assertFalse(cm.isEphemeral());
-        Assert.assertTrue(cm.isSequential());
-        
-        cm = CreateMode.EPHEMERAL_SEQUENTIAL;
-        Assert.assertEquals(cm.toFlag(), 3);
-        Assert.assertTrue(cm.isEphemeral());
-        Assert.assertTrue(cm.isSequential());
-    }
-    
-    @Test
-    public void testFlagConversion() throws KeeperException {
-        // Ensure we get the same value back after round trip conversion
-        EnumSet<CreateMode> allModes = EnumSet.allOf(CreateMode.class);
-
-        for(CreateMode cm : allModes) {
-            Assert.assertEquals(cm, CreateMode.fromFlag( cm.toFlag() ) );
-        }
-    }
-
-    @Test
-    public void testInvalidFlagConversion() throws KeeperException {
-        try {
-            CreateMode cm = CreateMode.fromFlag(99);
-            Assert.fail("Shouldn't be able to convert 99 to a CreateMode.");
-        } catch(KeeperException ke) {
-            Assert.assertEquals(Code.BADARGUMENTS, ke.code());
-        }
-
-        try {
-            CreateMode cm = CreateMode.fromFlag(-1);
-            Assert.fail("Shouldn't be able to convert -1 to a CreateMode.");
-        } catch(KeeperException ke) {
-            Assert.assertEquals(Code.BADARGUMENTS, ke.code());
-        }
-    }
-}