directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r721052 [3/3] - in /directory: apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/changelog/ apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/interceptor/context/ shared/...
Date Thu, 27 Nov 2008 01:00:32 GMT
Modified: directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java?rev=721052&r1=721051&r2=721052&view=diff
==============================================================================
--- directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
(original)
+++ directory/shared/branches/shared-mina2/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifUtilsTest.java
Wed Nov 26 17:00:32 2008
@@ -19,13 +19,8 @@
  */
 package org.apache.directory.shared.ldap.ldif;
 
-import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Modification;
-import org.apache.directory.shared.ldap.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.entry.client.ClientModification;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
-import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -35,7 +30,6 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import javax.naming.NamingException;
@@ -44,8 +38,6 @@
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 
@@ -58,19 +50,6 @@
 {
     private String testString = "this is a test";
     
-    /**
-     * Helper method to build a basic entry used by the Modify tests
-     */
-    private Entry buildEntry()
-    {
-        Entry entry = new DefaultClientEntry();
-        entry.put( "objectclass", "top", "person" );
-        entry.put( "cn", "test" );
-        entry.put( "sn", "joe doe" );
-        entry.put( "l", "USA" );
-        
-        return entry;
-    }
 
     /**
      * Tests the method IsLdifSafe with a null String
@@ -416,139 +395,6 @@
 
     
     /**
-     * Test a AddRequest reverse
-     *
-     * @throws NamingException
-     */
-    @Test
-    public void testReverseAdd() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "dc=apache, dc=com" );
-        LdifEntry reversed = LdifUtils.reverseAdd( dn );
-        
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Delete, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
-     * Test a AddRequest reverse where the DN is to be base64 encoded 
-     *
-     * @throws NamingException
-     */
-    @Test
-    public void testReverseAddBase64DN() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "dc=Emmanuel L\u00c9charny" );
-        LdifEntry reversed = LdifUtils.reverseAdd( dn );
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Delete, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
-     * Test a DelRequest reverse
-     *
-     * @throws NamingException
-     */
-    @Test
-    public void testReverseDel() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "dc=apache, dc=com" );
-        
-        Entry deletedEntry = new DefaultClientEntry( dn );
-        
-        EntryAttribute oc = new DefaultClientAttribute( "objectClass" );
-        oc.add( "top", "person" );
-        
-        deletedEntry.put( oc );
-        
-        deletedEntry.put( "cn", "test" );
-        deletedEntry.put( "sn", "apache" );
-        deletedEntry.put( "dc", "apache" );
-        
-        LdifEntry reversed = LdifUtils.reverseDel( dn, deletedEntry );
-        
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Add, reversed.getChangeType() );
-        assertNotNull( reversed.getEntry() );
-        assertEquals( deletedEntry, reversed.getEntry() );
-    }
-    
-    
-    /**
-     * Check that the correct reverse LDIF is produced for a modifyDn
-     * operation that just renames the person without preserving the
-     * old rdn.
-     *
-     * @throws NamingException on error
-     */
-    @Test
-    public void testReverseModifyDNDeleteOldRdnNoSuperior() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
-
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
-
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, null, dn, new
Rdn( "cn=jack doe" ) );
-
-        assertNotNull( reverseds );
-        assertEquals( 1, reverseds.size() );
-        
-        LdifEntry reversed = reverseds.get( 0 );
-        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn().getUpName() );
-        assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
-        assertTrue( reversed.isDeleteOldRdn() );
-        assertEquals( "cn=john doe", reversed.getNewRdn() );
-        assertNull( reversed.getNewSuperior() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
-     * Check that the correct reverse LDIF is produced for a modifyDn
-     * operation that just renames the person while preserving the
-     * old rdn.
-     *
-     * @throws NamingException on error
-     */
-    @Test
-    public void testReverseModifyDNNoSuperior() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
-
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "cn", "jack doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
-
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, null, dn, new
Rdn( "cn=jack doe" ) );
-
-        assertNotNull( reverseds );
-        assertEquals( 1, reverseds.size() );
-        
-        LdifEntry reversed = reverseds.get( 0 );
-        assertEquals( "cn=jack doe, dc=example, dc=com", reversed.getDn().getUpName() );
-        assertEquals( ChangeType.ModRdn, reversed.getChangeType() );
-        assertFalse( reversed.isDeleteOldRdn() );
-        assertEquals( "cn=john doe", reversed.getNewRdn() );
-        assertNull( reversed.getNewSuperior() );
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
      * Check that the correct reverse LDIF is produced for a modifyDn
      * operation that moves and renames the entry while preserving the
      * old rdn.
