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 [3/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
Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NullDataTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NullDataTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NullDataTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/NullDataTest.java Wed Mar 31 04:26:29 2010
@@ -28,13 +28,15 @@ import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.StatCallback;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
+import org.junit.Test;
 
 public class NullDataTest extends ClientBase implements StatCallback {
     String snapCount;
     CountDownLatch cn = new CountDownLatch(1);
     
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         // Change the snapcount to happen more often
         snapCount = System.getProperty("zookeeper.snapCount", "1024");
         System.setProperty("zookeeper.snapCount", "10");
@@ -42,11 +44,12 @@ public class NullDataTest extends Client
     }
     
     @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         System.setProperty("zookeeper.snapCount", snapCount);
         super.tearDown();
     }
     
+    @Test
     public void testNullData() throws IOException, 
         InterruptedException, KeeperException {
         String path = "/SIZE";
@@ -58,7 +61,7 @@ public class NullDataTest extends Client
             zk.exists(path, false);
             zk.exists(path, false, this , null);
             cn.await(10, TimeUnit.SECONDS);
-            assertSame(0L, cn.getCount());
+            Assert.assertSame(0L, cn.getCount());
         } finally {
             if(zk != null)
                 zk.close();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/OOMTest.java Wed Mar 31 04:26:29 2010
@@ -25,24 +25,21 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
 
-import junit.framework.TestCase;
-
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 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.data.Stat;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
+import org.junit.Assert;
 import org.junit.Test;
 
-/**
- *
- */
-public class OOMTest extends TestCase implements Watcher {
+public class OOMTest extends ZKTestCase implements Watcher {
     @Test
     public void testOOM() throws IOException, InterruptedException, KeeperException {
         // This test takes too long to run!
@@ -67,7 +64,7 @@ public class OOMTest extends TestCase im
         NIOServerCnxn.Factory f = new NIOServerCnxn.Factory(
                 new InetSocketAddress(PORT));
         f.startup(zks);
-        assertTrue("waiting for server up",
+        Assert.assertTrue("waiting for server up",
                    ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                                               CONNECTION_TIMEOUT));
 
@@ -103,7 +100,7 @@ public class OOMTest extends TestCase im
         hog.get(0)[0] = (byte) 1;
 
         f.shutdown();
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                 CONNECTION_TIMEOUT));
     }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverHierarchicalQuorumTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverHierarchicalQuorumTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverHierarchicalQuorumTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverHierarchicalQuorumTest.java Wed Mar 31 04:26:29 2010
@@ -21,11 +21,6 @@ import org.apache.log4j.Logger;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.junit.Test;
 
-/**
- * Mimics QuorumHierarchical test, but on an ensemble that includes 2 
- * observers.
- */
-
 public class ObserverHierarchicalQuorumTest extends HierarchicalQuorumTest {
     private static final Logger LOG = Logger.getLogger(QuorumBase.class);
        

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverQuorumHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverQuorumHammerTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverQuorumHammerTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverQuorumHammerTest.java Wed Mar 31 04:26:29 2010
@@ -20,16 +20,13 @@ package org.apache.zookeeper.test;
 import org.junit.Before;
 import org.junit.Test;
 
-/**
- * Mimics QuorumHammerTest, but with 2 observers in the 5 Learner ensemble.
- */
 public class ObserverQuorumHammerTest extends QuorumHammerTest {
     public static final long CONNECTION_TIMEOUT = ClientTest.CONNECTION_TIMEOUT;
 
     
     @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         qb.setUp(true);
         cht.hostPort = qb.hostPort;
         cht.setUpAll();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ObserverTest.java Wed Mar 31 04:26:29 2010
@@ -34,12 +34,9 @@ import org.apache.zookeeper.Watcher.Even
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.ZooKeeper.States;
 import org.apache.zookeeper.server.quorum.QuorumPeerTestBase;
+import org.junit.Assert;
 import org.junit.Test;
 
-/**
- * Test Observer behaviour and specific code paths.
- *
- */
 public class ObserverTest extends QuorumPeerTestBase implements Watcher{
     protected static final Logger LOG =
         Logger.getLogger(ObserverTest.class);    
@@ -89,13 +86,13 @@ public class ObserverTest extends Quorum
         q1.start();
         q2.start();
         q3.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));
-        assertTrue("waiting for server 3 being up",
+        Assert.assertTrue("waiting for server 3 being up",
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_OBS,
                         CONNECTION_TIMEOUT));        
         
@@ -105,29 +102,29 @@ public class ObserverTest extends Quorum
                 CreateMode.PERSISTENT);
         
         // Assert that commands are getting forwarded correctly
-        assertEquals(new String(zk.getData("/obstest", null, null)), "test");
+        Assert.assertEquals(new String(zk.getData("/obstest", null, null)), "test");
         
         // Now check that other commands don't blow everything up
         zk.sync("/", null, null);
         zk.setData("/obstest", "test2".getBytes(), -1);
         zk.getChildren("/", false);
         
-        assertEquals(zk.getState(), States.CONNECTED);
+        Assert.assertEquals(zk.getState(), States.CONNECTED);
         
         // Now kill one of the other real servers        
         q2.shutdown();
                 
-        assertTrue("Waiting for server 2 to shut down",
+        Assert.assertTrue("Waiting for server 2 to shut down",
                     ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_QP2, 
                                     ClientBase.CONNECTION_TIMEOUT));
         
         // Now the resulting ensemble shouldn't be quorate         
         latch.await();        
-        assertNotSame("Client is still connected to non-quorate cluster", 
+        Assert.assertNotSame("Client is still connected to non-quorate cluster", 
                 KeeperState.SyncConnected,lastEvent.getState());
 
         try {
-            assertFalse("Shouldn't get a response when cluster not quorate!",
+            Assert.assertFalse("Shouldn't get a response when cluster not quorate!",
                     new String(zk.getData("/obstest", null, null)).equals("test"));
         }
         catch (ConnectionLossException c) {
@@ -140,14 +137,14 @@ public class ObserverTest extends Quorum
         q2 = new MainThread(2, CLIENT_PORT_QP2, quorumCfgSection);
         q2.start();
         LOG.info("Waiting for server 2 to come up");
-        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));
         
         latch.await();
         // It's possible our session expired - but this is ok, shows we 
         // were able to talk to the ensemble
-        assertTrue("Client didn't reconnect to quorate ensemble (state was" +
+        Assert.assertTrue("Client didn't reconnect to quorate ensemble (state was" +
                 lastEvent.getState() + ")",
                 (KeeperState.SyncConnected==lastEvent.getState() ||
                 KeeperState.Expired==lastEvent.getState())); 
@@ -157,13 +154,13 @@ public class ObserverTest extends Quorum
         q3.shutdown();
         
         zk.close();        
-        assertTrue("Waiting for server 1 to shut down",
+        Assert.assertTrue("Waiting for server 1 to shut down",
                 ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_QP1, 
                                 ClientBase.CONNECTION_TIMEOUT));
-        assertTrue("Waiting for server 2 to shut down",
+        Assert.assertTrue("Waiting for server 2 to shut down",
                 ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_QP2, 
                                 ClientBase.CONNECTION_TIMEOUT));
-        assertTrue("Waiting for server 3 to shut down",
+        Assert.assertTrue("Waiting for server 3 to shut down",
                 ClientBase.waitForServerDown("127.0.0.1:"+CLIENT_PORT_OBS, 
                                 ClientBase.CONNECTION_TIMEOUT));
     
@@ -195,7 +192,7 @@ public class ObserverTest extends Quorum
                     
         MainThread q1 = new MainThread(1, CLIENT_PORT_QP1, quorumCfgSection);
         q1.start();
-        assertFalse("Observer shouldn't come up",
+        Assert.assertFalse("Observer shouldn't come up",
                 ClientBase.waitForServerUp("127.0.0.1:" + CLIENT_PORT_QP1,
                                             CONNECTION_TIMEOUT));
         

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/PurgeTxnTest.java Wed Mar 31 04:26:29 2010
@@ -22,12 +22,11 @@ import java.io.File;
 import java.net.InetSocketAddress;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 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.server.NIOServerCnxn;
@@ -35,12 +34,10 @@ import org.apache.zookeeper.server.Purge
 import org.apache.zookeeper.server.SyncRequestProcessor;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
+import org.junit.Assert;
+import org.junit.Test;
 
-/**
- * test the purging of the logs
- * and purging of the snapshots.
- */
-public class PurgeTxnTest extends TestCase implements  Watcher {
+public class PurgeTxnTest extends ZKTestCase implements  Watcher {
     //private static final Logger LOG = Logger.getLogger(PurgeTxnTest.class);
     private static String HOSTPORT = "127.0.0.1:" + PortAssignment.unique();
     private static final int CONNECTION_TIMEOUT = 3000;
@@ -48,6 +45,7 @@ public class PurgeTxnTest extends TestCa
      * test the purge
      * @throws Exception an exception might be thrown here
      */
+    @Test
     public void testPurge() throws Exception {
         File tmpDir = ClientBase.createTmpDir();
         ClientBase.setupTestEnv();
@@ -57,7 +55,7 @@ public class PurgeTxnTest extends TestCa
         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 {
@@ -69,7 +67,7 @@ public class PurgeTxnTest extends TestCa
             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
         PurgeTxnLog.purge(tmpDir, tmpDir, 3);
@@ -81,7 +79,7 @@ public class PurgeTxnTest extends TestCa
                 numSnaps++;
             }
         }
-        assertTrue("exactly 3 snapshots ", (numSnaps == 3));
+        Assert.assertTrue("exactly 3 snapshots ", (numSnaps == 3));
     }
 
     public void process(WatchedEvent event) {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumBase.java Wed Mar 31 04:26:29 2010
@@ -34,7 +34,7 @@ import org.apache.zookeeper.server.quoru
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.LearnerType;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
-import org.junit.After;
+import org.junit.Assert;
 
 import com.sun.management.UnixOperatingSystemMXBean;
 
@@ -56,12 +56,12 @@ public class QuorumBase extends ClientBa
     private int portLE5;
 
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         setUp(false);
     }
         
     protected void setUp(boolean withObservers) throws Exception {
-        LOG.info("STARTING " + getName());
+        LOG.info("QuorumBase.setup " + getTestName());
         setupTestEnv();
 
         JMXEnv.setUp();
@@ -144,19 +144,19 @@ public class QuorumBase extends ClientBa
 
         LOG.info("creating QuorumPeer 1 port " + port1);
         s1 = new QuorumPeer(peers, s1dir, s1dir, port1, 3, 1, tickTime, initLimit, syncLimit);
-        assertEquals(port1, s1.getClientPort());
+        Assert.assertEquals(port1, s1.getClientPort());
         LOG.info("creating QuorumPeer 2 port " + port2);
         s2 = new QuorumPeer(peers, s2dir, s2dir, port2, 3, 2, tickTime, initLimit, syncLimit);
-        assertEquals(port2, s2.getClientPort());
+        Assert.assertEquals(port2, s2.getClientPort());
         LOG.info("creating QuorumPeer 3 port " + port3);
         s3 = new QuorumPeer(peers, s3dir, s3dir, port3, 3, 3, tickTime, initLimit, syncLimit);
-        assertEquals(port3, s3.getClientPort());
+        Assert.assertEquals(port3, s3.getClientPort());
         LOG.info("creating QuorumPeer 4 port " + port4);
         s4 = new QuorumPeer(peers, s4dir, s4dir, port4, 3, 4, tickTime, initLimit, syncLimit);
-        assertEquals(port4, s4.getClientPort());
+        Assert.assertEquals(port4, s4.getClientPort());
         LOG.info("creating QuorumPeer 5 port " + port5);
         s5 = new QuorumPeer(peers, s5dir, s5dir, port5, 3, 5, tickTime, initLimit, syncLimit);
-        assertEquals(port5, s5.getClientPort());
+        Assert.assertEquals(port5, s5.getClientPort());
         
         if (withObservers) {
             s4.setPeerType(LearnerType.OBSERVER);
@@ -177,7 +177,7 @@ public class QuorumBase extends ClientBa
 
         LOG.info ("Checking ports " + hostPort);
         for (String hp : hostPort.split(",")) {
-            assertTrue("waiting for server up",
+            Assert.assertTrue("waiting for server up",
                        ClientBase.waitForServerUp(hp,
                                     CONNECTION_TIMEOUT));
             LOG.info(hp + " is accepting client connections");
@@ -234,24 +234,23 @@ public class QuorumBase extends ClientBa
         
         LOG.info("creating QuorumPeer 1 port " + port1);
         s1 = new QuorumPeer(peers, s1dir, s1dir, port1, 3, 1, tickTime, initLimit, syncLimit);
-        assertEquals(port1, s1.getClientPort());
+        Assert.assertEquals(port1, s1.getClientPort());
         LOG.info("creating QuorumPeer 2 port " + port2);
         s2 = new QuorumPeer(peers, s2dir, s2dir, port2, 3, 2, tickTime, initLimit, syncLimit);
-        assertEquals(port2, s2.getClientPort());
+        Assert.assertEquals(port2, s2.getClientPort());
         LOG.info("creating QuorumPeer 3 port " + port3);
         s3 = new QuorumPeer(peers, s3dir, s3dir, port3, 3, 3, tickTime, initLimit, syncLimit);
-        assertEquals(port3, s3.getClientPort());
+        Assert.assertEquals(port3, s3.getClientPort());
         LOG.info("creating QuorumPeer 4 port " + port4);
         s4 = new QuorumPeer(peers, s4dir, s4dir, port4, 3, 4, tickTime, initLimit, syncLimit);
-        assertEquals(port4, s4.getClientPort());
+        Assert.assertEquals(port4, s4.getClientPort());
         LOG.info("creating QuorumPeer 5 port " + port5);
         s5 = new QuorumPeer(peers, s5dir, s5dir, port5, 3, 5, tickTime, initLimit, syncLimit);
-        assertEquals(port5, s5.getClientPort());
+        Assert.assertEquals(port5, s5.getClientPort());
     }
 
-    @After
     @Override
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         LOG.info("TearDown started");
         
         OperatingSystemMXBean osMbean =
@@ -266,15 +265,13 @@ public class QuorumBase extends ClientBa
         shutdownServers();
 
         for (String hp : hostPort.split(",")) {
-            assertTrue("waiting for server down",
+            Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(hp,
                                            ClientBase.CONNECTION_TIMEOUT));
             LOG.info(hp + " is no longer accepting client connections");
         }
 
         JMXEnv.tearDown();
-
-        LOG.info("FINISHED " + getName());
     }
     public void shutdownServers() {
         shutdown(s1);
@@ -298,7 +295,7 @@ public class QuorumBase extends ClientBa
             LOG.info("Waiting for " + qp.getName() + " to exit thread");
             qp.join(30000);
             if (qp.isAlive()) {
-                fail("QP failed to shutdown in 30 seconds: " + qp.getName());
+                Assert.fail("QP failed to shutdown in 30 seconds: " + qp.getName());
             }
         } catch (InterruptedException e) {
             LOG.debug("QP interrupted: " + qp.getName(), e);

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumHammerTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumHammerTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumHammerTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumHammerTest.java Wed Mar 31 04:26:29 2010
@@ -18,6 +18,7 @@
 
 package org.apache.zookeeper.test;
 import org.apache.log4j.Logger;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -30,17 +31,19 @@ public class QuorumHammerTest extends Qu
 
     @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         qb.setUp();
         cht.hostPort = qb.hostPort;
         cht.setUpAll();
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    @Override
+    public void tearDown() throws Exception {
         cht.tearDownAll();
         qb.tearDown();
     }
-    
+
     @Test
     public void testHammerBasic() throws Throwable {
         cht.testHammerBasic();

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumQuotaTest.java Wed Mar 31 04:26:29 2010
@@ -26,29 +26,14 @@ import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooKeeperMain;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
-
-/**
- * this class tests quota on a quorum
- * zookeeper server.
- *
- */
+import org.junit.Assert;
+import org.junit.Test;
 
 public class QuorumQuotaTest extends QuorumBase {
     private static final Logger LOG =
         Logger.getLogger(QuorumQuotaTest.class);
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        LOG.info("STARTING " + getClass().getName());
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        LOG.info("STOPPING " + getClass().getName());
-    }
-
+    @Test
     public void testQuotaWithQuorum() throws Exception {
         ZooKeeper zk = createClient();
         zk.setData("/", "some".getBytes(), -1);
@@ -63,15 +48,15 @@ public class QuorumQuotaTest extends Quo
         String statPath = Quotas.quotaZookeeper + "/a"+ "/" + Quotas.statNode;
         byte[] data = zk.getData(statPath, false, new Stat());
         StatsTrack st = new StatsTrack(new String(data));
-        assertTrue("bytes are set", st.getBytes() == 1204L);
-        assertTrue("num count is set", st.getCount() == 301);
+        Assert.assertTrue("bytes are set", st.getBytes() == 1204L);
+        Assert.assertTrue("num count is set", st.getCount() == 301);
         for (i=300; i < 600; i++) {
             zk.create("/a/" + i, "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
                     CreateMode.PERSISTENT);
         }
         data = zk.getData(statPath, false, new Stat());
         st = new StatsTrack(new String(data));
-        assertTrue("bytes are set", st.getBytes() == 2404L);
-        assertTrue("num count is set", st.getCount() == 601);
+        Assert.assertTrue("bytes are set", st.getBytes() == 2404L);
+        Assert.assertTrue("num count is set", st.getCount() == 601);
     }
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java Wed Mar 31 04:26:29 2010
@@ -33,6 +33,8 @@ import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.server.quorum.Leader;
 import org.apache.zookeeper.server.quorum.LearnerHandler;
+import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -45,17 +47,19 @@ public class QuorumTest extends QuorumBa
 
     @Before
     @Override
-    protected void setUp() throws Exception {
+    public void setUp() throws Exception {
         qb.setUp();
         ct.hostPort = qb.hostPort;
         ct.setUpAll();
     }
 
-    protected void tearDown() throws Exception {
+    @After
+    @Override
+    public void tearDown() throws Exception {
         ct.tearDownAll();
         qb.tearDown();
     }
-    
+
     @Test
     public void testDeleteWithChildren() throws Exception {
         ct.testDeleteWithChildren();
@@ -91,28 +95,28 @@ public class QuorumTest extends QuorumBa
     {
         ct.testClientWithWatcherObj();
     }
-    
+
     @Test
-    public void testGetView() {                
-        ct.assertEquals(5,qb.s1.getView().size());        
-        ct.assertEquals(5,qb.s2.getView().size());        
-        ct.assertEquals(5,qb.s3.getView().size());        
-        ct.assertEquals(5,qb.s4.getView().size());
-        ct.assertEquals(5,qb.s5.getView().size());
+    public void testGetView() {
+        Assert.assertEquals(5,qb.s1.getView().size());
+        Assert.assertEquals(5,qb.s2.getView().size());
+        Assert.assertEquals(5,qb.s3.getView().size());
+        Assert.assertEquals(5,qb.s4.getView().size());
+        Assert.assertEquals(5,qb.s5.getView().size());
     }
-    
+
     @Test
     public void testViewContains() {
         // Test view contains self
-        ct.assertTrue(qb.s1.viewContains(qb.s1.getId()));
-        
+        Assert.assertTrue(qb.s1.viewContains(qb.s1.getId()));
+
         // Test view contains other servers
-        ct.assertTrue(qb.s1.viewContains(qb.s2.getId()));
-        
+        Assert.assertTrue(qb.s1.viewContains(qb.s2.getId()));
+
         // Test view does not contain non-existant servers
-        ct.assertFalse(qb.s1.viewContains(-1L));
+        Assert.assertFalse(qb.s1.viewContains(-1L));
     }
-    
+
     volatile int counter = 0;
     volatile int errors = 0;
     @Test
@@ -127,7 +131,7 @@ public class QuorumTest extends QuorumBa
         if (leader == null) leader = qb.s3.leader;
         if (leader == null) leader = qb.s4.leader;
         if (leader == null) leader = qb.s5.leader;
-        assertNotNull(leader);
+        Assert.assertNotNull(leader);
         for(int i = 0; i < 5000; i++) {
             zk.setData("/blah/blah", new byte[0], -1, new AsyncCallback.StatCallback() {
                 public void processResult(int rc, String path, Object ctx,
@@ -155,23 +159,23 @@ public class QuorumTest extends QuorumBa
             }, null);
         }
         // check if all the followers are alive
-        assertTrue(qb.s1.isAlive());
-        assertTrue(qb.s2.isAlive());
-        assertTrue(qb.s3.isAlive());
-        assertTrue(qb.s4.isAlive());
-        assertTrue(qb.s5.isAlive());
+        Assert.assertTrue(qb.s1.isAlive());
+        Assert.assertTrue(qb.s2.isAlive());
+        Assert.assertTrue(qb.s3.isAlive());
+        Assert.assertTrue(qb.s4.isAlive());
+        Assert.assertTrue(qb.s5.isAlive());
         zk.close();
     }
-    
+
     @Test
     public void testMultipleWatcherObjs() throws IOException,
             InterruptedException, KeeperException
     {
         ct.testMutipleWatcherObjs();
     }
-	
+
     /**
-     * Make sure that we can change sessions 
+     * Make sure that we can change sessions
      *  from follower to leader.
      *
      * @throws IOException
@@ -188,7 +192,7 @@ public class QuorumTest extends QuorumBa
         // we want to loop through the list twice
         for(int i = 0; i < hostPorts.length*2; i++) {
             // This should stomp the zk handle
-            DisconnectableZooKeeper zknew = new DisconnectableZooKeeper(hostPorts[(i+1)%hostPorts.length], ClientBase.CONNECTION_TIMEOUT, 
+            DisconnectableZooKeeper zknew = new DisconnectableZooKeeper(hostPorts[(i+1)%hostPorts.length], ClientBase.CONNECTION_TIMEOUT,
                     new Watcher() {public void process(WatchedEvent event) {
                     }},
                     zk.getSessionId(),
@@ -196,7 +200,7 @@ public class QuorumTest extends QuorumBa
             zknew.setData("/", new byte[1], -1);
             try {
                 zk.setData("/", new byte[1], -1);
-                fail("Should have lost the connection");
+                Assert.fail("Should have lost the connection");
             } catch(KeeperException.ConnectionLossException e) {
             }
             zk.disconnect(); // close w/o closing session
@@ -214,11 +218,11 @@ public class QuorumTest extends QuorumBa
         }
     }
 
-    @Test
     /**
      * Connect to two different servers with two different handles using the same session and
      * make sure we cannot do any changes.
      */
+    @Test
     public void testSessionMove() throws IOException, InterruptedException, KeeperException {
         String hps[] = qb.hostPort.split(",");
         DiscoWatcher oldWatcher = new DiscoWatcher();
@@ -233,7 +237,7 @@ public class QuorumTest extends QuorumBa
         zknew.create("/t2", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
         try {
             zk.create("/t3", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
-            fail("Should have lost the connection");
+            Assert.fail("Should have lost the connection");
         } catch(KeeperException.ConnectionLossException e) {
             // wait up to 30 seconds for the disco to be delivered
             for (int i = 0; i < 30; i++) {
@@ -242,7 +246,7 @@ public class QuorumTest extends QuorumBa
                 }
                 Thread.sleep(1000);
             }
-            assertTrue(oldWatcher.zkDisco);
+            Assert.assertTrue(oldWatcher.zkDisco);
         }
 
         ArrayList<ZooKeeper> toClose = new ArrayList<ZooKeeper>();
@@ -260,5 +264,5 @@ public class QuorumTest extends QuorumBa
         }
         zk.close();
     }
-	// skip superhammer and clientcleanup as they are too expensive for quorum
+    // skip superhammer and clientcleanup as they are too expensive for quorum
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumZxidSyncTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumZxidSyncTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumZxidSyncTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumZxidSyncTest.java Wed Mar 31 04:26:29 2010
@@ -20,34 +20,29 @@ package org.apache.zookeeper.test;
 
 import java.io.File;
 
-import junit.framework.TestCase;
-
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-/**
- * Test what happens when logs fall behind the snapshots or a follower has a
- * higher epoch than a leader.
- */
-public class QuorumZxidSyncTest extends TestCase {
+public class QuorumZxidSyncTest extends ZKTestCase {
     QuorumBase qb = new QuorumBase();
-    
+
     @Before
-    @Override
-    protected void setUp() throws Exception {
-    	qb.setUp();
+    public void setUp() throws Exception {
+        qb.setUp();
     }
-    
-    @Test
+
     /**
      * find out what happens when a follower connects to leader that is behind
      */
+    @Test
     public void testBehindLeader() throws Exception {
         // crank up the epoch numbers
         ClientBase.waitForServerUp(qb.hostPort, 10000);
@@ -89,25 +84,25 @@ public class QuorumZxidSyncTest extends 
         qb.s2.start();
         qb.s3.start();
         qb.s4.start();
-        assertTrue("Servers didn't come up", ClientBase.waitForServerUp(qb.hostPort, 10000));
+        Assert.assertTrue("Servers didn't come up", ClientBase.waitForServerUp(qb.hostPort, 10000));
         qb.s5.start();
         String hostPort = "127.0.0.1:" + qb.s5.getClientPort();
-        assertFalse("Servers came up, but shouldn't have since it's ahead of leader",
+        Assert.assertFalse("Servers came up, but shouldn't have since it's ahead of leader",
                 ClientBase.waitForServerUp(hostPort, 10000));
     }
-    
+
     private void deleteFiles(File f) {
         File v = new File(f, "version-2");
         for(File c: v.listFiles()) {
             c.delete();
         }
     }
-    
-    @Test
+
     /**
      * find out what happens when the latest state is in the snapshots not
      * the logs.
      */
+    @Test
     public void testLateLogs() throws Exception {
         // crank up the epoch numbers
         ClientBase.waitForServerUp(qb.hostPort, 10000);
@@ -157,9 +152,9 @@ public class QuorumZxidSyncTest extends 
             }
         }
         zk.close();
-        assertTrue("Didn't see /2 (went back in time)", saw2);
+        Assert.assertTrue("Didn't see /2 (went back in time)", saw2);
     }
-    
+
     private void deleteLogs(File f) {
         File v = new File(f, "version-2");
         for(File c: v.listFiles()) {
@@ -168,9 +163,8 @@ public class QuorumZxidSyncTest extends 
             }
         }
     }
-    
+
     @After
-    @Override
     public void tearDown() throws Exception {
         qb.tearDown();
     }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java Wed Mar 31 04:26:29 2010
@@ -25,13 +25,12 @@ import java.net.InetSocketAddress;
 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;
@@ -39,9 +38,10 @@ import org.apache.zookeeper.data.Stat;
 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 RecoveryTest extends TestCase implements Watcher {
+public class RecoveryTest extends ZKTestCase implements Watcher {
     protected static final Logger LOG = Logger.getLogger(RecoveryTest.class);
 
     private static final String HOSTPORT =
@@ -49,16 +49,6 @@ public class RecoveryTest extends TestCa
 
     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 if a server goes down that clients will reconnect
      * automatically after the server is restarted. Note that this requires the
@@ -71,6 +61,7 @@ public class RecoveryTest extends TestCa
      * occurs after the server is down, but before the client recognizes
      * that the server is down (ping) then the op will throw connectionloss.
      */
+    @Test
     public void testRecovery() throws Exception {
         File tmpDir = ClientBase.createTmpDir();
 
@@ -86,7 +77,7 @@ public class RecoveryTest extends TestCa
             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));
 
@@ -94,7 +85,7 @@ public class RecoveryTest extends TestCa
             ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
             startSignal.await(CONNECTION_TIMEOUT,
                     TimeUnit.MILLISECONDS);
-            assertTrue("count == 0", startSignal.getCount() == 0);
+            Assert.assertTrue("count == 0", startSignal.getCount() == 0);
             String path;
             LOG.info("starting creating nodes");
             for (int i = 0; i < 10; i++) {
@@ -115,7 +106,7 @@ public class RecoveryTest extends TestCa
             }
 
             f.shutdown();
-            assertTrue("waiting for server down",
+            Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
                                           CONNECTION_TIMEOUT));
 
@@ -126,34 +117,34 @@ public class RecoveryTest extends TestCa
 
             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);
 
             Stat stat = new Stat();
             for (int i = 0; i < 10; i++) {
                 path = "/" + i;
                 LOG.info("Checking " + path);
-                assertEquals(new String(zk.getData(path, false, stat)), path
+                Assert.assertEquals(new String(zk.getData(path, false, stat)), path
                         + "!");
                 for (int j = 0; j < 10; j++) {
                     String subpath = path + "/" + j;
-                    assertEquals(new String(zk.getData(subpath, false, stat)),
+                    Assert.assertEquals(new String(zk.getData(subpath, false, stat)),
                             subpath + "!");
                     for (int k = 0; k < 20; k++) {
                         String subsubpath = subpath + "/" + k;
-                        assertEquals(new String(zk.getData(subsubpath, false,
+                        Assert.assertEquals(new String(zk.getData(subsubpath, false,
                                 stat)), subsubpath + "!");
                     }
                 }
             }
             f.shutdown();
 
-            assertTrue("waiting for server down",
+            Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
                                           ClientBase.CONNECTION_TIMEOUT));
 
@@ -164,26 +155,26 @@ public class RecoveryTest extends TestCa
 
             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);
 
             stat = new Stat();
             LOG.info("Check 2");
             for (int i = 0; i < 10; i++) {
                 path = "/" + i;
-                assertEquals(new String(zk.getData(path, false, stat)),
+                Assert.assertEquals(new String(zk.getData(path, false, stat)),
                              path + "!");
                 for (int j = 0; j < 10; j++) {
                     String subpath = path + "/" + j;
-                    assertEquals(new String(zk.getData(subpath, false, stat)),
+                    Assert.assertEquals(new String(zk.getData(subpath, false, stat)),
                             subpath + "!");
                     for (int k = 0; k < 20; k++) {
                         String subsubpath = subpath + "/" + k;
-                        assertEquals(new String(zk.getData(subsubpath, false,
+                        Assert.assertEquals(new String(zk.getData(subsubpath, false,
                                 stat)), subsubpath + "!");
                     }
                 }
@@ -192,7 +183,7 @@ public class RecoveryTest extends TestCa
 
             f.shutdown();
 
-            assertTrue("waiting for server down",
+            Assert.assertTrue("waiting for server down",
                        ClientBase.waitForServerDown(HOSTPORT,
                                                     CONNECTION_TIMEOUT));
         } finally {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java Wed Mar 31 04:26:29 2010
@@ -20,20 +20,16 @@ package org.apache.zookeeper.test;
 
 import java.net.InetSocketAddress;
 
-import junit.framework.TestCase;
-
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
+import org.junit.Assert;
 import org.junit.Test;
 
-/**
- * this test fails quorum peers and then brings up one of the node as
- * a standalone server
- */
-public class RepeatStartupTest extends TestCase {
+public class RepeatStartupTest extends ZKTestCase {
 
     /** bring up 5 quorum peers and then shut them down
      * and then bring one of the nodes as server
@@ -63,11 +59,11 @@ public class RepeatStartupTest extends T
 
         factory.startup(zks);
         System.out.println("Comment: starting factory");
-        assertTrue("waiting for server up",
+        Assert.assertTrue("waiting for server up",
                    ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                            QuorumTest.CONNECTION_TIMEOUT));
         factory.shutdown();
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                 QuorumTest.CONNECTION_TIMEOUT));
         System.out.println("Comment: shutting down standalone");

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java Wed Mar 31 04:26:29 2010
@@ -27,14 +27,13 @@ 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.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.EventType;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
@@ -42,9 +41,12 @@ import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
-public class SessionTest extends TestCase implements Watcher {
+public class SessionTest extends ZKTestCase implements Watcher {
     protected static final Logger LOG = Logger.getLogger(SessionTest.class);
 
     private static final String HOSTPORT = "127.0.0.1:" +
@@ -54,13 +56,11 @@ public class SessionTest extends TestCas
     private CountDownLatch startSignal;
 
     File tmpDir;
-    
-    private final int TICK_TIME = 3000;
 
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
+    private final int TICK_TIME = 3000;
 
+    @Before
+    public void setUp() throws Exception {
         if (tmpDir == null) {
             tmpDir = ClientBase.createTmpDir();
         }
@@ -72,18 +72,17 @@ public class SessionTest extends TestCas
         serverFactory = new NIOServerCnxn.Factory(new InetSocketAddress(PORT));
         serverFactory.startup(zs);
 
-        assertTrue("waiting for server up",
+        Assert.assertTrue("waiting for server up",
                    ClientBase.waitForServerUp(HOSTPORT,
                                               CONNECTION_TIMEOUT));
     }
-    @Override
-    protected void tearDown() throws Exception {
+
+    @After
+    public void tearDown() throws Exception {
         serverFactory.shutdown();
-        assertTrue("waiting for server down",
+        Assert.assertTrue("waiting for server down",
                    ClientBase.waitForServerDown(HOSTPORT,
                                                 CONNECTION_TIMEOUT));
-
-        LOG.info("FINISHED " + getName());
     }
 
     private static class CountdownWatcher implements Watcher {
@@ -117,13 +116,13 @@ public class SessionTest extends TestCas
         DisconnectableZooKeeper zk =
                 new DisconnectableZooKeeper(HOSTPORT, timeout, watcher);
         if(!watcher.clientConnected.await(timeout, TimeUnit.MILLISECONDS)) {
-            fail("Unable to connect to server");
+            Assert.fail("Unable to connect to server");
         }
 
         return zk;
     }
 
-// FIXME this test is failing due to client close race condition fixing in separate patch for ZOOKEEPER-63
+// FIXME this test is Assert.failing due to client close race condition fixing in separate patch for ZOOKEEPER-63
 //    /**
 //     * this test checks to see if the sessionid that was created for the
 //     * first zookeeper client can be reused for the second one immidiately
@@ -150,17 +149,17 @@ public class SessionTest extends TestCas
 //
 //        LOG.info("Opened reuse");
 //
-//        assertEquals(sessionId, zk.getSessionId());
+//        Assert.assertEquals(sessionId, zk.getSessionId());
 //
 //        zk.close();
 //    }
 
-    @Test
     /**
      * This test verifies that when the session id is reused, and the original
      * client is disconnected, but not session closed, that the server
      * will remove ephemeral nodes created by the original session.
      */
+    @Test
     public void testSession()
         throws IOException, InterruptedException, KeeperException
     {
@@ -189,16 +188,16 @@ public class SessionTest extends TestCas
         zk.close();
 
         zk = createClient();
-        assertEquals(null, zk.exists("/e", false));
+        Assert.assertEquals(null, zk.exists("/e", false));
         LOG.info("before close zk with session id 0x"
                 + Long.toHexString(zk.getSessionId()) + "!");
         zk.close();
     }
 
-    @Test
     /**
      * Make sure ephemerals get cleaned up when a session times out.
      */
+    @Test
     public void testSessionTimeout() throws Exception {
         final int TIMEOUT = 5000;
         DisconnectableZooKeeper zk = createClient(TIMEOUT);
@@ -217,9 +216,9 @@ public class SessionTest extends TestCas
         setUp();
 
         zk = createClient(TIMEOUT);
-        assertTrue(zk.exists("/stest", false) != null);
+        Assert.assertTrue(zk.exists("/stest", false) != null);
         Thread.sleep(TIMEOUT*2);
-        assertTrue(zk.exists("/stest", false) == null);
+        Assert.assertTrue(zk.exists("/stest", false) == null);
         zk.close();
     }
 
@@ -245,7 +244,7 @@ public class SessionTest extends TestCas
             zknew.setData("/", new byte[1], -1);
             try {
                 zk.setData("/", new byte[1], -1);
-                fail("Should have lost the connection");
+                Assert.fail("Should have lost the connection");
             } catch(KeeperException.ConnectionLossException e) {
             }
             //zk.close();
@@ -253,7 +252,6 @@ public class SessionTest extends TestCas
         }
         zk.close();
     }
-    @Test
     /**
      * This test makes sure that duplicate state changes are not communicated
      * to the client watcher. For example we should not notify state as
@@ -261,6 +259,7 @@ public class SessionTest extends TestCas
      * we don't consider a dup state notification if the event type is
      * not "None" (ie non-None communicates an event).
      */
+    @Test
     public void testSessionStateNoDupStateReporting()
         throws IOException, InterruptedException, KeeperException
     {
@@ -280,20 +279,20 @@ public class SessionTest extends TestCas
         // verify that the size is just 2 - ie connect then disconnect
         // if the client attempts reconnect and we are not handling current
         // state correctly (ie eventing on duplicate disconnects) then we'll
-        // see a disconnect for each failed connection attempt
-        assertEquals(2, watcher.states.size());
+        // see a disconnect for each Assert.failed connection attempt
+        Assert.assertEquals(2, watcher.states.size());
 
         zk.close();
     }
 
-    @Test
     /**
      * Verify access to the negotiated session timeout.
      */
+    @Test
     public void testSessionTimeoutAccess() throws Exception {
         // validate typical case - requested == negotiated
         DisconnectableZooKeeper zk = createClient(TICK_TIME * 4);
-        assertEquals(TICK_TIME * 4, zk.getSessionTimeout());
+        Assert.assertEquals(TICK_TIME * 4, zk.getSessionTimeout());
         // make sure tostring works in both cases
         LOG.info(zk.toString());
         zk.close();
@@ -301,14 +300,14 @@ public class SessionTest extends TestCas
 
         // validate lower limit
         zk = createClient(TICK_TIME);
-        assertEquals(TICK_TIME * 2, zk.getSessionTimeout());
+        Assert.assertEquals(TICK_TIME * 2, zk.getSessionTimeout());
         LOG.info(zk.toString());
         zk.close();
         LOG.info(zk.toString());
 
         // validate upper limit
         zk = createClient(TICK_TIME * 30);
-        assertEquals(TICK_TIME * 20, zk.getSessionTimeout());
+        Assert.assertEquals(TICK_TIME * 20, zk.getSessionTimeout());
         LOG.info(zk.toString());
         zk.close();
         LOG.info(zk.toString());
@@ -345,7 +344,7 @@ public class SessionTest extends TestCas
         // validate typical case - requested == negotiated
         int timeout = 120000;
         DisconnectableZooKeeper zk = createClient(timeout);
-        assertEquals(timeout, zk.getSessionTimeout());
+        Assert.assertEquals(timeout, zk.getSessionTimeout());
         // make sure tostring works in both cases
         LOG.info(zk.toString());
         zk.close();
@@ -353,14 +352,14 @@ public class SessionTest extends TestCas
 
         // validate lower limit
         zk = createClient(MINSESS/2);
-        assertEquals(MINSESS, zk.getSessionTimeout());
+        Assert.assertEquals(MINSESS, zk.getSessionTimeout());
         LOG.info(zk.toString());
         zk.close();
         LOG.info(zk.toString());
 
         // validate upper limit
         zk = createClient(MAXSESS * 2);
-        assertEquals(MAXSESS, zk.getSessionTimeout());
+        Assert.assertEquals(MAXSESS, zk.getSessionTimeout());
         LOG.info(zk.toString());
         zk.close();
         LOG.info(zk.toString());

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/StatTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/StatTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/StatTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/StatTest.java Wed Mar 31 04:26:29 2010
@@ -25,35 +25,35 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
 import org.junit.Test;
 
-/**
- *
- */
 public class StatTest extends ClientBase {
     private ZooKeeper zk;
-    
-    protected void setUp() throws Exception {
+
+    @Override
+    public void setUp() throws Exception {
         super.setUp();
-        
+
         zk = createClient();
     }
 
-    protected void tearDown() throws Exception {
+    @Override
+    public void tearDown() throws Exception {
         super.tearDown();
-        
+
         zk.close();
     }
-    
+
     /**
-     * Create a new Stat, fill in dummy values trying to catch failure
+     * Create a new Stat, fill in dummy values trying to catch Assert.failure
      * to copy in client or server code.
-     * 
+     *
      * @return a new stat with dummy values
      */
     private Stat newStat() {
         Stat stat = new Stat();
-        
+
         stat.setAversion(100);
         stat.setCtime(100);
         stat.setCversion(100);
@@ -65,7 +65,7 @@ public class StatTest extends ClientBase
         stat.setNumChildren(100);
         stat.setPzxid(100);
         stat.setVersion(100);
-        
+
         return stat;
     }
 
@@ -76,21 +76,21 @@ public class StatTest extends ClientBase
         String name = "/foo";
         zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        
+
         Stat stat;
-        
+
         stat = newStat();
         zk.getData(name, false, stat);
-        
-        assertEquals(stat.getCzxid(), stat.getMzxid());
-        assertEquals(stat.getCzxid(), stat.getPzxid());
-        assertEquals(stat.getCtime(), stat.getMtime());
-        assertEquals(0, stat.getCversion());
-        assertEquals(0, stat.getVersion());
-        assertEquals(0, stat.getAversion());
-        assertEquals(0, stat.getEphemeralOwner());
-        assertEquals(name.length(), stat.getDataLength());
-        assertEquals(0, stat.getNumChildren());
+
+        Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
+        Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
+        Assert.assertEquals(stat.getCtime(), stat.getMtime());
+        Assert.assertEquals(0, stat.getCversion());
+        Assert.assertEquals(0, stat.getVersion());
+        Assert.assertEquals(0, stat.getAversion());
+        Assert.assertEquals(0, stat.getEphemeralOwner());
+        Assert.assertEquals(name.length(), stat.getDataLength());
+        Assert.assertEquals(0, stat.getNumChildren());
     }
 
     @Test
@@ -100,38 +100,38 @@ public class StatTest extends ClientBase
         String name = "/foo";
         zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        
+
         String childname = name + "/bar";
         zk.create(childname, childname.getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.EPHEMERAL);
 
         Stat stat;
-        
+
         stat = newStat();
         zk.getData(name, false, stat);
 
-        assertEquals(stat.getCzxid(), stat.getMzxid());
-        assertEquals(stat.getCzxid() + 1, stat.getPzxid());
-        assertEquals(stat.getCtime(), stat.getMtime());
-        assertEquals(1, stat.getCversion());
-        assertEquals(0, stat.getVersion());
-        assertEquals(0, stat.getAversion());
-        assertEquals(0, stat.getEphemeralOwner());
-        assertEquals(name.length(), stat.getDataLength());
-        assertEquals(1, stat.getNumChildren());
+        Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
+        Assert.assertEquals(stat.getCzxid() + 1, stat.getPzxid());
+        Assert.assertEquals(stat.getCtime(), stat.getMtime());
+        Assert.assertEquals(1, stat.getCversion());
+        Assert.assertEquals(0, stat.getVersion());
+        Assert.assertEquals(0, stat.getAversion());
+        Assert.assertEquals(0, stat.getEphemeralOwner());
+        Assert.assertEquals(name.length(), stat.getDataLength());
+        Assert.assertEquals(1, stat.getNumChildren());
 
         stat = newStat();
         zk.getData(childname, false, stat);
 
-        assertEquals(stat.getCzxid(), stat.getMzxid());
-        assertEquals(stat.getCzxid(), stat.getPzxid());
-        assertEquals(stat.getCtime(), stat.getMtime());
-        assertEquals(0, stat.getCversion());
-        assertEquals(0, stat.getVersion());
-        assertEquals(0, stat.getAversion());
-        assertEquals(zk.getSessionId(), stat.getEphemeralOwner());
-        assertEquals(childname.length(), stat.getDataLength());
-        assertEquals(0, stat.getNumChildren());
+        Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
+        Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
+        Assert.assertEquals(stat.getCtime(), stat.getMtime());
+        Assert.assertEquals(0, stat.getCversion());
+        Assert.assertEquals(0, stat.getVersion());
+        Assert.assertEquals(0, stat.getAversion());
+        Assert.assertEquals(zk.getSessionId(), stat.getEphemeralOwner());
+        Assert.assertEquals(childname.length(), stat.getDataLength());
+        Assert.assertEquals(0, stat.getNumChildren());
     }
 
     @Test
@@ -141,26 +141,26 @@ public class StatTest extends ClientBase
         String name = "/foo";
         zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        
+
         for(int i = 0; i < 10; i++) {
             String childname = name + "/bar" + i;
             zk.create(childname, childname.getBytes(), Ids.OPEN_ACL_UNSAFE,
                     CreateMode.EPHEMERAL);
 
             Stat stat;
-            
+
             stat = newStat();
             zk.getData(name, false, stat);
-    
-            assertEquals(stat.getCzxid(), stat.getMzxid());
-            assertEquals(stat.getCzxid() + i + 1, stat.getPzxid());
-            assertEquals(stat.getCtime(), stat.getMtime());
-            assertEquals(i + 1, stat.getCversion());
-            assertEquals(0, stat.getVersion());
-            assertEquals(0, stat.getAversion());
-            assertEquals(0, stat.getEphemeralOwner());
-            assertEquals(name.length(), stat.getDataLength());
-            assertEquals(i + 1, stat.getNumChildren());
+
+            Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
+            Assert.assertEquals(stat.getCzxid() + i + 1, stat.getPzxid());
+            Assert.assertEquals(stat.getCtime(), stat.getMtime());
+            Assert.assertEquals(i + 1, stat.getCversion());
+            Assert.assertEquals(0, stat.getVersion());
+            Assert.assertEquals(0, stat.getAversion());
+            Assert.assertEquals(0, stat.getEphemeralOwner());
+            Assert.assertEquals(name.length(), stat.getDataLength());
+            Assert.assertEquals(i + 1, stat.getNumChildren());
         }
     }
 
@@ -171,35 +171,35 @@ public class StatTest extends ClientBase
         String name = "/foo";
         zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
                 CreateMode.PERSISTENT);
-        
+
         Stat stat;
-        
+
         stat = newStat();
         zk.getData(name, false, stat);
-        
-        assertEquals(stat.getCzxid(), stat.getMzxid());
-        assertEquals(stat.getCzxid(), stat.getPzxid());
-        assertEquals(stat.getCtime(), stat.getMtime());
-        assertEquals(0, stat.getCversion());
-        assertEquals(0, stat.getVersion());
-        assertEquals(0, stat.getAversion());
-        assertEquals(0, stat.getEphemeralOwner());
-        assertEquals(name.length(), stat.getDataLength());
-        assertEquals(0, stat.getNumChildren());
+
+        Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
+        Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
+        Assert.assertEquals(stat.getCtime(), stat.getMtime());
+        Assert.assertEquals(0, stat.getCversion());
+        Assert.assertEquals(0, stat.getVersion());
+        Assert.assertEquals(0, stat.getAversion());
+        Assert.assertEquals(0, stat.getEphemeralOwner());
+        Assert.assertEquals(name.length(), stat.getDataLength());
+        Assert.assertEquals(0, stat.getNumChildren());
 
         zk.setData(name, (name + name).getBytes(), -1);
-        
+
         stat = newStat();
         zk.getData(name, false, stat);
-        
-        assertNotSame(stat.getCzxid(), stat.getMzxid());
-        assertEquals(stat.getCzxid(), stat.getPzxid());
-        assertNotSame(stat.getCtime(), stat.getMtime());
-        assertEquals(0, stat.getCversion());
-        assertEquals(1, stat.getVersion());
-        assertEquals(0, stat.getAversion());
-        assertEquals(0, stat.getEphemeralOwner());
-        assertEquals(name.length() * 2, stat.getDataLength());
-        assertEquals(0, stat.getNumChildren());
+
+        Assert.assertNotSame(stat.getCzxid(), stat.getMzxid());
+        Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
+        Assert.assertNotSame(stat.getCtime(), stat.getMtime());
+        Assert.assertEquals(0, stat.getCversion());
+        Assert.assertEquals(1, stat.getVersion());
+        Assert.assertEquals(0, stat.getAversion());
+        Assert.assertEquals(0, stat.getEphemeralOwner());
+        Assert.assertEquals(name.length() * 2, stat.getDataLength());
+        Assert.assertEquals(0, stat.getNumChildren());
     }
 }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SyncCallTest.java Wed Mar 31 04:26:29 2010
@@ -27,15 +27,15 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
 import org.apache.zookeeper.AsyncCallback.Children2Callback;
+import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
 import org.apache.zookeeper.AsyncCallback.StringCallback;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
 import org.junit.Test;
 
-
 public class SyncCallTest extends ClientBase
     implements ChildrenCallback, Children2Callback, StringCallback, VoidCallback
 {
@@ -67,10 +67,10 @@ public class SyncCallTest extends Client
             LOG.info("Submitted all operations:" + (new Date()).toString());
             
             if(!opsCount.await(10000, TimeUnit.MILLISECONDS))
-                fail("Haven't received all confirmations" + opsCount.getCount());
+                Assert.fail("Haven't received all confirmations" + opsCount.getCount());
 
             for(int i = 0; i < limit ; i++){
-                assertEquals(0, (int) results.get(i));
+                Assert.assertEquals(0, (int) results.get(i));
             }
             
         } catch (IOException e) {

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TruncateTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TruncateTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TruncateTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/TruncateTest.java Wed Mar 31 04:26:29 2010
@@ -23,13 +23,12 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.HashMap;
 
-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.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.Stat;
@@ -38,10 +37,11 @@ import org.apache.zookeeper.server.ZKDat
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-public class TruncateTest extends TestCase {
+public class TruncateTest extends ZKTestCase {
 	private static final Logger LOG = Logger.getLogger(TruncateTest.class);
     File dataDir1, dataDir2, dataDir3;
     final int baseHostPort = 12233;
@@ -115,7 +115,7 @@ public class TruncateTest extends TestCa
         zk2.getData("/9", false, new Stat());
         try {
             zk2.getData("/10", false, new Stat());
-            fail("Should have gotten an error");
+            Assert.fail("Should have gotten an error");
         } catch(KeeperException.NoNodeException e) {
             // this is what we want
         }
@@ -134,7 +134,7 @@ public class TruncateTest extends TestCa
         	// actually truncate the zxid for 10 creation
         	// but for 11 we will for sure
         	zk1.getData("/11", false, new Stat());
-            fail("Should have gotten an error");
+            Assert.fail("Should have gotten an error");
         } catch(KeeperException.NoNodeException e) {
             // this is what we want
         }

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java Wed Mar 31 04:26:29 2010
@@ -26,13 +26,12 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 
-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,8 +40,10 @@ import org.apache.zookeeper.server.NIOSe
 import org.apache.zookeeper.server.SyncRequestProcessor;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.upgrade.UpgradeMain;
+import org.junit.Assert;
+import org.junit.Test;
 
-public class UpgradeTest extends TestCase implements Watcher {
+public class UpgradeTest extends ZKTestCase implements Watcher {
     private final static Logger LOG = Logger.getLogger(UpgradeTest.class);
 
     private static String HOSTPORT = "127.0.0.1:" + PortAssignment.unique();
@@ -50,19 +51,11 @@ public class UpgradeTest extends TestCas
             System.getProperty("test.data.dir", "build/test/data"));
     private CountDownLatch startSignal;
 
-    @Override
-    protected void setUp() throws Exception {
-        LOG.info("STARTING " + getName());
-    }
-    @Override
-    protected void tearDown() throws Exception {
-        LOG.info("FINISHED " + getName());
-    }
-
     /**
      * test the upgrade
      * @throws Exception
      */
+    @Test
     public void testUpgrade() throws Exception {
         File upgradeDir = new File(testData, "upgrade");
         UpgradeMain upgrade = new UpgradeMain(upgradeDir, upgradeDir);
@@ -74,14 +67,14 @@ public class UpgradeTest extends TestCas
                 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);
         Stat stat = zk.exists("/", false);
         List<String> children = zk.getChildren("/", false);
         Collections.sort(children);
         for (int i = 0; i < 10; i++) {
-            assertTrue("data tree sanity check",
+            Assert.assertTrue("data tree sanity check",
                     ("test-" + i).equals(children.get(i)));
         }
         //try creating one node
@@ -89,14 +82,14 @@ public class UpgradeTest extends TestCas
                 CreateMode.PERSISTENT);
         // check if its there
         if (zk.exists("/upgrade", false) == null) {
-            assertTrue(false);
+            Assert.assertTrue(false);
         }
 
         zk.close();
 
         // bring down the server
         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/WatchedEventTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java?rev=929377&r1=929376&r2=929377&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatchedEventTest.java Wed Mar 31 04:26:29 2010
@@ -20,15 +20,15 @@ package org.apache.zookeeper.test;
 
 import java.util.EnumSet;
 
-import junit.framework.TestCase;
-
 import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.proto.WatcherEvent;
+import org.junit.Assert;
 import org.junit.Test;
 
-public class WatchedEventTest extends TestCase {
+public class WatchedEventTest extends ZKTestCase {
     
     @Test
     public void testCreatingWatchedEvent() {
@@ -42,9 +42,9 @@ public class WatchedEventTest extends Te
         for(EventType et : allTypes) {
            for(KeeperState ks : allStates) {
                we = new WatchedEvent(et, ks, "blah");
-               assertEquals(et, we.getType());
-               assertEquals(ks, we.getState());
-               assertEquals("blah", we.getPath());
+               Assert.assertEquals(et, we.getType());
+               Assert.assertEquals(ks, we.getState());
+               Assert.assertEquals("blah", we.getPath());
            }
             
         }
@@ -63,9 +63,9 @@ public class WatchedEventTest extends Te
            for(KeeperState ks : allStates) {
                wep = new WatcherEvent(et.getIntValue(), ks.getIntValue(), "blah");
                we = new WatchedEvent(wep);
-               assertEquals(et, we.getType());
-               assertEquals(ks, we.getState());
-               assertEquals("blah", we.getPath());
+               Assert.assertEquals(et, we.getType());
+               Assert.assertEquals(ks, we.getState());
+               Assert.assertEquals("blah", we.getPath());
            }
         }
     }
@@ -77,7 +77,7 @@ public class WatchedEventTest extends Te
        try {
            WatcherEvent wep = new WatcherEvent(-2342, -252352, "foo");
            WatchedEvent we = new WatchedEvent(wep);
-           fail("Was able to create WatchedEvent from bad wrapper");
+           Assert.fail("Was able to create WatchedEvent from bad wrapper");
        } catch (RuntimeException re) {
            // we're good
        }
@@ -88,8 +88,8 @@ public class WatchedEventTest extends Te
        WatchedEvent we = new WatchedEvent(EventType.NodeCreated, KeeperState.Expired, "blah");
        WatcherEvent wew = we.getWrapper();
        
-       assertEquals(EventType.NodeCreated.getIntValue(), wew.getType());
-       assertEquals(KeeperState.Expired.getIntValue(), wew.getState());
-       assertEquals("blah", wew.getPath());
+       Assert.assertEquals(EventType.NodeCreated.getIntValue(), wew.getType());
+       Assert.assertEquals(KeeperState.Expired.getIntValue(), wew.getState());
+       Assert.assertEquals("blah", wew.getPath());
    }
 }



Mime
View raw message