directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r980921 - in /directory/shared/branches/shared-dnfactory-experiment: ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/ ldap/src/main/java/org/apache/directory/shared/ldap/entry/ ldap/src/main/java/org/apache/directory/shared/ld...
Date Fri, 30 Jul 2010 18:50:24 GMT
Author: kayyagari
Date: Fri Jul 30 18:50:23 2010
New Revision: 980921

URL: http://svn.apache.org/viewvc?rev=980921&view=rev
Log:
o updated code which was impacted after making DN immutable
o removed useless schema manager assignment in the RDN.clone() method 

Modified:
    directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
    directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
    directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java
    directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java
    directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
    directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
    directory/shared/branches/shared-dnfactory-experiment/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
Fri Jul 30 18:50:23 2010
@@ -112,7 +112,7 @@ public class LdifEntry implements Clonea
      */
     public void setDn( DN dn )
     {
-        entry.setDn( (DN)dn.clone() );
+        entry.setDn( dn );
     }
 
     

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
Fri Jul 30 18:50:23 2010
@@ -268,12 +268,12 @@ public class LdifRevertor
             throw new IllegalArgumentException( I18n.err( I18n.ERR_12076 ) );
         }
 
-        currentParent = ( DN ) modifiedDn.clone();
+        currentParent = modifiedDn;
         currentRdn = currentParent.getRdn();
-        currentParent.remove( currentParent.size() - 1 );
+        currentParent = currentParent.remove( currentParent.size() - 1 );
 
-        newDn = ( DN ) newSuperiorDn.clone();
-        newDn.add( modifiedDn.getRdn() );
+        newDn = newSuperiorDn;
+        newDn = newDn.add( modifiedDn.getRdn() );
 
         entry.setChangeType( ChangeType.ModDn );
         entry.setDn( newDn );
@@ -298,7 +298,7 @@ public class LdifRevertor
         
         if ( newSuperior != null )
         {
-            DN restoredDn = (DN)((DN)newSuperior.clone()).add( newRdn ); 
+            DN restoredDn = newSuperior.add( newRdn ); 
             reverted.setDn( restoredDn );
         }
         else
@@ -317,9 +317,9 @@ public class LdifRevertor
         
         if ( newSuperior != null )
         {
-            DN oldSuperior = ( DN ) entry.getDn().clone();
+            DN oldSuperior = entry.getDn();
 
-            oldSuperior.remove( oldSuperior.size() - 1 );
+            oldSuperior = oldSuperior.remove( oldSuperior.size() - 1 );
             reverted.setNewSuperior( oldSuperior.getName() );
         }
 
@@ -371,7 +371,7 @@ public class LdifRevertor
 
         if ( newSuperior != null )
         {
-            DN restoredDn = (DN)((DN)newSuperior.clone()).add( newRdn ); 
+            DN restoredDn = newSuperior.add( newRdn ); 
             reverted.setDn( restoredDn );
         }
         else
@@ -383,9 +383,9 @@ public class LdifRevertor
         
         if ( newSuperior != null )
         {
-            DN oldSuperior = ( DN ) newDn.clone();
+            DN oldSuperior = newDn;
 
-            oldSuperior.remove( oldSuperior.size() - 1 );
+            oldSuperior = oldSuperior.remove( oldSuperior.size() - 1 );
             reverted.setNewSuperior( oldSuperior.getName() );
         }
         
@@ -445,12 +445,12 @@ public class LdifRevertor
             throw new IllegalArgumentException( I18n.err( I18n.ERR_12079 ) );
         }
 
-        parentDn = ( DN ) entry.getDn().clone();
+        parentDn = entry.getDn();
         RDN oldRdn = parentDn.getRdn();
 
-        newDn = ( DN ) parentDn.clone();
-        newDn.remove( newDn.size() - 1 );
-        newDn.add( newRdn );
+        newDn = parentDn;
+        newDn = newDn.remove( newDn.size() - 1 );
+        newDn = newDn.add( newRdn );
 
         List<LdifEntry> entries = new ArrayList<LdifEntry>( 1 );
         LdifEntry reverted = new LdifEntry();

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java
Fri Jul 30 18:50:23 2010
@@ -199,7 +199,7 @@ public class DefaultEntry implements Ent
         // We will clone the existing entry, because it may be normalized
         if ( entry.getDn() != null )
         {
-            dn = ( DN ) entry.getDn().clone();
+            dn = entry.getDn();
         }
         else
         {
@@ -982,11 +982,7 @@ public class DefaultEntry implements Ent
             }
 
             // An Entry has a DN and many attributes.