@@ -590,39 +436,6 @@
 
 
     /**
-     * Test a reversed move ModifyDN no rdn changes
-     *
-     * @throws NamingException on error
-     */
-    @Test
-    public void testReverseModifyDNMove() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "cn=john doe, dc=example, dc=com" );
-        LdapDN newSuperior = new LdapDN( "ou=system" );
-
-        Attributes attrs = new BasicAttributes( "objectClass", "person", true );
-        attrs.get( "objectClass" ).add( "uidObject" );
-        attrs.put( "cn", "john doe" );
-        attrs.put( "cn", "jack doe" );
-        attrs.put( "sn", "doe" );
-        attrs.put( "uid", "jdoe" );
-
-        List<LdifEntry> reverseds = LdifUtils.reverseModifyRdn( attrs, newSuperior,
dn, null );
-
-        assertNotNull( reverseds );
-        assertEquals( 1, reverseds.size() );
-        
-        LdifEntry reversed = reverseds.get( 0 );
-        assertEquals( "cn=john doe,ou=system", reversed.getDn().getUpName() );
-        assertEquals( ChangeType.ModDn, reversed.getChangeType() );
-        assertFalse( reversed.isDeleteOldRdn() );
-        assertNull( reversed.getNewRdn() );
-        assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() )
);
-        assertNull( reversed.getEntry() );
-    }
-
-
-    /**
      * Test a reversed ModifyDN with a deleteOldRdn, rdn change, and a superior
      *
      * @throws NamingException on error
@@ -652,527 +465,4 @@
         assertEquals( "dc=example, dc=com", StringTools.trim( reversed.getNewSuperior() )
);
         assertNull( reversed.getEntry() );
     }
-
-    
-    /**
-     * Test a reversed Modify adding a new attribute value
-     * in an exiting attribute
-     */
-    @Test
-    public void testReverseModifyAddNewOuValue() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
-        modifiedEntry.put( ou );
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        Modification mod = new ClientModification(
-            ModificationOperation.ADD_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou", "BigCompany inc." ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        assertEquals( "BigCompany inc.", attr.getString() );
-    }
-
-
-    /**
-     * Test a reversed Modify adding a new attribute
-     */
-    @Test
-    public void testReverseModifyAddNewOu() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        Modification mod = new ClientModification(
-            ModificationOperation.ADD_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou", "BigCompany inc." ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-
-        assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        assertEquals( "BigCompany inc.", attr.getString() );
-    }
-
-   
-    /**
-     * Test a reversed Modify adding a existing attribute value
-     */
-    @Test
-    @Ignore ( "This is just not a valid test since it leaves us with no reverse LDIF" )
-    public void testReverseModifyAddExistingCnValue() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        Modification mod = new ClientModification(
-            ModificationOperation.ADD_ATTRIBUTE,
-            new DefaultClientAttribute( "cn", "test" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNull( reversed );
-    }
-
-    
-    /**
-     * Test a reversed Modify adding a existing value from an existing attribute
-     */
-    @Test
-    public void testReverseModifyDelExistingOuValue() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache", "acme corp" );
-        modifiedEntry.put( ou );
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-
-        Modification mod = new ClientModification( 
-            ModificationOperation.REMOVE_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou", "acme corp" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-
-        assertEquals( "ou", attr.getId() );
-        assertEquals( "acme corp", attr.getString() );
-    }
-
-
-    /**
-     * Test a reversed Modify deleting an existing attribute
-     */
-    @Test
-    public void testReverseModifyDeleteOU() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache", "acme corp" );
-        modifiedEntry.put( ou );
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-
-        Modification mod = new ClientModification(
-            ModificationOperation.REMOVE_ATTRIBUTE, 
-            new DefaultClientAttribute( "ou" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertEquals( ou, attr );
-    }
-
-   
-    /**
-     * Test a reversed Modify deleting all values of an existing attribute
-     */
-    @Test
-    public void testReverseModifyDelExistingOuWithAllValues() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        EntryAttribute ou = new DefaultClientAttribute( "ou", "apache", "acme corp" );
-        modifiedEntry.put( ou );
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        Modification mod = new ClientModification(
-            ModificationOperation.REMOVE_ATTRIBUTE, ou );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn, 
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.ADD_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertEquals( ou, attr );
-    }
-
-    
-    /**
-     * Test a reversed Modify replacing existing values with new values
-     */
-    @Test
-    public void testReverseModifyReplaceExistingOuValues() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache", "acme corp" );
-        modifiedEntry.put( ou );
-
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-
-        EntryAttribute ouModified = new DefaultClientAttribute( "ou" );
-        ouModified.add( "directory" );
-        ouModified.add( "BigCompany inc." );
-        
-        Modification mod = new ClientModification(
-            ModificationOperation.REPLACE_ATTRIBUTE, ouModified );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( ou, attr );
-    }
-
-
-    /**
-     * Test a reversed Modify replace by injecting a new attribute
-     */
-    @Test
-    public void testReverseModifyReplaceNewAttribute() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        EntryAttribute newOu = new DefaultClientAttribute( "ou" );
-        newOu.add( "apache" );
-        newOu.add( "acme corp" );
-
-        
-        Modification mod = new ClientModification(
-            ModificationOperation.REPLACE_ATTRIBUTE, newOu );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertNull( attr.get() );
-    }
-
-   
-    /**
-     * Test a reversed Modify replace by removing an attribute
-     */
-    @Test
-    public void testReverseModifyReplaceExistingOuWithNothing() throws NamingException
-    {
-        Entry modifiedEntry = buildEntry();
-
-        EntryAttribute ou = new DefaultClientAttribute( "ou" );
-        ou.add( "apache" );
-        ou.add( "acme corp" );
-        modifiedEntry.put( ou );
-        
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        Modification mod = new ClientModification( 
-            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "ou" ) );
-
-        LdifEntry reversed = LdifUtils.reverseModify( dn,
-                Collections.<Modification>singletonList( mod ), modifiedEntry );
-
-        assertNotNull( reversed );
-        assertEquals( dn.getUpName(), reversed.getDn().getUpName() );
-        assertEquals( ChangeType.Modify, reversed.getChangeType() );
-        assertNull( reversed.getEntry() );
-        
-        List<Modification> mods = reversed.getModificationItems();
-        
-        assertNotNull( mods );
-        assertEquals( 1, mods.size() );
-        
-        Modification modif = mods.get( 0 );
-        
-        assertEquals( ModificationOperation.REPLACE_ATTRIBUTE, modif.getOperation() );
-
-        EntryAttribute attr = modif.getAttribute();
-        
-        assertNotNull( attr );
-        assertEquals( "ou", attr.getId() );
-        
-        assertEquals( ou, attr );
-    }
-    
-    
-    /**
-     * Test a multiple modifications reverse.
-     * 
-     * On the following entry :
-     *  dn: cn=test, ou=system
-     *  objectclass: top
-     *  objectclass: person
-     *  cn: test
-     *  sn: joe doe
-     *  l: USA
-     *  ou: apache
-     *  ou: acme corp
-     * 
-     * We will :
-     *  - add an 'ou' value 'BigCompany inc.'
-     *  - delete the 'l' attribute
-     *  - add the 'l=FR' attribute
-     *  - replace the 'l=FR' by a 'l=USA' attribute
-     *  - replace the 'ou' attribute with 'apache' value.
-     *  
-     * The modify ldif will be :
-     * 
-     *  dn: cn=test, ou=system
-     *  changetype: modify
-     *  add: ou
-     *  ou: BigCompany inc.
-     *  -
-     *  delete: l
-     *  -
-     *  add: l
-     *  l: FR
-     *  -
-     *  replace: l
-     *  l: USA
-     *  -
-     *  replace: ou
-     *  ou: apache
-     *  -
-     *  
-     * At the end, the entry will looks like :
-     *  dn: cn=test, ou=system
-     *  objectclass: top
-     *  objectclass: person
-     *  cn: test
-     *  sn: joe doe
-     *  l: USA
-     *  ou: apache
-     *  
-     * and the reversed LDIF will be :
-     * 
-     *  dn: cn=test, ou=system
-     *  changetype: modify
-     *  replace: ou
-     *  ou: apache
-     *  ou: acme corp
-     *  -
-     *  replace: l
-     *  l: USA
-     *  -
-     *  delete: l
-     *  l: FR
-     *  -
-     *  add: l
-     *  l: USA
-     *  -
-     *  delete: ou 
-     *  ou: BigCompany inc.
-     *  -
-     * 
-     */
-    @Test
-    public void testReverseMultipleModifications() throws NamingException
-    {
-        String initialEntryLdif = 
-                "dn: cn=test, ou=system\n" + 
-                "objectclass: top\n" + 
-                "objectclass: person\n" + 
-                "cn: test\n" + 
-                "sn: joe doe\n" + 
-                "l: USA\n" + 
-                "ou: apache\n" + 
-                "ou: acme corp\n"; 
-        
-        LdifReader reader = new LdifReader();
-        List<LdifEntry> entries = reader.parseLdif( initialEntryLdif );
-        
-        LdifEntry initialEntry = entries.get( 0 );
- 
-        // We will :
-        //   - add an 'ou' value 'BigCompany inc.'
-        //   - delete the 'l' attribute
-        //   - add the 'l=FR' attribute
-        //   - replace the 'l=FR' by a 'l=USA' attribute
-        //   - replace the 'ou' attribute with 'apache' value.
-        LdapDN dn = new LdapDN( "cn=test, ou=system" );
-        
-        List<Modification> modifications = new ArrayList<Modification>();
-
-        // First, inject the 'ou'
-        
-        Modification mod = new ClientModification( 
-            ModificationOperation.ADD_ATTRIBUTE, new DefaultClientAttribute( "ou", "BigCompany
inc." ) );
-        modifications.add( mod );
-
-        // Remove the 'l'
-        mod = new ClientModification(
-            ModificationOperation.REMOVE_ATTRIBUTE, new DefaultClientAttribute( "l" ) );
-        modifications.add( mod );
-        
-        // Add 'l=FR'
-        mod = new ClientModification( 
-            ModificationOperation.ADD_ATTRIBUTE, new DefaultClientAttribute( "l", "FR" )
);
-        modifications.add( mod );
-
-        // Replace it with 'l=USA'
-        mod = new ClientModification( 
-            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "l", "USA"
) );
-        modifications.add( mod );
-
-        // Replace the ou value
-        mod = new ClientModification( 
-            ModificationOperation.REPLACE_ATTRIBUTE, new DefaultClientAttribute( "ou", "apache"
) );
-        modifications.add( mod );
-        
-        LdifEntry reversedEntry = LdifUtils.reverseModify( dn, modifications, initialEntry.getEntry()
);
-
-        String expectedEntryLdif = 
-            "dn: cn=test, ou=system\n" +
-            "changetype: modify\n" +
-            "replace: ou\n" +
-            "ou: apache\n" +
-            "ou: acme corp\n" +
-            "-\n" +
-            "replace: l\n" +
-            "l: USA\n" +
-            "-\n" +
-            "delete: l\n" +
-            "l: FR\n" +
-            "-\n" +
-            "add: l\n" +
-            "l: USA\n" +
-            "-\n" +
-            "delete: ou\n" + 
-            "ou: BigCompany inc.\n" +
-            "-\n\n";
-    
-        reader = new LdifReader();
-        entries = reader.parseLdif( expectedEntryLdif );
-    
-        LdifEntry expectedEntry = entries.get( 0 );
-        
-        assertEquals( expectedEntry, reversedEntry );
-    }
 }



Mime
View raw message