o Cleaned up the JdbmStoreTest and AvlStore classes
o Prepared code for migration of the rename operation
o Removed an useless rename() method

git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/branches/apacheds-no-reverse-index@1142153 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
index 9f41b45..3d0c8ce 100644
--- a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
+++ b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
@@ -129,10 +129,10 @@
 
         EXAMPLE_COM = new Dn( schemaManager, "dc=example,dc=com" );
 
-        OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
-        DC_AT = schemaManager.getAttributeType( SchemaConstants.DC_AT );
-        SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
-        APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT );
+        OU_AT = schemaManager.getAttributeType( "ou" );
+        DC_AT = schemaManager.getAttributeType( "dc" );
+        SN_AT = schemaManager.getAttributeType( "sn" );
+        APACHE_ALIAS_AT = schemaManager.getAttributeType( "apacheAlias" );
     }
 
 
@@ -214,11 +214,13 @@
 
         // inject context entry
         Dn suffixDn = new Dn( schemaManager, "dc=example,dc=com" );
-        Entry entry = new DefaultEntry( schemaManager, suffixDn );
-        entry.add( "objectClass", "top", "domain" );
-        entry.add( "dc", "example" );
-        entry.add( SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString() );
-        entry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, suffixDn,
+            "objectClass: top", 
+            "objectClass: domain",
+            "dc: example",
+            "entryCSN", new CsnFactory( 0 ).newInstance().toString(),
+            SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+        
         store2.add( entry );
 
         // lookup the context entry
@@ -516,13 +518,15 @@
 
         // add an alias and delete to test dropAliasIndices method
         Dn dn = new Dn( schemaManager, "commonName=Jack Daniels,ou=Apache,ou=Board of Directors,o=Good Times Co." );
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "alias", "extensibleObject" );
-        entry.add( "ou", "Apache" );
-        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() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: alias", 
+            "objectClass: extensibleObject",
+            "ou: Apache",
+            "commonName: Jack Daniels",
+            "aliasedObjectName: cn=Jack Daniels,ou=Engineering,o=Good Times Co.",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
 
         store.delete( dn ); // drops the alias indices
@@ -563,12 +567,15 @@
 
         // dn id 12
         Dn martinDn = new Dn( schemaManager, "cn=Marting King,ou=Sales,o=Good Times Co." );
