hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r929377 [1/4] - in /hadoop/zookeeper/trunk: ./ src/java/test/org/apache/zookeeper/server/ src/java/test/org/apache/zookeeper/server/quorum/ src/java/test/org/apache/zookeeper/test/
Date Wed, 31 Mar 2010 04:26:30 GMT
Author: mahadev
Date: Wed Mar 31 04:26:29 2010
New Revision: 929377

URL: http://svn.apache.org/viewvc?rev=929377&view=rev
Log:
ZOOKEEPER-724. Improve junit test integration - log harness information (phunt via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DataTreeUnitTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ToStringTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLRootTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOps.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOpsTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AuthTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootAsyncTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootClientTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientRetry.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CnxManagerTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/CreateModeTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DataTreeTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/DisconnectableZooKeeper.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/EventTypeTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLELostMessageTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLENewEpochTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLERestartTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLEZeroWeightTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsQuorumTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FourLetterWordsTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/GetChildren2Test.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/HierarchicalQuorumTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/InvalidSnapshotTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/KeeperStateTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/LENonTerminateTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/LETest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/MaxCnxnsTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NullDataTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverHierarchicalQuorumTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverQuorumHammerTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumHammerTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumZxidSyncTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/StatTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TruncateTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherFuncTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZkDatabaseCorruptionTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperQuotaTest.java
    hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ZooKeeperTestClient.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Wed Mar 31 04:26:29 2010
@@ -9,6 +9,8 @@ Backward compatible changes:
 BUGFIXES: 
 
 IMPROVEMENTS:
+  ZOOKEEPER-724. Improve junit test integration - log harness information 
+  (phunt via mahadev)
 
 NEW FEATURES:
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java Wed Mar 31 04:26:29 2010
@@ -34,8 +34,6 @@ import java.util.concurrent.CountDownLat
 import java.util.zip.Adler32;
 import java.util.zip.CheckedInputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.jute.BinaryInputArchive;
 import org.apache.jute.InputArchive;
 import org.apache.log4j.Logger;
@@ -43,6 +41,7 @@ import org.apache.zookeeper.CreateMode;
 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.ZooDefs.Ids;
@@ -50,24 +49,16 @@ import org.apache.zookeeper.server.persi
 import org.apache.zookeeper.server.persistence.FileTxnLog;
 import org.apache.zookeeper.server.persistence.TxnLog.TxnIterator;
 import org.apache.zookeeper.test.ClientBase;
+import org.junit.Assert;
 import org.junit.Test;
 
-public class CRCTest extends TestCase implements Watcher{
+public class CRCTest extends ZKTestCase implements Watcher {
     private static final Logger LOG = Logger.getLogger(CRCTest.class);
 
     private static final String HOSTPORT =
         "127.0.0.1:" + PortAssignment.unique();
     private volatile CountDownLatch startSignal;
 
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
-    }
-    @Override
-    protected void tearDown() throws Exception {
-        LOG.info("FINISHED " + getName());
-    }
-
     /**
      * corrupt a file by writing m at 500 b
      * offset
@@ -129,7 +120,7 @@ public class CRCTest extends TestCase im
                 new InetSocketAddress(PORT));
         f.startup(zks);
         LOG.info("starting up the zookeeper server .. waiting");
-        assertTrue("waiting for server being up",
+        Assert.assertTrue("waiting for server being up",
                 ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
         ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
         try {
@@ -141,7 +132,7 @@ public class CRCTest extends TestCase im
             zk.close();
         }
         f.shutdown();
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                            ClientBase.CONNECTION_TIMEOUT));
 
@@ -164,7 +155,7 @@ public class CRCTest extends TestCase im
         try {
             while (itr.next()) {
             }
-            assertTrue(false);
+            Assert.assertTrue(false);
         } catch(IOException ie) {
             LOG.info("crc corruption", ie);
         }
@@ -185,7 +176,7 @@ public class CRCTest extends TestCase im
             corruptFile(snapFile);
             cfile = getCheckSum(snap, snapFile);
         }
-        assertTrue(cfile);
+        Assert.assertTrue(cfile);
    }
 
     public void process(WatchedEvent event) {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DataTreeUnitTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DataTreeUnitTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DataTreeUnitTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DataTreeUnitTest.java Wed Mar 31 04:26:29 2010
@@ -18,24 +18,29 @@
 
 package org.apache.zookeeper.server;
 
-import junit.framework.TestCase;
-
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.data.Stat;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
 
-public class DataTreeUnitTest extends TestCase {
+public class DataTreeUnitTest extends ZKTestCase {
     DataTree dt;
 
+    @Before
     public void setUp() throws Exception {
         dt=new DataTree();
     }
 
+    @After
     public void tearDown() throws Exception {
         dt=null;
     }
 
-
+    @Test
     public void testRootWatchTriggered() throws Exception {
         class MyWatcher implements Watcher{
             boolean fired=false;
@@ -49,7 +54,7 @@ public class DataTreeUnitTest extends Te
         dt.getChildren("/", new Stat(), watcher);
         // add a new node, should trigger a watch
         dt.createNode("/xyz", new byte[0], null, 0, 1, 1);
-        assertFalse("Root node watch not triggered",!watcher.fired);
+        Assert.assertFalse("Root node watch not triggered",!watcher.fired);
     }
 
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/DeserializationPerfTest.java Wed Mar 31 04:26:29 2010
@@ -22,15 +22,15 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.apache.jute.BinaryInputArchive;
 import org.apache.jute.BinaryOutputArchive;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZKTestCase;
+import org.junit.Assert;
 import org.junit.Test;
 
-public class DeserializationPerfTest extends TestCase {
+public class DeserializationPerfTest extends ZKTestCase {
     protected static final Logger LOG = Logger.getLogger(DeserializationPerfTest.class);
 
     private static void deserializeTree(int depth, int width, int len)
@@ -60,7 +60,7 @@ public class DeserializationPerfTest ext
         long durationms = (end - start) / 1000000L;
         long pernodeus = ((end - start) / 1000L) / count;
 
-        assertEquals(count, dserTree.getNodeCount());
+        Assert.assertEquals(count, dserTree.getNodeCount());
 
         LOG.info("Deserialized " + count + " nodes in " + durationms
                 + " ms (" + pernodeus + "us/node), depth=" + depth + " width="

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java Wed Mar 31 04:26:29 2010
@@ -22,16 +22,16 @@ import java.io.File;
 import java.io.RandomAccessFile;
 import java.net.InetSocketAddress;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 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.ZooDefs.Ids;
 import org.apache.zookeeper.test.ClientBase;
+import org.junit.Assert;
 import org.junit.Test;
 
 /**
@@ -40,7 +40,7 @@ import org.junit.Test;
  * by corruption or if the server crashes
  * while generating the snapshot.
  */
-public class InvalidSnapshotTest extends TestCase implements Watcher {
+public class InvalidSnapshotTest extends ZKTestCase implements Watcher {
     private static final Logger LOG =
         Logger.getLogger(InvalidSnapshotTest.class);
 
@@ -63,7 +63,7 @@ public class InvalidSnapshotTest extends
        NIOServerCnxn.Factory f = new NIOServerCnxn.Factory(
                new InetSocketAddress(PORT));
        f.startup(zks);
-       assertTrue("waiting for server being up ",
+       Assert.assertTrue("waiting for server being up ",
                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
        try {
@@ -75,7 +75,7 @@ public class InvalidSnapshotTest extends
            zk.close();
        }
        f.shutdown();
-       assertTrue("waiting for server to shutdown",
+       Assert.assertTrue("waiting for server to shutdown",
                ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
        // now corrupt the snapshot
        File snapFile = zks.getTxnLogFactory().findMostRecentSnapshot();
@@ -87,22 +87,22 @@ public class InvalidSnapshotTest extends
        SyncRequestProcessor.setSnapCount(100);
        f = new NIOServerCnxn.Factory(new InetSocketAddress(PORT));
        f.startup(zks);
-       assertTrue("waiting for server being up ",
+       Assert.assertTrue("waiting for server being up ",
                ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
        // the server should come up
        zk = new ZooKeeper(HOSTPORT, 20000, this);
        try {
-           assertTrue("the node should exist",
+           Assert.assertTrue("the node should exist",
                    (zk.exists("/invalidsnap-1999", false) != null));
            f.shutdown();
-           assertTrue("waiting for server to shutdown",
+           Assert.assertTrue("waiting for server to shutdown",
                    ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
        } finally {
            zk.close();
        }
 
        f.shutdown();
-       assertTrue("waiting for server to shutdown",
+       Assert.assertTrue("waiting for server to shutdown",
                ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/SerializationPerfTest.java Wed Mar 31 04:26:29 2010
@@ -21,14 +21,13 @@ package org.apache.zookeeper.server;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import junit.framework.TestCase;
-
 import org.apache.jute.BinaryOutputArchive;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZKTestCase;
 import org.junit.Test;
 
-public class SerializationPerfTest extends TestCase {
+public class SerializationPerfTest extends ZKTestCase {
     protected static final Logger LOG = Logger.getLogger(SerializationPerfTest.class);
 
     private static class NullOutputStream extends OutputStream {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ToStringTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ToStringTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ToStringTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ToStringTest.java Wed Mar 31 04:26:29 2010
@@ -18,21 +18,21 @@
 
 package org.apache.zookeeper.server;
 
-import junit.framework.TestCase;
-
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.proto.SetDataRequest;
+import org.junit.Assert;
 import org.junit.Test;
 
 /**
  * A misc place to verify toString methods - mainly to make sure they don't
  * fail.
  */
-public class ToStringTest extends TestCase {
+public class ToStringTest extends ZKTestCase {
     /** Verify jute - which we've had particular problems with in the past 
      * wrt null fields */
     @Test
     public void testJuteToString() {
         SetDataRequest req = new SetDataRequest(null, null, 0);
-        assertNotSame("ERROR", req.toString());
+        Assert.assertNotSame("ERROR", req.toString());
     }
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java Wed Mar 31 04:26:29 2010
@@ -24,22 +24,22 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.test.ClientBase;
+import org.junit.Assert;
 import org.junit.Test;
 
 /**
  * Test stand-alone server.
  *
  */
-public class ZooKeeperServerMainTest extends TestCase implements Watcher {
+public class ZooKeeperServerMainTest extends ZKTestCase implements Watcher {
     protected static final Logger LOG =
         Logger.getLogger(ZooKeeperServerMainTest.class);
 
@@ -97,7 +97,6 @@ public class ZooKeeperServerMainTest ext
      */
     @Test
     public void testStandalone() throws Exception {
-        LOG.info("STARTING " + getName());
         ClientBase.setupTestEnv();
 
         final int CLIENT_PORT = 3181;
@@ -105,7 +104,7 @@ public class ZooKeeperServerMainTest ext
         MainThread main = new MainThread(CLIENT_PORT);
         main.start();
 
-        assertTrue("waiting for server being up",
+        Assert.assertTrue("waiting for server being up",
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT,
                         CONNECTION_TIMEOUT));
 
@@ -115,12 +114,12 @@ public class ZooKeeperServerMainTest ext
 
         zk.create("/foo", "foobar".getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        assertEquals(new String(zk.getData("/foo", null, null)), "foobar");
+        Assert.assertEquals(new String(zk.getData("/foo", null, null)), "foobar");
         zk.close();
 
         main.shutdown();
 
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                 ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT,
                         ClientBase.CONNECTION_TIMEOUT));
     }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerTest.java Wed Mar 31 04:26:29 2010
@@ -21,13 +21,13 @@ package org.apache.zookeeper.server;
 import java.io.File;
 import java.util.List;
 
-import junit.framework.TestCase;
-
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.server.persistence.FileTxnLog;
 import org.apache.zookeeper.server.persistence.Util;
+import org.junit.Assert;
 import org.junit.Test;
 
-public class ZooKeeperServerTest extends TestCase {
+public class ZooKeeperServerTest extends ZKTestCase {
     @Test
     public void testSortDataDirAscending() {
         File[] files = new File[5];
@@ -42,11 +42,11 @@ public class ZooKeeperServerTest extends
 
         List<File> filelist = Util.sortDataDir(files, "foo", true);
 
-        assertEquals(orig[2], filelist.get(0));
-        assertEquals(orig[3], filelist.get(1));
-        assertEquals(orig[0], filelist.get(2));
-        assertEquals(orig[1], filelist.get(3));
-        assertEquals(orig[4], filelist.get(4));
+        Assert.assertEquals(orig[2], filelist.get(0));
+        Assert.assertEquals(orig[3], filelist.get(1));
+        Assert.assertEquals(orig[0], filelist.get(2));
+        Assert.assertEquals(orig[1], filelist.get(3));
+        Assert.assertEquals(orig[4], filelist.get(4));
     }
 
     @Test
@@ -63,11 +63,11 @@ public class ZooKeeperServerTest extends
 
         List<File> filelist = Util.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));
+        Assert.assertEquals(orig[4], filelist.get(0));
+        Assert.assertEquals(orig[1], filelist.get(1));
+        Assert.assertEquals(orig[0], filelist.get(2));
+        Assert.assertEquals(orig[3], filelist.get(3));
+        Assert.assertEquals(orig[2], filelist.get(4));
     }
 
     @Test
@@ -86,10 +86,10 @@ public class ZooKeeperServerTest extends
                 FileTxnLog.getLogFiles(files,
                 Long.parseLong("10027c6de", 16));
 
-        assertEquals(3, filelist.length);
-        assertEquals(orig[0], filelist[0]);
-        assertEquals(orig[1], filelist[1]);
-        assertEquals(orig[4], filelist[2]);
+        Assert.assertEquals(3, filelist.length);
+        Assert.assertEquals(orig[0], filelist[0]);
+        Assert.assertEquals(orig[1], filelist[1]);
+        Assert.assertEquals(orig[4], filelist[2]);
     }
 
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java Wed Mar 31 04:26:29 2010
@@ -37,6 +37,7 @@ import org.apache.zookeeper.PortAssignme
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.test.ClientBase;
+import org.junit.Assert;
 import org.junit.Test;
 
 
@@ -50,7 +51,6 @@ public class QuorumPeerMainTest extends 
      */
     @Test
     public void testQuorum() throws Exception {
-        LOG.info("STARTING " + getName());
         ClientBase.setupTestEnv();
 
         final int CLIENT_PORT_QP1 = PortAssignment.unique();
@@ -67,10 +67,10 @@ public class QuorumPeerMainTest extends 
         q1.start();
         q2.start();
 
-        assertTrue("waiting for server 1 being up",
+        Assert.assertTrue("waiting for server 1 being up",
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP1,
                         CONNECTION_TIMEOUT));
-        assertTrue("waiting for server 2 being up",
+        Assert.assertTrue("waiting for server 2 being up",
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP2,
                         CONNECTION_TIMEOUT));
 
@@ -80,7 +80,7 @@ public class QuorumPeerMainTest extends 
 
         zk.create("/foo_q1", "foobar1".getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        assertEquals(new String(zk.getData("/foo_q1", null, null)), "foobar1");
+        Assert.assertEquals(new String(zk.getData("/foo_q1", null, null)), "foobar1");
         zk.close();
 
         zk = new ZooKeeper("127.0.0.1:" + CLIENT_PORT_QP2,
@@ -88,16 +88,16 @@ public class QuorumPeerMainTest extends 
 
         zk.create("/foo_q2", "foobar2".getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        assertEquals(new String(zk.getData("/foo_q2", null, null)), "foobar2");
+        Assert.assertEquals(new String(zk.getData("/foo_q2", null, null)), "foobar2");
         zk.close();
 
         q1.shutdown();
         q2.shutdown();
 
-        assertTrue("waiting for server 1 down",
+        Assert.assertTrue("waiting for server 1 down",
                 ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT_QP1,
                         ClientBase.CONNECTION_TIMEOUT));
-        assertTrue("waiting for server 2 down",
+        Assert.assertTrue("waiting for server 2 down",
                 ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT_QP2,
                         ClientBase.CONNECTION_TIMEOUT));
     }
@@ -107,7 +107,6 @@ public class QuorumPeerMainTest extends 
      */
     @Test
     public void testBadPeerAddressInQuorum() throws Exception {
-        LOG.info("STARTING " + getName());
         ClientBase.setupTestEnv();
 
         // setup the logger to capture all logs
@@ -136,11 +135,11 @@ public class QuorumPeerMainTest extends 
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP1,
                         5000);
 
-            assertFalse("Server never came up", isup);
+            Assert.assertFalse("Server never came up", isup);
 
             q1.shutdown();
 
-            assertTrue("waiting for server 1 down",
+            Assert.assertTrue("waiting for server 1 down",
                     ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT_QP1,
                             ClientBase.CONNECTION_TIMEOUT));
 
@@ -159,7 +158,7 @@ public class QuorumPeerMainTest extends 
                 break;
             }
         }
-        assertTrue("complains about host", found);
+        Assert.assertTrue("complains about host", found);
     }
 
     /**
@@ -167,8 +166,8 @@ public class QuorumPeerMainTest extends 
      * at the quorum port
      * @throws Exception
      */
+    @Test
     public void testBadPackets() throws Exception {
-        LOG.info("STARTING " + getName());
         ClientBase.setupTestEnv();
         final int CLIENT_PORT_QP1 = PortAssignment.unique();
         final int CLIENT_PORT_QP2 = PortAssignment.unique();
@@ -185,10 +184,10 @@ public class QuorumPeerMainTest extends 
         q1.start();
         q2.start();
         
-        assertTrue("waiting for server 1 being up",
+        Assert.assertTrue("waiting for server 1 being up",
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP1,
                         CONNECTION_TIMEOUT));
-        assertTrue("waiting for server 2 being up",
+        Assert.assertTrue("waiting for server 2 being up",
                     ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP2,
                             CONNECTION_TIMEOUT));
             
@@ -210,7 +209,7 @@ public class QuorumPeerMainTest extends 
 
         zk.create("/foo_q1", "foobar1".getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        assertEquals(new String(zk.getData("/foo_q1", null, null)), "foobar1");
+        Assert.assertEquals(new String(zk.getData("/foo_q1", null, null)), "foobar1");
         zk.close();
         q1.shutdown();
         q2.shutdown();
@@ -223,7 +222,6 @@ public class QuorumPeerMainTest extends 
      */
     @Test
     public void testQuorumDefaults() throws Exception {
-        LOG.info("STARTING " + getName());
         ClientBase.setupTestEnv();
 
         // setup the logger to capture all logs
@@ -251,20 +249,20 @@ public class QuorumPeerMainTest extends 
             q1.start();
             q2.start();
 
-            assertTrue("waiting for server 1 being up",
+            Assert.assertTrue("waiting for server 1 being up",
                     ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP1,
                             CONNECTION_TIMEOUT));
-            assertTrue("waiting for server 2 being up",
+            Assert.assertTrue("waiting for server 2 being up",
                     ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP2,
                             CONNECTION_TIMEOUT));
 
             q1.shutdown();
             q2.shutdown();
 
-            assertTrue("waiting for server 1 down",
+            Assert.assertTrue("waiting for server 1 down",
                     ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT_QP1,
                             ClientBase.CONNECTION_TIMEOUT));
-            assertTrue("waiting for server 2 down",
+            Assert.assertTrue("waiting for server 2 down",
                     ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT_QP2,
                             ClientBase.CONNECTION_TIMEOUT));
 
@@ -283,7 +281,7 @@ public class QuorumPeerMainTest extends 
                 break;
             }
         }
-        assertTrue("fastleaderelection used", found);
+        Assert.assertTrue("fastleaderelection used", found);
     }
    
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java Wed Mar 31 04:26:29 2010
@@ -25,11 +25,10 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.test.ClientBase;
 import org.apache.zookeeper.test.QuorumBase;
 
@@ -37,7 +36,7 @@ import org.apache.zookeeper.test.QuorumB
  * Has some common functionality for tests that work with QuorumPeers.
  * Override process(WatchedEvent) to implement the Watcher interface
  */
-public class QuorumPeerTestBase extends TestCase implements Watcher {
+public class QuorumPeerTestBase extends ZKTestCase implements Watcher {
     protected static final Logger LOG =
         Logger.getLogger(QuorumPeerTestBase.class);
     

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLRootTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLRootTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLRootTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLRootTest.java Wed Mar 31 04:26:29 2010
@@ -23,35 +23,12 @@ import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Assert;
 import org.junit.Test;
 
-/**
- * Functional testing of asynchronous operations, both positive and negative
- * testing.
- * 
- * This just scratches the surface, but exercises the basic async functionality.
- */
 public class ACLRootTest extends ClientBase {
     private static final Logger LOG = Logger.getLogger(ACLRootTest.class);
 
-    @Before
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        
-        LOG.info("STARTING " + getName());
-    }
-
-    @After
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        
-        LOG.info("FINISHED " + getName());
-    }
-
     @Test
     public void testRootAcl() throws Exception {
         ZooKeeper zk = createClient();
@@ -65,14 +42,14 @@ public class ACLRootTest extends ClientB
             zk = createClient();
             try {
                 zk.getData("/", false, null);
-                fail("validate auth");
+                Assert.fail("validate auth");
             } catch (KeeperException.NoAuthException e) {
                 // expected
             }
             try {
                 zk.create("/apps", null, Ids.CREATOR_ALL_ACL,
                         CreateMode.PERSISTENT);
-                fail("validate auth");
+                Assert.fail("validate auth");
             } catch (KeeperException.InvalidACLException e) {
                 // expected
             }
@@ -80,7 +57,7 @@ public class ACLRootTest extends ClientB
             try {
                 zk.create("/apps", null, Ids.CREATOR_ALL_ACL,
                         CreateMode.PERSISTENT);
-                fail("validate auth");
+                Assert.fail("validate auth");
             } catch (KeeperException.NoAuthException e) {
                 // expected
             }
@@ -102,7 +79,7 @@ public class ACLRootTest extends ClientB
             try {
                 zk.create("/apps", null, Ids.CREATOR_ALL_ACL,
                         CreateMode.PERSISTENT);
-                fail("validate auth");
+                Assert.fail("validate auth");
             } catch (KeeperException.InvalidACLException e) {
                 // expected
             }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java Wed Mar 31 04:26:29 2010
@@ -26,13 +26,12 @@ import java.util.ArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 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.ZooDefs.Ids;
@@ -41,22 +40,16 @@ import org.apache.zookeeper.data.Id;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.SyncRequestProcessor;
 import org.apache.zookeeper.server.ZooKeeperServer;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class ACLTest extends TestCase implements Watcher {
+public class ACLTest extends ZKTestCase implements Watcher {
     private static final Logger LOG = Logger.getLogger(ACLTest.class);
     private static final String HOSTPORT =
         "127.0.0.1:" + PortAssignment.unique();
     private volatile CountDownLatch startSignal;
 
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
-    }
-    @Override
-    protected void tearDown() throws Exception {
-        LOG.info("FINISHED " + getName());
-    }
-
+    @Test
     public void testDisconnectedAddAuth() throws Exception {
         File tmpDir = ClientBase.createTmpDir();
         ClientBase.setupTestEnv();
@@ -67,7 +60,7 @@ public class ACLTest extends TestCase im
                 new InetSocketAddress(PORT));
         f.startup(zks);
         LOG.info("starting up the zookeeper server .. waiting");
-        assertTrue("waiting for server being up",
+        Assert.assertTrue("waiting for server being up",
                 ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
         ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
         try {
@@ -79,7 +72,7 @@ public class ACLTest extends TestCase im
 
         f.shutdown();
 
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                            ClientBase.CONNECTION_TIMEOUT));
     }
@@ -89,6 +82,7 @@ public class ACLTest extends TestCase im
      * a few acls and there references in the data
      * node is actually working.
      */
+    @Test
     public void testAcls() throws Exception {
         File tmpDir = ClientBase.createTmpDir();
         ClientBase.setupTestEnv();
@@ -99,7 +93,7 @@ public class ACLTest extends TestCase im
                 new InetSocketAddress(PORT));
         f.startup(zks);
         LOG.info("starting up the zookeeper server .. waiting");
-        assertTrue("waiting for server being up",
+        Assert.assertTrue("waiting for server being up",
                 ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
         ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
         String path;
@@ -109,7 +103,7 @@ public class ACLTest extends TestCase im
             zk.create(path, path.getBytes(), Ids.OPEN_ACL_UNSAFE,
                     CreateMode.PERSISTENT);
         }
-        assertTrue("size of the acl map ", (1 == zks.getZKDatabase().getAclSize()));
+        Assert.assertTrue("size of the acl map ", (1 == zks.getZKDatabase().getAclSize()));
         for (int j = 100; j < 200; j++) {
             path = "/" + j;
             ACL acl = new ACL();
@@ -122,10 +116,10 @@ public class ACLTest extends TestCase im
             list.add(acl);
             zk.create(path, path.getBytes(), list, CreateMode.PERSISTENT);
         }
-        assertTrue("size of the acl map ", (101 == zks.getZKDatabase().getAclSize()));
+        Assert.assertTrue("size of the acl map ", (101 == zks.getZKDatabase().getAclSize()));
         // now shutdown the server and restart it
         f.shutdown();
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                 ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
         startSignal = new CountDownLatch(1);
 
@@ -134,14 +128,14 @@ public class ACLTest extends TestCase im
 
         f.startup(zks);
 
-        assertTrue("waiting for server up",
+        Assert.assertTrue("waiting for server up",
                    ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
 
         startSignal.await(CONNECTION_TIMEOUT,
                 TimeUnit.MILLISECONDS);
-        assertTrue("count == 0", startSignal.getCount() == 0);
+        Assert.assertTrue("count == 0", startSignal.getCount() == 0);
 
-        assertTrue("acl map ", (101 == zks.getZKDatabase().getAclSize()));
+        Assert.assertTrue("acl map ", (101 == zks.getZKDatabase().getAclSize()));
         for (int j = 200; j < 205; j++) {
             path = "/" + j;
             ACL acl = new ACL();
@@ -154,13 +148,13 @@ public class ACLTest extends TestCase im
             list.add(acl);
             zk.create(path, path.getBytes(), list, CreateMode.PERSISTENT);
         }
-        assertTrue("acl map ", (106 == zks.getZKDatabase().getAclSize()));
+        Assert.assertTrue("acl map ", (106 == zks.getZKDatabase().getAclSize()));
 
         zk.close();
 
         f.shutdown();
 
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                            ClientBase.CONNECTION_TIMEOUT));
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncHammerTest.java Wed Mar 31 04:26:29 2010
@@ -23,13 +23,12 @@ import static org.apache.zookeeper.test.
 
 import java.util.LinkedList;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.TestableZooKeeper;
 import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.AsyncCallback.DataCallback;
 import org.apache.zookeeper.AsyncCallback.StringCallback;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
@@ -37,10 +36,11 @@ import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.test.ClientBase.CountdownWatcher;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public class AsyncHammerTest extends TestCase
+public class AsyncHammerTest extends ZKTestCase
     implements StringCallback, VoidCallback, DataCallback
 {
     private static final Logger LOG = Logger.getLogger(AsyncHammerTest.class);
@@ -50,14 +50,12 @@ public class AsyncHammerTest extends Tes
     private volatile boolean bang;
 
     @Before
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
+    public void setUp() throws Exception {
         qb.setUp();
     }
 
     protected void restart() throws Exception {
-        LOG.info("RESTARTING " + getName());
+        LOG.info("RESTARTING " + getTestName());
         qb.tearDown();
 
         // don't call setup - we don't want to reassign ports/dirs, etc...
@@ -66,11 +64,9 @@ public class AsyncHammerTest extends Tes
     }
 
     @After
-    @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         LOG.info("Test clients shutting down");
         qb.tearDown();
-        LOG.info("FINISHED " + getName());
     }
 
     /**
@@ -101,11 +97,11 @@ public class AsyncHammerTest extends Tes
                 }
             } catch (InterruptedException e) {
                 if (bang) {
-                    LOG.error("sanity check failed!!!"); // sanity check
+                    LOG.error("sanity check Assert.failed!!!"); // sanity check
                     return;
                 }
             } catch (Exception e) {
-                LOG.error("Client create operation failed", e);
+                LOG.error("Client create operation Assert.failed", e);
                 return;
             } finally {
                 if (zk != null) {
@@ -131,7 +127,7 @@ public class AsyncHammerTest extends Tes
 
         private synchronized void decOutstanding() {
             outstanding--;
-            assertTrue("outstanding >= 0", outstanding >= 0);
+            Assert.assertTrue("outstanding >= 0", outstanding >= 0);
             notifyAll();
         }
 
@@ -143,7 +139,7 @@ public class AsyncHammerTest extends Tes
             if (rc != KeeperException.Code.OK.intValue()) {
                 if (bang) {
                     failed = true;
-                    LOG.error("Create failed for 0x"
+                    LOG.error("Create Assert.failed for 0x"
                             + Long.toHexString(zk.getSessionId())
                             + "with rc:" + rc + " path:" + path);
                 }
@@ -156,7 +152,7 @@ public class AsyncHammerTest extends Tes
             } catch (Exception e) {
                 if (bang) {
                     failed = true;
-                    LOG.error("Client delete failed", e);
+                    LOG.error("Client delete Assert.failed", e);
                 }
             }
         }
@@ -165,7 +161,7 @@ public class AsyncHammerTest extends Tes
             if (rc != KeeperException.Code.OK.intValue()) {
                 if (bang) {
                     failed = true;
-                    LOG.error("Delete failed for 0x"
+                    LOG.error("Delete Assert.failed for 0x"
                             + Long.toHexString(zk.getSessionId())
                             + "with rc:" + rc + " path:" + path);
                 }
@@ -189,7 +185,7 @@ public class AsyncHammerTest extends Tes
         for (int i = 0; i < hammers.length; i++) {
             hammers[i].interrupt();
             verifyThreadTerminated(hammers[i], 60000);
-            assertFalse(hammers[i].failed);
+            Assert.assertFalse(hammers[i].failed);
         }
 
         // before restart
@@ -202,7 +198,7 @@ public class AsyncHammerTest extends Tes
         LOG.info("Verifying hammers 2");
         qb.verifyRootOfAllServersMatch(qb.hostPort);
     }
-    
+
     @Test
     public void testObserversHammer() throws Exception {
         qb.tearDown();
@@ -220,7 +216,7 @@ public class AsyncHammerTest extends Tes
             verifyThreadTerminated(hammers[i], 60000);
         }
         // before restart
-        qb.verifyRootOfAllServersMatch(qb.hostPort);          
+        qb.verifyRootOfAllServersMatch(qb.hostPort);
     }
 
     @SuppressWarnings("unchecked")

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOps.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOps.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOps.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOps.java Wed Mar 31 04:26:29 2010
@@ -18,10 +18,6 @@
 
 package org.apache.zookeeper.test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertSame;
-import static junit.framework.Assert.fail;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -31,8 +27,8 @@ import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.ACLCallback;
-import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
 import org.apache.zookeeper.AsyncCallback.Children2Callback;
+import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
 import org.apache.zookeeper.AsyncCallback.DataCallback;
 import org.apache.zookeeper.AsyncCallback.StatCallback;
 import org.apache.zookeeper.AsyncCallback.StringCallback;
@@ -41,22 +37,8 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
 
-/**
- * The intent of these classes is to support testing the functionality of
- * asynchronous client operations. Both positive as well as negative tests.
- * 
- * This code acts as a "contract checker" of sorts. We look at the 
- * actual output as well as the expected output - if the actual output 
- * changes over time this code should catch the regression and alert to a 
- * potentially unwanted (unexpected) change.
- * 
- * In addition these classes can be re-used by other tests that need to
- * perform these operations. In general the classes err on the side of
- * convention over a lot of setup - such that you can use start using them
- * w/o a lot of though (default path/data/acl/etc...). See AsyncOpsTest
- * for some good examples of use.
- */
 public class AsyncOps {
     /**
      * This is the base class for all of the async callback classes. It will
@@ -121,14 +103,14 @@ public class AsyncOps {
             try {
                 latch.await(defaultTimeoutMillis, TimeUnit.MILLISECONDS);
             } catch (InterruptedException e) {
-                fail("unexpected interrupt");
+                Assert.fail("unexpected interrupt");
             }
             // on the lookout for timeout
-            assertSame(0L, latch.getCount());
+            Assert.assertSame(0L, latch.getCount());
             
             String actual = toString();
             
-            assertEquals(expected, actual);
+            Assert.assertEquals(expected, actual);
         }
     }
     

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOpsTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOpsTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOpsTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncOpsTest.java Wed Mar 31 04:26:29 2010
@@ -23,8 +23,8 @@ import java.util.concurrent.CountDownLat
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.test.AsyncOps.ACLCB;
-import org.apache.zookeeper.test.AsyncOps.ChildrenCB;
 import org.apache.zookeeper.test.AsyncOps.Children2CB;
+import org.apache.zookeeper.test.AsyncOps.ChildrenCB;
 import org.apache.zookeeper.test.AsyncOps.DataCB;
 import org.apache.zookeeper.test.AsyncOps.StatCB;
 import org.apache.zookeeper.test.AsyncOps.StringCB;
@@ -33,12 +33,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-/**
- * Functional testing of asynchronous operations, both positive and negative
- * testing.
- *
- * This just scratches the surface, but exercises the basic async functionality.
- */
 public class AsyncOpsTest extends ClientBase {
     private static final Logger LOG = Logger.getLogger(AsyncOpsTest.class);
 
@@ -46,10 +40,10 @@ public class AsyncOpsTest extends Client
 
     @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         super.setUp();
 
-        LOG.info("STARTING " + getName());
+        LOG.info("Creating client " + getTestName());
 
         zk = createClient();
         zk.addAuthInfo("digest", "ben:passwd".getBytes());
@@ -57,14 +51,12 @@ public class AsyncOpsTest extends Client
 
     @After
     @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         zk.close();
 
         super.tearDown();
 
         LOG.info("Test clients shutting down");
-
-        LOG.info("FINISHED " + getName());
     }
 
     @Test

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AsyncTest.java Wed Mar 31 04:26:29 2010
@@ -25,13 +25,12 @@ import java.util.LinkedList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.DataCallback;
 import org.apache.zookeeper.AsyncCallback.StringCallback;
@@ -41,10 +40,11 @@ import org.apache.zookeeper.Watcher.Even
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public class AsyncTest extends TestCase
+public class AsyncTest extends ZKTestCase
     implements StringCallback, VoidCallback, DataCallback
 {
     private static final Logger LOG = Logger.getLogger(AsyncTest.class);
@@ -52,23 +52,19 @@ public class AsyncTest extends TestCase
     private QuorumBase qb = new QuorumBase();
 
     @Before
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
+    public void setUp() throws Exception {
         qb.setUp();
     }
 
-    protected void restart() throws Exception {
+    public void restart() throws Exception {
         JMXEnv.setUp();
         qb.startServers();
     }
 
     @After
-    @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         LOG.info("Test clients shutting down");
         qb.tearDown();
-        LOG.info("FINISHED " + getName());
     }
 
     private static class CountdownWatcher implements Watcher {
@@ -93,7 +89,7 @@ public class AsyncTest extends TestCase
         if(!watcher.clientConnected.await(CONNECTION_TIMEOUT,
                 TimeUnit.MILLISECONDS))
         {
-            fail("Unable to connect to server");
+            Assert.fail("Unable to connect to server");
         }
         return zk;
     }
@@ -117,11 +113,11 @@ public class AsyncTest extends TestCase
                     results.wait();
                 }
             }
-            assertEquals(0, (int) results.get(0));
-            assertEquals(Code.NOAUTH, Code.get(results.get(1)));
-            assertEquals(0, (int) results.get(2));
-            assertEquals(0, (int) results.get(3));
-            assertEquals(0, (int) results.get(4));
+            Assert.assertEquals(0, (int) results.get(0));
+            Assert.assertEquals(Code.NOAUTH, Code.get(results.get(1)));
+            Assert.assertEquals(0, (int) results.get(2));
+            Assert.assertEquals(0, (int) results.get(3));
+            Assert.assertEquals(0, (int) results.get(4));
         } finally {
             zk.close();
         }
@@ -131,9 +127,9 @@ public class AsyncTest extends TestCase
             zk.addAuthInfo("digest", "ben:passwd2".getBytes());
             try {
                 zk.getData("/ben2", false, new Stat());
-                fail("Should have received a permission error");
+                Assert.fail("Should have received a permission error");
             } catch (KeeperException e) {
-                assertEquals(Code.NOAUTH, e.code());
+                Assert.assertEquals(Code.NOAUTH, e.code());
             }
         } finally {
             zk.close();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AuthTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AuthTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AuthTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/AuthTest.java Wed Mar 31 04:26:29 2010
@@ -22,6 +22,7 @@ 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 AuthTest extends ClientBase {
@@ -43,27 +44,27 @@ public class AuthTest extends ClientBase
             zk = createClient();
             try {
                 zk.getData("/path1", false, null);
-                fail("auth verification");
+                Assert.fail("auth verification");
             } catch (KeeperException.NoAuthException e) {
                 // expected
             }
             zk.close();
-            // verify bad pass fails
+            // verify bad pass Assert.fails
             zk = createClient();
             zk.addAuthInfo("digest", "pat:pass2".getBytes());
             try {
                 zk.getData("/path1", false, null);
-                fail("auth verification");
+                Assert.fail("auth verification");
             } catch (KeeperException.NoAuthException e) {
                 // expected
             }
             zk.close();
-            // verify super with bad pass fails
+            // verify super with bad pass Assert.fails
             zk = createClient();
             zk.addAuthInfo("digest", "super:test2".getBytes());
             try {
                 zk.getData("/path1", false, null);
-                fail("auth verification");
+                Assert.fail("auth verification");
             } catch (KeeperException.NoAuthException e) {
                 // expected
             }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootAsyncTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootAsyncTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootAsyncTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootAsyncTest.java Wed Mar 31 04:26:29 2010
@@ -22,20 +22,18 @@ import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
-import org.junit.Before;
 
 public class ChrootAsyncTest extends AsyncOpsTest {
     private static final Logger LOG = Logger.getLogger(ChrootAsyncTest.class);
 
-    @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         String hp = hostPort;
         hostPort = hostPort + "/chrootasynctest";
 
         super.setUp();
 
-        LOG.info("STARTING " + getName());
+        LOG.info("Creating client " + getTestName());
 
         ZooKeeper zk = createClient(hp);
         try {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootClientTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootClientTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootClientTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootClientTest.java Wed Mar 31 04:26:29 2010
@@ -22,22 +22,20 @@ import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
-import org.junit.Before;
 import org.junit.Test;
 
 public class ChrootClientTest extends ClientTest {
     private static final Logger LOG = Logger.getLogger(ChrootClientTest.class);
 
-    @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         String hp = hostPort;
         hostPort = hostPort + "/chrootclienttest";
 
         System.out.println(hostPort);
         super.setUp();
 
-        LOG.info("STARTING " + getName());
+        LOG.info("STARTING " + getTestName());
 
         ZooKeeper zk = createClient(hp);
         try {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ChrootTest.java Wed Mar 31 04:26:29 2010
@@ -29,6 +29,8 @@ import org.apache.zookeeper.WatchedEvent
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
+import org.junit.Assert;
+import org.junit.Test;
 
 public class ChrootTest extends ClientBase {
     private class MyWatcher implements Watcher {
@@ -46,12 +48,13 @@ public class ChrootTest extends ClientBa
         }
         public boolean matches() throws InterruptedException {
             if (!latch.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)) {
-                fail("No watch received within timeout period " + path);
+                Assert.fail("No watch received within timeout period " + path);
             }
             return path.equals(eventPath);
         }
     }
 
+    @Test
     public void testChrootSynchronous()
         throws IOException, InterruptedException, KeeperException
     {
@@ -65,7 +68,7 @@ public class ChrootTest extends ClientBa
         }
         ZooKeeper zk2 = createClient(hostPort + "/ch1");
         try {
-            assertEquals("/ch2",
+            Assert.assertEquals("/ch2",
                     zk2.create("/ch2", null, Ids.OPEN_ACL_UNSAFE,
                             CreateMode.PERSISTENT));
         } finally {
@@ -78,12 +81,12 @@ public class ChrootTest extends ClientBa
         try {
             // check get
             MyWatcher w1 = new MyWatcher("/ch1");
-            assertNotNull(zk1.exists("/ch1", w1));
+            Assert.assertNotNull(zk1.exists("/ch1", w1));
             MyWatcher w2 = new MyWatcher("/ch1/ch2");
-            assertNotNull(zk1.exists("/ch1/ch2", w2));
+            Assert.assertNotNull(zk1.exists("/ch1/ch2", w2));
 
             MyWatcher w3 = new MyWatcher("/ch2");
-            assertNotNull(zk2.exists("/ch2", w3));
+            Assert.assertNotNull(zk2.exists("/ch2", w3));
             
             // set watches on child
             MyWatcher w4 = new MyWatcher("/ch1");
@@ -96,33 +99,33 @@ public class ChrootTest extends ClientBa
             zk2.setData("/ch2", "2".getBytes(), -1);
 
             // check watches
-            assertTrue(w1.matches());
-            assertTrue(w2.matches());
-            assertTrue(w3.matches());
+            Assert.assertTrue(w1.matches());
+            Assert.assertTrue(w2.matches());
+            Assert.assertTrue(w3.matches());
 
             // check exceptions
             try {
                 zk2.setData("/ch3", "3".getBytes(), -1);
             } catch (KeeperException.NoNodeException e) {
-                assertEquals("/ch3", e.getPath());
+                Assert.assertEquals("/ch3", e.getPath());
             }
 
-            assertTrue(Arrays.equals("1".getBytes(),
+            Assert.assertTrue(Arrays.equals("1".getBytes(),
                     zk1.getData("/ch1", false, null)));
-            assertTrue(Arrays.equals("2".getBytes(),
+            Assert.assertTrue(Arrays.equals("2".getBytes(),
                     zk1.getData("/ch1/ch2", false, null)));
-            assertTrue(Arrays.equals("2".getBytes(),
+            Assert.assertTrue(Arrays.equals("2".getBytes(),
                     zk2.getData("/ch2", false, null)));
 
             // check delete
             zk2.delete("/ch2", -1);
-            assertTrue(w4.matches());
-            assertTrue(w5.matches());
+            Assert.assertTrue(w4.matches());
+            Assert.assertTrue(w5.matches());
             
             zk1.delete("/ch1", -1);
-            assertNull(zk1.exists("/ch1", false));
-            assertNull(zk1.exists("/ch1/ch2", false));
-            assertNull(zk2.exists("/ch2", false));
+            Assert.assertNull(zk1.exists("/ch1", false));
+            Assert.assertNull(zk1.exists("/ch1/ch2", false));
+            Assert.assertNull(zk2.exists("/ch2", false));
         } finally {
             if(zk1 != null)
                 zk1.close();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java Wed Mar 31 04:26:29 2010
@@ -39,24 +39,26 @@ import java.util.concurrent.TimeoutExcep
 
 import javax.management.MBeanServerConnection;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 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.ZKTestCase;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZKDatabase;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.persistence.FileTxnLog;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
 
 import com.sun.management.UnixOperatingSystemMXBean;
 
-public abstract class ClientBase extends TestCase {
+public abstract class ClientBase extends ZKTestCase {
     protected static final Logger LOG = Logger.getLogger(ClientBase.class);
 
     public static int CONNECTION_TIMEOUT = 30000;
@@ -162,12 +164,12 @@ public abstract class ClientBase extends
         TestableZooKeeper zk = new TestableZooKeeper(hp, timeout, watcher);
         if (!watcher.clientConnected.await(timeout, TimeUnit.MILLISECONDS))
         {
-            fail("Unable to connect to server");
+            Assert.fail("Unable to connect to server");
         }
         synchronized(this) {
             if (!allClientsSetup) {
                 LOG.error("allClients never setup");
-                fail("allClients never setup");
+                Assert.fail("allClients never setup");
             }
             if (allClients != null) {
                 allClients.add(zk);
@@ -297,7 +299,7 @@ public abstract class ClientBase extends
         if (thread.isAlive()) {
             LOG.error("Thread " + thread.getName() + " : "
                     + Arrays.toString(thread.getStackTrace()));
-            assertFalse("thread " + thread.getName()
+            Assert.assertFalse("thread " + thread.getName()
                     + " still alive after join", true);
         }
     }
@@ -311,8 +313,8 @@ public abstract class ClientBase extends
         // don't delete tmpFile - this ensures we don't attempt to create
         // a tmpDir with a duplicate name
         File tmpDir = new File(tmpFile + ".dir");
-        assertFalse(tmpDir.exists()); // never true if tmpfile does it's job
-        assertTrue(tmpDir.mkdirs());
+        Assert.assertFalse(tmpDir.exists()); // never true if tmpfile does it's job
+        Assert.assertTrue(tmpDir.mkdirs());
 
         return tmpDir;
     }
@@ -336,7 +338,7 @@ public abstract class ClientBase extends
             factory = new NIOServerCnxn.Factory(new InetSocketAddress(PORT),maxCnxns);
         }
         factory.startup(zks);
-        assertTrue("waiting for server up",
+        Assert.assertTrue("waiting for server up",
                    ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                                               CONNECTION_TIMEOUT));
 
@@ -345,18 +347,18 @@ public abstract class ClientBase extends
 
     static void shutdownServerInstance(NIOServerCnxn.Factory factory,
             String hostPort)
-    {    	
-    	if (factory != null) {
-    	    ZKDatabase zkDb = factory.getZooKeeperServer().getZKDatabase();
+    {
+        if (factory != null) {
+            ZKDatabase zkDb = factory.getZooKeeperServer().getZKDatabase();
             factory.shutdown();
             try {
                 zkDb.close();
             } catch (IOException ie) {
                 LOG.warn("Error closing logs ", ie);
-       	 	}
+            }
             final int PORT = getPort(hostPort);
 
-            assertTrue("waiting for server down",
+            Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                     CONNECTION_TIMEOUT));
         }
@@ -368,7 +370,7 @@ public abstract class ClientBase extends
     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 failure (client timeout on first session).
+        // 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");
         FileTxnLog.setPreallocSize(100 * 1024);
@@ -379,9 +381,8 @@ public abstract class ClientBase extends
         allClientsSetup = true;
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
+    @Before
+    public void setUp() throws Exception {
         setupTestEnv();
 
         JMXEnv.setUp();
@@ -438,8 +439,8 @@ public abstract class ClientBase extends
         }
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         LOG.info("tearDown starting");
 
         /* some useful information - log the number of fds used before
@@ -461,15 +462,13 @@ public abstract class ClientBase extends
         stopServer();
 
         if (tmpDir != null) {
-            assertTrue("delete " + tmpDir.toString(), recursiveDelete(tmpDir));
+            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();
-
-        LOG.info("FINISHED " + getName());
     }
 
     public static MBeanServerConnection jmxConn() throws IOException {
@@ -480,7 +479,7 @@ public abstract class ClientBase extends
         if (d.isDirectory()) {
             File children[] = d.listFiles();
             for (File f : children) {
-                assertTrue("delete " + f.toString(), recursiveDelete(f));
+                Assert.assertTrue("delete " + f.toString(), recursiveDelete(f));
             }
         }
         return d.delete();
@@ -519,7 +518,7 @@ public abstract class ClientBase extends
             for (String hp : parts) {
                 try {
                     ZooKeeper zk = createClient(hp);
-                   
+
                     try {
                         newcounts[i++] = zk.getChildren("/", false).size();
                     } finally {
@@ -527,7 +526,7 @@ public abstract class ClientBase extends
                     }
                 } catch (Throwable t) {
                     failed++;
-                    // if session creation fails dump the thread stack
+                    // if session creation Assert.fails dump the thread stack
                     // and try the next server
                     logAllStackTraces();
                 }
@@ -542,8 +541,8 @@ public abstract class ClientBase extends
                 counts = newcounts;
                 Thread.sleep(10000);
             }
-            
-            // don't keep this up too long, will assert false below
+
+            // don't keep this up too long, will Assert.assert false below
             if (failed > 10) {
                 break;
             }
@@ -551,7 +550,7 @@ public abstract class ClientBase extends
 
         // verify all the servers reporting same number of nodes
         for (int i = 1; i < parts.length; i++) {
-            assertEquals("node count not consistent", counts[i-1], counts[i]);
+            Assert.assertEquals("node count not consistent", counts[i-1], counts[i]);
         }
     }
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientHammerTest.java Wed Mar 31 04:26:29 2010
@@ -27,16 +27,12 @@ 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 = Logger.getLogger(ClientHammerTest.class);
 
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        LOG.info("FINISHED " + getName());
-    }
     private static final long HAMMERTHREAD_LATENCY = 5;
 
     private static abstract class HammerThread extends Thread {
@@ -68,7 +64,7 @@ public class ClientHammerTest extends Cl
                     zk.create(prefix + current, b, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
                 }
             } catch (Throwable t) {
-                LOG.error("Client create operation failed", t);
+                LOG.error("Client create operation Assert.failed", t);
             } finally {
                 try {
                     zk.close();
@@ -107,7 +103,7 @@ public class ClientHammerTest extends Cl
                     }
                 }
             } catch (Throwable t) {
-                LOG.error("Client create operation failed", t);
+                LOG.error("Client create operation Assert.failed", t);
             }
         }
     }
@@ -143,7 +139,7 @@ public class ClientHammerTest extends Cl
 
             verifyHammer(start, threads, childCount);
         } catch (Throwable t) {
-            LOG.error("test failed", t);
+            LOG.error("test Assert.failed", t);
             throw t;
         }
     }
@@ -182,7 +178,7 @@ public class ClientHammerTest extends Cl
 
             verifyHammer(start, threads, childCount);
         } catch (Throwable t) {
-            LOG.error("test failed", t);
+            LOG.error("test Assert.failed", t);
             throw t;
         }
     }
@@ -230,16 +226,16 @@ public class ClientHammerTest extends Cl
                 LOG.info("Doing thread: " + i + " " + new Date());
                 List<String> children =
                     zk.getChildren("/test-" + i, false);
-                assertEquals(childCount, children.size());
+                Assert.assertEquals(childCount, children.size());
                 children = zk.getChildren("/test-" + i, false, null);
-                assertEquals(childCount, children.size());
+                Assert.assertEquals(childCount, children.size());
             }
             for (int i = 0; i < threads.length; i++) {
                 List<String> children =
                     zk.getChildren("/test-" + i, false);
-                assertEquals(childCount, children.size());
+                Assert.assertEquals(childCount, children.size());
                 children = zk.getChildren("/test-" + i, false, null);
-                assertEquals(childCount, children.size());
+                Assert.assertEquals(childCount, children.size());
             }
         } finally {
             zk.close();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java Wed Mar 31 04:26:29 2010
@@ -28,37 +28,28 @@ import java.util.Enumeration;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import junit.framework.TestCase;
-
 import org.apache.log4j.Logger;
 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.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
+import org.junit.Assert;
 import org.junit.Test;
 
-public class ClientPortBindTest extends TestCase implements Watcher {
+public class ClientPortBindTest extends ZKTestCase implements Watcher {
     protected static final Logger LOG = 
         Logger.getLogger(ClientPortBindTest.class);
 
     private volatile CountDownLatch startSignal;
 
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
-    }
-    @Override
-    protected void tearDown() throws Exception {
-        LOG.info("FINISHED " + getName());
-    }
-
-    @Test
     /**
      * Verify that the server binds to the specified address
      */
+    @Test
     public void testBindByAddress() throws Exception {
         String bindAddress = null;
         Enumeration<NetworkInterface> intfs =
@@ -96,7 +87,7 @@ public class ClientPortBindTest extends 
         f.startup(zks);
         LOG.info("starting up the the server, waiting");
 
-        assertTrue("waiting for server up",
+        Assert.assertTrue("waiting for server up",
                    ClientBase.waitForServerUp(HOSTPORT,
                                    CONNECTION_TIMEOUT));
 
@@ -105,12 +96,12 @@ public class ClientPortBindTest extends 
         try {
             startSignal.await(CONNECTION_TIMEOUT,
                     TimeUnit.MILLISECONDS);
-            assertTrue("count == 0", startSignal.getCount() == 0);
+            Assert.assertTrue("count == 0", startSignal.getCount() == 0);
             zk.close();
         } finally {
             f.shutdown();
 
-            assertTrue("waiting for server down",
+            Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
                                                     CONNECTION_TIMEOUT));
         }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientRetry.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientRetry.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientRetry.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientRetry.java Wed Mar 31 04:26:29 2010
@@ -22,25 +22,29 @@ import java.util.concurrent.TimeoutExcep
 
 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();     
+        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 
+     * 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 
+     * 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. 
+     * 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();
@@ -51,12 +55,12 @@ public class ClientRetry extends ClientB
             try {
                 States s1 = zk.getState();
                 States s2 = zk2.getState();
-                assertSame(s1,States.CONNECTED);
-                assertSame(s2,States.CONNECTING);
+                Assert.assertSame(s1,States.CONNECTED);
+                Assert.assertSame(s2,States.CONNECTING);
                 cdw1.reset();
                 cdw1.waitForDisconnected(CONNECTION_TIMEOUT);
                 cdw2.waitForConnected(CONNECTION_TIMEOUT);
-                assertSame(zk2.getState(),States.CONNECTED);
+                Assert.assertSame(zk2.getState(),States.CONNECTED);
             } finally {
                 zk2.close();
             }
@@ -65,4 +69,4 @@ public class ClientRetry extends ClientB
         }
     }
 }
-           
+



Mime
View raw message