directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1031561 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/operational/ xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/
Date Fri, 05 Nov 2010 13:39:37 GMT
Author: seelmann
Date: Fri Nov  5 13:39:37 2010
New Revision: 1031561

URL: http://svn.apache.org/viewvc?rev=1031561&view=rev
Log:
DIRSERVER-1579: Save operational attributes (modifiersName, modifyTimestamp) for moveAndRename()
operation, added test to check operational attributes are set for rename, move, and moveAndRename.

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java?rev=1031561&r1=1031560&r2=1031561&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
Fri Nov  5 13:39:37 2010
@@ -29,7 +29,6 @@ import static org.junit.Assert.assertTru
 import javax.naming.NamingException;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
@@ -43,6 +42,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.message.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.ModifyResponse;
 import org.apache.directory.shared.ldap.message.Response;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -63,8 +63,6 @@ import org.junit.runner.RunWith;
  */
 @RunWith(FrameworkRunner.class)
 @CreateDS(name = "OperationalDS")
-@ApplyLdifs(
-    { "dn: cn=Kate Bush,ou=system", "objectClass: top", "objectClass: person", "cn: Bush",
"sn: Kate Bush" })
 public class OperationalAttributeServiceIT extends AbstractLdapTestUnit
 {
     private static final String DN_KATE_BUSH = "cn=Kate Bush,ou=system";
@@ -76,12 +74,22 @@ public class OperationalAttributeService
     public void setup() throws Exception
     {
         connection = IntegrationUtils.getAdminConnection( service );
+
+        // add this entry before each test because we want 
+        // to check that operational attributes are added
+        Entry entry = LdifUtils
+            .createEntry( DN_KATE_BUSH, "objectClass: top", "objectClass: person", "cn: Kate
Bush", "sn: Bush" );
+        connection.add( entry );
     }
 
 
     @After
     public void shutdown() throws Exception
     {
+        // delete this entry after each test because we want 
+        // to check that operational attributes are added
+        connection.delete( DN_KATE_BUSH );
+
         connection.close();
     }
 
@@ -236,7 +244,7 @@ public class OperationalAttributeService
 
         assertNull( entry.get( "modifiersName" ) );
         assertNull( entry.get( "modifyTimestamp" ) );
-        
+
         Modification modifyOp = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultEntryAttribute( "description", "Singer Songwriter" ) );
 
@@ -339,4 +347,78 @@ public class OperationalAttributeService
 
         assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, response.getLdapResult().getResultCode()
);
     }
+
+
+    /**
+     * Rename an entry and check whether attribute modifyTimestamp changes.
+     */
+    @Test
+    public void testRenameShouldChangeModifyTimestamp() throws Exception, InterruptedException
+    {
+        Entry entry = connection.lookup( DN_KATE_BUSH, "*", "+" );
+
+        assertNotNull( entry.get( "creatorsName" ) );
+        assertNotNull( entry.get( "createTimestamp" ) );
+        assertNull( entry.get( "modifiersName" ) );
+        assertNull( entry.get( "modifyTimestamp" ) );
+
+        ModifyDnResponse rename = connection.rename( DN_KATE_BUSH, "cn=KB" );
+        System.out.println( rename );
+
+        entry = connection.lookup( "cn=KB,ou=system", "*", "+" );
+
+        assertNotNull( entry.get( "creatorsName" ) );
+        assertNotNull( entry.get( "createTimestamp" ) );
+        assertNotNull( entry.get( "modifiersName" ) );
+        assertNotNull( entry.get( "modifyTimestamp" ) );
+    }
+
+
+    /**
+     * Move an entry and check whether attribute modifyTimestamp changes.
+     */
+    @Test
+    public void testMoveShouldChangeModifyTimestamp() throws Exception, InterruptedException
+    {
+        Entry entry = connection.lookup( DN_KATE_BUSH, "*", "+" );
+
+        assertNotNull( entry.get( "creatorsName" ) );
+        assertNotNull( entry.get( "createTimestamp" ) );
+        assertNull( entry.get( "modifiersName" ) );
+        assertNull( entry.get( "modifyTimestamp" ) );
+
+        connection.move( DN_KATE_BUSH, "ou=users,ou=system" );
+
+        entry = connection.lookup( "cn=Kate Bush,ou=users,ou=system", "*", "+" );
+
+        assertNotNull( entry.get( "creatorsName" ) );
+        assertNotNull( entry.get( "createTimestamp" ) );
+        assertNotNull( entry.get( "modifiersName" ) );
+        assertNotNull( entry.get( "modifyTimestamp" ) );
+    }
+
+
+    /**
+     * MoveAndRename an entry and check whether attribute modifyTimestamp changes.
+     */
+    @Test
+    public void testMoveAndRenameShouldChangeModifyTimestamp() throws Exception, InterruptedException
+    {
+        Entry entry = connection.lookup( DN_KATE_BUSH, "*", "+" );
+
+        assertNotNull( entry.get( "creatorsName" ) );
+        assertNotNull( entry.get( "createTimestamp" ) );
+        assertNull( entry.get( "modifiersName" ) );
+        assertNull( entry.get( "modifyTimestamp" ) );
+
+        connection.moveAndRename( DN_KATE_BUSH, "cn=KB,ou=users,ou=system" );
+
+        entry = connection.lookup( "cn=KB,ou=users,ou=system", "*", "+" );
+
+        assertNotNull( entry.get( "creatorsName" ) );
+        assertNotNull( entry.get( "createTimestamp" ) );
+        assertNotNull( entry.get( "modifiersName" ) );
+        assertNotNull( entry.get( "modifyTimestamp" ) );
+    }
+
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java?rev=1031561&r1=1031560&r2=1031561&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
Fri Nov  5 13:39:37 2010
@@ -414,8 +414,9 @@ public abstract class AbstractXdbmPartit
         	DN newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
         	RDN newRdn = moveAndRenameContext.getNewRdn();
         	boolean deleteOldRdn = moveAndRenameContext.getDeleteOldRdn();
+        	Entry modifiedEntry = moveAndRenameContext.getModifiedEntry();
         	
-            store.moveAndRename( oldDn, newSuperiorDn, newRdn, null, deleteOldRdn );
+            store.moveAndRename( oldDn, newSuperiorDn, newRdn, modifiedEntry, deleteOldRdn
);
         }
         catch ( LdapException le )
         {



Mime
View raw message