-        Entry entry = new DefaultEntry( 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() );
+        Entry entry = new DefaultEntry( schemaManager, martinDn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou: Sales",
+            "cn: Martin King",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
+        
         store.add( entry );
 
         cursor = subLevelIdx.forwardCursor( 2L );
@@ -588,21 +595,24 @@
 
         // dn id 13
         Dn marketingDn = new Dn( schemaManager, "ou=Marketing,ou=Sales,o=Good Times Co." );
-        entry = new DefaultEntry( 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() );
+        entry = new DefaultEntry( schemaManager, marketingDn,
+            "objectClass: top", 
+            "objectClass: organizationalUnit",
+            "ou: Marketing",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
 
         // dn id 14
         Dn jimmyDn = new Dn( schemaManager, "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co." );
-        entry = new DefaultEntry( 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() );
+        entry = new DefaultEntry( schemaManager, jimmyDn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou: Marketing",
+            "cn: Jimmy Wales",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
 
         newDn = newParentDn.add( marketingDn.getRdn() );
@@ -662,12 +672,14 @@
     public void testAddWithoutParentId() throws Exception
     {
         Dn dn = new Dn( schemaManager, "cn=Marting King,ou=Not Present,o=Good Times Co." );
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Not Present" );
-        entry.add( "cn", "Martin King" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person",
+            "objectClass: organizationalPerson",
+            "ou: Not Present",
+            "cn: Martin King",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
     }
 
@@ -678,7 +690,7 @@
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
         List<Modification> mods = new ArrayList<Modification>();
-        Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
+        Attribute attrib = new DefaultAttribute( "ou", OU_AT );
         attrib.add( "Engineering" );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
@@ -693,18 +705,20 @@
     public void testRename() throws Exception
     {
         Dn dn = new Dn( schemaManager, "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." );
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Engineering" );
-        entry.add( "cn", "Private Ryan" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou", "Engineering",
+            "cn", "Private Ryan",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         store.add( entry );
 
         Rdn rdn = new Rdn( "sn=James" );
 
-        store.rename( dn, rdn, true );
+        store.rename( dn, rdn, true, entry );
     }
 
 
@@ -712,18 +726,20 @@
     public void testRenameEscaped() throws Exception
     {
         Dn dn = new Dn( schemaManager, "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." );
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Engineering" );
-        entry.add( "cn", "Private Ryan" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou", "Engineering",
+            "cn", "Private Ryan",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         store.add( entry );
 
         Rdn rdn = new Rdn( "sn=Ja\\+es" );
 
-        store.rename( dn, rdn, true );
+        store.rename( dn, rdn, true, entry );
 
         Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
         Long id = store.getEntryId( dn2 );
@@ -785,7 +801,7 @@
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
         List<Modification> mods = new ArrayList<Modification>();
-        Attribute attrib = new DefaultAttribute( SchemaConstants.SURNAME_AT, SN_AT );
+        Attribute attrib = new DefaultAttribute( "sn", SN_AT );
 
         String attribVal = "Walker";
         attrib.add( attribVal );
@@ -815,7 +831,7 @@
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
         List<Modification> mods = new ArrayList<Modification>();
-        Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, SN_AT );
+        Attribute attrib = new DefaultAttribute( "sn", SN_AT );
 
         String attribVal = "Johnny";
         attrib.add( attribVal );
@@ -846,7 +862,7 @@
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
         List<Modification> mods = new ArrayList<Modification>();
-        Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, SN_AT );
+        Attribute attrib = new DefaultAttribute( "sn", SN_AT );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
         mods.add( add );
@@ -875,16 +891,18 @@
     public void testModifyReplaceNonExistingIndexAttribute() throws Exception
     {
         Dn dn = new Dn( schemaManager, "cn=Tim B,ou=Sales,o=Good Times Co." );
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "cn", "Tim B" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "cn: Tim B",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         store.add( entry );
 
         List<Modification> mods = new ArrayList<Modification>();
-        Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
+        Attribute attrib = new DefaultAttribute( "ou", OU_AT );
 
         String attribVal = "Marketing";
         attrib.add( attribVal );
@@ -943,5 +961,4 @@
         assertTrue( uuidIndexDbFile.exists() );
         assertTrue( uuidIndexTxtFile.exists() );
     }
-
 }
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java b/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
index 995b5ff..1f514ab 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
@@ -383,16 +383,9 @@
             Dn oldDn = renameContext.getDn();
             Rdn newRdn = renameContext.getNewRdn();
             boolean deleteOldRdn = renameContext.getDeleteOldRdn();
-
-            if ( renameContext.getEntry() != null )
-            {
-                Entry modifiedEntry = renameContext.getModifiedEntry();
-                store.rename( oldDn, newRdn, deleteOldRdn, modifiedEntry );
-            }
-            else
-            {
-                store.rename( oldDn, newRdn, deleteOldRdn );
-            }
+            
+            Entry modifiedEntry = renameContext.getModifiedEntry();
+            store.rename( oldDn, newRdn, deleteOldRdn, modifiedEntry );
         }
         catch ( Exception e )
         {
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
index 2b061df..807e4e5 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
@@ -1393,15 +1393,6 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized void rename( Dn dn, Rdn newRdn, boolean deleteOldRdn ) throws Exception
-    {
-        rename( dn, newRdn, deleteOldRdn, null );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public synchronized void moveAndRename( Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry, boolean deleteOldRdn ) throws Exception
     {
     	// Check that the old entry exists
@@ -1453,15 +1444,6 @@
     /**
      * {@inheritDoc}
      */
-    public synchronized void move( Dn oldDn, Dn newSuperiorDn, Dn newDn  ) throws Exception
-    {
-        move( oldDn, newSuperiorDn, newDn, null );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public synchronized void move( Dn oldDn, Dn newSuperiorDn, Dn newDn, Entry modifiedEntry ) throws Exception
     {
         // Check that the parent Dn exists
@@ -1499,13 +1481,6 @@
             oldParentId = oldParentIds.get( oldParentIds.size() - 1 );
         }
 
-        ID contextEntryId = rootId;
-        
-        if ( newParentIds.size() > 1 )
-        {
-            contextEntryId = newParentIds.get( 1 );
-        }
-
         /*
          * Drop the old parent child relationship and add the new one
          * Set the new parent id for the child replacing the old parent id
@@ -1513,59 +1488,8 @@
         oneLevelIdx.drop( oldParentId, entryId );
         oneLevelIdx.add( newParentId, entryId );
 
-        // Update the sublevel index
-        // first, drop the old position in the subLevel index
-        for ( ID ancestor : oldParentIds )
-        {
-            if ( ancestor.equals( rootId ) )
-            {
-                continue;
-            }
-            
-            subLevelIdx.drop( ancestor, oldParentId );
-        }
-        
-        // find all the children of the childId
-        Cursor<IndexEntry<ID, E, ID>> cursor = subLevelIdx.forwardCursor( entryId );
-
-        List<ID> childIds = new ArrayList<ID>();
-        childIds.add( entryId );
-
-        while ( cursor.next() )
-        {
-            childIds.add( cursor.get().getId() );
-        }
-
-        // detach the childId and all its children from oldParentId and all it parents excluding the root
-        for ( ID pid : oldParentIds )
-        {
-            for ( ID cid : childIds )
-            {
-                subLevelIdx.drop( pid, cid );
-            }
-        }
-
-        // then add the new position in the sublevel index
-        for ( ID id : newParentIds )
-        {
-            if ( id.equals( rootId ) || id.equals( contextEntryId ) )
-            {
-                // Skip the rootDSE and the context entry
-                continue;
-            }
-            
-            // Add the <ancestor, newId> tuple
-            subLevelIdx.add( id, entryId );
-        }
-
-        // attach the childId and all its children to newParentId and all it parents excluding the root
-        for ( ID id : newParentIds )
-        {
-            for ( ID cid : childIds )
-            {
-                subLevelIdx.add( id, cid );
-            }
-        }
+        // Update the subLevel index
+        updateSubLevelIndex( entryId, oldParentIds, newParentIds );
 
         // Update the Rdn index
         ParentIdAndRdn<ID> oldKey = new ParentIdAndRdn<ID>( oldParentId, oldDn.getRdn() );
@@ -2237,18 +2161,35 @@
      * @param newParentId new parent's id
      * @throws Exception
      */
-    protected void updateSubLevelIndex( ID entryId, ID oldParentId, ID newParentId ) throws Exception
+    protected void updateSubLevelIndex( ID entryId, List<ID> oldParentIds, List<ID> newParentIds ) throws Exception
     {
-        ID tempId = oldParentId;
-        List<ID> parentIds = new ArrayList<ID>();
-
-        // find all the parents of the oldParentId
-        while ( ( tempId != null ) && !tempId.equals( getRootId() ) && !tempId.equals( getSuffixId() ) )
+        ID rootId = getRootId();
+        ID oldParentId = rootId;
+        
+        if ( oldParentIds.size() > 2 )
         {
-            parentIds.add( tempId );
-            tempId = getParentId( tempId );
+            oldParentId = oldParentIds.get( oldParentIds.size() - 1 );
         }
 
+        ID contextEntryId = rootId;
+        
+        if ( newParentIds.size() > 1 )
+        {
+            contextEntryId = newParentIds.get( 1 );
+        }
+
+        // Update the sublevel index
+        // first, drop the old position in the subLevel index
+        for ( ID ancestor : oldParentIds )
+        {
+            if ( ancestor.equals( rootId ) )
+            {
+                continue;
+            }
+            
+            subLevelIdx.drop( ancestor, oldParentId );
+        }
+        
         // find all the children of the childId
         Cursor<IndexEntry<ID, E, ID>> cursor = subLevelIdx.forwardCursor( entryId );
 
@@ -2261,7 +2202,7 @@
         }
 
         // detach the childId and all its children from oldParentId and all it parents excluding the root
-        for ( ID pid : parentIds )
+        for ( ID pid : oldParentIds )
         {
             for ( ID cid : childIds )
             {
@@ -2269,18 +2210,21 @@
             }
         }
 
-        parentIds.clear();
-        tempId = newParentId;
-
-        // find all the parents of the newParentId
-        while ( ( tempId != null)  && !tempId.equals( getRootId() ) && !tempId.equals( getSuffixId() ) )
+        // then add the new position in the sublevel index
+        for ( ID id : newParentIds )
         {
-            parentIds.add( tempId );
-            tempId = getParentId( tempId );
+            if ( id.equals( rootId ) || id.equals( contextEntryId ) )
+            {
+                // Skip the rootDSE and the context entry
+                continue;
+            }
+            
+            // Add the <ancestor, newId> tuple
+            subLevelIdx.add( id, entryId );
         }
 
         // attach the childId and all its children to newParentId and all it parents excluding the root
-        for ( ID id : parentIds )
+        for ( ID id : newParentIds )
         {
             for ( ID cid : childIds )
             {
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
index f9a3a81..517372d 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
@@ -573,25 +573,6 @@
     void rename( Dn dn, Rdn newRdn, boolean deleteOldRdn, Entry entry ) throws Exception;
 
 
-    /**
-     * Changes the relative distinguished name of an entry specified by a
-     * distinguished name with the optional removal of the old Rdn attribute
-     * value from the entry.  Name changes propagate down as dn changes to the
-     * descendants of the entry where the Rdn changed.
-     *
-     * An Rdn change operation does not change parent child relationships.  It
-     * merely propagates a name change at a point in the DIT where the Rdn is
-     * changed. The change propagates down the subtree rooted at the
-     * distinguished name specified.
-     *
-     * @param dn the normalized distinguished name of the entry to alter
-     * @param newRdn the new Rdn to set
-     * @param deleteOldRdn whether or not to remove the old Rdn attr/val
-     * @throws Exception if there are any errors propagating the name changes
-     */
-    void rename( Dn dn, Rdn newRdn, boolean deleteOldRdn ) throws Exception;
-
-    
     void moveAndRename( Dn oldChildDn, Dn newParentDn, Rdn newRdn, Entry entry, boolean deleteOldRdn ) throws Exception;
 
 
@@ -622,38 +603,6 @@
      * @param oldDn The previous entry Dn
      * @param newSuperior The new superior Dn
      * @param newDn The new Dn
-     * @throws Exception If the move failed
-     */
-    void move( Dn oldDn, Dn newSuperior, Dn newDn ) throws Exception;
-
-
-    /**
-     * <p>Move an entry from one place to the other. The Rdn remains unchanged,
-     * the parent Dn changes</p>
-     * <p>We have to update some of the index when moving an entry. Assuming
-     * that the target destination does not exist, the following index must
-     * be updated :</p>
-     * <ul>
-     * <li><b>oneLevel</b> index</li>
-     * <li><b>subLevel</b> index</li>
-     * </ul>
-     * <p>If the moved entry is an alias, then we also have to update the
-     * following index :</p>
-     * <ul>
-     * <li><b>oneAlias</b> index</li>
-     * <li><b>subAlias</b> index</li>
-     * </ul>
-     * <p>The <b>Alias</b> index is not updated, as the entry ID won't change.</p> 
-     * <p>We have a few check we must do before moving the entry :
-     * <ul>
-     * <li>The destination must not exist
-     * <li>The moved entry must exist (this has already been checked)
-     * <li>The moved entry must not inherit from a referral (already checked)
-     * </ul>
-     *
-     * @param oldDn The previous entry Dn
-     * @param newSuperior The new superior Dn
-     * @param newDn The new Dn
      * @param entry The entry to move
      * @throws Exception If the move failed
      */
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
index 67f4117..18f657b 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
@@ -381,7 +381,7 @@
         // move
         Dn newSuperior = new Dn( schemaManager, "o=Good Times Co." );
         Dn newDn = new Dn( schemaManager, "cn=user,o=Good Times Co." );
-        store.move( dn, newSuperior, newDn );
+        store.move( dn, newSuperior, newDn , entry);
         entry = verifyParentId( newDn );
         
         // move and rename
@@ -396,9 +396,9 @@
     
     private Entry verifyParentId( Dn dn ) throws Exception
     {
-        Long entryId = store.getEntryId( dn );
         Entry entry = store.lookup( dn );
-        Long parentId = store.getParentId( entryId );
+        List<Long> parentIds = store.getParentIds( dn );
+        Long parentId = parentIds.get( parentIds.size() - 1 );
         
         Attribute parentIdAt = entry.get( SchemaConstants.ENTRY_PARENT_ID_AT );
         assertNotNull( parentIdAt );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
index de7ac3f..33e7ca5 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
@@ -603,18 +603,20 @@
     public void testRename() throws Exception
     {
         Dn dn = new Dn( schemaManager, "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." );
-        DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Engineering" );
-        entry.add( "cn", "Private Ryan" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        DefaultEntry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou", "Engineering",
+            "cn", "Private Ryan",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         store.add( entry );
 
         Rdn rdn = new Rdn( "sn=James" );
 
-        store.rename( dn, rdn, true );
+        store.rename( dn, rdn, true, entry );
     }
 
 
@@ -622,18 +624,20 @@
     public void testRenameEscaped() throws Exception
     {
         Dn dn = new Dn( schemaManager, "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." );
-        DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Engineering" );
-        entry.add( "cn", "Private Ryan" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        DefaultEntry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou: Engineering",
+            "cn: Private Ryan",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         store.add( entry );
 
         Rdn rdn = new Rdn( "sn=Ja\\+es" );
 
-        store.rename( dn, rdn, true );
+        store.rename( dn, rdn, true, entry );
 
         Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
         Long id = store.getEntryId( dn2 );