You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/07/08 13:10:13 UTC

svn commit: r1144255 - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-partition/src/ma...

Author: elecharny
Date: Fri Jul  8 11:10:13 2011
New Revision: 1144255

URL: http://svn.apache.org/viewvc?rev=1144255&view=rev
Log:
o The getRootId() method has been added to the Store interface
o Removed the Store.hasIndexOn( String id ), Store.getUserIndex( String id ) and Store.getSystemIndex( String id ) methods.
o Added some Javadoc
o The Store suffix ID is now computed only once
o Fixed the tests accordingly to those changes


Modified:
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Fri Jul  8 11:10:13 2011
@@ -95,8 +95,10 @@ public class JdbmStore<E> extends Abstra
     }
 
 
-    @Override
-    protected Long getRootId()
+    /**
+     * {@inheritDoc}
+     */
+    public Long getRootId()
     {
         return 0L;
     }

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Fri Jul  8 11:10:13 2011
@@ -100,7 +100,6 @@ public class JdbmStoreTest
     /** The SN AttributeType instance */
     private static AttributeType SN_AT;
 
-
     @BeforeClass
     public static void setup() throws Exception
     {
@@ -418,7 +417,7 @@ public class JdbmStoreTest
 
         try
         {
-            store.getSystemIndex( "bogus" );
+            store.getSystemIndex( SN_AT );
             fail();
         }
         catch ( IndexNotFoundException e )
@@ -448,7 +447,7 @@ public class JdbmStoreTest
         assertNotNull( store.getUserIndex( OU_AT ) );
         try
         {
-            store.getUserIndex( "bogus" );
+            store.getUserIndex( SN_AT );
             fail();
         }
         catch ( IndexNotFoundException e )
@@ -456,7 +455,7 @@ public class JdbmStoreTest
         }
         try
         {
-            store.getUserIndex( "dc" );
+            store.getUserIndex( DC_AT );
             fail();
         }
         catch ( IndexNotFoundException e )

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Fri Jul  8 11:10:13 2011
@@ -95,6 +95,9 @@ public abstract class AbstractStore<E, I
     /** The suffix Dn */
     protected Dn suffixDn;
 
+    /** The suffix ID */
+    private volatile ID suffixId;
+
     /** A pointer on the schemaManager */
     protected SchemaManager schemaManager;
 
