directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1378577 [2/2] - in /directory/apacheds/branches/apacheds-mvbt: core-annotations/src/main/java/org/apache/directory/server/core/factory/ core-api/src/main/java/org/apache/directory/server/core/api/ core-api/src/main/java/org/apache/director...
Date Wed, 29 Aug 2012 14:26:00 GMT
Modified: directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=1378577&r1=1378576&r2=1378577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
(original)
+++ directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
Wed Aug 29 14:25:58 2012
@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.UUID;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
@@ -41,6 +42,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.After;
 import org.junit.Before;
@@ -56,7 +58,7 @@ import org.junit.Test;
 public class JdbmRdnIndexTest
 {
     private static File dbFileDir;
-    Index<ParentIdAndRdn<Long>, Entry, Long> idx;
+    Index<ParentIdAndRdn<UUID>, Entry, UUID> idx;
     private static SchemaManager schemaManager;
 
 
@@ -243,23 +245,23 @@ public class JdbmRdnIndexTest
         initIndex();
         assertEquals( 0, idx.count() );
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key"
) );
+        ParentIdAndRdn<UUID> key = new ParentIdAndRdn<UUID>( Strings.getUUID(
0L ), new Rdn( "cn=key" ) );
 
-        idx.add( key, 0l );
+        idx.add( key, Strings.getUUID( 0L ) );
         assertEquals( 1, idx.count() );
 
         // setting a different parentId should make this key a different key
-        key = new ParentIdAndRdn<Long>( 1L, new Rdn( "cn=key" ) );
+        key = new ParentIdAndRdn<UUID>( Strings.getUUID( 1L ), new Rdn( "cn=key" )
);
 
-        idx.add( key, 1l );
+        idx.add( key, Strings.getUUID( 1L ) );
         assertEquals( 2, idx.count() );
 
         //count shouldn't get affected cause of inserting the same key
-        idx.add( key, 2l );
+        idx.add( key, Strings.getUUID( 2L ) );
         assertEquals( 2, idx.count() );
 
-        key = new ParentIdAndRdn<Long>( 2L, new Rdn( "cn=key" ) );
-        idx.add( key, 3l );
+        key = new ParentIdAndRdn<UUID>( Strings.getUUID( 2L ), new Rdn( "cn=key" )
);
+        idx.add( key, Strings.getUUID( 3L ) );
         assertEquals( 3, idx.count() );
     }
 
@@ -269,11 +271,11 @@ public class JdbmRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key"
) );
+        ParentIdAndRdn<UUID> key = new ParentIdAndRdn<UUID>( Strings.getUUID(
0L ), new Rdn( "cn=key" ) );
 
         assertEquals( 0, idx.count( key ) );
 
-        idx.add( key, 0l );
+        idx.add( key, Strings.getUUID( 0L ) );
         assertEquals( 1, idx.count( key ) );
     }
 
@@ -287,19 +289,19 @@ public class JdbmRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager,
"cn=key" ) );
+        ParentIdAndRdn<UUID> key = new ParentIdAndRdn<UUID>( Strings.getUUID(
0L ), new Rdn( schemaManager, "cn=key" ) );
 
         assertNull( idx.forwardLookup( key ) );
 
-        idx.add( key, 0l );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
+        idx.add( key, Strings.getUUID( 0L ) );
+        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
+        assertEquals( key, idx.reverseLookup( Strings.getUUID( 0L ) ) );
 
         // check with the different case in UP name, this ensures that the custom
         // key comparator is used
-        key = new ParentIdAndRdn<Long>( 0L, new Rdn( schemaManager, "cn=KEY" ) );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
-        assertEquals( key, idx.reverseLookup( 0l ) );
+        key = new ParentIdAndRdn<UUID>( Strings.getUUID( 0L ), new Rdn( schemaManager,
"cn=KEY" ) );
+        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
+        assertEquals( key, idx.reverseLookup( Strings.getUUID( 0L ) ) );
     }
 
 
@@ -308,17 +310,17 @@ public class JdbmRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key"
) );
+        ParentIdAndRdn<UUID> key = new ParentIdAndRdn<UUID>( Strings.getUUID(
0L ), new Rdn( "cn=key" ) );
 
         assertNull( idx.forwardLookup( key ) );
 
         // test add/drop without adding any duplicates
-        idx.add( key, 0l );
-        assertEquals( 0, ( long ) idx.forwardLookup( key ) );
+        idx.add( key, Strings.getUUID( 0L ) );
+        assertEquals( Strings.getUUID( 0L ), idx.forwardLookup( key ) );
 
