hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r944515 - in /hadoop/zookeeper/trunk: ./ src/recipes/lock/test/org/apache/zookeeper/recipes/lock/ src/recipes/queue/test/org/apache/zookeeper/recipes/queue/
Date Fri, 14 May 2010 23:32:21 GMT
Author: phunt
Date: Fri May 14 23:32:20 2010
New Revision: 944515

URL: http://svn.apache.org/viewvc?rev=944515&view=rev
Log:
ZOOKEEPER-774. Recipes tests are slightly outdated: they do not compile against JUnit 4.8

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/WriteLockTest.java
    hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/ZNodeNameTest.java
    hadoop/zookeeper/trunk/src/recipes/queue/test/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=944515&r1=944514&r2=944515&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Fri May 14 23:32:20 2010
@@ -52,6 +52,9 @@ BUGFIXES: 
   ZOOKEEPER-763. Deadlock on close w/ zkpython / c client
   (henry via phunt)
 
+  ZOOKEEPER-774. Recipes tests are slightly outdated: they do not compile
+  against JUnit 4.8 (Sergey Doroshenko via phunt)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

Modified: hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/WriteLockTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/WriteLockTest.java?rev=944515&r1=944514&r2=944515&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/WriteLockTest.java
(original)
+++ hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/WriteLockTest.java
Fri May 14 23:32:20 2010
@@ -23,6 +23,10 @@ import org.apache.zookeeper.test.ClientB
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
 /**
  * test for writelock
  */
@@ -35,6 +39,7 @@ public class WriteLockTest extends Clien
     private boolean workAroundClosingLastZNodeFails = true;
     private boolean killLeader = true;
 
+    @Test
     public void testRun() throws Exception {
         runTest(3);
     }
@@ -68,11 +73,11 @@ public class WriteLockTest extends Clien
         dumpNodes(count);
 
         // lets assert that the first election is the leader
-        assertTrue("The first znode should be the leader " + first.getId(), first.isOwner());
+        Assert.assertTrue("The first znode should be the leader " + first.getId(), first.isOwner());
 
         for (int i = 1; i < count; i++) {
             WriteLock node = nodes[i];
-            assertFalse("Node should not be the leader " + node.getId(), node.isOwner());
+            Assert.assertFalse("Node should not be the leader " + node.getId(), node.isOwner());
         }
 
         if (count > 1) {
@@ -86,11 +91,11 @@ public class WriteLockTest extends Clien
             WriteLock second = nodes[1];
             dumpNodes(count);
             // lets assert that the first election is the leader
-            assertTrue("The second znode should be the leader " + second.getId(), second.isOwner());
+            Assert.assertTrue("The second znode should be the leader " + second.getId(),
second.isOwner());
 
             for (int i = 2; i < count; i++) {
                 WriteLock node = nodes[i];
-                assertFalse("Node should not be the leader " + node.getId(), node.isOwner());
+                Assert.assertFalse("Node should not be the leader " + node.getId(), node.isOwner());
             }
             }
 
