directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1128731 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Date Sat, 28 May 2011 18:28:30 GMT
Author: kayyagari
Date: Sat May 28 18:28:30 2011
New Revision: 1128731

URL: http://svn.apache.org/viewvc?rev=1128731&view=rev
Log:
o fixed a NPE in handling the SyncModifyDn control 
o added more tests

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java?rev=1128731&r1=1128730&r2=1128731&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
Sat May 28 18:28:30 2011
@@ -341,12 +341,9 @@ public class SyncReplConsumer implements
                     break;
 
                 case MODDN:
-                    Control adsModDnControl = syncResult.getControls().get( SyncModifyDn.OID
);
+                    SyncModifyDn adsModDnControl = ( SyncModifyDn ) syncResult.getControls().get(
SyncModifyDn.OID );
                     //Apache Directory Server's special control
-                    SyncModifyDnDecorator syncModDnControl = 
-                        new SyncModifyDnDecorator( directoryService.getLdapCodecService()
);
-                    syncModDnControl.setDecorated( ( SyncModifyDn ) adsModDnControl );
-                    applyModDnOperation( syncModDnControl );
+                    applyModDnOperation( adsModDnControl );
                     break;
 
                 case DELETE:

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java?rev=1128731&r1=1128730&r2=1128731&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientServerReplicationIT.java
Sat May 28 18:28:30 2011
@@ -21,11 +21,13 @@
 package org.apache.directory.server.replication;
 
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
@@ -44,6 +46,10 @@ import org.apache.directory.server.ldap.
 import org.apache.directory.server.ldap.replication.SyncreplConfiguration;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.message.ModifyRequest;
+import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -67,6 +73,8 @@ public class ClientServerReplicationIT
     
     private CoreSession consumerSession;
     
+    private static AtomicInteger entryCount = new AtomicInteger();
+    
     @BeforeClass
     public static void setUp() throws Exception
     {
@@ -107,17 +115,93 @@ public class ClientServerReplicationIT
        
        providerSession.add( entry );
        
-       // sleep for 2 sec (twice the refresh interval), just to let the first refresh request
succeed
-       Thread.sleep( 2000 );
-       
-       assertTrue( consumerSession.exists( dn ) );
-       
-       Entry providerEntry = providerSession.lookup( entry.getDn(), "*", "+" );
-       
-       Entry consumerEntry = consumerSession.lookup( entry.getDn(), "*", "+" );
-       assertEquals( providerEntry, consumerEntry );
+       waitAndCompareEntries( entry.getDn() );
+    }
+
+    
+    @Test
+    public void testModify() throws Exception
+    {
+        Entry provUser = createEntry();
+        
+        assertFalse( consumerSession.exists( provUser.getDn() ) );
+        
+        providerSession.add( provUser );
+        
+        ModifyRequest modReq = new ModifyRequestImpl();
+        modReq.setName( provUser.getDn() );
+        modReq.add( "userPassword", "secret" );
+        
+        providerSession.modify( modReq );
+        
+        waitAndCompareEntries( provUser.getDn() );
+    }
+    
+    
+    @Test
+    public void testModDn() throws Exception
+    {
+        Entry provUser = createEntry();
+        
+        assertFalse( consumerSession.exists( provUser.getDn() ) );
+        
+        providerSession.add( provUser );
+     
+        Dn usersContainer = new Dn( schemaManager, "ou=users,dc=example,dc=com" );
+        
+        DefaultEntry entry = new DefaultEntry( schemaManager, usersContainer );
+        entry.add( "objectClass", "organizationalUnit" );
+        entry.add( "ou", "users" );
+        
+        providerSession.add( entry );
+        
+        waitAndCompareEntries( entry.getDn() );
+        
+        // move
+        Dn userDn = provUser.getDn();
+        providerSession.move( userDn, usersContainer );
+        
+        userDn = usersContainer.add( userDn.getRdn() );
+        
+        waitAndCompareEntries( userDn );
+        
+        // now try renaming
+        Rdn newName = new Rdn( schemaManager, userDn.getRdn().getName() + "renamed");
+        
+        providerSession.rename( userDn, newName, true );
+        
+        userDn = usersContainer.add( newName );
+        
+        waitAndCompareEntries( userDn );
     }
+    
+    
+    private void waitAndCompareEntries( Dn dn ) throws Exception
+    {
+        // sleep for 2 sec (twice the refresh interval), just to let the first refresh request
succeed
+        Thread.sleep( 2000 );
 
+        Entry providerEntry = providerSession.lookup( dn, "*", "+" );
+        
+        Entry consumerEntry = consumerSession.lookup( dn, "*", "+" );
+        assertEquals( providerEntry, consumerEntry );
+    }
+    
+    
+    private Entry createEntry() throws Exception
+    {
+        String user = "user"+ entryCount.incrementAndGet();
+        
+        String dn = "cn=" + user + ",dc=example,dc=com";
+        
+        DefaultEntry entry = new DefaultEntry( schemaManager, dn );
+        entry.add( "objectClass", "person" );
+        entry.add( "cn", user );
+        entry.add( "sn", user );
+        
+        return entry;
+    }
+    
     
     @CreateDS(allowAnonAccess = true, name = "provider-replication", partitions =
         {



Mime
View raw message