jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r793830 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
Date Tue, 14 Jul 2009 09:48:44 GMT
Author: jukka
Date: Tue Jul 14 09:48:43 2009
New Revision: 793830

URL: http://svn.apache.org/viewvc?rev=793830&view=rev
Log:
JCR-1232: Merge UUID to NodeId

Copy UUID format tests from UUIDTest to NodeIdTest.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java?rev=793830&r1=793829&r2=793830&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/id/NodeIdTest.java
Tue Jul 14 09:48:43 2009
@@ -78,4 +78,29 @@
         }
     }
 
+    public void testUuidFormat() {
+        long maxHigh = 0, maxLow = 0, minHigh = -1L, minLow = -1L;
+        for (int i = 0; i < 100; i++) {
+            NodeId id = new NodeId();
+            assertUuidFormat(id);
+            maxHigh |= id.getMostSignificantBits();
+            maxLow |= id.getLeastSignificantBits();
+            minHigh &= id.getMostSignificantBits();
+            minLow &= id.getLeastSignificantBits();
+        }
+        NodeId max = new NodeId(maxHigh, maxLow);
+        assertEquals("ffffffff-ffff-4fff-bfff-ffffffffffff", max.toString());
+        NodeId min = new NodeId(minHigh, minLow);
+        assertEquals("00000000-0000-4000-8000-000000000000", min.toString());
+    }
+
+    private void assertUuidFormat(NodeId id) {
+        long high = id.getMostSignificantBits();
+        long low = id.getLeastSignificantBits();
+        long high2 = (high & (~0xf000L)) | 0x4000L; // version 4 (random)
+        assertEquals(high, high2);
+        long low2 = (low & 0x3fffffffffffffffL) | 0x8000000000000000L; // variant (Leach-Salz)
+        assertEquals(low, low2);
+    }
+
 }



Mime
View raw message