directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r917225 - in /directory/apacheds/trunk/avl-partition/src: main/java/org/apache/directory/server/core/partition/avl/ test/java/org/apache/directory/server/core/partition/avl/
Date Sun, 28 Feb 2010 17:51:20 GMT
Author: seelmann
Date: Sun Feb 28 17:51:20 2010
New Revision: 917225

URL: http://svn.apache.org/viewvc?rev=917225&view=rev
Log:
formatting

Modified:
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
    directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java?rev=917225&r1=917224&r2=917225&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlIndex.java
Sun Feb 28 17:51:20 2010
@@ -42,44 +42,44 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AvlIndex<K,O> implements Index<K, O>
+public class AvlIndex<K, O> implements Index<K, O>
 {
     private Normalizer normalizer;
     private AttributeType attributeType;
-    private AvlTable<K,Long> forward;
-    private AvlTable<Long,K> reverse;
+    private AvlTable<K, Long> forward;
+    private AvlTable<Long, K> reverse;
     private String attributeId;
-    
-    
+
+
     public AvlIndex()
     {
     }
 
-    
+
     public AvlIndex( String attributeId )
     {
         setAttributeId( attributeId );
     }
 
-    
+
     void initialize( AttributeType attributeType ) throws Exception
     {
         this.attributeType = attributeType;
 
         MatchingRule mr = attributeType.getEquality();
-        
+
         if ( mr == null )
         {
             mr = attributeType.getOrdering();
         }
-        
+
         if ( mr == null )
         {
             mr = attributeType.getSubstring();
         }
 
         normalizer = mr.getNormalizer();
-        
+
         if ( normalizer == null )
         {
             throw new Exception( I18n.err( I18n.ERR_212, attributeType ) );
@@ -92,9 +92,7 @@
          * primary keys.  A value for an attribute can occur several times in
          * different entries so the forward map can have more than one value.
          */
-        forward = new AvlTable<K, Long>(
-            attributeType.getName(), 
-            comp, LongComparator.INSTANCE, true);
+        forward = new AvlTable<K, Long>( attributeType.getName(), comp, LongComparator.INSTANCE,
true );
 
         /*
          * Now the reverse map stores the primary key into the master table as
@@ -104,22 +102,15 @@
          */
         if ( attributeType.isSingleValued() )
         {
-            reverse = new AvlTable<Long,K>(
-                attributeType.getName(),
-                LongComparator.INSTANCE,
-                comp,
-                false );
+            reverse = new AvlTable<Long, K>( attributeType.getName(), LongComparator.INSTANCE,
comp, false );
         }
         else
         {
-            reverse = new AvlTable<Long,K>(
-                attributeType.getName(),
-                LongComparator.INSTANCE, comp,
-                true);
+            reverse = new AvlTable<Long, K>( attributeType.getName(), LongComparator.INSTANCE,
comp, true );
         }
     }
 
-    
+
     public void add( K attrVal, Long id ) throws Exception
     {
         forward.put( getNormalized( attrVal ), id );
@@ -160,11 +151,11 @@
      */
     public void drop( Long id ) throws Exception
     {
-        Cursor<Tuple<Long,K>> cursor = reverse.cursor( id );
+        Cursor<Tuple<Long, K>> cursor = reverse.cursor( id );
 
         while ( cursor.next() )
         {
-            Tuple<Long,K> tuple = cursor.get();
+            Tuple<Long, K> tuple = cursor.get();
             forward.remove( tuple.getValue(), id );
         }
 
@@ -298,12 +289,12 @@
     @SuppressWarnings("unchecked")
     public K getNormalized( K attrVal ) throws Exception
     {
-        if( attrVal instanceof Long )
+        if ( attrVal instanceof Long )
         {
             return attrVal;
         }
 
-        if( attrVal instanceof String )
+        if ( attrVal instanceof String )
         {
             return ( K ) normalizer.normalize( ( String ) attrVal );
         }
@@ -405,7 +396,7 @@
         return reverse.hasLessOrEqual( id );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -441,7 +432,7 @@
         this.attributeId = attributeId;
     }
 
-    
+
     /**
      * throws UnsupportedOperationException cause it is a in-memory index
      */
@@ -450,7 +441,7 @@
         throw new UnsupportedOperationException( I18n.err( I18n.ERR_213 ) );
     }
 
-    
+
     /**
      * this method always returns null for AvlIndex cause this is a in-memory index.
      */
@@ -459,7 +450,7 @@
         return null;
     }
 
-    
+
     /**
      * throws UnsupportedOperationException cause it is a in-memory index
      */
@@ -468,7 +459,7 @@
         throw new UnsupportedOperationException( I18n.err( I18n.ERR_214 ) );
     }
 
-    
+
     public int getCacheSize()
     {
         return 0;

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java?rev=917225&r1=917224&r2=917225&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
Sun Feb 28 17:51:20 2010
@@ -61,7 +61,7 @@
     /**
      * {@inheritDoc}
      */
-    public void initialize( ) throws Exception
+    public void initialize() throws Exception
     {
         setSchemaManager( schemaManager );
 
@@ -102,7 +102,8 @@
 
             String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId()
);
 
-            if ( SYS_INDEX_OIDS.contains( schemaManager.getAttributeTypeRegistry().getOidByName(
index.getAttributeId() ) ) )
+            if ( SYS_INDEX_OIDS.contains( schemaManager.getAttributeTypeRegistry()
+                .getOidByName( index.getAttributeId() ) ) )
             {
                 if ( oid.equals( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) )
                 {
@@ -158,10 +159,10 @@
      */
     public final void modify( long entryId, List<Modification> modifications ) throws
Exception
     {
-        ((AvlStore<ServerEntry>)store).modify( entryId, modifications );
+        ( ( AvlStore<ServerEntry> ) store ).modify( entryId, modifications );
     }
-    
-    
+
+
     /*
      * TODO requires review 
      * 
@@ -172,7 +173,7 @@
      */
     public AvlStore<ServerEntry> getStore()
     {
-        return (AvlStore<ServerEntry>)store;
+        return ( AvlStore<ServerEntry> ) store;
     }
-    
+
 }

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=917225&r1=917224&r2=917225&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
Sun Feb 28 17:51:20 2010
@@ -823,7 +823,7 @@
                 }
                 else
                 {
-                    LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() )   );
+                    LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() ) );
                 }
             }
 