@@ -126,8 +131,8 @@ public class WriteLockTest extends Clien
         }
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         if (nodes != null) {
             for (int i = 0; i < nodes.length; i++) {
                 WriteLock node = nodes[i];

Modified: hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/ZNodeNameTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/ZNodeNameTest.java?rev=944515&r1=944514&r2=944515&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/ZNodeNameTest.java
(original)
+++ hadoop/zookeeper/trunk/src/recipes/lock/test/org/apache/zookeeper/recipes/lock/ZNodeNameTest.java
Fri May 14 23:32:20 2010
@@ -22,15 +22,19 @@ import junit.framework.TestCase;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
+import org.junit.Test;
+
 /**
  * test for znodenames
  */
 public class ZNodeNameTest extends TestCase {
+    @Test
     public void testOrderWithSamePrefix() throws Exception {
         String[] names = { "x-3", "x-5", "x-11", "x-1" };
         String[] expected = { "x-1", "x-3", "x-5", "x-11" };
         assertOrderedNodeNames(names, expected);
     }
+    @Test
     public void testOrderWithDifferentPrefixes() throws Exception {
         String[] names = { "r-3", "r-2", "r-1", "w-2", "w-1" };
         String[] expected = { "r-1", "r-2", "r-3", "w-1", "w-2" };

Modified: hadoop/zookeeper/trunk/src/recipes/queue/test/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/recipes/queue/test/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java?rev=944515&r1=944514&r2=944515&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/recipes/queue/test/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
(original)
+++ hadoop/zookeeper/trunk/src/recipes/queue/test/org/apache/zookeeper/recipes/queue/DistributedQueueTest.java
Fri May 14 23:32:20 2010
@@ -17,25 +17,27 @@
  */
 package org.apache.zookeeper.recipes.queue;
 
-import java.util.Calendar;
 import java.util.NoSuchElementException;
 
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.recipes.queue.DistributedQueue;
 import org.apache.zookeeper.test.ClientBase;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
 
 
 
 public class DistributedQueueTest extends ClientBase {
-    @Override
-    protected void tearDown() throws Exception {
+
+    @After
+    public void tearDown() throws Exception {
         super.tearDown();
-        LOG.info("FINISHED " + getName());
+        LOG.info("FINISHED " + getTestName());
     }
 
 
-
+    @Test
     public void testOffer1() throws Exception {
         String dir = "/testOffer1";
         String testString = "Hello World";
@@ -50,9 +52,10 @@ public class DistributedQueueTest extend
         queueHandles[0].offer(testString.getBytes());
 
         byte dequeuedBytes[] = queueHandles[0].remove();
-        assertEquals(new String(dequeuedBytes), testString);
+        Assert.assertEquals(new String(dequeuedBytes), testString);
     }
 
+    @Test
     public void testOffer2() throws Exception {
         String dir = "/testOffer2";
         String testString = "Hello World";
@@ -67,9 +70,10 @@ public class DistributedQueueTest extend
         queueHandles[0].offer(testString.getBytes());
 
         byte dequeuedBytes[] = queueHandles[1].remove();
-        assertEquals(new String(dequeuedBytes), testString);
+        Assert.assertEquals(new String(dequeuedBytes), testString);
     }
 
+    @Test
     public void testTake1() throws Exception {
         String dir = "/testTake1";
         String testString = "Hello World";
@@ -84,11 +88,12 @@ public class DistributedQueueTest extend
         queueHandles[0].offer(testString.getBytes());
 
         byte dequeuedBytes[] = queueHandles[0].take();
-        assertEquals(new String(dequeuedBytes), testString);
+        Assert.assertEquals(new String(dequeuedBytes), testString);
     }
 
 
 
+    @Test
     public void testRemove1() throws Exception{
         String dir = "/testRemove1";
         String testString = "Hello World";
@@ -105,7 +110,7 @@ public class DistributedQueueTest extend
         }catch(NoSuchElementException e){
             return;
         }
-        assertTrue(false);
+        Assert.assertTrue(false);
     }
 
     public void createNremoveMtest(String dir,int n,int m) throws Exception{
@@ -127,12 +132,14 @@ public class DistributedQueueTest extend
         for(int i=0; i<m; i++){
             data=queueHandles[1].remove();
         }
-        assertEquals(new String(data), testString+(m-1));
+        Assert.assertEquals(new String(data), testString+(m-1));
     }
 
+    @Test
     public void testRemove2() throws Exception{
         createNremoveMtest("/testRemove2",10,2);
     }
+    @Test
     public void testRemove3() throws Exception{
         createNremoveMtest("/testRemove3",1000,1000);
     }
@@ -156,25 +163,30 @@ public class DistributedQueueTest extend
         for(int i=0; i<m; i++){
             data=queueHandles[1].remove();
         }
-        assertEquals(new String(queueHandles[1].element()), testString+m);
+        Assert.assertEquals(new String(queueHandles[1].element()), testString+m);
     }
 
+    @Test
     public void testElement1() throws Exception {
         createNremoveMelementTest("/testElement1",1,0);
     }
 
+    @Test
     public void testElement2() throws Exception {
         createNremoveMelementTest("/testElement2",10,2);
     }
 
+    @Test
     public void testElement3() throws Exception {
         createNremoveMelementTest("/testElement3",1000,500);
     }
 
+    @Test
     public void testElement4() throws Exception {
         createNremoveMelementTest("/testElement4",1000,1000-1);
     }
 
+    @Test
     public void testTakeWait1() throws Exception{
         String dir = "/testTakeWait1";
         final String testString = "Hello World";
@@ -217,10 +229,11 @@ public class DistributedQueueTest extend
 
         takeThread.join();
 
-        assertTrue(takeResult[0] != null);
-        assertEquals(new String(takeResult[0]), testString);
+        Assert.assertTrue(takeResult[0] != null);
+        Assert.assertEquals(new String(takeResult[0]), testString);
     }
 
+    @Test
     public void testTakeWait2() throws Exception{
         String dir = "/testTakeWait2";
         final String testString = "Hello World";
@@ -265,8 +278,8 @@ public class DistributedQueueTest extend
 
             takeThread.join();
 
-            assertTrue(takeResult[0] != null);
-            assertEquals(new String(takeResult[0]), threadTestString);
+            Assert.assertTrue(takeResult[0] != null);
+            Assert.assertEquals(new String(takeResult[0]), threadTestString);
         }
     }
 }



Mime
View raw message