Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-20 11:50:52 +0000
committerEike Stepper2011-07-20 11:50:52 +0000
commitaf719ba16912427971a462cf41f6245cde962ab6 (patch)
tree8ea61c606d79b36652b1fdbcc7299aeac7ea0b9b /plugins/org.eclipse.net4j.tests
parentad46e775fa0f070dcb43eaea4e8b260e3e9bf443 (diff)
downloadcdo-af719ba16912427971a462cf41f6245cde962ab6.tar.gz
cdo-af719ba16912427971a462cf41f6245cde962ab6.tar.xz
cdo-af719ba16912427971a462cf41f6245cde962ab6.zip
[352561] Support client assigned CDOIDs (UUIDs)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352561
Diffstat (limited to 'plugins/org.eclipse.net4j.tests')
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java2
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java59
2 files changed, 61 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
index 8cf91ee8de..562992e7af 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
@@ -21,6 +21,7 @@ import org.eclipse.net4j.util.tests.SecurityTest;
import org.eclipse.net4j.util.tests.SortedFileMapTest;
import org.eclipse.net4j.util.tests.StringCompressorTest;
import org.eclipse.net4j.util.tests.SynchronizingCorrelatorTest;
+import org.eclipse.net4j.util.tests.UUIDGeneratorTest;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -33,6 +34,7 @@ public class AllTests
public static Test suite()
{
TestSuite suite = new TestSuite("Tests for Net4j"); //$NON-NLS-1$
+ suite.addTestSuite(UUIDGeneratorTest.class);
suite.addTestSuite(MultiMapTest.class);
suite.addTestSuite(SortedFileMapTest.class);
suite.addTestSuite(SynchronizingCorrelatorTest.class);
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java
new file mode 100644
index 0000000000..cfd89a788a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.tests;
+
+import org.eclipse.net4j.util.UUIDGenerator;
+
+/**
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public class UUIDGeneratorTest extends AbstractOMTest
+{
+ public void testCodec()
+ {
+ byte[] uuid = new byte[16];
+ long start = System.currentTimeMillis();
+
+ for (int b3 = Byte.MIN_VALUE; b3 <= Byte.MAX_VALUE; b3++)
+ {
+ for (int b2 = Byte.MIN_VALUE; b2 <= Byte.MAX_VALUE; b2++)
+ {
+ // System.out.println(b3 + ", " + b2);
+ for (int b1 = Byte.MIN_VALUE; b1 <= Byte.MAX_VALUE; b1++)
+ {
+ for (int off = 0; off < 13; off++)
+ {
+ check(uuid, b1, b2, b3, off);
+ }
+ }
+ }
+ }
+
+ long millis = System.currentTimeMillis() - start;
+ System.out.println("Millis: " + millis);
+ }
+
+ private static void check(byte[] uuid, int b1, int b2, int b3, int off)
+ {
+ uuid[0 + off] = (byte)b1;
+ uuid[2 + off] = (byte)b2;
+ uuid[3 + off] = (byte)b3;
+
+ String encoded = UUIDGenerator.DEFAULT.encode(uuid);
+ byte[] decoded = UUIDGenerator.DEFAULT.decode(encoded);
+
+ for (int i = 0; i < 3; i++)
+ {
+ assertEquals(uuid[i + off], decoded[i + off]);
+ }
+ }
+}

Back to the top