Modified: directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java?rev=917225&r1=917224&r2=917225&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
Sun Feb 28 17:51:20 2010
@@ -92,7 +92,7 @@
     @BeforeClass
     public static void setup() throws Exception
     {
-    	String workingDirectory = System.getProperty( "workingDirectory" );
+        String workingDirectory = System.getProperty( "workingDirectory" );
 
         if ( workingDirectory == null )
         {
@@ -105,7 +105,7 @@
         SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory
) );
         extractor.extractOrCopy( true );
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
-        
+
         schemaManager = new DefaultSchemaManager( loader );
 
         boolean loaded = schemaManager.loadAllEnabled();
@@ -151,23 +151,23 @@
     {
         AvlStore<Attributes> store = new AvlStore<Attributes>();
         store.setSyncOnWrite( true ); // for code coverage
-        
+
         assertNull( store.getAliasIndex() );
-        store.setAliasIndex( new AvlIndex<String,Attributes>( "alias" ) );
+        store.setAliasIndex( new AvlIndex<String, Attributes>( "alias" ) );
         assertNotNull( store.getAliasIndex() );
 
         assertEquals( 0, store.getCacheSize() );
 
         assertNull( store.getPresenceIndex() );
-        store.setPresenceIndex( new AvlIndex<String,Attributes>( "existence" ) );
+        store.setPresenceIndex( new AvlIndex<String, Attributes>( "existence" ) );
         assertNotNull( store.getPresenceIndex() );
 
         assertNull( store.getOneLevelIndex() );
-        store.setOneLevelIndex( new AvlIndex<Long,Attributes>( "hierarchy" ) );
+        store.setOneLevelIndex( new AvlIndex<Long, Attributes>( "hierarchy" ) );
         assertNotNull( store.getOneLevelIndex() );
-        
+
         assertNull( store.getSubLevelIndex() );
-        store.setSubLevelIndex( new AvlIndex<Long,Attributes>( "sublevel" ) );
+        store.setSubLevelIndex( new AvlIndex<Long, Attributes>( "sublevel" ) );
         assertNotNull( store.getSubLevelIndex() );
 
         assertNull( store.getName() );
@@ -175,15 +175,15 @@
         assertEquals( "foo", store.getName() );
 
         assertNull( store.getNdnIndex() );
-        store.setNdnIndex( new AvlIndex<String,Attributes>( "ndn" ) );
+        store.setNdnIndex( new AvlIndex<String, Attributes>( "ndn" ) );
         assertNotNull( store.getNdnIndex() );
 
         assertNull( store.getOneAliasIndex() );
-        store.setOneAliasIndex( new AvlIndex<Long,Attributes>( "oneAlias" ) );
+        store.setOneAliasIndex( new AvlIndex<Long, Attributes>( "oneAlias" ) );
         assertNotNull( store.getNdnIndex() );
 
         assertNull( store.getSubAliasIndex() );
-        store.setSubAliasIndex( new AvlIndex<Long,Attributes>( "subAlias" ) );
+        store.setSubAliasIndex( new AvlIndex<Long, Attributes>( "subAlias" ) );
         assertNotNull( store.getSubAliasIndex() );
 
         assertNull( store.getSuffixDn() );
@@ -191,15 +191,15 @@
         assertEquals( "dc=example,dc=com", store.getSuffixDn() );
 
         assertNull( store.getUpdnIndex() );
-        store.setUpdnIndex( new AvlIndex<String,Attributes>( "updn" ) );
+        store.setUpdnIndex( new AvlIndex<String, Attributes>( "updn" ) );
         assertNotNull( store.getUpdnIndex() );
 
         assertNotNull( store.getUpSuffix() );
         assertNotNull( store.getSuffix() );
 
         assertEquals( 0, store.getUserIndices().size() );
-        Set<Index<?,Attributes>> set = new HashSet<Index<?,Attributes>>();
-        set.add( new AvlIndex<Object,Attributes>( "foo" ) );
+        Set<Index<?, Attributes>> set = new HashSet<Index<?, Attributes>>();
+        set.add( new AvlIndex<Object, Attributes>( "foo" ) );
         store.setUserIndices( set );
         assertEquals( set.size(), store.getUserIndices().size() );
 
@@ -221,60 +221,132 @@
     public void testSimplePropertiesLocked() throws Exception
     {
         assertNotNull( store.getAliasIndex() );
-        try { store.setAliasIndex( new AvlIndex<String,ServerEntry>( "alias" ) ); fail();
}
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setAliasIndex( new AvlIndex<String, ServerEntry>( "alias" ) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertEquals( 0, store.getCacheSize() );
 
         assertNotNull( store.getPresenceIndex() );
-        try { store.setPresenceIndex( new AvlIndex<String,ServerEntry>( "existence"
) ); fail(); }
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setPresenceIndex( new AvlIndex<String, ServerEntry>( "existence"
) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getOneLevelIndex() );
-        try { store.setOneLevelIndex( new AvlIndex<Long,ServerEntry>( "hierarchy" )
); fail(); }
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setOneLevelIndex( new AvlIndex<Long, ServerEntry>( "hierarchy" )
);
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getSubLevelIndex() );
-        try { store.setSubLevelIndex( new AvlIndex<Long,ServerEntry>( "sublevel" )
); fail(); }
-        catch( IllegalStateException e ) {}
-        
+        try
+        {
+            store.setSubLevelIndex( new AvlIndex<Long, ServerEntry>( "sublevel" ) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
+
         assertNotNull( store.getName() );
-        try { store.setName( "foo" ); fail(); }
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setName( "foo" );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getNdnIndex() );
-        try { store.setNdnIndex( new AvlIndex<String,ServerEntry>( "ndn" ) ); fail();
}
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setNdnIndex( new AvlIndex<String, ServerEntry>( "ndn" ) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getOneAliasIndex() );
-        try { store.setOneAliasIndex( new AvlIndex<Long,ServerEntry>( "oneAlias" )
); fail(); }
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setOneAliasIndex( new AvlIndex<Long, ServerEntry>( "oneAlias" ) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getSubAliasIndex() );
-        try { store.setSubAliasIndex( new AvlIndex<Long,ServerEntry>( "subAlias" )
); fail(); }
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setSubAliasIndex( new AvlIndex<Long, ServerEntry>( "subAlias" ) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getSuffixDn() );
-        try { store.setSuffixDn( "dc=example,dc=com" ); fail(); }
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setSuffixDn( "dc=example,dc=com" );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
 
         assertNotNull( store.getUpdnIndex() );
-        try { store.setUpdnIndex( new AvlIndex<String,ServerEntry>( "updn" ) ); fail();
}
-        catch( IllegalStateException e ) {}
+        try
+        {
+            store.setUpdnIndex( new AvlIndex<String, ServerEntry>( "updn" ) );
+            fail();
+        }
+        catch ( IllegalStateException e )
+        {
+        }
         Iterator<String> systemIndices = store.systemIndices();
-        
+
         for ( int ii = 0; ii < 11; ii++ )
         {
             assertTrue( systemIndices.hasNext() );
             assertNotNull( systemIndices.next() );
         }
-        
+
         assertFalse( systemIndices.hasNext() );
         assertNotNull( store.getSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID )
);
-        try { store.getSystemIndex( "bogus" ); fail(); }
-        catch ( IndexNotFoundException e ) {}
-        try { store.getSystemIndex( "dc" ); fail(); }
-        catch ( IndexNotFoundException e ) {}
+        try
+        {
+            store.getSystemIndex( "bogus" );
+            fail();
+        }
+        catch ( IndexNotFoundException e )
+        {
+        }
+        try
+        {
+            store.getSystemIndex( "dc" );
+            fail();
+        }
+        catch ( IndexNotFoundException e )
+        {
+        }
 
         assertNotNull( store.getUpSuffix() );
         assertNotNull( store.getSuffix() );
@@ -286,14 +358,26 @@
         Iterator<String> userIndices = store.userIndices();
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
-        assertTrue( userIndices.hasNext() );        
+        assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
-        assertFalse( userIndices.hasNext() );        
+        assertFalse( userIndices.hasNext() );
         assertNotNull( store.getUserIndex( SchemaConstants.OU_AT_OID ) );
-        try { store.getUserIndex( "bogus" ); fail(); }
-        catch ( IndexNotFoundException e ) {}
-        try { store.getUserIndex( "dc" ); fail(); }
-        catch ( IndexNotFoundException e ) {}
+        try
+        {
+            store.getUserIndex( "bogus" );
+            fail();
+        }
+        catch ( IndexNotFoundException e )
+        {
+        }
+        try
+        {
+            store.getUserIndex( "dc" );
+            fail();
+        }
+        catch ( IndexNotFoundException e )
+        {
+        }
 
         assertNull( store.getWorkingDirectory() );
 
@@ -329,7 +413,7 @@
         assertNull( store.getParentId( 0L ) );
 
         // should NOW be allowed
-        store.delete( 1L ); 
+        store.delete( 1L );
     }
 
 
@@ -338,182 +422,199 @@
     {
         assertEquals( 3, store.getChildCount( 1L ) );
 
-        Cursor<IndexEntry<Long,ServerEntry>> cursor = store.list( 1L );
+        Cursor<IndexEntry<Long, ServerEntry>> cursor = store.list( 1L );
         assertNotNull( cursor );
         cursor.beforeFirst();
         assertTrue( cursor.next() );
         assertEquals( 2L, ( long ) cursor.get().getId() );
         assertTrue( cursor.next() );
         assertEquals( 3, store.getChildCount( 1L ) );
-        
+
         store.delete( 2L );
         assertEquals( 2, store.getChildCount( 1L ) );
         assertEquals( 10, store.count() );
-        
+
         // add an alias and delete to test dropAliasIndices method
         LdapDN dn = new LdapDN( "commonName=Jack Daniels,ou=Apache,ou=Board of Directors,o=Good
Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
         DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "alias", "extensibleObject" );
         entry.add( "ou", "Apache" );
-        entry.add( "commonName",  "Jack Daniels");
+        entry.add( "commonName", "Jack Daniels" );
         entry.add( "aliasedObjectName", "cn=Jack Daniels,ou=Engineering,o=Good Times Co."
);
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
         entry.add( "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
-        
+
         store.delete( 12L ); // drops the alias indices
-        
+
     }
-    
+
 
     @Test
     public void testSubLevelIndex() throws Exception
     {
-      Index idx = store.getSubLevelIndex();
-      
-      assertEquals( 19, idx.count() );
-      
-      Cursor<IndexEntry<Long,Attributes>> cursor = idx.forwardCursor( 2L );
-      
-      assertTrue( cursor.next() );
-      assertEquals( 2, ( long ) cursor.get().getId() );
-      
-      assertTrue( cursor.next() );
-      assertEquals( 5, ( long ) cursor.get().getId() );
-      
-      assertTrue( cursor.next() );
-      assertEquals( 6, ( long ) cursor.get().getId() );
-
-      assertFalse( cursor.next() );
-      
-      idx.drop( 5L );
-      
-      cursor = idx.forwardCursor( 2L );
-
-      assertTrue( cursor.next() );
-      assertEquals( 2, ( long ) cursor.get().getId() );
-      
-      assertTrue( cursor.next() );
-      assertEquals( 6, ( long ) cursor.get().getId() );
-      
-      assertFalse( cursor.next() );
-      
-      // dn id 12
-      LdapDN martinDn = new LdapDN( "cn=Marting King,ou=Sales,o=Good Times Co." );
-      martinDn.normalize( schemaManager.getNormalizerMapping() );
-      DefaultServerEntry entry = new DefaultServerEntry( schemaManager, martinDn );
-      entry.add( "objectClass", "top", "person", "organizationalPerson" );
-      entry.add( "ou", "Sales" );
-      entry.add( "cn",  "Martin King");
-      entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-      entry.add( "entryUUID", UUID.randomUUID().toString() );
-      store.add( entry );
-      
-      cursor = idx.forwardCursor( 2L);
-      cursor.afterLast();
-      assertTrue( cursor.previous() );
-      assertEquals( 12, ( long ) cursor.get().getId() );
-      
-      LdapDN newParentDn = new LdapDN( "ou=Board of Directors,o=Good Times Co." );
-      newParentDn.normalize( schemaManager.getNormalizerMapping() );
-      
-      store.move( martinDn, newParentDn );
-      cursor = idx.forwardCursor( 3L);
-      cursor.afterLast();
-      assertTrue( cursor.previous() );
-      assertEquals( 12, ( long ) cursor.get().getId() );
-      
-      // dn id 13
-      LdapDN marketingDn = new LdapDN( "ou=Marketing,ou=Sales,o=Good Times Co." );
-      marketingDn.normalize( schemaManager.getNormalizerMapping() );
-      entry = new DefaultServerEntry( schemaManager, marketingDn );
-      entry.add( "objectClass", "top", "organizationalUnit" );
-      entry.add( "ou", "Marketing" );
-      entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-      entry.add( "entryUUID", UUID.randomUUID().toString() );
-      store.add( entry );
-
-      // dn id 14
-      LdapDN jimmyDn = new LdapDN( "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co."
);
-      jimmyDn.normalize( schemaManager.getNormalizerMapping() );
-      entry = new DefaultServerEntry( schemaManager, jimmyDn );
-      entry.add( "objectClass", "top", "person", "organizationalPerson" );
-      entry.add( "ou", "Marketing" );
-      entry.add( "cn",  "Jimmy Wales");
-      entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-      entry.add( "entryUUID", UUID.randomUUID().toString() );
-      store.add( entry );
-      
-      store.move( marketingDn, newParentDn );
-
-      cursor = idx.forwardCursor( 3L);
-      cursor.afterLast();
-
-      assertTrue( cursor.previous() );
-      assertEquals( 14, ( long ) cursor.get().getId() );
-      
-      assertTrue( cursor.previous() );
-      assertEquals( 13, ( long ) cursor.get().getId() );
-
-      assertTrue( cursor.previous() );
-      assertEquals( 12, ( long ) cursor.get().getId() );
-
-      assertTrue( cursor.previous() );
-      assertEquals( 10, ( long ) cursor.get().getId() );
-
-      assertTrue( cursor.previous() );
-      assertEquals( 9, ( long ) cursor.get().getId() );
-
-      assertTrue( cursor.previous() );
-      assertEquals( 7, ( long ) cursor.get().getId() );
-
-      assertTrue( cursor.previous() );
-      assertEquals( 3, ( long ) cursor.get().getId() );
-      
-      assertFalse( cursor.previous() );
+        Index idx = store.getSubLevelIndex();
+
+        assertEquals( 19, idx.count() );
+
+        Cursor<IndexEntry<Long, Attributes>> cursor = idx.forwardCursor( 2L );
+
+        assertTrue( cursor.next() );
+        assertEquals( 2, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.next() );
+        assertEquals( 5, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.next() );
+        assertEquals( 6, ( long ) cursor.get().getId() );
+
+        assertFalse( cursor.next() );
+
+        idx.drop( 5L );
+
+        cursor = idx.forwardCursor( 2L );
+
+        assertTrue( cursor.next() );
+        assertEquals( 2, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.next() );
+        assertEquals( 6, ( long ) cursor.get().getId() );
+
+        assertFalse( cursor.next() );
+
+        // dn id 12
+        LdapDN martinDn = new LdapDN( "cn=Marting King,ou=Sales,o=Good Times Co." );
+        martinDn.normalize( schemaManager.getNormalizerMapping() );
+        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, martinDn );
+        entry.add( "objectClass", "top", "person", "organizationalPerson" );
+        entry.add( "ou", "Sales" );
+        entry.add( "cn", "Martin King" );
+        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
+        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        store.add( entry );
+
+        cursor = idx.forwardCursor( 2L );
+        cursor.afterLast();
+        assertTrue( cursor.previous() );
+        assertEquals( 12, ( long ) cursor.get().getId() );
+
+        LdapDN newParentDn = new LdapDN( "ou=Board of Directors,o=Good Times Co." );
+        newParentDn.normalize( schemaManager.getNormalizerMapping() );
+
+        store.move( martinDn, newParentDn );
+        cursor = idx.forwardCursor( 3L );
+        cursor.afterLast();
+        assertTrue( cursor.previous() );
+        assertEquals( 12, ( long ) cursor.get().getId() );
+
+        // dn id 13
+        LdapDN marketingDn = new LdapDN( "ou=Marketing,ou=Sales,o=Good Times Co." );
+        marketingDn.normalize( schemaManager.getNormalizerMapping() );
+        entry = new DefaultServerEntry( schemaManager, marketingDn );
+        entry.add( "objectClass", "top", "organizationalUnit" );
+        entry.add( "ou", "Marketing" );
+        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
+        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        store.add( entry );
+
+        // dn id 14
+        LdapDN jimmyDn = new LdapDN( "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times
Co." );
+        jimmyDn.normalize( schemaManager.getNormalizerMapping() );
+        entry = new DefaultServerEntry( schemaManager, jimmyDn );
+        entry.add( "objectClass", "top", "person", "organizationalPerson" );
+        entry.add( "ou", "Marketing" );
+        entry.add( "cn", "Jimmy Wales" );
+        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
+        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        store.add( entry );
+
+        store.move( marketingDn, newParentDn );
+
+        cursor = idx.forwardCursor( 3L );
+        cursor.afterLast();
+
+        assertTrue( cursor.previous() );
+        assertEquals( 14, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.previous() );
+        assertEquals( 13, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.previous() );
+        assertEquals( 12, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.previous() );
+        assertEquals( 10, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.previous() );
+        assertEquals( 9, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.previous() );
+        assertEquals( 7, ( long ) cursor.get().getId() );
+
+        assertTrue( cursor.previous() );
+        assertEquals( 3, ( long ) cursor.get().getId() );
+
+        assertFalse( cursor.previous() );
     }
-   
-    
+
+
     @Test
     public void testConvertIndex() throws Exception
     {
         Index nonAvlIndex = new Index()
         {
 
-            public void add( Object attrVal, Long id ) throws Exception { }
+            public void add( Object attrVal, Long id ) throws Exception
+            {
+            }
+
+
+            public void close() throws Exception
+            {
+            }
 
-            public void close() throws Exception { }
 
             public int count() throws Exception
             {
                 return 0;
             }
 
+
             public int count( Object attrVal ) throws Exception
             {
                 return 0;
             }
 
-            public void drop( Long id ) throws Exception { }
 
-            public void drop( Object attrVal, Long id ) throws Exception { }
+            public void drop( Long id ) throws Exception
+            {
+            }
+
+
+            public void drop( Object attrVal, Long id ) throws Exception
+            {
+            }
+
 
             public IndexCursor forwardCursor() throws Exception
             {
                 return null;
             }
 
+
             public IndexCursor forwardCursor( Object key ) throws Exception
             {
                 return null;
             }
 
+
             public Long forwardLookup( Object attrVal ) throws Exception
             {
                 return null;
             }
 
+
             public Cursor forwardValueCursor( Object key ) throws Exception
             {
                 return null;
@@ -597,81 +698,104 @@
                 return null;
             }
 
+
             public String getAttributeId()
             {
                 return "ou";
             }
 
+
             public int getCacheSize()
             {
                 return 10;
             }
 
+
             public Object getNormalized( Object attrVal ) throws Exception
             {
                 return null;
             }
 
+
             public File getWkDirPath()
             {
-                return new File(".");
+                return new File( "." );
             }
 
+
             public int greaterThanCount( Object attrVal ) throws Exception
             {
                 return 0;
             }
 
+
             public boolean isCountExact()
             {
                 return false;
             }
 
+
             public int lessThanCount( Object attrVal ) throws Exception
             {
                 return 0;
             }
 
+
             public IndexCursor reverseCursor() throws Exception
             {
                 return null;
             }
 
+
             public IndexCursor reverseCursor( Long id ) throws Exception
             {
                 return null;
             }
 
+
             public Object reverseLookup( Long id ) throws Exception
             {
                 return null;
             }
 
+
             public Cursor reverseValueCursor( Long id ) throws Exception
             {
                 return null;
             }
 
-            public void setAttributeId( String attributeId ) { }
 
-            public void setCacheSize( int cacheSize ) { }
+            public void setAttributeId( String attributeId )
+            {
+            }
+
+
+            public void setCacheSize( int cacheSize )
+            {
+            }
+
+
+            public void setWkDirPath( File wkDirPath )
+            {
+            }
 
-            public void setWkDirPath( File wkDirPath ) { }
 
-            public void sync() throws Exception { }
-            
+            public void sync() throws Exception
+            {
+            }
+
         };
-        
+
         Method convertIndex = store.getClass().getDeclaredMethod( "convert", Index.class
);
         convertIndex.setAccessible( true );
         Object obj = convertIndex.invoke( store, nonAvlIndex );
-        
+
         assertNotNull( obj );
         assertEquals( AvlIndex.class, obj.getClass() );
     }
-    
-    
-    @Test( expected = LdapNameNotFoundException.class )
+
+
+    @Test(expected = LdapNameNotFoundException.class)
     public void testAddWithoutParentId() throws Exception
     {
         LdapDN dn = new LdapDN( "cn=Marting King,ou=Not Present,o=Good Times Co." );
@@ -679,23 +803,23 @@
         DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Not Present" );
-        entry.add( "cn",  "Martin King");
+        entry.add( "cn", "Martin King" );
         store.add( entry );
     }
-    
-    
-    @Test( expected = LdapSchemaViolationException.class )
+
+
+    @Test(expected = LdapSchemaViolationException.class)
     public void testAddWithoutObjectClass() throws Exception
     {
         LdapDN dn = new LdapDN( "cn=Martin King,ou=Sales,o=Good Times Co." );
         dn.normalize( schemaManager.getNormalizerMapping() );
         DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         entry.add( "ou", "Sales" );
-        entry.add( "cn",  "Martin King");
+        entry.add( "cn", "Martin King" );
         store.add( entry );
     }
-        
-    
+
+
     @Test
     public void testModifyAddOUAttrib() throws Exception
     {
@@ -703,18 +827,18 @@
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT,
-            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );
+        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT, schemaManager
+            .lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );
         attrib.add( "Engineering" );
-        
+
         Modification add = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attrib
);
-        
+
         mods.add( add );