-            // First, clone the DN, if not null.
-            if ( dn != null )
-            {
-                clone.dn = ( DN ) dn.clone();
-            }
+            clone.dn = dn; // note that DN is immutable now
 
             // then clone the ClientAttribute Map.
             clone.attributes = ( Map<String, EntryAttribute> ) ( ( ( HashMap<String,
EntryAttribute> ) attributes )
@@ -2692,14 +2688,14 @@ public class DefaultEntry implements Ent
     public void deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
     {
         // Read the DN
-        dn = new DN();
+        dn = DN.EMPTY_DN;
 
         byte b = in.readByte();
 
         if ( b == 1 )
         {
             RDN rdn = RdnSerializer.deserialize( in );
-            dn.add( rdn );
+            dn = new DN( rdn );
         }
 
         // Read the number of attributes

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java
Fri Jul 30 18:50:23 2010
@@ -22,6 +22,8 @@ package org.apache.directory.shared.ldap
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -134,14 +136,13 @@ public class DnSerializer
         // Read the RDNs. Is it's null, the number will be -1.
         int nbRdns = in.readInt();
         
-        DN dn = new DN( upName, normName, bytes );
-        
+        List<RDN> rdnList = new ArrayList<RDN>();
         for ( int i = 0; i < nbRdns; i++ )
         {
             RDN rdn = RdnSerializer.deserialize( in );
-            dn.add( 0, rdn );
+            rdnList.add( rdn );
         }
     
-        return dn;
+        return new DN( upName, normName, bytes, rdnList );
     }
 }

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/name/RDN.java
Fri Jul 30 18:50:23 2010
@@ -812,7 +812,6 @@ public class RDN implements Cloneable, C
         try
         {
             RDN rdn = ( RDN ) super.clone();
-            rdn.schemaManager = schemaManager;
 
             // The AttributeTypeAndValue is immutable. We won't clone it
 

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
Fri Jul 30 18:50:23 2010
@@ -79,15 +79,13 @@ public class NamespaceTools
      */
     public static DN getRelativeName( DN ancestor, DN descendant ) throws LdapInvalidDnException
     {
-        DN rdn = null;
+        DN rdn = descendant;
         
-        rdn = ( DN ) descendant.clone();
-
         if ( rdn.isChildOf( ancestor ) )
         {
             for ( int ii = 0; ii < ancestor.size(); ii++ )
             {
-                rdn.remove( 0 );
+                rdn = rdn.remove( 0 );
             }
         }
         else

Modified: directory/shared/branches/shared-dnfactory-experiment/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-dnfactory-experiment/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java?rev=980921&r1=980920&r2=980921&view=diff
==============================================================================
--- directory/shared/branches/shared-dnfactory-experiment/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
(original)
+++ directory/shared/branches/shared-dnfactory-experiment/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
Fri Jul 30 18:50:23 2010
@@ -53,6 +53,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -112,6 +113,7 @@ public class DNTest
     {
         DN dn = new DN();
         assertEquals( "", dn.getName() );
+        assertEquals( "", dn.getNormName() );
         assertTrue( dn.isEmpty() );
     }
 
@@ -252,7 +254,7 @@ public class DNTest
         DN target = new DN();
 
         assertTrue( DN.isValid( "cn=Kate Bush+sn=Bush,ou=system" ) );
-        target.addAll( target.size(), dn );
+        target = target.addAll( target.size(), dn );
         assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.toString() );
         assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.getName() );
     }
@@ -543,7 +545,8 @@ public class DNTest
         DN dn = new DN( "a=b, c=d, e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d, e=f" ) );
-        assertEquals( "e=f", dn.remove( 0 ).getNormName() );
+        // now remove method reurns a modified cloned DN
+        dn = dn.remove( 0 );
         assertEquals( "a=b,c=d", dn.getNormName() );
         assertEquals( "a=b, c=d", dn.getName() );
     }
@@ -558,8 +561,7 @@ public class DNTest
         DN dn = new DN( "a=b, c=d, e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d, e=f" ) );