-        idx.drop( key, 0l );
+        idx.drop( key, Strings.getUUID( 0L ) );
         assertNull( idx.forwardLookup( key ) );
-        assertNull( idx.reverseLookup( 0l ) );
+        assertNull( idx.reverseLookup( Strings.getUUID( 0L ) ) );
     }
 
 
@@ -331,43 +333,43 @@ public class JdbmRdnIndexTest
     {
         initIndex();
 
-        ParentIdAndRdn<Long> key = new ParentIdAndRdn<Long>( 0L, new Rdn( "cn=key"
) );
+        ParentIdAndRdn<UUID> key = new ParentIdAndRdn<UUID>( Strings.getUUID(
0L ), new Rdn( "cn=key" ) );
 
         assertEquals( 0, idx.count() );
 
-        idx.add( key, 0l );
+        idx.add( key, Strings.getUUID( 0L ) );
         assertEquals( 1, idx.count() );
 
         for ( long i = 1; i < 5; i++ )
         {
-            key = new ParentIdAndRdn<Long>( i, new Rdn( "cn=key" + i ) );
+            key = new ParentIdAndRdn<UUID>( Strings.getUUID( i ), new Rdn( "cn=key"
+ i ) );
 
-            idx.add( key, i );
+            idx.add( key, Strings.getUUID( i ) );
         }
 
         assertEquals( 5, idx.count() );
 
         // use forward index's cursor
-        Cursor<IndexEntry<ParentIdAndRdn<Long>, Long>> cursor = idx.forwardCursor();
+        Cursor<IndexEntry<ParentIdAndRdn<UUID>, UUID>> cursor = idx.forwardCursor();
         cursor.beforeFirst();
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e1 = cursor.get();
-        assertEquals( 0, ( long ) e1.getId() );
+        IndexEntry<ParentIdAndRdn<UUID>, UUID> e1 = cursor.get();
+        assertEquals( Strings.getUUID( 0L ), e1.getId() );
         assertEquals( "cn=key", e1.getKey().getRdns()[0].getName() );
-        assertEquals( 0, e1.getKey().getParentId().longValue() );
+        assertEquals( Strings.getUUID( 0L ), e1.getKey().getParentId() );
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e2 = cursor.get();
-        assertEquals( 1, ( long ) e2.getId() );
+        IndexEntry<ParentIdAndRdn<UUID>, UUID> e2 = cursor.get();
+        assertEquals( Strings.getUUID( 1L ), e2.getId() );
         assertEquals( "cn=key1", e2.getKey().getRdns()[0].getName() );
-        assertEquals( 1, e2.getKey().getParentId().longValue() );
+        assertEquals( Strings.getUUID( 1L ), e2.getKey().getParentId() );
 
         cursor.next();
-        IndexEntry<ParentIdAndRdn<Long>, Long> e3 = cursor.get();
-        assertEquals( 2, ( long ) e3.getId() );
+        IndexEntry<ParentIdAndRdn<UUID>, UUID> e3 = cursor.get();
+        assertEquals( Strings.getUUID( 2L ), e3.getId() );
         assertEquals( "cn=key2", e3.getKey().getRdns()[0].getName() );
-        assertEquals( 2, e3.getKey().getParentId().longValue() );
+        assertEquals( Strings.getUUID( 2 ), e3.getKey().getParentId() );
 
         cursor.close();
     }

Modified: directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1378577&r1=1378576&r2=1378577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/branches/apacheds-mvbt/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Wed Aug 29 14:25:58 2012
@@ -60,6 +60,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schemaloader.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.After;
 import org.junit.Before;
@@ -221,7 +222,7 @@ public class JdbmStoreTest
         store2.add( new AddOperationContext( null, entry ) );
 
         // lookup the context entry
-        Long id = store2.getEntryId( suffixDn );
+        UUID id = store2.getEntryId( suffixDn );
         Entry lookup = store2.lookup( id, suffixDn );
         assertEquals( 2, lookup.getDn().size() );
 
@@ -237,9 +238,9 @@ public class JdbmStoreTest
         jdbmPartition.setSyncOnWrite( true ); // for code coverage
 
         assertNull( jdbmPartition.getAliasIndex() );
-        Index<String, Entry, Long> index = new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
+        Index<String, Entry, UUID> index = new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
             true );
-        ( ( Store<Entry, Long> ) jdbmPartition ).addIndex( index );
+        ( ( Store<Entry> ) jdbmPartition ).addIndex( index );
         assertNotNull( jdbmPartition.getAliasIndex() );
 
         assertEquals( JdbmPartition.DEFAULT_CACHE_SIZE, jdbmPartition.getCacheSize() );