-        
+
         store.modify( dn, mods );
     }
-    
-    
+
+
     @Test
     public void testRename() throws Exception
     {
@@ -723,18 +847,18 @@
         DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Engineering" );
-        entry.add( "cn",  "Private Ryan");
+        entry.add( "cn", "Private Ryan" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
         entry.add( "entryUUID", UUID.randomUUID().toString() );
 
         store.add( entry );
-        
-        RDN rdn = new RDN("sn=James");
-        
+
+        RDN rdn = new RDN( "sn=James" );
+
         store.rename( dn, rdn, true );
     }
-    
-    
+
+
     @Test
     public void testRenameEscaped() throws Exception
     {
@@ -743,25 +867,25 @@
         DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Engineering" );
-        entry.add( "cn",  "Private Ryan");
+        entry.add( "cn", "Private Ryan" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
         entry.add( "entryUUID", UUID.randomUUID().toString() );
-        
+
         store.add( entry );
-        
-        RDN rdn = new RDN("sn=Ja\\+es");
-        
+
+        RDN rdn = new RDN( "sn=Ja\\+es" );
+
         store.rename( dn, rdn, true );
-        
+
         LdapDN dn2 = new LdapDN( "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
         dn2.normalize( schemaManager.getNormalizerMapping() );
         Long id = store.getEntryId( dn2.getNormName() );
         assertNotNull( id );
         ServerEntry entry2 = store.lookup( id );
-        assertEquals("Ja+es", entry2.get( "sn" ).getString());
+        assertEquals( "Ja+es", entry2.get( "sn" ).getString() );
     }
-    
-    
+
+
     @Test
     public void testMove() throws Exception
     {
@@ -770,7 +894,7 @@
         DefaultServerEntry childEntry = new DefaultServerEntry( schemaManager, childDn );
         childEntry.add( "objectClass", "top", "person", "organizationalPerson" );
         childEntry.add( "ou", "Engineering" );
-        childEntry.add( "cn",  "Private Ryan");
+        childEntry.add( "cn", "Private Ryan" );
         childEntry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
         childEntry.add( "entryUUID", UUID.randomUUID().toString() );
 
@@ -779,25 +903,25 @@
         LdapDN parentDn = new LdapDN( "ou=Sales,o=Good Times Co." );
         parentDn.normalize( schemaManager.getNormalizerMapping() );
 
-        RDN rdn = new RDN("cn=Ryan");
+        RDN rdn = new RDN( "cn=Ryan" );
 
         store.move( childDn, parentDn, rdn, true );
 
         // to drop the alias indices   
         childDn = new LdapDN( "commonName=Jim Bean,ou=Apache,ou=Board of Directors,o=Good
Times Co." );
         childDn.normalize( schemaManager.getNormalizerMapping() );
-        
+
         parentDn = new LdapDN( "ou=Engineering,o=Good Times Co." );
         parentDn.normalize( schemaManager.getNormalizerMapping() );
-        
+
         assertEquals( 3, store.getSubAliasIndex().count() );
-        
-        store.move( childDn, parentDn);
-        
+
+        store.move( childDn, parentDn );
+
         assertEquals( 4, store.getSubAliasIndex().count() );
     }
-    
-    
+
+
     @Test
     public void testModifyAdd() throws Exception
     {
@@ -805,31 +929,31 @@
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SURNAME_AT,
-            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) );
-        
+        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SURNAME_AT,
schemaManager
+            .lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) );
+
         String attribVal = "Walker";
         attrib.add( attribVal );
-        
+
         Modification add = new ServerModification( ModificationOperation.ADD_ATTRIBUTE, attrib
);
         mods.add( add );
-        
+
         ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );
 
         store.modify( dn, mods );
         assertTrue( lookedup.get( "sn" ).contains( attribVal ) );