-        assertEquals( "c=d", dn.remove( 1 ).getNormName() );
-        assertEquals( "a=b, e=f", dn.getName() );
+        assertEquals( "a=b, c=d, e=f", dn.getName() );
     }
 
 
@@ -572,7 +574,7 @@ public class DNTest
         DN dn = new DN( "a=b, c=d, e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d, e=f" ) );
-        assertEquals( "a=b", dn.remove( 2 ).toString() );
+        dn = dn.remove( 2 );
         assertEquals( " c=d, e=f", dn.getName() );
     }
 
@@ -586,7 +588,7 @@ public class DNTest
         DN dn = new DN( "a=b, c=d; e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d; e=f" ) );
-        assertEquals( "c=d", dn.remove( 1 ).getNormName() );
+        dn = dn.remove( 1 );
         assertEquals( "a=b, e=f", dn.getName() );
     }
 
@@ -676,16 +678,16 @@ public class DNTest
         DN dn = new DN();
         assertEquals( 0, dn.size() );
 
-        dn.add( "e = f" );
+        dn = dn.add( "e = f" );
         assertEquals( 1, dn.size() );
 
-        dn.add( "c = d" );
+        dn = dn.add( "c = d" );
         assertEquals( 2, dn.size() );
 
-        dn.remove( 0 );
+        dn = dn.remove( 0 );
         assertEquals( 1, dn.size() );
 
-        dn.remove( 0 );
+        dn = dn.remove( 0 );
         assertEquals( 0, dn.size() );
     }
 
@@ -699,7 +701,7 @@ public class DNTest
     {
         DN dn = new DN();
 
-        dn.add( "e = f" );
+        dn = dn.add( "e = f" );
         assertEquals( "e=f", dn.getNormName() );
         assertEquals( "e = f", dn.getName() );
         assertEquals( 1, dn.size() );
@@ -714,7 +716,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( "e = f" );
+        dn = dn.add( "e = f" );
         assertEquals( "e=f,a=b,c=d", dn.getNormName() );
         assertEquals( "e = f,a=b, c=d", dn.getName() );
         assertEquals( 3, dn.size() );
@@ -729,7 +731,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( "e = f + g = h" );
+        dn = dn.add( "e = f + g = h" );
 
         // Warning ! The order of AVAs has changed during the parsing
         // This has no impact on the correctness of the DN, but the
@@ -747,7 +749,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( dn.size(), "e = f" );
+        dn = dn.add( dn.size(), "e = f" );
         assertEquals( "e = f,a=b, c=d", dn.getName() );
         assertEquals( 3, dn.size() );
     }
@@ -761,7 +763,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( 0, "e = f" );
+        dn = dn.add( 0, "e = f" );
         assertEquals( "a=b, c=d,e = f", dn.getName() );
         assertEquals( 3, dn.size() );
     }
@@ -775,7 +777,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( 1, "e = f" );
+        dn = dn.add( 1, "e = f" );
         assertEquals( "a=b,e = f, c=d", dn.getName() );
         assertEquals( 3, dn.size() );
     }
@@ -792,7 +794,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN( "c = d" );
-        dn.addAll( dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "c = d,a = b", dn.getName() );
     }
 
@@ -807,7 +809,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN();
-        dn.addAll( dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "a=b", dn.getNormName() );
         assertEquals( "a = b", dn.getName() );
     }
@@ -823,7 +825,7 @@ public class DNTest
     {
         DN dn = new DN();
         DN dn2 = new DN( "a = b" );
-        dn.addAll( dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "a = b", dn.getName() );
     }
 
@@ -838,7 +840,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN( "c = d" );
-        dn.addAll( 0, dn2 );
+        dn = dn.addAll( 0, dn2 );
         assertEquals( "a = b,c = d", dn.getName() );
     }
 
@@ -853,7 +855,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN( "c = d" );
-        dn.addAll( 1, dn2 );
+        dn = dn.addAll( 1, dn2 );
         assertEquals( "c = d,a = b", dn.getName() );
     }
 
@@ -868,7 +870,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b, c = d" );
         DN dn2 = new DN( "e = f" );
-        dn.addAll( 1, dn2 );
+        dn = dn.addAll( 1, dn2 );
         assertEquals( "a = b,e = f, c = d", dn.getName() );
     }
 
