commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe...@apache.org
Subject svn commit: r356872 - /jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGeneratorTest.java
Date Wed, 14 Dec 2005 21:17:06 GMT
Author: joehni
Date: Wed Dec 14 13:17:01 2005
New Revision: 356872

URL: http://svn.apache.org/viewcvs?rev=356872&view=rev
Log:
Improve unit test.

Modified:
    jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGeneratorTest.java

Modified: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGeneratorTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGeneratorTest.java?rev=356872&r1=356871&r2=356872&view=diff
==============================================================================
--- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGeneratorTest.java
(original)
+++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/serial/TimeBasedAlphanumericIdentifierGeneratorTest.java
Wed Dec 14 13:17:01 2005
@@ -20,6 +20,7 @@
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.TimeZone;
 
@@ -43,6 +44,18 @@
             next = System.currentTimeMillis();
         }
     }
+    
+    /**
+     * Test time stability of current box. Especially in VMs not always proper!
+     */
+    public void testSystemTimeIsStableOnThisBox() {
+        long last = System.currentTimeMillis();
+        for (int i = 0; i < 50000; i++) {
+            long now = System.currentTimeMillis();
+            assertTrue("Iteration " + i,  now >= last);
+            last = now;
+        }
+    }
 
     /**
      * Test constant size of generated identifier.
@@ -160,7 +173,11 @@
         }
         final List sorted = new ArrayList(idList);
         Collections.sort(sorted);
-        assertEquals(idList, sorted);
+        final Iterator idIter = idList.iterator();
+        final Iterator sortIter = sorted.iterator();
+        for(int i = 0; idIter.hasNext(); ++i) {
+            assertEquals("Index " + i, idIter.next(), sortIter.next());
+        }
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message