@@ -243,6 +246,9 @@ public abstract class AbstractStore<E, I
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public Dn getSuffixDn()
     {
         return suffixDn;
@@ -392,28 +398,6 @@ public abstract class AbstractStore<E, I
 
 
     /**
-     * Gets the root ID of this store implementation.
-     *
-     * @return the root ID
-     */
-    protected abstract ID getRootId();
-
-
-    /**
-     * Gets the suffix ID of this store implementation.
-     *
-     * @return the suffix ID
-     */
-    protected ID getSuffixId() throws Exception
-    {
-        // TODO: optimize
-        ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( getRootId(), suffixDn.getRdns() );
-        
-        return rdnIdx.forwardLookup( key );
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public Iterator<String> userIndices()
@@ -434,15 +418,6 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
-    public boolean hasIndexOn( String id ) throws LdapException
-    {
-        return hasUserIndexOn( id ) || hasSystemIndexOn( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public boolean hasIndexOn( AttributeType attributeType ) throws LdapException
     {
         return hasUserIndexOn( attributeType ) || hasSystemIndexOn( attributeType );
@@ -518,68 +493,42 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
-    public Index<?, E, ID> getUserIndex( String id ) throws IndexNotFoundException
+    public Index<?, E, ID> getUserIndex( AttributeType attributeType ) throws IndexNotFoundException
     {
-        try
-        {
-            return getUserIndex( schemaManager.lookupAttributeTypeRegistry( id ) );
-        }
-        catch ( LdapException e )
+        if ( attributeType == null )
         {
-            String msg = I18n.err( I18n.ERR_128, id );
-            LOG.error( msg, e );
-            throw new IndexNotFoundException( msg, id, e );
+            throw new IndexNotFoundException( I18n.err( I18n.ERR_3, attributeType, attributeType ) );
         }
-    }
 
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<?, E, ID> getUserIndex( AttributeType attributeType ) throws IndexNotFoundException
-    {
-        String id = attributeType.getOid();
-
-        if ( userIndices.containsKey( id ) )
+        String oid = attributeType.getOid();
+        
+        if ( userIndices.containsKey( oid ) )
         {
-            return userIndices.get( id );
+            return userIndices.get( oid );
         }
 
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, id ) );
+        throw new IndexNotFoundException( I18n.err( I18n.ERR_3, attributeType, attributeType ) );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public Index<?, E, ID> getSystemIndex( String id ) throws IndexNotFoundException
+    public Index<?, E, ID> getSystemIndex( AttributeType attributeType ) throws IndexNotFoundException
     {
-        try
-        {
-            return getSystemIndex( schemaManager.lookupAttributeTypeRegistry( id ) );
-        }
-        catch ( LdapException e )
+        if ( attributeType == null )
         {
-            String msg = I18n.err( I18n.ERR_128, id );
-            LOG.error( msg, e );
-            throw new IndexNotFoundException( msg, id, e );
+            throw new IndexNotFoundException( I18n.err( I18n.ERR_2, attributeType, attributeType ) );
         }
-    }
-
 
-    /**
-     * {@inheritDoc}
-     */
-    public Index<?, E, ID> getSystemIndex( AttributeType attributeType ) throws IndexNotFoundException
-    {
-        String id = attributeType.getOid();
-
-        if ( systemIndices.containsKey( id ) )
+        String oid = attributeType.getOid();
+        
+        if ( systemIndices.containsKey( oid ) )
         {
-            return systemIndices.get( id );
+            return systemIndices.get( oid );
         }
 
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, id ) );
+        throw new IndexNotFoundException( I18n.err( I18n.ERR_2, attributeType, attributeType ) );
     }
 
 
@@ -951,11 +900,12 @@ public abstract class AbstractStore<E, I
         // Now work on the user defined userIndices
         for ( Attribute attribute : entry )
         {
-            String attributeOid = attribute.getAttributeType().getOid();
+            AttributeType attributeType = attribute.getAttributeType();
+            String attributeOid = attributeType.getOid();
 
-            if ( hasUserIndexOn( attribute.getAttributeType() ) )
+            if ( hasUserIndexOn( attributeType ) )
             {
-                Index<Object, E, ID> idx = ( Index<Object, E, ID> ) getUserIndex( attributeOid );
+                Index<Object, E, ID> idx = ( Index<Object, E, ID> ) getUserIndex( attributeType );
 
                 // here lookup by attributeId is OK since we got attributeId from
                 // the entry via the enumeration - it's in there as is for sure
@@ -1111,11 +1061,12 @@ public abstract class AbstractStore<E, I
         // Update the user indexes
         for ( Attribute attribute : entry )
         {
-            String attributeOid = attribute.getAttributeType().getOid();
+            AttributeType attributeType = attribute.getAttributeType();
+            String attributeOid = attributeType.getOid();
 
-            if ( hasUserIndexOn( attribute.getAttributeType() ) )
+            if ( hasUserIndexOn( attributeType ) )
             {
-                Index<?, E, ID> index = getUserIndex( attributeOid );
+                Index<?, E, ID> index = getUserIndex( attributeType );
 
                 // here lookup by attributeId is ok since we got attributeId from
                 // the entry via the enumeration - it's in there as is for sure
@@ -1180,7 +1131,7 @@ public abstract class AbstractStore<E, I
 
             if ( hasUserIndexOn( newNormType ) )
             {
-                Index<?, E, ID> index = getUserIndex( newNormType );
+                Index<?, E, ID> index = getUserIndex( newRdnAttrType );
                 ( ( Index ) index ).add( newNormValue, id );
 
                 // Make sure the altered entry shows the existence of the new attrib
@@ -1236,7 +1187,7 @@ public abstract class AbstractStore<E, I
 
                     if ( hasUserIndexOn( oldNormType ) )
                     {
-                        Index<?, E, ID> index = getUserIndex( oldNormType );
+                        Index<?, E, ID> index = getUserIndex( oldRdnAttrType );
                         ( ( Index ) index ).drop( oldNormValue, id );
 
                         /*
@@ -1485,6 +1436,7 @@ public abstract class AbstractStore<E, I
         }
 
         String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() );
+        AttributeType attributeType = mods.getAttributeType();
 
         // Special case for the ObjectClass index
         if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
@@ -1494,9 +1446,9 @@ public abstract class AbstractStore<E, I
                 objectClassIdx.add( value.getString(), id );
             }
         }
-        else if ( hasUserIndexOn( mods.getAttributeType() ) )
+        else if ( hasUserIndexOn( attributeType ) )
         {
-            Index<?, E, ID> index = getUserIndex( modsOid );
+            Index<?, E, ID> index = getUserIndex( attributeType );
 
             for ( Value<?> value : mods )
             {
@@ -1546,9 +1498,10 @@ public abstract class AbstractStore<E, I
         }
 
         String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() );
+        AttributeType attributeType = mods.getAttributeType();
 
         // Special case for the ObjectClass index
-        if ( mods.getAttributeType().equals( OBJECT_CLASS_AT ) )
+        if ( attributeType.equals( OBJECT_CLASS_AT ) )
         {
             // if the id exists in the index drop all existing attribute
             // value index entries and add new ones
@@ -1562,9 +1515,9 @@ public abstract class AbstractStore<E, I
                 objectClassIdx.add( value.getString(), id );
             }
         }
-        else if ( hasUserIndexOn( mods.getAttributeType() ) )
+        else if ( hasUserIndexOn( attributeType ) )
         {
-            Index<?, E, ID> index = getUserIndex( modsOid );
+            Index<?, E, ID> index = getUserIndex( attributeType );
 
             // if the id exists in the index drop all existing attribute
             // value index entries and add new ones
@@ -1637,9 +1590,10 @@ public abstract class AbstractStore<E, I
         }
 
         String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() );
+        AttributeType attributeType = mods.getAttributeType();
 
         // Special case for the ObjectClass index
-        if ( mods.getAttributeType().equals( OBJECT_CLASS_AT ) )
+        if ( attributeType.equals( OBJECT_CLASS_AT ) )
         {
             /*
              * If there are no attribute values in the modifications then this
@@ -1658,9 +1612,9 @@ public abstract class AbstractStore<E, I
                 }
             }
         }
-        else if ( hasUserIndexOn( mods.getAttributeType() ) )
+        else if ( hasUserIndexOn( attributeType ) )
         {
-            Index<?, E, ID> index = getUserIndex( modsOid );
+            Index<?, E, ID> index = getUserIndex( attributeType );
 
             /*
              * If there are no attribute values in the modifications then this
@@ -2216,4 +2170,20 @@ public abstract class AbstractStore<E, I
             throw errors;
         }
     }
+    
+    
+    /**
+     * Retrieve the SuffixID
+     */
+    private ID getSuffixId() throws Exception
+    {
+        if ( suffixId == null )
+        {
+            ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( getRootId(), suffixDn.getRdns() );
+            
+            suffixId = rdnIdx.forwardLookup( key );
+        }
+
+        return suffixId;
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java Fri Jul  8 11:10:13 2011
@@ -152,6 +152,13 @@ public interface Store<E, ID extends Com
 
 
     /**
+     * Gets the root ID of this store implementation.
+     *
+     * @return the root ID
+     */
+    ID getRootId();
+
+    /**
      * Sets the flag telling the server to flush on disk when some
      * modification has been done.
      * @param isSyncOnWrite A boolean set to true if we have to flush on disk 
@@ -324,16 +331,6 @@ public interface Store<E, ID extends Com
      * User's <strong>or</strong> System's index list 
      * @throws Exception If something went wrong
      */
-    boolean hasIndexOn( String id ) throws Exception;
-
-
-    /**
-     * Tells if an index is already present in the User's <strong>or</strong> System's index list
-     * @param attributeType The index we are looking for
-     * @return <code>true</code> if the index is already present in the
-     * User's <strong>or</strong> System's index list 
-     * @throws Exception If something went wrong
-     */
     boolean hasIndexOn( AttributeType attributeType ) throws Exception;
 
 
@@ -389,16 +386,7 @@ public interface Store<E, ID extends Com
 
     /**
      * Get the user index associated with the given name
-     * @param id The index name we are looking for
-     * @return The associated user index
-     * @throws IndexNotFoundException If the index does not exist
-     */
-    Index<?, E, ID> getUserIndex( String id ) throws IndexNotFoundException;
-
-
-    /**
-     * Get the user index associated with the given attributeType
-     * @param attributeType The index attributeType we are looking for
+     * @param attributeType The index name we are looking for
      * @return The associated user index
      * @throws IndexNotFoundException If the index does not exist
      */
@@ -407,16 +395,7 @@ public interface Store<E, ID extends Com
 
     /**
      * Get the system index associated with the given name
-     * @param id The index name we are looking for
-     * @return The associated system index
-     * @throws IndexNotFoundException If the index does not exist
-     */
-    Index<?, E, ID> getSystemIndex( String id ) throws IndexNotFoundException;
-
-
-    /**
-     * Get the system index associated with the given attributeType
-     * @param attributeType The index attributeType we are looking for
+     * @param attributeType The index name we are looking for
      * @return The associated system index
      * @throws IndexNotFoundException If the index does not exist
      */

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java Fri Jul  8 11:10:13 2011
@@ -142,8 +142,10 @@ public class AvlStore<E> extends Abstrac
     }
 
 
-    @Override
-    protected Long getRootId()
+    /**
+     * {@inheritDoc}
+     */
+    public Long getRootId()
     {
         return 0L;
     }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Fri Jul  8 11:10:13 2011
@@ -26,8 +26,8 @@ import org.apache.directory.server.i18n.
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
+import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.filter.LessEqNode;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Fri Jul  8 11:10:13 2011
@@ -29,8 +29,8 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
-import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
+import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.filter.SubstringNode;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java Fri Jul  8 11:10:13 2011
@@ -70,20 +70,17 @@ public class AbstractStoreTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractStoreTest.class );
 
-    private static File wkdir;
     private static Store<Entry, Long> store;
     private static SchemaManager schemaManager = null;
-    private static Dn EXAMPLE_COM;
     
     /** The OU AttributType instance */
     private static AttributeType OU_AT;
-
-    /** The CN AttributType instance */
-    private static AttributeType CN_AT;
-
+    
     /** The UID AttributType instance */
     private static AttributeType UID_AT;
-
+    
+    /** The CN AttributType instance */
+    private static AttributeType CN_AT;
 
     @BeforeClass
     public static void setup() throws Exception
@@ -110,12 +107,10 @@ public class AbstractStoreTest
         {
             fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
         }
-
-        EXAMPLE_COM = new Dn( schemaManager, "dc=example,dc=com" );
         
         OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
-        CN_AT = schemaManager.getAttributeType( SchemaConstants.CN_AT );
         UID_AT = schemaManager.getAttributeType( SchemaConstants.UID_AT );
+        CN_AT = schemaManager.getAttributeType( SchemaConstants.CN_AT );
     }
 
 

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java?rev=1144255&r1=1144254&r2=1144255&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Fri Jul  8 11:10:13 2011
@@ -89,13 +89,15 @@ public class AvlStoreTest
     /** The OU AttributeType instance */
     private static AttributeType OU_AT;
 
+    /** The SN AttributeType instance */
+    private static AttributeType SN_AT;
+
     /** The DC AttributeType instance */
     private static AttributeType DC_AT;
     
     /** The ApacheAlias AttributeType instance */
     private static AttributeType APACHE_ALIAS_AT;
 
-
     @BeforeClass
     public static void setup() throws Exception
     {
@@ -125,6 +127,7 @@ public class AvlStoreTest
         EXAMPLE_COM = new Dn( schemaManager, "dc=example,dc=com" );
 
         OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
+        SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
         DC_AT = schemaManager.getAttributeType( SchemaConstants.DC_AT );
         APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT );
     }
@@ -143,6 +146,7 @@ public class AvlStoreTest
 
         store.addIndex( new AvlIndex( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex( SchemaConstants.UID_AT_OID ) );
+        
         StoreUtils.loadExampleData( store, schemaManager );
         LOG.debug( "Created new store" );
     }
@@ -336,7 +340,7 @@ public class AvlStoreTest
         
         try
         {
-            store.getSystemIndex( "bogus" );
+            store.getSystemIndex( SN_AT );
             fail();
         }
         catch ( IndexNotFoundException e )
@@ -354,9 +358,9 @@ public class AvlStoreTest
 
         assertNotNull( store.getSuffixDn() );
         assertEquals( 2, store.getUserIndices().size() );
-        assertFalse( store.hasUserIndexOn( DC_AT ) );
-        assertTrue( store.hasUserIndexOn( OU_AT ) );
-        assertTrue( store.hasSystemIndexOn( APACHE_ALIAS_AT ) );
+        assertFalse( store.hasUserIndexOn( "dc" ) );
+        assertTrue( store.hasUserIndexOn( "ou" ) );
+        assertTrue( store.hasSystemIndexOn( "apacheAlias" ) );
         Iterator<String> userIndices = store.userIndices();
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
@@ -367,7 +371,7 @@ public class AvlStoreTest
         
         try
         {
-            store.getUserIndex( "bogus" );
+            store.getUserIndex( SN_AT );
             fail();
         }
         catch ( IndexNotFoundException e )
@@ -376,7 +380,7 @@ public class AvlStoreTest
         
         try
         {
-            store.getUserIndex( "dc" );
+            store.getUserIndex( DC_AT );
             fail();
         }
         catch ( IndexNotFoundException e )