@@ -883,7 +885,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN();
-        dn.addAll( 0, dn2 );
+        dn = dn.addAll( 0, dn2 );
         assertEquals( "a=b", dn.getNormName() );
         assertEquals( "a = b", dn.getName() );
     }
@@ -899,7 +901,7 @@ public class DNTest
     {
         DN dn = new DN();
         DN dn2 = new DN( "a = b" );
-        dn.addAll( 0, dn2 );
+        dn = dn.addAll( 0, dn2 );
         assertEquals( "a = b", dn.getName() );
     }
 
@@ -1098,10 +1100,13 @@ public class DNTest
     public void testDnRemoveIsEmpty() throws LdapException
     {
         DN dn = new DN( "a=b, c=d" );
-        dn.remove( 0 );
-        dn.remove( 0 );
+        DN clonedDn = dn.remove( 0 );
+        
+        assertFalse( dn == clonedDn );
+        
+        clonedDn = clonedDn.remove( 0 );
 
-        assertEquals( true, dn.isEmpty() );
+        assertEquals( true, clonedDn.isEmpty() );
     }
 
 
@@ -1467,12 +1472,14 @@ public class DNTest
         DN name = new DN( "cn=John,ou=People,ou=Marketing" );
 
         // Remove the second component from the head: ou=People
-        String out = name.remove( 1 ).toString();
+        name = name.remove( 1 );
+        String out = name.toString();
 
-        assertEquals( "ou=People", out );
+        assertEquals( "cn=John,ou=Marketing", out );
 
         // Add to the head (first): cn=John,ou=Marketing,ou=East
-        out = name.add( 0, "ou=East" ).toString();
+        name = name.add( 0, "ou=East" );
+        out = name.toString();
 
         assertEquals( "cn=John,ou=Marketing,ou=East", out );
 
@@ -2174,7 +2181,8 @@ public class DNTest
         DN name1 = new DN( "cn=HomeDir,cn=John" );
         DN name2 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        name = name.addAll( name0 );
+        assertTrue( name0.equals( name ) );
         assertTrue( name2.equals( name.addAll( name1 ) ) );
     }
 
@@ -2193,7 +2201,8 @@ public class DNTest
         DN name1 = new DN( "cn=HomeDir,cn=John" );
         DN name2 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        name = name.addAll( name0 );
+        assertTrue( name0.equals( name ) );
         assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
     }
 
@@ -2212,13 +2221,17 @@ public class DNTest
         DN name1 = new DN( "cn=John" );
         DN name2 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name0.equals( name.addAll( name0 ) ) );
-        assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
+        name = name.addAll( name0 );
+        assertTrue( name0.equals( name ) );
+        
+        name = name.addAll( 2, name1 );
+        assertTrue( name2.equals( name ) );
 
         DN name3 = new DN( "cn=Airport" );
         DN name4 = new DN( "cn=Airport,cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name4.equals( name.addAll( 4, name3 ) ) );
+        name = name.addAll( 4, name3 );
+        assertTrue( name4.equals( name ) );
 
         DN name5 = new DN( "cn=ABC123" );
         DN name6 = new DN( "cn=Airport,cn=HomeDir,cn=ABC123,cn=John,ou=Marketing,ou=East"
);
@@ -2240,19 +2253,19 @@ public class DNTest
         assertEquals( name, new DN( "" ) );
 
         DN name4 = new DN( "ou=East" );
-        name.add( "ou=East" );
+        name = name.add( "ou=East" );
         assertEquals( name4, name );
 
         DN name3 = new DN( "ou=Marketing,ou=East" );
-        name.add( "ou=Marketing" );
+        name = name.add( "ou=Marketing" );
         assertEquals( name3, name );
 
         DN name2 = new DN( "cn=John,ou=Marketing,ou=East" );
-        name.add( "cn=John" );
+        name = name.add( "cn=John" );
         assertEquals( name2, name );
 
         DN name0 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-        name.add( "cn=HomeDir" );
+        name = name.add( "cn=HomeDir" );
         assertEquals( name0, name );
     }
 
@@ -2270,31 +2283,31 @@ public class DNTest
         assertEquals( name, new DN( "" ) );
 
         DN name4 = new DN( "ou=East" );
-        name.add( "ou=East" );
+        name = name.add( "ou=East" );
         assertEquals( name4, name );
 
         DN name3 = new DN( "ou=Marketing,ou=East" );
