incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r757044 - in /incubator/droids/trunk/droids-core/src/test/java/org/apache/droids: delay/TestDelay.java impl/TestSimpleQueue.java
Date Sat, 21 Mar 2009 22:44:49 GMT
Author: olegk
Date: Sat Mar 21 22:44:49 2009
New Revision: 757044

URL: http://svn.apache.org/viewvc?rev=757044&view=rev
Log:
Ported test cases to JUnit 4

Modified:
    incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/delay/TestDelay.java
    incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleQueue.java

Modified: incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/delay/TestDelay.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/delay/TestDelay.java?rev=757044&r1=757043&r2=757044&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/delay/TestDelay.java
(original)
+++ incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/delay/TestDelay.java
Sat Mar 21 22:44:49 2009
@@ -17,22 +17,14 @@
 package org.apache.droids.delay;
 
 import org.apache.droids.api.DelayTimer;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import junit.framework.Assert;
 
-
-public class TestDelay extends TestCase
+public class TestDelay
 {
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-  }
 
-  @Override
-  protected void tearDown() throws Exception {
-    super.tearDown();
-  }
-  
+  @Test
   public void testTimers()
   {
     int i=0;
@@ -41,31 +33,31 @@
     RandomDelayTimer timer = new RandomDelayTimer( min, spread );
     for( i=0; i<100; i++ ) {
       long delay = timer.getDelayMillis();
-      assertTrue( delay >= min );
-      assertTrue( delay < (min+spread) );
+      Assert.assertTrue( delay >= min );
+      Assert.assertTrue( delay < (min+spread) );
     }
     min = 300; spread = 20;
     timer.setDelaySpread( spread );
     timer.setMinimumDelay( min );
     for( i=0; i<100; i++ ) {
       long delay = timer.getDelayMillis();
-      assertTrue( delay >= min );
-      assertTrue( delay < (min+spread) );
+      Assert.assertTrue( delay >= min );
+      Assert.assertTrue( delay < (min+spread) );
     }
     
     timer = new GaussianRandomDelayTimer( min, spread );
     for( i=0; i<100; i++ ) {
       long delay = timer.getDelayMillis();
-      assertTrue( "DELAY:"+delay, delay >= min );
-      assertTrue( "DELAY:"+delay, delay < (min+(spread*4)) );
+      Assert.assertTrue( "DELAY:"+delay, delay >= min );
+      Assert.assertTrue( "DELAY:"+delay, delay < (min+(spread*4)) );
     }
     
     DelayTimer t = new SimpleDelayTimer( 1000 );
-    assertTrue( 1000 == t.getDelayMillis() );
+    Assert.assertTrue( 1000 == t.getDelayMillis() );
     
     // default timers all have time zero
-    assertEquals( 0, new SimpleDelayTimer().getDelayMillis() );
-    assertEquals( 0, new RandomDelayTimer().getDelayMillis() );
-    assertEquals( 0, new GaussianRandomDelayTimer().getDelayMillis() );
+    Assert.assertEquals( 0, new SimpleDelayTimer().getDelayMillis() );
+    Assert.assertEquals( 0, new RandomDelayTimer().getDelayMillis() );
+    Assert.assertEquals( 0, new GaussianRandomDelayTimer().getDelayMillis() );
   }
 }

Modified: incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleQueue.java
URL: http://svn.apache.org/viewvc/incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleQueue.java?rev=757044&r1=757043&r2=757044&view=diff
==============================================================================
--- incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleQueue.java
(original)
+++ incubator/droids/trunk/droids-core/src/test/java/org/apache/droids/impl/TestSimpleQueue.java
Sat Mar 21 22:44:49 2009
@@ -22,22 +22,14 @@
 import org.apache.droids.LinkTask;
 import org.apache.droids.exception.InvalidTaskException;
 import org.apache.droids.robot.walker.FileTask;
+import org.junit.Test;
 
-import junit.framework.TestCase;
+import junit.framework.Assert;
 
-
-public class TestSimpleQueue extends TestCase
+public class TestSimpleQueue
 {
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-  }
 
-  @Override
-  protected void tearDown() throws Exception {
-    super.tearDown();
-  }
-  
+  @Test
   public void testMaxSize() throws Exception
   {
     SimpleTaskQueue<LinkTask> taskQueue = new SimpleTaskQueue<LinkTask>();
@@ -47,15 +39,16 @@
     for( int i=0; i<taskQueue.getMaxSize(); i++ ) {
       taskQueue.merge( new LinkTask( null, new URI("http://www/"+i), 0 ) );
     }
-    assertEquals( 10, taskQueue.getSize() );
+    Assert.assertEquals( 10, taskQueue.getSize() );
     
     try {
       taskQueue.merge( new LinkTask( null, new URI("http://xxxx/"), 0 ) );
-      fail( "adding a task should have failed -- it is too big" );
+      Assert.fail( "adding a task should have failed -- it is too big" );
     }
     catch( InvalidTaskException ex ) { }
   }
 
+  @Test
   public void testMaxDepth() throws Exception
   {
     SimpleTaskValidator<FileTask> validator = new SimpleTaskValidator<FileTask>();
@@ -71,7 +64,7 @@
     task = new FileTask( new File( "" ), 7 );
     try {
       validator.validateTask( task );  
-      fail( "should faile because it was too deep" );
+      Assert.fail( "should faile because it was too deep" );
     }
     catch( InvalidTaskException ex ) {}
   }



Mime
View raw message