@@ -259,7 +260,7 @@ public class JdbmStoreTest
         assertNotNull( jdbmPartition.getRdnIndex() );
 
         assertNull( jdbmPartition.getOneAliasIndex() );
-        ( ( Store<Entry, Long> ) jdbmPartition ).addIndex( new JdbmIndex<Long, Entry>(
+        ( ( Store<Entry> ) jdbmPartition ).addIndex( new JdbmIndex<Long, Entry>(
             ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, true ) );
         assertNotNull( jdbmPartition.getOneAliasIndex() );
 
@@ -465,43 +466,43 @@ public class JdbmStoreTest
     public void testFreshStore() throws Exception
     {
         Dn dn = new Dn( schemaManager, "o=Good Times Co." );
-        assertEquals( 1L, ( long ) store.getEntryId( dn ) );
+        assertEquals( Strings.getUUID( 1L ), store.getEntryId( dn ) );
         assertEquals( 11, store.count() );
-        assertEquals( "o=Good Times Co.", store.getEntryDn( 1L ).getName() );
-        assertEquals( dn.getNormName(), store.getEntryDn( 1L ).getNormName() );
-        assertEquals( dn.getName(), store.getEntryDn( 1L ).getName() );
+        assertEquals( "o=Good Times Co.", store.getEntryDn( Strings.getUUID( 1L ) ).getName()
);
+        assertEquals( dn.getNormName(), store.getEntryDn( Strings.getUUID( 1L ) ).getNormName()
);
+        assertEquals( dn.getName(), store.getEntryDn( Strings.getUUID( 1L ) ).getName() );
 
         // note that the suffix entry returns 0 for it's parent which does not exist
-        assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) );
-        assertNull( store.getParentId( 0L ) );
+        assertEquals( Strings.getUUID( 0L ), store.getParentId( store.getEntryId( dn ) )
);
+        assertNull( store.getParentId( Strings.getUUID( 0L ) ) );
 
         // should NOW be allowed
-        store.delete( 1L );
+        store.delete( Strings.getUUID( 1L ) );
     }
 
 
     @Test
     public void testEntryOperations() throws Exception
     {
-        assertEquals( 3, store.getChildCount( 1L ) );
+        assertEquals( 3, store.getChildCount( Strings.getUUID( 1L ) ) );
 
-        Cursor<IndexEntry<Long, Long>> cursor = store.list( 1L );
+        Cursor<IndexEntry<UUID, UUID>> cursor = store.list( Strings.getUUID(
1L ) );
         assertNotNull( cursor );
         cursor.beforeFirst();
         assertTrue( cursor.next() );
-        assertEquals( 3L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 3L ), cursor.get().getId() );
         assertTrue( cursor.next() );
-        assertEquals( 4L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 4L ), cursor.get().getId() );
         assertTrue( cursor.next() );
-        assertEquals( 2L, ( long ) cursor.get().getId() );
+        assertEquals( Strings.getUUID( 2L ), cursor.get().getId() );
         assertFalse( cursor.next() );
 
         cursor.close();
 
-        assertEquals( 3, store.getChildCount( 1L ) );
+        assertEquals( 3, store.getChildCount( Strings.getUUID( 1L ) ) );
 
-        store.delete( 2L );
-        assertEquals( 2, store.getChildCount( 1L ) );
+        store.delete( Strings.getUUID( 2L ) );
+        assertEquals( 2, store.getChildCount( Strings.getUUID( 1L ) ) );
         assertEquals( 10, store.count() );
 
         // add an alias and delete to test dropAliasIndices method
@@ -514,12 +515,12 @@ public class JdbmStoreTest
             "commonName: Jack Daniels",
             "aliasedObjectName: cn=Jack Daniels,ou=Engineering,o=Good Times Co.",
             "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
-            "entryUUID", UUID.randomUUID().toString() );
+            "entryUUID", Strings.getUUID( 12L ).toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         store.add( addContext );
 
-        store.delete( 12L ); // drops the alias indices
+        store.delete( Strings.getUUID( 12L ) ); // drops the alias indices
     }
 
 
@@ -612,7 +613,7 @@ public class JdbmStoreTest
         store.rename( dn, rdn, true, null );
 
         Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
-        Long id = store.getEntryId( dn2 );
+        UUID id = store.getEntryId( dn2 );
         assertNotNull( id );
         Entry entry2 = store.lookup( id, dn2 );
         assertEquals( "Ja+es", entry2.get( "sn" ).getString() );



Mime
View raw message