-        name.add( 1, "ou=Marketing" );
+        name = name.add( 1, "ou=Marketing" );
         assertEquals( name3, name );
 
         DN name2 = new DN( "cn=John,ou=Marketing,ou=East" );
-        name.add( 2, "cn=John" );
+        name = name.add( 2, "cn=John" );
         assertEquals( name2, name );
 
         DN name0 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-        name.add( 3, "cn=HomeDir" );
+        name = name.add( 3, "cn=HomeDir" );
         assertEquals( name0, name );
 
         DN name5 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East,o=LL " + "Bean Inc."
);
-        name.add( 0, "o=LL Bean Inc." );
+        name = name.add( 0, "o=LL Bean Inc." );
         assertEquals( name5, name );
 
         DN name6 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East,c=US,o=LL " + "Bean Inc."
);
-        name.add( 1, "c=US" );
+        name = name.add( 1, "c=US" );
         assertEquals( name6, name );
 
         DN name7 = new DN( "cn=HomeDir,cn=John,ou=Advertising,ou=Marketing," + "ou=East,c=US,o=LL
" + "Bean Inc." );
-        name.add( 4, "ou=Advertising" );
+        name = name.add( 4, "ou=Advertising" );
         assertEquals( name7, name );
     }
 
@@ -2312,27 +2325,27 @@ public class DNTest
         assertEquals( new DN( "" ), name );
 
         DN name3 = new DN( "ou=Marketing" );
-        name.add( "ou=East" );
-        name.add( 1, "ou=Marketing" );
-        name.remove( 0 );
+        name = name.add( "ou=East" );
+        name = name.add( 1, "ou=Marketing" );
+        name = name.remove( 0 );
         assertEquals( name3, name );
 
         DN name2 = new DN( "cn=HomeDir,ou=Marketing,ou=East" );
-        name.add( 0, "ou=East" );
-        name.add( 2, "cn=John" );
-        name.add( "cn=HomeDir" );
-        name.remove( 2 );
+        name = name.add( 0, "ou=East" );
+        name = name.add( 2, "cn=John" );
+        name = name.add( "cn=HomeDir" );
+        name = name.remove( 2 );
         assertEquals( name2, name );
 
-        name.remove( 1 );
+        name = name.remove( 1 );
         DN name1 = new DN( "cn=HomeDir,ou=East" );
         assertEquals( name1, name );
 
-        name.remove( 1 );
+        name = name.remove( 1 );
         DN name0 = new DN( "ou=East" );
         assertEquals( name0, name );
 
-        name.remove( 0 );
+        name = name.remove( 0 );
         assertEquals( new DN( "" ), name );
     }
 
@@ -2349,16 +2362,16 @@ public class DNTest
         DN name = new DN();
         assertEquals( "", name.toString() );
 
-        name.add( "ou=East" );
+        name = name.add( "ou=East" );
         assertEquals( "ou=East", name.toString() );
 
-        name.add( 1, "ou=Marketing" );
+        name = name.add( 1, "ou=Marketing" );
         assertEquals( "ou=Marketing,ou=East", name.toString() );
 
-        name.add( "cn=John" );
+        name = name.add( "cn=John" );
         assertEquals( "cn=John,ou=Marketing,ou=East", name.toString() );
 
-        name.add( "cn=HomeDir" );
+        name = name.add( "cn=HomeDir" );
         assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.toString() );
     }
 
@@ -2628,6 +2641,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddStringName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2643,6 +2657,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddIntString() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2666,6 +2681,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddAllName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2681,6 +2697,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddAllIntName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2754,6 +2771,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testRemoveName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -3006,13 +3024,13 @@ public class DNTest
 
         CompoundName name = new CompoundName( "cn=blah,dc=example,dc=com", props );
         DN dn = new DN();
-        dn.addAll( 0, name );
+        dn = dn.addAll( 0, name );
 
         assertEquals( "cn=blah,dc=example,dc=com", dn.toString() );
 
         name = new CompoundName( "cn=blah,dc=example,dc=com", props );
         dn = new DN( "cn=xyz" );
-        dn.addAll( 0, name );
+        dn = dn.addAll( 0, name );
 
         assertEquals( "cn=xyz,cn=blah,dc=example,dc=com", dn.toString() );
     }



Mime
View raw message