[jboss-cvs] JBoss Messaging SVN: r4207 - trunk/tests/src/org/jboss/messaging/tests/unit/core/util.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 15 10:52:16 EDT 2008
Author: jmesnil
Date: 2008-05-15 10:52:15 -0400 (Thu, 15 May 2008)
New Revision: 4207
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/core/util/UUIDTest.java
Log:
added UUIDTest
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/util/UUIDTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/util/UUIDTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/util/UUIDTest.java 2008-05-15 14:52:15 UTC (rev 4207)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.tests.unit.core.util;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.util.UUIDGenerator;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class UUIDTest extends TestCase
+{
+ // Constants -----------------------------------------------------
+
+ private static final int MANY_TIMES = 100000;
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testManyUUIDs() throws Exception
+ {
+ List<String> uuids = new ArrayList<String>(MANY_TIMES);
+
+ UUIDGenerator gen = UUIDGenerator.getInstance();
+ InetAddress addr = InetAddress.getLocalHost();
+
+ for (int i = 0; i < MANY_TIMES; i++)
+ {
+ uuids.add(gen.generateTimeBasedUUID(addr).toString());
+ }
+
+ // we sort the UUIDs...
+ Collections.sort(uuids);
+ // ...and put them in a set to check duplicates
+ Set<String> uuidsSet = new HashSet<String>(uuids);
+
+ assertEquals(MANY_TIMES, uuidsSet.size());
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
More information about the jboss-cvs-commits
mailing list