directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r279936 - in /directory/apacheds/trunk/core/src: main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmContextPartition.java test/org/apache/ldap/server/subtree/SubentryServiceTest.java
Date Sat, 10 Sep 2005 02:34:24 GMT
Author: akarasulu
Date: Fri Sep  9 19:34:19 2005
New Revision: 279936

URL: http://svn.apache.org/viewcvs?rev=279936&view=rev
Log:
changes ...

 o added move() test case which attempts to move an entry with respect to its
   parent this failed to show a bug in the move() code within the JDBM backend
 o fixed the jdbm backend move() functionality so the childId is saved before 
   the modifyRn() operation ... this fixes the bug that caused move() to fail
   where the RDN was being changed


Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmContextPartition.java
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmContextPartition.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmContextPartition.java?rev=279936&r1=279935&r2=279936&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmContextPartition.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/partition/impl/btree/jdbm/JdbmContextPartition.java
Fri Sep  9 19:34:19 2005
@@ -1450,8 +1450,16 @@
     public void move( Name oldChildDn, Name newParentDn, String newRdn,
         boolean deleteOldRdn ) throws NamingException
     {
+        BigInteger childId = getEntryId( oldChildDn.toString() );
         modifyRn( oldChildDn, newRdn, deleteOldRdn );
-        move( oldChildDn, newParentDn );
+        move( oldChildDn, childId, newParentDn );
+    }
+
+
+    public void move( Name oldChildDn, Name newParentDn ) throws NamingException
+    {
+        BigInteger childId = getEntryId( oldChildDn.toString() );
+        move( oldChildDn, childId, newParentDn );
     }
 
 
@@ -1468,10 +1476,9 @@
      * @param newParentDn the normalized dn of the new parent for the child
      * @throws NamingException if something goes wrong
      */
-    public void move( Name oldChildDn, Name newParentDn ) throws NamingException
+    private void move( Name oldChildDn, BigInteger childId, Name newParentDn ) throws NamingException
     {
         // Get the child and the new parent to be entries and Ids
-        BigInteger childId = getEntryId( oldChildDn.toString() );
         BigInteger newParentId = getEntryId( newParentDn.toString() );
         BigInteger oldParentId = getParentId( childId );
         

Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java?rev=279936&r1=279935&r2=279936&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java
(original)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/subtree/SubentryServiceTest.java
Fri Sep  9 19:34:19 2005
@@ -669,4 +669,103 @@
         assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
         assertEquals( 1, autonomousSubentry.size() );
     }
+
+
+    public void testEntryMove() throws NamingException
+    {
+        addAdministrativeRole( "autonomousArea" );
+        super.sysRoot.createSubcontext( "cn=testsubentry", getTestSubentryWithExclusion()
);
+        super.sysRoot.createSubcontext( "cn=unmarked", getTestEntry( "unmarked" ) );
+        super.sysRoot.createSubcontext( "cn=marked,ou=configuration", getTestEntry( "marked"
) );
+        Map results = getAllEntries();
+
+        // --------------------------------------------------------------------
+        // Make sure entries selected by the subentry do have the mark
+        // --------------------------------------------------------------------
+
+        Attributes configuration = ( Attributes ) results.get( "ou=configuration,ou=system"
);
+        Attribute autonomousSubentry = configuration.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY
);
+        assertNotNull( "ou=configuration,ou=system should be marked", autonomousSubentry
);
+        assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+        assertEquals( 1, autonomousSubentry.size() );
+
+        Attributes interceptors = ( Attributes ) results.get( "ou=interceptors,ou=configuration,ou=system"
);
+        autonomousSubentry = interceptors.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY
);
+        assertNotNull( "ou=interceptors,ou=configuration,ou=system should be marked", autonomousSubentry
);
+        assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+        assertEquals( 1, autonomousSubentry.size() );
+
+        Attributes partitions = ( Attributes ) results.get( "ou=partitions,ou=configuration,ou=system"
);
+        autonomousSubentry = partitions.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+        assertNotNull( "ou=partitions,ou=configuration,ou=system should be marked", autonomousSubentry
);
+        assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+        assertEquals( 1, autonomousSubentry.size() );
+
+        Attributes services = ( Attributes ) results.get( "ou=services,ou=configuration,ou=system"
);
+        autonomousSubentry = services.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+        assertNotNull( "ou=services,ou=configuration,ou=system should be marked", autonomousSubentry
);
+        assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+        assertEquals( 1, autonomousSubentry.size() );
+
+        Attributes marked = ( Attributes ) results.get( "cn=marked,ou=configuration,ou=system"
);
+        autonomousSubentry = marked.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+        assertNotNull( "cn=marked,ou=configuration,ou=system should be marked", autonomousSubentry
);
+        assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+        assertEquals( 1, autonomousSubentry.size() );
+
+        // --------------------------------------------------------------------
+        // Make sure entries not selected by subentry do not have the mark
+        // --------------------------------------------------------------------
+
+        Attributes system = ( Attributes ) results.get( "ou=system" );
+        assertNull( "ou=system should not be marked",
+                system.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+        Attributes users = ( Attributes ) results.get( "ou=users,ou=system" );
+        assertNull( "ou=users,ou=system should not be marked",
+                users.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+        Attributes groups = ( Attributes ) results.get( "ou=groups,ou=system" );
+        assertNull( "ou=groups,ou=system should not be marked",
+                groups.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+        Attributes admin = ( Attributes ) results.get( "uid=admin,ou=system" );
+        assertNull( "uid=admin,ou=system should not be marked",
+                admin.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+        Attributes sysPrefRoot = ( Attributes ) results.get( "prefNodeName=sysPrefRoot,ou=system"
);
+        assertNull( "prefNode=sysPrefRoot,ou=system should not be marked",
+                sysPrefRoot.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+        Attributes unmarked = ( Attributes ) results.get( "cn=unmarked,ou=system" );
+        assertNull( "cn=unmarked,ou=system should not be marked",
+                unmarked.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+
+        // --------------------------------------------------------------------
+        // Now destry one of the marked/unmarked and rename to deleted entry
+        // --------------------------------------------------------------------
+
+        super.sysRoot.destroySubcontext( "cn=unmarked" );
+        super.sysRoot.rename( "cn=marked,ou=configuration", "cn=unmarked" );
+        results = getAllEntries();
+
+        unmarked = ( Attributes ) results.get( "cn=unmarked,ou=system" );
+        assertNull( "cn=unmarked,ou=system should not be marked",
+                unmarked.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY ) );
+        assertNull( results.get( "cn=marked,ou=configuration,ou=system" ) );
+
+        // --------------------------------------------------------------------
+        // Now rename unmarked to marked and see that subentry op attr is there
+        // --------------------------------------------------------------------
+
+        super.sysRoot.rename( "cn=unmarked", "cn=marked,ou=configuration" );
+        results = getAllEntries();
+        assertNull( results.get( "cn=unmarked,ou=system" ) );
+        marked = ( Attributes ) results.get( "cn=marked,ou=configuration,ou=system" );
+        assertNotNull( marked );
+        autonomousSubentry = marked.get( SubentryService.AUTONOUMOUS_AREA_SUBENTRY );
+        assertNotNull( "cn=marked,ou=configuration,ou=system should be marked", autonomousSubentry
);
+        assertEquals( "cn=testsubentry,ou=system", autonomousSubentry.get() );
+        assertEquals( 1, autonomousSubentry.size() );
+    }
 }



Mime
View raw message