-        
+
         // testing the store.modify( dn, mod, entry ) API
         ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         attribVal = "+1974045779";
         entry.add( "telephoneNumber", attribVal );
-        
+
         store.modify( dn, ModificationOperation.ADD_ATTRIBUTE, entry );
         lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );
         assertTrue( lookedup.get( "telephoneNumber" ).contains( attribVal ) );
     }
-    
-    
+
+
     @Test
     public void testModifyReplace() throws Exception
     {
@@ -837,32 +961,32 @@
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT,
-            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
-        
+        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT, schemaManager
+            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
+
         String attribVal = "Johnny";
         attrib.add( attribVal );
-        
+
         Modification add = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE,
attrib );
         mods.add( add );
-        
+
         ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );
-        
+
         assertEquals( "WAlkeR", lookedup.get( "sn" ).get().getString() ); // before replacing
-        
+
         store.modify( dn, mods );
         assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );
-        
+
         // testing the store.modify( dn, mod, entry ) API
         ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         attribVal = "JWalker";
         entry.add( "sn", attribVal );
-        
+
         store.modify( dn, ModificationOperation.REPLACE_ATTRIBUTE, entry );
         assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );
     }
-    
-    
+
+
     @Test
     public void testModifyRemove() throws Exception
     {
@@ -870,32 +994,32 @@
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT,
-            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
-        
+        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.SN_AT, schemaManager
+            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
+
         Modification add = new ServerModification( ModificationOperation.REMOVE_ATTRIBUTE,
attrib );
         mods.add( add );
-        
+
         ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );
-        
+
         assertNotNull( lookedup.get( "sn" ).get() );
-        
+
         store.modify( dn, mods );
         assertNull( lookedup.get( "sn" ) );
-        
+
         // testing the store.modify( dn, mod, entry ) API
         ServerEntry entry = new DefaultServerEntry( schemaManager, dn );
-        
+
         // add an entry for the sake of testing the remove operation
         entry.add( "sn", "JWalker" );
         store.modify( dn, ModificationOperation.ADD_ATTRIBUTE, entry );
         assertNotNull( lookedup.get( "sn" ) );
-        
+
         store.modify( dn, ModificationOperation.REMOVE_ATTRIBUTE, entry );
         assertNull( lookedup.get( "sn" ) );
     }
 
-    
+
     @Test
     public void testModifyReplaceNonExistingIndexAttribute() throws Exception
     {
@@ -903,26 +1027,26 @@
         dn.normalize( schemaManager.getNormalizerMapping() );
         DefaultServerEntry entry = new DefaultServerEntry( schemaManager, dn );
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "cn", "Tim B");
+        entry.add( "cn", "Tim B" );
         entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
         entry.add( "entryUUID", UUID.randomUUID().toString() );
-        
+
         store.add( entry );
-        
+
         List<Modification> mods = new ArrayList<Modification>();
-        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT,
-            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );
-        
+        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT, schemaManager
+            .lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );
+
         String attribVal = "Marketing";
         attrib.add( attribVal );
-        
+
         Modification add = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE,
attrib );
         mods.add( add );
-        
+
         ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );
-        
+
         assertNull( lookedup.get( "ou" ) ); // before replacing
-        
+
         store.modify( dn, mods );
         assertEquals( attribVal, lookedup.get( "ou" ).get().getString() );
     }



Mime
View raw message