You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/07/09 00:12:04 UTC

svn commit: r675000 [2/2] - in /directory: apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/ shared/branches/bigbang/ldap/src/main/java/org...

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=675000&r1=674999&r2=675000&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java Tue Jul  8 15:12:03 2008
@@ -20,7 +20,6 @@
 package org.apache.directory.shared.ldap.name;
 
 
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -68,2679 +67,2919 @@
     private Map<String, OidNormalizer> oids;
     private Map<String, OidNormalizer> oidOids;
 
+
     /**
      * Initialize OIDs maps for normalization
      */
-    @Before public void initMapOids()
+    @Before
+    public void initMapOids()
     {
         oids = new HashMap<String, OidNormalizer>();
 
         oids.put( "dc", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
         oids.put( "domaincomponent", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
         oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "dc", new DeepTrimToLowerNormalizer() ) );
+
         oids.put( "ou", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
         oids.put( "organizationalUnitName", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
         oids.put( "2.5.4.11", new OidNormalizer( "ou", new DeepTrimToLowerNormalizer() ) );
-    
-    
+
         // Another map where we store OIDs instead of names.
         oidOids = new HashMap<String, OidNormalizer>();
 
         oidOids.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-        oidOids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-        oidOids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
+        oidOids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25",
+            new DeepTrimToLowerNormalizer() ) );
+        oidOids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25",
+            new DeepTrimToLowerNormalizer() ) );
         oidOids.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
         oidOids.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
         oidOids.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
     }
-    
-    
-    
-   // ~ Methods
-   // ------------------------------------------------------------------------------------
-   // CONSTRUCTOR functions --------------------------------------------------
-
-   /**
-    * Test a null DN
-    */
-   @Test public void testLdapDNNull()
-   {
-       LdapDN dn = new LdapDN();
-       assertEquals( "", dn.getUpName() );
-       assertTrue( dn.isEmpty() );
-   }
 
 
-   /**
-    * test an empty DN
-    */
-   @Test public void testLdapDNEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "" );
-       assertEquals( "", dn.getUpName() );
-       assertTrue( dn.isEmpty() );
-   }
+    // ~ Methods
+    // ------------------------------------------------------------------------------------
+    // CONSTRUCTOR functions --------------------------------------------------
 
+    /**
+     * Test a null DN
+     */
+    @Test
+    public void testLdapDNNull()
+    {
+        LdapDN dn = new LdapDN();
+        assertEquals( "", dn.getUpName() );
+        assertTrue( dn.isEmpty() );
+    }
 
-   /**
-    * test a simple DN : a = b
-    */
-   @Test public void testLdapDNSimple() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b" );
-
-       assertTrue( LdapDN.isValid( "a = b" ) );
-       assertEquals( "a = b", dn.getUpName() );
-       assertEquals( "a=b", dn.toString() );
-   }
 
-   /**
-    * test a simple DN with some spaces : "a = b  "
-    */
-   @Test public void testLdapDNSimpleWithSpaces() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b  " );
-       
-       assertTrue( LdapDN.isValid( "a = b  " ) );
-       assertEquals( "a = b  ", dn.getUpName() );
-       assertEquals( "a=b", dn.toString() );
-   }
+    /**
+     * test an empty DN
+     */
+    @Test
+    public void testLdapDNEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "" );
+        assertEquals( "", dn.getUpName() );
+        assertTrue( dn.isEmpty() );
+    }
 
 
-   /**
-    * test a composite DN : a = b, d = e
-    */
-   @Test public void testLdapDNComposite() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b, c = d" );
-
-       assertTrue( LdapDN.isValid( "a = b, c = d" ) );
-       assertEquals( "a=b,c=d", dn.toString() );
-       assertEquals( "a = b, c = d", dn.getUpName() );
-   }
+    /**
+     * test a simple DN : a = b
+     */
+    @Test
+    public void testLdapDNSimple() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
 
-   /**
-    * test a composite DN with spaces : a = b  , d = e
-    */
-   @Test public void testLdapDNCompositeWithSpaces() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b  , c = d" );
-
-       assertTrue( LdapDN.isValid( "a = b  , c = d" ) );
-       assertEquals( "a=b,c=d", dn.toString() );
-       assertEquals( "a = b  , c = d", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a = b" ) );
+        assertEquals( "a = b", dn.getUpName() );
+        assertEquals( "a=b", dn.toString() );
+    }
 
 
-   /**
-    * test a composite DN with or without spaces: a=b, a =b, a= b, a = b, a = b
-    */
-   @Test public void testLdapDNCompositeWithSpace() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, a =b, a= b, a = b, a  =  b" );
-
-       assertTrue( LdapDN.isValid( "a=b, a =b, a= b, a = b, a  =  b" ) );
-       assertEquals( "a=b,a=b,a=b,a=b,a=b", dn.toString() );
-       assertEquals( "a=b, a =b, a= b, a = b, a  =  b", dn.getUpName() );
-   }
+    /**
+     * test a simple DN with some spaces : "a = b  "
+     */
+    @Test
+    public void testLdapDNSimpleWithSpaces() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b  " );
 
+        assertTrue( LdapDN.isValid( "a = b  " ) );
+        assertEquals( "a = b  ", dn.getUpName() );
+        assertEquals( "a=b", dn.toString() );
+    }
 
-   /**
-    * test a composite DN with differents separators : a=b;c=d,e=f It should
-    * return a=b,c=d,e=f (the ';' is replaced by a ',')
-    */
-   @Test public void testLdapDNCompositeSepators() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b;c=d,e=f" );
-
-       assertTrue( LdapDN.isValid( "a=b;c=d,e=f" ) );
-       assertEquals( "a=b,c=d,e=f", dn.toString() );
-       assertEquals( "a=b;c=d,e=f", dn.getUpName() );
-   }
 
+    /**
+     * test a composite DN : a = b, d = e
+     */
+    @Test
+    public void testLdapDNComposite() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b, c = d" );
 
-   /**
-    * test a simple DN with multiple NameComponents : a = b + c = d
-    */
-   @Test public void testLdapDNSimpleMultivaluedAttribute() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b + c = d" );
-
-       assertTrue( LdapDN.isValid( "a = b + c = d" ) );
-       assertEquals( "a=b+c=d", dn.toString() );
-       assertEquals( "a = b + c = d", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a = b, c = d" ) );
+        assertEquals( "a=b,c=d", dn.toString() );
+        assertEquals( "a = b, c = d", dn.getUpName() );
+    }
 
 
-   /**
-    * test a composite DN with multiple NC and separators : a=b+c=d, e=f + g=h +
-    * i=j
-    */
-   @Test public void testLdapDNCompositeMultivaluedAttribute() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b+c=d, e=f + g=h + i=j" );
-
-       assertTrue( LdapDN.isValid( "a=b+c=d, e=f + g=h + i=j" ) );
-       assertEquals( "a=b+c=d,e=f+g=h+i=j", dn.toString() );
-       assertEquals( "a=b+c=d, e=f + g=h + i=j", dn.getUpName() );
-   }
-
-    
-   /**
-   * Test to see if a DN with multiRdn values is preserved after an addAll.
-   */
-   @Test public void testAddAllWithMultivaluedAttribute() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "cn=Kate Bush+sn=Bush,ou=system" );
-       LdapDN target = new LdapDN();
-
-       assertTrue( LdapDN.isValid( "cn=Kate Bush+sn=Bush,ou=system" ) );
-       target.addAll( target.size(), dn );
-       assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.toString() );
-       assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.getUpName() );
-   }
+    /**
+     * test a composite DN with spaces : a = b  , d = e
+     */
+    @Test
+    public void testLdapDNCompositeWithSpaces() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b  , c = d" );
 
+        assertTrue( LdapDN.isValid( "a = b  , c = d" ) );
+        assertEquals( "a=b,c=d", dn.toString() );
+        assertEquals( "a = b  , c = d", dn.getUpName() );
+    }
 
-   /**
-    * test a simple DN with an oid prefix (uppercase) : OID.12.34.56 = azerty
-    */
-   @Test public void testLdapDNOidUpper() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "OID.12.34.56 = azerty" );
-
-       assertTrue( LdapDN.isValid( "OID.12.34.56 = azerty" ) );
-       assertEquals( "oid.12.34.56=azerty", dn.toString() );
-       assertEquals( "OID.12.34.56 = azerty", dn.getUpName() );
-   }
 
+    /**
+     * test a composite DN with or without spaces: a=b, a =b, a= b, a = b, a = b
+     */
+    @Test
+    public void testLdapDNCompositeWithSpace() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, a =b, a= b, a = b, a  =  b" );
 
-   /**
-    * test a simple DN with an oid prefix (lowercase) : oid.12.34.56 = azerty
-    */
-   @Test public void testLdapDNOidLower() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "oid.12.34.56 = azerty" );
-
-       assertTrue( LdapDN.isValid( "oid.12.34.56 = azerty" ) );
-       assertEquals( "oid.12.34.56=azerty", dn.toString() );
-       assertEquals( "oid.12.34.56 = azerty", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a=b, a =b, a= b, a = b, a  =  b" ) );
+        assertEquals( "a=b,a=b,a=b,a=b,a=b", dn.toString() );
+        assertEquals( "a=b, a =b, a= b, a = b, a  =  b", dn.getUpName() );
+    }
 
 
-   /**
-    * test a simple DN with an oid attribut without oid prefix : 12.34.56 =
-    * azerty
-    */
-   @Test public void testLdapDNOidWithoutPrefix() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "12.34.56 = azerty" );
-
-       assertTrue( LdapDN.isValid( "12.34.56 = azerty" ) );
-       assertEquals( "12.34.56=azerty", dn.toString() );
-       assertEquals( "12.34.56 = azerty", dn.getUpName() );
-   }
+    /**
+     * test a composite DN with differents separators : a=b;c=d,e=f It should
+     * return a=b,c=d,e=f (the ';' is replaced by a ',')
+     */
+    @Test
+    public void testLdapDNCompositeSepators() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b;c=d,e=f" );
 
+        assertTrue( LdapDN.isValid( "a=b;c=d,e=f" ) );
+        assertEquals( "a=b,c=d,e=f", dn.toString() );
+        assertEquals( "a=b;c=d,e=f", dn.getUpName() );
+    }
 
-   /**
-    * test a composite DN with an oid attribut wiithout oid prefix : 12.34.56 =
-    * azerty; 7.8 = test
-    */
-   @Test public void testLdapDNCompositeOidWithoutPrefix() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "12.34.56 = azerty; 7.8 = test" );
-
-       assertTrue( LdapDN.isValid( "12.34.56 = azerty; 7.8 = test" ) );
-       assertEquals( "12.34.56=azerty,7.8=test", dn.toString() );
-       assertEquals( "12.34.56 = azerty; 7.8 = test", dn.getUpName() );
-   }
 
+    /**
+     * test a simple DN with multiple NameComponents : a = b + c = d
+     */
+    @Test
+    public void testLdapDNSimpleMultivaluedAttribute() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b + c = d" );
 
-   /**
-    * test a simple DN with pair char attribute value : a = \,\=\+\<\>\#\;\\\"\C4\8D"
-    */
-   @Test public void testLdapDNPairCharAttributeValue() throws InvalidNameException
-   {
-       
-       LdapDN dn = new LdapDN( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D" );
-
-       assertTrue( LdapDN.isValid( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D" ) );
-       assertEquals( "a=\\,=\\+\\<\\>#\\;\\\\\\\"\\C4\\8D", dn.toString() );
-       assertEquals( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a = b + c = d" ) );
+        assertEquals( "a=b+c=d", dn.toString() );
+        assertEquals( "a = b + c = d", dn.getUpName() );
+    }
 
-   /**
-    * test a simple DN with pair char attribute value : "SN=Lu\C4\8Di\C4\87"
-    */
-   @Test public void testLdapDNRFC253_Lucic() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "SN=Lu\\C4\\8Di\\C4\\87" );
-
-       assertTrue( LdapDN.isValid( "SN=Lu\\C4\\8Di\\C4\\87" ) );
-       assertEquals( "sn=Lu\\C4\\8Di\\C4\\87", dn.toString() );
-       assertEquals( "SN=Lu\\C4\\8Di\\C4\\87", dn.getUpName() );
-   }
 
-   /**
-    * test a simple DN with hexString attribute value : a = #0010A0AAFF
-    */
-   @Test public void testLdapDNHexStringAttributeValue() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = #0010A0AAFF" );
-
-       assertTrue( LdapDN.isValid( "a = #0010A0AAFF" ) );
-       assertEquals( "a=#0010A0AAFF", dn.toString() );
-       assertEquals( "a = #0010A0AAFF", dn.getUpName() );
-   }
+    /**
+     * test a composite DN with multiple NC and separators : a=b+c=d, e=f + g=h +
+     * i=j
+     */
+    @Test
+    public void testLdapDNCompositeMultivaluedAttribute() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b+c=d, e=f + g=h + i=j" );
 
-   /**
-    * test a simple DN with a # on first position
-    */
-   @Test public void testLdapDNSharpFirst() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = \\#this is a sharp" );
-
-       assertTrue( LdapDN.isValid( "a = \\#this is a sharp" ) );
-       assertEquals( "a=\\#this is a sharp", dn.toString() );
-       assertEquals( "a = \\#this is a sharp", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a=b+c=d, e=f + g=h + i=j" ) );
+        assertEquals( "a=b+c=d,e=f+g=h+i=j", dn.toString() );
+        assertEquals( "a=b+c=d, e=f + g=h + i=j", dn.getUpName() );
+    }
 
-   /**
-    * test a simple DN with a wrong hexString attribute value : a = #0010Z0AAFF
-    */
-   @Test public void testLdapDNWrongHexStringAttributeValue()
-   {
-       try
-       {
-           new LdapDN( "a = #0010Z0AAFF" );
-           fail();
-       }
-       catch ( InvalidNameException ine )
-       {
-
-           assertFalse( LdapDN.isValid( "a = #0010Z0AAFF" ) );
-           assertTrue( true );
-       }
-   }
 
-   /**
-    * test a simple DN with a wrong hexString attribute value : a = #AABBCCDD3
+    /**
+    * Test to see if a DN with multiRdn values is preserved after an addAll.
     */
-   @Test public void testLdapDNWrongHexStringAttributeValue2()
-   {
-       try
-       {
-           new LdapDN( "a = #AABBCCDD3" );
-           fail();
-       }
-       catch ( InvalidNameException ine )
-       {
-           assertFalse( LdapDN.isValid( "a = #AABBCCDD3" ) );
-           assertTrue( true );
-       }
-   }
+    @Test
+    public void testAddAllWithMultivaluedAttribute() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "cn=Kate Bush+sn=Bush,ou=system" );
+        LdapDN target = new LdapDN();
 
-   /**
-    * test a simple DN with a quote in attribute value : a = quoted \"value\"
-    */
-   @Test public void testLdapDNQuoteInAttributeValue() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = quoted \\\"value\\\"" );
-
-       assertTrue( LdapDN.isValid( "a = quoted \\\"value\\\"" ) );
-       assertEquals( "a=quoted \\\"value\\\"", dn.toString() );
-       assertEquals( "a = quoted \\\"value\\\"", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "cn=Kate Bush+sn=Bush,ou=system" ) );
+        target.addAll( target.size(), dn );
+        assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.toString() );
+        assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.getUpName() );
+    }
 
-   /**
-    * test a simple DN with quoted attribute value : a = \" quoted value \"
-    */
-   @Test public void testLdapDNQuotedAttributeValue() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = \\\" quoted value \\\"" );
-
-       assertTrue( LdapDN.isValid( "a = \\\" quoted value \\\"" ) );
-       assertEquals( "a=\\\" quoted value \\\"", dn.toString() );
-       assertEquals( "a = \\\" quoted value \\\"", dn.getUpName() );
-   }
 
-   /**
-    * test a simple DN with a comma at the end
-    */
-   @Test public void testLdapDNComaAtEnd()
-   {
-       assertFalse( LdapDN.isValid( "a = b,"  ) );
-       assertFalse( LdapDN.isValid( "a = b, "  ) );
-       
-       try
-       {
-           new LdapDN( "a = b," );
-           fail();
-       }
-       catch ( InvalidNameException ine )
-       {
-           assertTrue( true );
-       }
-   }
+    /**
+     * test a simple DN with an oid prefix (uppercase) : OID.12.34.56 = azerty
+     */
+    @Test
+    public void testLdapDNOidUpper() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "OID.12.34.56 = azerty" );
 
+        assertTrue( LdapDN.isValid( "OID.12.34.56 = azerty" ) );
+        assertEquals( "oid.12.34.56=azerty", dn.toString() );
+        assertEquals( "OID.12.34.56 = azerty", dn.getUpName() );
+    }
 
-   // REMOVE operation -------------------------------------------------------
 
-   /**
-    * test a remove from position 0
-    */
-   @Test public void testLdapDNRemove0() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
-
-       assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
-       assertEquals( "e=f", dn.remove( 0 ).toString() );
-       assertEquals( "a=b,c=d", dn.toString() );
-       assertEquals( "a=b, c=d", dn.getUpName() );
-   }
+    /**
+     * test a simple DN with an oid prefix (lowercase) : oid.12.34.56 = azerty
+     */
+    @Test
+    public void testLdapDNOidLower() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "oid.12.34.56 = azerty" );
 
+        assertTrue( LdapDN.isValid( "oid.12.34.56 = azerty" ) );
+        assertEquals( "oid.12.34.56=azerty", dn.toString() );
+        assertEquals( "oid.12.34.56 = azerty", dn.getUpName() );
+    }
 
-   /**
-    * test a remove from position 1
-    */
-   @Test public void testLdapDNRemove1() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
-
-       assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
-       assertEquals( "c=d", dn.remove( 1 ).toString() );
-       assertEquals( "a=b, e=f", dn.getUpName() );
-   }
 
+    /**
+     * test a simple DN with an oid attribut without oid prefix : 12.34.56 =
+     * azerty
+     */
+    @Test
+    public void testLdapDNOidWithoutPrefix() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "12.34.56 = azerty" );
 
-   /**
-    * test a remove from position 2
-    */
-   @Test public void testLdapDNRemove2() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
-
-       assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
-       assertEquals( "a=b", dn.remove( 2 ).toString() );
-       assertEquals( " c=d, e=f", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "12.34.56 = azerty" ) );
+        assertEquals( "12.34.56=azerty", dn.toString() );
+        assertEquals( "12.34.56 = azerty", dn.getUpName() );
+    }
 
 
-   /**
-    * test a remove from position 1 whith semi colon
-    */
-   @Test public void testLdapDNRemove1WithSemiColon() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d; e=f" );
-
-       assertTrue( LdapDN.isValid( "a=b, c=d; e=f" ) );
-       assertEquals( "c=d", dn.remove( 1 ).toString() );
-       assertEquals( "a=b, e=f", dn.getUpName() );
-   }
+    /**
+     * test a composite DN with an oid attribut wiithout oid prefix : 12.34.56 =
+     * azerty; 7.8 = test
+     */
+    @Test
+    public void testLdapDNCompositeOidWithoutPrefix() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "12.34.56 = azerty; 7.8 = test" );
 
+        assertTrue( LdapDN.isValid( "12.34.56 = azerty; 7.8 = test" ) );
+        assertEquals( "12.34.56=azerty,7.8=test", dn.toString() );
+        assertEquals( "12.34.56 = azerty; 7.8 = test", dn.getUpName() );
+    }
 
-   /**
-    * test a remove out of bound
-    */
-   @Test public void testLdapDNRemoveOutOfBound() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d; e=f" );
-
-       assertTrue( LdapDN.isValid( "a=b, c=d; e=f" ) );
-
-       try
-       {
-           dn.remove( 4 );
-           // We whould never reach this point
-           fail();
-       }
-       catch ( ArrayIndexOutOfBoundsException aoobe )
-       {
-           assertTrue( true );
-       }
-   }
-
-
-   // SIZE operations
-   /**
-    * test a 0 size
-    */
-   @Test public void testLdapDNSize0()
-   {
-       LdapDN dn = new LdapDN();
 
-       assertTrue( LdapDN.isValid( "" ) );
-       assertEquals( 0, dn.size() );
-   }
+    /**
+     * test a simple DN with pair char attribute value : a = \,\=\+\<\>\#\;\\\"\C4\8D"
+     */
+    @Test
+    public void testLdapDNPairCharAttributeValue() throws InvalidNameException
+    {
 
+        LdapDN dn = new LdapDN( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D" );
 
-   /**
-    * test a 1 size
-    */
-   @Test public void testLdapDNSize1() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b" );
+        assertTrue( LdapDN.isValid( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D" ) );
+        assertEquals( "a=\\,=\\+\\<\\>#\\;\\\\\\\"\\C4\\8D", dn.toString() );
+        assertEquals( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D", dn.getUpName() );
+    }
 
-       assertTrue( LdapDN.isValid( "a=b" ) );
-       assertEquals( 1, dn.size() );
-   }
 
+    /**
+     * test a simple DN with pair char attribute value : "SN=Lu\C4\8Di\C4\87"
+     */
+    @Test
+    public void testLdapDNRFC253_Lucic() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "SN=Lu\\C4\\8Di\\C4\\87" );
 
-   /**
-    * test a 3 size
-    */
-   @Test public void testLdapDNSize3() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
+        assertTrue( LdapDN.isValid( "SN=Lu\\C4\\8Di\\C4\\87" ) );
+        assertEquals( "sn=Lu\\C4\\8Di\\C4\\87", dn.toString() );
+        assertEquals( "SN=Lu\\C4\\8Di\\C4\\87", dn.getUpName() );
+    }
 
-       assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
-       assertEquals( 3, dn.size() );
-   }
 
+    /**
+     * test a simple DN with hexString attribute value : a = #0010A0AAFF
+     */
+    @Test
+    public void testLdapDNHexStringAttributeValue() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = #0010A0AAFF" );
 
-   /**
-    * test a 3 size with NameComponents
-    */
-   @Test public void testLdapDNSize3NC() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b+c=d, c=d, e=f" );
+        assertTrue( LdapDN.isValid( "a = #0010A0AAFF" ) );
+        assertEquals( "a=#0010A0AAFF", dn.toString() );
+        assertEquals( "a = #0010A0AAFF", dn.getUpName() );
+    }
 
-       assertTrue( LdapDN.isValid( "a=b+c=d, c=d, e=f" ) );
-       assertEquals( 3, dn.size() );
-   }
 
+    /**
+     * test a simple DN with a # on first position
+     */
+    @Test
+    public void testLdapDNSharpFirst() throws InvalidNameException, NamingException
+    {
+        LdapDN dn = new LdapDN( "a = \\#this is a sharp" );
 
-   /**
-    * test size after operations
-    */
-   @Test public void testLdapResizing() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN();
-       assertEquals( 0, dn.size() );
+        assertTrue( LdapDN.isValid( "a = \\#this is a sharp" ) );
+        assertEquals( "a=\\#this is a sharp", dn.toString() );
+        assertEquals( "a = \\#this is a sharp", dn.getUpName() );
 
-       dn.add( "e = f" );
-       assertEquals( 1, dn.size() );
+        Rdn rdn = dn.getRdn();
+        assertEquals( "a = \\#this is a sharp", rdn.getUpName() );
+    }
 
-       dn.add( "c = d" );
-       assertEquals( 2, dn.size() );
 
-       dn.remove( 0 );
-       assertEquals( 1, dn.size() );
+    /**
+     * Normalize a simple DN with a # on first position
+     */
+    @Test
+    public void testNormalizeLdapDNSharpFirst() throws InvalidNameException, NamingException
+    {
+        LdapDN dn = new LdapDN( "ou = \\#this is a sharp" );
 
-       dn.remove( 0 );
-       assertEquals( 0, dn.size() );
-   }
+        assertTrue( LdapDN.isValid( "ou = \\#this is a sharp" ) );
+        assertEquals( "ou=\\#this is a sharp", dn.toString() );
+        assertEquals( "ou = \\#this is a sharp", dn.getUpName() );
 
+        // Check the normalization now
+        LdapDN ndn = dn.normalize( oidOids );
 
-   // ADD Operations
-   /**
-    * test Add on a new LdapDN
-    */
-   @Test public void testLdapEmptyAdd() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN();
-
-       dn.add( "e = f" );
-       assertEquals( "e=f", dn.toString() );
-       assertEquals( "e = f", dn.getUpName() );
-       assertEquals( 1, dn.size() );
-   }
+        assertEquals( "ou = \\#this is a sharp", ndn.getUpName() );
+        assertEquals( "2.5.4.11=\\#this is a sharp", ndn.toString() );
+    }
 
 
-   /**
-    * test Add to an existing LdapDN
-    */
-   @Test public void testLdapDNAdd() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d" );
-
-       dn.add( "e = f" );
-       assertEquals( "e=f,a=b,c=d", dn.toString() );
-       assertEquals( "e = f,a=b, c=d", dn.getUpName() );
-       assertEquals( 3, dn.size() );
-   }
+    /**
+     * test a simple DN with a wrong hexString attribute value : a = #0010Z0AAFF
+     */
+    @Test
+    public void testLdapDNWrongHexStringAttributeValue()
+    {
+        try
+        {
+            new LdapDN( "a = #0010Z0AAFF" );
+            fail();
+        }
+        catch ( InvalidNameException ine )
+        {
 
+            assertFalse( LdapDN.isValid( "a = #0010Z0AAFF" ) );
+            assertTrue( true );
+        }
+    }
 
-   /**
-    * test Add a composite RDN to an existing LdapDN
-    */
-   @Test public void testLdapDNAddComposite() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d" );
-
-       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
-       // String used to do the comparizon should be inverted.
-       assertEquals( "e=f+g=h,a=b,c=d", dn.toString() );
-       assertEquals( 3, dn.size() );
-   }
 
+    /**
+     * test a simple DN with a wrong hexString attribute value : a = #AABBCCDD3
+     */
+    @Test
+    public void testLdapDNWrongHexStringAttributeValue2()
+    {
+        try
+        {
+            new LdapDN( "a = #AABBCCDD3" );
+            fail();
+        }
+        catch ( InvalidNameException ine )
+        {
+            assertFalse( LdapDN.isValid( "a = #AABBCCDD3" ) );
+            assertTrue( true );
+        }
+    }
 
-   /**
-    * test Add at the end of an existing LdapDN
-    */
-   @Test public void testLdapDNAddEnd() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d" );
-
-       dn.add( dn.size(), "e = f" );
-       assertEquals( "e = f,a=b, c=d", dn.getUpName() );
-       assertEquals( 3, dn.size() );
-   }
 
+    /**
+     * test a simple DN with a quote in attribute value : a = quoted \"value\"
+     */
+    @Test
+    public void testLdapDNQuoteInAttributeValue() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = quoted \\\"value\\\"" );
 
-   /**
-    * test Add at the start of an existing LdapDN
-    */
-   @Test public void testLdapDNAddStart() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d" );
-
-       dn.add( 0, "e = f" );
-       assertEquals( "a=b, c=d,e = f", dn.getUpName() );
-       assertEquals( 3, dn.size() );
-   }
+        assertTrue( LdapDN.isValid( "a = quoted \\\"value\\\"" ) );
+        assertEquals( "a=quoted \\\"value\\\"", dn.toString() );
+        assertEquals( "a = quoted \\\"value\\\"", dn.getUpName() );
+    }
 
 
-   /**
-    * test Add at the middle of an existing LdapDN
-    */
-   @Test public void testLdapDNAddMiddle() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d" );
-
-       dn.add( 1, "e = f" );
-       assertEquals( "a=b,e = f, c=d", dn.getUpName() );
-       assertEquals( 3, dn.size() );
-   }
+    /**
+     * test a simple DN with quoted attribute value : a = \" quoted value \"
+     */
+    @Test
+    public void testLdapDNQuotedAttributeValue() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = \\\" quoted value \\\"" );
 
+        assertTrue( LdapDN.isValid( "a = \\\" quoted value \\\"" ) );
+        assertEquals( "a=\\\" quoted value \\\"", dn.toString() );
+        assertEquals( "a = \\\" quoted value \\\"", dn.getUpName() );
+    }
 
-   // ADD ALL Operations
-   /**
-    * Test AddAll
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAddAll() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b" );
-       LdapDN dn2 = new LdapDN( "c = d" );
-       dn.addAll( dn2 );
-       assertEquals( "c = d,a = b", dn.getUpName() );
-   }
 
+    /**
+     * test a simple DN with a comma at the end
+     */
+    @Test
+    public void testLdapDNComaAtEnd()
+    {
+        assertFalse( LdapDN.isValid( "a = b," ) );
+        assertFalse( LdapDN.isValid( "a = b, " ) );
 
-   /**
-    * Test AddAll with an empty added name
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAddAllAddedNameEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b" );
-       LdapDN dn2 = new LdapDN();
-       dn.addAll( dn2 );
-       assertEquals( "a=b", dn.toString() );
-       assertEquals( "a = b", dn.getUpName() );
-   }
+        try
+        {
+            new LdapDN( "a = b," );
+            fail();
+        }
+        catch ( InvalidNameException ine )
+        {
+            assertTrue( true );
+        }
+    }
 
 
-   /**
-    * Test AddAll to an empty name
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAddAllNameEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN();
-       LdapDN dn2 = new LdapDN( "a = b" );
-       dn.addAll( dn2 );
-       assertEquals( "a = b", dn.getUpName() );
-   }
+    // REMOVE operation -------------------------------------------------------
 
+    /**
+     * test a remove from position 0
+     */
+    @Test
+    public void testLdapDNRemove0() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
-   /**
-    * Test AddAll at position 0
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAt0AddAll() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b" );
-       LdapDN dn2 = new LdapDN( "c = d" );
-       dn.addAll( 0, dn2 );
-       assertEquals( "a = b,c = d", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
+        assertEquals( "e=f", dn.remove( 0 ).toString() );
+        assertEquals( "a=b,c=d", dn.toString() );
+        assertEquals( "a=b, c=d", dn.getUpName() );
+    }
 
 
-   /**
-    * Test AddAll at position 1
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAt1AddAll() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b" );
-       LdapDN dn2 = new LdapDN( "c = d" );
-       dn.addAll( 1, dn2 );
-       assertEquals( "c = d,a = b", dn.getUpName() );
-   }
+    /**
+     * test a remove from position 1
+     */
+    @Test
+    public void testLdapDNRemove1() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
+        assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
+        assertEquals( "c=d", dn.remove( 1 ).toString() );
+        assertEquals( "a=b, e=f", dn.getUpName() );
+    }
 
-   /**
-    * Test AddAll at the middle
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAtTheMiddleAddAll() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b, c = d" );
-       LdapDN dn2 = new LdapDN( "e = f" );
-       dn.addAll( 1, dn2 );
-       assertEquals( "a = b,e = f, c = d", dn.getUpName() );
-   }
 
+    /**
+     * test a remove from position 2
+     */
+    @Test
+    public void testLdapDNRemove2() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
-   /**
-    * Test AddAll with an empty added name at position 0
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAddAllAt0AddedNameEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a = b" );
-       LdapDN dn2 = new LdapDN();
-       dn.addAll( 0, dn2 );
-       assertEquals( "a=b", dn.toString() );
-       assertEquals( "a = b", dn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
+        assertEquals( "a=b", dn.remove( 2 ).toString() );
+        assertEquals( " c=d, e=f", dn.getUpName() );
+    }
 
 
-   /**
-    * Test AddAll to an empty name at position 0
-    *
-    * @throws InvalidNameException
-    */
-   @Test public void testLdapDNAddAllAt0NameEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN();
-       LdapDN dn2 = new LdapDN( "a = b" );
-       dn.addAll( 0, dn2 );
-       assertEquals( "a = b", dn.getUpName() );
-   }
+    /**
+     * test a remove from position 1 whith semi colon
+     */
+    @Test
+    public void testLdapDNRemove1WithSemiColon() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d; e=f" );
 
+        assertTrue( LdapDN.isValid( "a=b, c=d; e=f" ) );
+        assertEquals( "c=d", dn.remove( 1 ).toString() );
+        assertEquals( "a=b, e=f", dn.getUpName() );
+    }
 
-   // GET PREFIX actions
-   /**
-    * Get the prefix at pos 0
-    */
-   @Test public void testLdapDNGetPrefixPos0() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 0 ) );
-       assertEquals( "", newDn.getUpName() );
-   }
 
+    /**
+     * test a remove out of bound
+     */
+    @Test
+    public void testLdapDNRemoveOutOfBound() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d; e=f" );
 
-   /**
-    * Get the prefix at pos 1
-    */
-   @Test public void testLdapDNGetPrefixPos1() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 1 ) );
-       assertEquals( "e = f", newDn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a=b, c=d; e=f" ) );
 
+        try
+        {
+            dn.remove( 4 );
+            // We whould never reach this point
+            fail();
+        }
+        catch ( ArrayIndexOutOfBoundsException aoobe )
+        {
+            assertTrue( true );
+        }
+    }
 
-   /**
-    * Get the prefix at pos 2
-    */
-   @Test public void testLdapDNGetPrefixPos2() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 2 ) );
-       assertEquals( " c=d,e = f", newDn.getUpName() );
-   }
 
+    // SIZE operations
+    /**
+     * test a 0 size
+     */
+    @Test
+    public void testLdapDNSize0()
+    {
+        LdapDN dn = new LdapDN();
 
-   /**
-    * Get the prefix at pos 3
-    */
-   @Test public void testLdapDNGetPrefixPos3() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 3 ) );
-       assertEquals( "a=b, c=d,e = f", newDn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "" ) );
+        assertEquals( 0, dn.size() );
+    }
 
 
-   /**
-    * Get the prefix out of bound
-    */
-   @Test public void testLdapDNGetPrefixPos4() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-
-       try
-       {
-           dn.getPrefix( 4 );
-           // We should not reach this point.
-           fail();
-       }
-       catch ( ArrayIndexOutOfBoundsException aoobe )
-       {
-           assertTrue( true );
-       }
-   }
+    /**
+     * test a 1 size
+     */
+    @Test
+    public void testLdapDNSize1() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b" );
 
+        assertTrue( LdapDN.isValid( "a=b" ) );
+        assertEquals( 1, dn.size() );
+    }
 
-   /**
-    * Get the prefix of an empty LdapName
-    */
-   @Test public void testLdapDNGetPrefixEmptyDN()
-   {
-       LdapDN dn = new LdapDN();
-       LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 0 ) );
-       assertEquals( "", newDn.getUpName() );
-   }
 
+    /**
+     * test a 3 size
+     */
+    @Test
+    public void testLdapDNSize3() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
-   // GET SUFFIX operations
-   /**
-    * Get the suffix at pos 0
-    */
-   @Test public void testLdapDNGetSuffixPos0() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 0 ) );
-       assertEquals( "a=b, c=d,e = f", newDn.getUpName() );
-   }
+        assertTrue( LdapDN.isValid( "a=b, c=d, e=f" ) );
+        assertEquals( 3, dn.size() );
+    }
 
 
-   /**
-    * Get the suffix at pos 1
-    */
-   @Test public void testLdapDNGetSuffixPos1() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 1 ) );
-       assertEquals( "a=b, c=d", newDn.getUpName() );
-   }
+    /**
+     * test a 3 size with NameComponents
+     */
+    @Test
+    public void testLdapDNSize3NC() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b+c=d, c=d, e=f" );
 
+        assertTrue( LdapDN.isValid( "a=b+c=d, c=d, e=f" ) );
+        assertEquals( 3, dn.size() );
+    }
 
-   /**
-    * Get the suffix at pos 2
-    */
-   @Test public void testLdapDNGetSuffixPos2() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 2 ) );
-       assertEquals( "a=b", newDn.getUpName() );
-   }
 
+    /**
+     * test size after operations
+     */
+    @Test
+    public void testLdapResizing() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN();
+        assertEquals( 0, dn.size() );
 
-   /**
-    * Get the suffix at pos 3
-    */
-   @Test public void testLdapDNGetSuffixPos3() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 3 ) );
-       assertEquals( "", newDn.getUpName() );
-   }
+        dn.add( "e = f" );
+        assertEquals( 1, dn.size() );
 
+        dn.add( "c = d" );
+        assertEquals( 2, dn.size() );
 
-   /**
-    * Get the suffix out of bound
-    */
-   @Test public void testLdapDNGetSuffixPos4() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-
-       try
-       {
-           dn.getSuffix( 4 );
-           // We should not reach this point.
-           fail();
-       }
-       catch ( ArrayIndexOutOfBoundsException aoobe )
-       {
-           assertTrue( true );
-       }
-   }
+        dn.remove( 0 );
+        assertEquals( 1, dn.size() );
 
+        dn.remove( 0 );
+        assertEquals( 0, dn.size() );
+    }
 
-   /**
-    * Get the suffix of an empty LdapName
-    */
-   @Test public void testLdapDNGetSuffixEmptyDN()
-   {
-       LdapDN dn = new LdapDN();
-       LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 0 ) );
-       assertEquals( "", newDn.getUpName() );
-   }
 
+    // ADD Operations
+    /**
+     * test Add on a new LdapDN
+     */
+    @Test
+    public void testLdapEmptyAdd() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN();
 
-   // IS EMPTY operations
-   /**
-    * Test that a LdapDN is empty
-    */
-   @Test public void testLdapDNIsEmpty()
-   {
-       LdapDN dn = new LdapDN();
-       assertEquals( true, dn.isEmpty() );
-   }
+        dn.add( "e = f" );
+        assertEquals( "e=f", dn.toString() );
+        assertEquals( "e = f", dn.getUpName() );
+        assertEquals( 1, dn.size() );
+    }
 
 
-   /**
-    * Test that a LdapDN is empty
-    */
-   @Test public void testLdapDNNotEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b" );
-       assertEquals( false, dn.isEmpty() );
-   }
+    /**
+     * test Add to an existing LdapDN
+     */
+    @Test
+    public void testLdapDNAdd() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d" );
 
+        dn.add( "e = f" );
+        assertEquals( "e=f,a=b,c=d", dn.toString() );
+        assertEquals( "e = f,a=b, c=d", dn.getUpName() );
+        assertEquals( 3, dn.size() );
+    }
 
-   /**
-    * Test that a LdapDN is empty
-    */
-   @Test public void testLdapDNRemoveIsEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d" );
-       dn.remove( 0 );
-       dn.remove( 0 );
-
-       assertEquals( true, dn.isEmpty() );
-   }
 
+    /**
+     * test Add a composite RDN to an existing LdapDN
+     */
+    @Test
+    public void testLdapDNAddComposite() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d" );
 
-   // STARTS WITH operations
-   /**
-    * Test a startsWith a null LdapDN
-    */
-   @Test public void testLdapDNStartsWithNull() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.startsWith( null ) );
-   }
+        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
+        // String used to do the comparizon should be inverted.
+        assertEquals( "e=f+g=h,a=b,c=d", dn.toString() );
+        assertEquals( 3, dn.size() );
+    }
 
-   /**
-    * Test a startsWith an empty LdapDN
-    */
-   @Test public void testLdapDNStartsWithEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.startsWith( new LdapDN() ) );
-   }
 
+    /**
+     * test Add at the end of an existing LdapDN
+     */
+    @Test
+    public void testLdapDNAddEnd() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d" );
 
-   /**
-    * Test a startsWith an simple LdapDN
-    */
-   @Test public void testLdapDNStartsWithSimple() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.startsWith( new LdapDN( "e=f" ) ) );
-   }
+        dn.add( dn.size(), "e = f" );
+        assertEquals( "e = f,a=b, c=d", dn.getUpName() );
+        assertEquals( 3, dn.size() );
+    }
 
 
-   /**
-    * Test a startsWith a complex LdapDN
-    */
-   @Test public void testLdapDNStartsWithComplex() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.startsWith( new LdapDN( "c =  d, e =  f" ) ) );
-   }
+    /**
+     * test Add at the start of an existing LdapDN
+     */
+    @Test
+    public void testLdapDNAddStart() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d" );
 
+        dn.add( 0, "e = f" );
+        assertEquals( "a=b, c=d,e = f", dn.getUpName() );
+        assertEquals( 3, dn.size() );
+    }
 
-   /**
-    * Test a startsWith a complex LdapDN
-    */
-   @Test public void testLdapDNStartsWithComplexMixedCase() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( false, dn.startsWith( new LdapDN( "c =  D, E =  f" ) ) );
-   }
 
+    /**
+     * test Add at the middle of an existing LdapDN
+     */
+    @Test
+    public void testLdapDNAddMiddle() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d" );
 
-   /**
-    * Test a startsWith a full LdapDN
-    */
-   @Test public void testLdapDNStartsWithFull() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.startsWith( new LdapDN( "a=  b; c =  d, e =  f" ) ) );
-   }
+        dn.add( 1, "e = f" );
+        assertEquals( "a=b,e = f, c=d", dn.getUpName() );
+        assertEquals( 3, dn.size() );
+    }
 
 
-   /**
-    * Test a startsWith which returns false
-    */
-   @Test public void testLdapDNStartsWithWrong() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( false, dn.startsWith( new LdapDN( "c =  t, e =  f" ) ) );
-   }
+    // ADD ALL Operations
+    /**
+     * Test AddAll
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAddAll() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
+        LdapDN dn2 = new LdapDN( "c = d" );
+        dn.addAll( dn2 );
+        assertEquals( "c = d,a = b", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll with an empty added name
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAddAllAddedNameEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
+        LdapDN dn2 = new LdapDN();
+        dn.addAll( dn2 );
+        assertEquals( "a=b", dn.toString() );
+        assertEquals( "a = b", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll to an empty name
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAddAllNameEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN();
+        LdapDN dn2 = new LdapDN( "a = b" );
+        dn.addAll( dn2 );
+        assertEquals( "a = b", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll at position 0
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAt0AddAll() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
+        LdapDN dn2 = new LdapDN( "c = d" );
+        dn.addAll( 0, dn2 );
+        assertEquals( "a = b,c = d", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll at position 1
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAt1AddAll() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
+        LdapDN dn2 = new LdapDN( "c = d" );
+        dn.addAll( 1, dn2 );
+        assertEquals( "c = d,a = b", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll at the middle
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAtTheMiddleAddAll() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b, c = d" );
+        LdapDN dn2 = new LdapDN( "e = f" );
+        dn.addAll( 1, dn2 );
+        assertEquals( "a = b,e = f, c = d", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll with an empty added name at position 0
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAddAllAt0AddedNameEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
+        LdapDN dn2 = new LdapDN();
+        dn.addAll( 0, dn2 );
+        assertEquals( "a=b", dn.toString() );
+        assertEquals( "a = b", dn.getUpName() );
+    }
+
+
+    /**
+     * Test AddAll to an empty name at position 0
+     *
+     * @throws InvalidNameException
+     */
+    @Test
+    public void testLdapDNAddAllAt0NameEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN();
+        LdapDN dn2 = new LdapDN( "a = b" );
+        dn.addAll( 0, dn2 );
+        assertEquals( "a = b", dn.getUpName() );
+    }
+
+
+    // GET PREFIX actions
+    /**
+     * Get the prefix at pos 0
+     */
+    @Test
+    public void testLdapDNGetPrefixPos0() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 0 ) );
+        assertEquals( "", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the prefix at pos 1
+     */
+    @Test
+    public void testLdapDNGetPrefixPos1() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 1 ) );
+        assertEquals( "e = f", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the prefix at pos 2
+     */
+    @Test
+    public void testLdapDNGetPrefixPos2() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 2 ) );
+        assertEquals( " c=d,e = f", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the prefix at pos 3
+     */
+    @Test
+    public void testLdapDNGetPrefixPos3() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 3 ) );
+        assertEquals( "a=b, c=d,e = f", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the prefix out of bound
+     */
+    @Test
+    public void testLdapDNGetPrefixPos4() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+
+        try
+        {
+            dn.getPrefix( 4 );
+            // We should not reach this point.
+            fail();
+        }
+        catch ( ArrayIndexOutOfBoundsException aoobe )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Get the prefix of an empty LdapName
+     */
+    @Test
+    public void testLdapDNGetPrefixEmptyDN()
+    {
+        LdapDN dn = new LdapDN();
+        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 0 ) );
+        assertEquals( "", newDn.getUpName() );
+    }
+
+
+    // GET SUFFIX operations
+    /**
+     * Get the suffix at pos 0
+     */
+    @Test
+    public void testLdapDNGetSuffixPos0() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 0 ) );
+        assertEquals( "a=b, c=d,e = f", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the suffix at pos 1
+     */
+    @Test
+    public void testLdapDNGetSuffixPos1() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 1 ) );
+        assertEquals( "a=b, c=d", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the suffix at pos 2
+     */
+    @Test
+    public void testLdapDNGetSuffixPos2() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 2 ) );
+        assertEquals( "a=b", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the suffix at pos 3
+     */
+    @Test
+    public void testLdapDNGetSuffixPos3() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 3 ) );
+        assertEquals( "", newDn.getUpName() );
+    }
+
+
+    /**
+     * Get the suffix out of bound
+     */
+    @Test
+    public void testLdapDNGetSuffixPos4() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+
+        try
+        {
+            dn.getSuffix( 4 );
+            // We should not reach this point.
+            fail();
+        }
+        catch ( ArrayIndexOutOfBoundsException aoobe )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Get the suffix of an empty LdapName
+     */
+    @Test
+    public void testLdapDNGetSuffixEmptyDN()
+    {
+        LdapDN dn = new LdapDN();
+        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 0 ) );
+        assertEquals( "", newDn.getUpName() );
+    }
+
+
+    // IS EMPTY operations
+    /**
+     * Test that a LdapDN is empty
+     */
+    @Test
+    public void testLdapDNIsEmpty()
+    {
+        LdapDN dn = new LdapDN();
+        assertEquals( true, dn.isEmpty() );
+    }
+
+
+    /**
+     * Test that a LdapDN is empty
+     */
+    @Test
+    public void testLdapDNNotEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b" );
+        assertEquals( false, dn.isEmpty() );
+    }
+
+
+    /**
+     * Test that a LdapDN is empty
+     */
+    @Test
+    public void testLdapDNRemoveIsEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d" );
+        dn.remove( 0 );
+        dn.remove( 0 );
+
+        assertEquals( true, dn.isEmpty() );
+    }
+
+
+    // STARTS WITH operations
+    /**
+     * Test a startsWith a null LdapDN
+     */
+    @Test
+    public void testLdapDNStartsWithNull() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.startsWith( null ) );
+    }
+
+
+    /**
+     * Test a startsWith an empty LdapDN
+     */
+    @Test
+    public void testLdapDNStartsWithEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.startsWith( new LdapDN() ) );
+    }
+
+
+    /**
+     * Test a startsWith an simple LdapDN
+     */
+    @Test
+    public void testLdapDNStartsWithSimple() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.startsWith( new LdapDN( "e=f" ) ) );
+    }
+
+
+    /**
+     * Test a startsWith a complex LdapDN
+     */
+    @Test
+    public void testLdapDNStartsWithComplex() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.startsWith( new LdapDN( "c =  d, e =  f" ) ) );
+    }
+
+
+    /**
+     * Test a startsWith a complex LdapDN
+     */
+    @Test
+    public void testLdapDNStartsWithComplexMixedCase() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( false, dn.startsWith( new LdapDN( "c =  D, E =  f" ) ) );
+    }
+
+
+    /**
+     * Test a startsWith a full LdapDN
+     */
+    @Test
+    public void testLdapDNStartsWithFull() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.startsWith( new LdapDN( "a=  b; c =  d, e =  f" ) ) );
+    }
+
+
+    /**
+     * Test a startsWith which returns false
+     */
+    @Test
+    public void testLdapDNStartsWithWrong() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( false, dn.startsWith( new LdapDN( "c =  t, e =  f" ) ) );
+    }
+
+
+    // ENDS WITH operations
+    /**
+     * Test a endsWith a null LdapDN
+     */
+    @Test
+    public void testLdapDNEndsWithNull() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.endsWith( null ) );
+    }
+
+
+    /**
+     * Test a endsWith an empty LdapDN
+     */
+    @Test
+    public void testLdapDNEndsWithEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.endsWith( new LdapDN() ) );
+    }
+
+
+    /**
+     * Test a endsWith an simple LdapDN
+     */
+    @Test
+    public void testLdapDNEndsWithSimple() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.endsWith( new LdapDN( "a=b" ) ) );
+    }
+
+
+    /**
+     * Test a endsWith a complex LdapDN
+     */
+    @Test
+    public void testLdapDNEndsWithComplex() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.endsWith( new LdapDN( "a =  b, c =  d" ) ) );
+    }
+
+
+    /**
+     * Test a endsWith a complex LdapDN
+     */
+    @Test
+    public void testLdapDNEndsWithComplexMixedCase() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( false, dn.endsWith( new LdapDN( "a =  B, C =  d" ) ) );
+    }
+
+
+    /**
+     * Test a endsWith a full LdapDN
+     */
+    @Test
+    public void testLdapDNEndsWithFull() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( true, dn.endsWith( new LdapDN( "a=  b; c =  d, e =  f" ) ) );
+    }
+
+
+    /**
+     * Test a endsWith which returns false
+     */
+    @Test
+    public void testLdapDNEndsWithWrong() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
+        assertEquals( false, dn.endsWith( new LdapDN( "a =  b, e =  f" ) ) );
+    }
+
+
+    // GET ALL operations
+    /**
+     * test a getAll operation on a null DN
+     */
+    @Test
+    public void testLdapDNGetAllNull()
+    {
+        LdapDN dn = new LdapDN();
+        Enumeration<String> nc = dn.getAll();
+
+        assertEquals( false, nc.hasMoreElements() );
+    }
+
+
+    /**
+     * test a getAll operation on an empty DN
+     */
+    @Test
+    public void testLdapDNGetAllEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "" );
+        Enumeration<String> nc = dn.getAll();
+
+        assertEquals( false, nc.hasMoreElements() );
+    }
+
+
+    /**
+     * test a getAll operation on a simple DN
+     */
+    @Test
+    public void testLdapDNGetAllSimple() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b" );
+        Enumeration<String> nc = dn.getAll();
+
+        assertEquals( true, nc.hasMoreElements() );
+        assertEquals( "a=b", nc.nextElement() );
+        assertEquals( false, nc.hasMoreElements() );
+    }
+
+
+    /**
+     * test a getAll operation on a complex DN
+     */
+    @Test
+    public void testLdapDNGetAllComplex() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "e=f+g=h,a=b,c=d" );
+        Enumeration<String> nc = dn.getAll();
+
+        assertEquals( true, nc.hasMoreElements() );
+        assertEquals( "c=d", nc.nextElement() );
+        assertEquals( true, nc.hasMoreElements() );
+        assertEquals( "a=b", nc.nextElement() );
+        assertEquals( true, nc.hasMoreElements() );
+        assertEquals( "e=f+g=h", nc.nextElement() );
+        assertEquals( false, nc.hasMoreElements() );
+    }
+
+
+    /**
+     * test a getAll operation on a complex DN
+     */
+    @Test
+    public void testLdapDNGetAllComplexOrdered() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "g=h+e=f,a=b,c=d" );
+        Enumeration<String> nc = dn.getAll();
+
+        assertEquals( true, nc.hasMoreElements() );
+        assertEquals( "c=d", nc.nextElement() );
+        assertEquals( true, nc.hasMoreElements() );
+        assertEquals( "a=b", nc.nextElement() );
+        assertEquals( true, nc.hasMoreElements() );
+
+        // The lowest atav should be the first one
+        assertEquals( "e=f+g=h", nc.nextElement() );
+        assertEquals( false, nc.hasMoreElements() );
+    }
+
+
+    // CLONE Operation
+    /**
+     * test a clone operation on a empty DN
+     */
+    @Test
+    public void testLdapDNCloneEmpty()
+    {
+        LdapDN dn = new LdapDN();
+        LdapDN clone = ( LdapDN ) dn.clone();
+
+        assertEquals( "", clone.getUpName() );
+    }
+
+
+    /**
+     * test a clone operation on a simple DN
+     */
+    @Test
+    public void testLdapDNCloneSimple() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a=b" );
+        LdapDN clone = ( LdapDN ) dn.clone();
+
+        assertEquals( "a=b", clone.getUpName() );
+        dn.remove( 0 );
+        assertEquals( "a=b", clone.getUpName() );
+    }
+
+
+    /**
+     * test a clone operation on a complex DN
+     */
+    @Test
+    public void testLdapDNCloneComplex() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "e=f+g=h,a=b,c=d" );
+        LdapDN clone = ( LdapDN ) dn.clone();
+
+        assertEquals( "e=f+g=h,a=b,c=d", clone.getUpName() );
+        dn.remove( 2 );
+        assertEquals( "e=f+g=h,a=b,c=d", clone.getUpName() );
+    }
+
+
+    // GET operations
+    /**
+     * test a get in a null DN
+     */
+    @Test
+    public void testLdapDNGetNull()
+    {
+        LdapDN dn = new LdapDN();
+        assertEquals( "", dn.get( 0 ) );
+    }
+
+
+    /**
+     * test a get in an empty DN
+     */
+    @Test
+    public void testLdapDNGetEmpty() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "" );
+        assertEquals( "", dn.get( 0 ) );
+    }
+
+
+    /**
+     * test a get in a simple DN
+     */
+    @Test
+    public void testLdapDNGetSimple() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b" );
+        assertEquals( "a=b", dn.get( 0 ) );
+    }
+
+
+    /**
+     * test a get in a complex DN
+     */
+    @Test
+    public void testLdapDNGetComplex() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b + c= d, e= f; g =h" );
+        assertEquals( "g=h", dn.get( 0 ) );
+        assertEquals( "e=f", dn.get( 1 ) );
+        assertEquals( "a=b+c=d", dn.get( 2 ) );
+    }
+
+
+    /**
+     * test a get out of bound
+     */
+    @Test
+    public void testLdapDNGetOutOfBound() throws InvalidNameException
+    {
+        LdapDN dn = new LdapDN( "a = b + c= d, e= f; g =h" );
+
+        try
+        {
+            dn.get( 4 );
+            fail();
+        }
+        catch ( IndexOutOfBoundsException aioob )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Tests the examples from the JNDI tutorials to make sure LdapName behaves
+     * appropriately. The example can be found online <a href="">here</a>.
+     *
+     * @throws Exception
+     *             if anything goes wrong
+     */
+    @Test
+    public void testJNDITutorialExample() throws Exception
+    {
+        // Parse the name
+        Name name = new LdapDN( "cn=John,ou=People,ou=Marketing" );
+
+        // Remove the second component from the head: ou=People
+        String out = name.remove( 1 ).toString();
+
+        assertEquals( "ou=People", out );
+
+        // Add to the head (first): cn=John,ou=Marketing,ou=East
+        out = name.add( 0, "ou=East" ).toString();
+
+        assertEquals( "cn=John,ou=Marketing,ou=East", out );
+
+        // Add to the tail (last): cn=HomeDir,cn=John,ou=Marketing,ou=East
+        out = name.add( "cn=HomeDir" ).toString();
+
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", out );
+    }
+
+
+    @Test
+    public void testAttributeEqualsIsCaseInSensitive() throws Exception
+    {
+        Name name1 = new LdapDN( "cn=HomeDir" );
+        Name name2 = new LdapDN( "CN=HomeDir" );
+
+        assertTrue( name1.equals( name2 ) );
+    }
+
+
+    @Test
+    public void testAttributeTypeEqualsIsCaseInsensitive() throws Exception
+    {
+        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
+        Name name2 = new LdapDN( "cn=HomeDir+CN=WorkDir" );
+
+        assertTrue( name1.equals( name2 ) );
+    }
+
+
+    @Test
+    public void testNameEqualsIsInsensitiveToAttributesOrder() throws Exception
+    {
+
+        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
+        Name name2 = new LdapDN( "cn=WorkDir+cn=HomeDir" );
+
+        assertTrue( name1.equals( name2 ) );
+    }
+
+
+    @Test
+    public void testAttributeComparisonIsCaseInSensitive() throws Exception
+    {
+        Name name1 = new LdapDN( "cn=HomeDir" );
+        Name name2 = new LdapDN( "CN=HomeDir" );
+
+        assertEquals( 0, name1.compareTo( name2 ) );
+    }
+
+
+    @Test
+    public void testAttributeTypeComparisonIsCaseInsensitive() throws Exception
+    {
+        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
+        Name name2 = new LdapDN( "cn=HomeDir+CN=WorkDir" );
+
+        assertEquals( 0, name1.compareTo( name2 ) );
+    }
+
+
+    @Test
+    public void testNameComparisonIsInsensitiveToAttributesOrder() throws Exception
+    {
+
+        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
+        Name name2 = new LdapDN( "cn=WorkDir+cn=HomeDir" );
+
+        assertEquals( 0, name1.compareTo( name2 ) );
+    }
+
+
+    @Test
+    public void testNameComparisonIsInsensitiveToAttributesOrderFailure() throws Exception
+    {
+
+        Name name1 = new LdapDN( "cn= HomeDir+cn=Workdir" );
+        Name name2 = new LdapDN( "cn = Work+cn=HomeDir" );
+
+        assertEquals( 1, name1.compareTo( name2 ) );
+    }
+
+
+    /**
+     * Test the encoding of a LdanDN
+     */
+    @Test
+    public void testNameToBytes() throws Exception
+    {
+        LdapDN dn = new LdapDN( "cn = John, ou = People, OU = Marketing" );
+
+        byte[] bytes = LdapDN.getBytes( dn );
+
+        assertEquals( 30, LdapDN.getNbBytes( dn ) );
+        assertEquals( "cn=John,ou=People,ou=Marketing", new String( bytes, "UTF-8" ) );
+    }
+
+
+    @Test
+    public void testStringParser() throws Exception
+    {
+
+        String dn = StringTools.utf8ToString( new byte[]
+            { 'C', 'N', ' ', '=', ' ', 'E', 'm', 'm', 'a', 'n', 'u', 'e', 'l', ' ', ' ', 'L', ( byte ) 0xc3,
+                ( byte ) 0xa9, 'c', 'h', 'a', 'r', 'n', 'y' } );
+
+        Name name = LdapDnParser.getNameParser().parse( dn );
+
+        assertEquals( dn, ( ( LdapDN ) name ).getUpName() );
+        assertEquals( "cn=Emmanuel  L\\C3\\A9charny", name.toString() );
+    }
+
+
+    /**
+     * Class to test for void LdapName(String)
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testLdapNameString() throws Exception
+    {
+        Name name = new LdapDN( "" );
+        Name name50 = new LdapDN();
+        assertEquals( name50, name );
+
+        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
+        Name copy = new LdapDN( "ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name2 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+        Name name4 = new LdapDN( "cn=Website,cn=John,ou=Marketing,ou=West" );
+        Name name5 = new LdapDN( "cn=Airline,cn=John,ou=Marketing,ou=West" );
+
+        assertTrue( name0.compareTo( copy ) == 0 );
+        assertTrue( name0.compareTo( name1 ) < 0 );
+        assertTrue( name0.compareTo( name2 ) < 0 );
+        assertTrue( name1.compareTo( name2 ) < 0 );
+        assertTrue( name2.compareTo( name1 ) > 0 );
+        assertTrue( name2.compareTo( name0 ) > 0 );
+        assertTrue( name2.compareTo( name3 ) < 0 );
+        assertTrue( name2.compareTo( name4 ) < 0 );
+        assertTrue( name3.compareTo( name4 ) < 0 );
+        assertTrue( name3.compareTo( name5 ) > 0 );
+        assertTrue( name4.compareTo( name5 ) > 0 );
+        assertTrue( name2.compareTo( name5 ) < 0 );
+    }
+
+
+    /**
+     * Class to test for void LdapName()
+     */
+    @Test
+    public void testLdapName()
+    {
+        Name name = new LdapDN();
+        assertTrue( name.toString().equals( "" ) );
+    }
+
+
+    /**
+     * Class to test for void LdapName(List)
+     */
+    @Test
+    public void testLdapNameList() throws InvalidNameException
+    {
+        List<String> list = new ArrayList<String>();
+        list.add( "ou=People" );
+        list.add( "dc=example" );
+        list.add( "dc=com" );
+        Name name = new LdapDN( list );
+        assertTrue( name.toString().equals( "ou=People,dc=example,dc=com" ) );
+    }
+
+
+    /**
+     * Class to test for void LdapName(Iterator)
+     */
+    @Test
+    public void testLdapNameIterator() throws InvalidNameException
+    {
+        List<String> list = new ArrayList<String>();
+        list.add( "ou=People" );
+        list.add( "dc=example" );
+        list.add( "dc=com" );
+        Name name = new LdapDN( list.iterator() );
+        assertTrue( name.toString().equals( "ou=People,dc=example,dc=com" ) );
+    }
+
+
+    /**
+     * Class to test for Object clone()
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testClone() throws Exception
+    {
+        String strName = "cn=HomeDir,cn=John,ou=Marketing,ou=East";
+        Name name = new LdapDN( strName );
+        assertEquals( name, name.clone() );
+    }
+
+
+    /**
+     * Class to test for compareTo
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testCompareTo() throws Exception
+    {
+        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
+        Name copy = new LdapDN( "ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name2 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+        Name name4 = new LdapDN( "cn=Website,cn=John,ou=Marketing,ou=West" );
+        Name name5 = new LdapDN( "cn=Airline,cn=John,ou=Marketing,ou=West" );
+
+        assertTrue( name0.compareTo( copy ) == 0 );
+        assertTrue( name0.compareTo( name1 ) < 0 );
+        assertTrue( name0.compareTo( name2 ) < 0 );
+        assertTrue( name1.compareTo( name2 ) < 0 );
+        assertTrue( name2.compareTo( name1 ) > 0 );
+        assertTrue( name2.compareTo( name0 ) > 0 );
+        assertTrue( name2.compareTo( name3 ) < 0 );
+        assertTrue( name2.compareTo( name4 ) < 0 );
+        assertTrue( name3.compareTo( name4 ) < 0 );
+        assertTrue( name3.compareTo( name5 ) > 0 );
+        assertTrue( name4.compareTo( name5 ) > 0 );
+        assertTrue( name2.compareTo( name5 ) < 0 );
+
+        List<Name> list = new ArrayList<Name>();
+
+        Comparator<Name> comparator = new Comparator<Name>()
+        {
+            public int compare( Name obj1, Name obj2 )
+            {
+                Name n1 = obj1;
+                Name n2 = obj2;
+                return n1.compareTo( n2 );
+            }
+
+
+            public boolean equals( Object obj )
+            {
+                return super.equals( obj );
+            }
 
 
-   // ENDS WITH operations
-   /**
-    * Test a endsWith a null LdapDN
-    */
-   @Test public void testLdapDNEndsWithNull() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.endsWith( null ) );
-   }
+            /**
+             * Compute the instance's hash code
+             * @return the instance's hash code 
+             */
+            public int hashCode()
+            {
+                return super.hashCode();
+            }
+        };
+
+        list.add( name0 );
+        list.add( name1 );
+        list.add( name2 );
+        list.add( name3 );
+        list.add( name4 );
+        list.add( name5 );
+        Collections.sort( list, comparator );
+
+        assertEquals( name0, list.get( 0 ) );
+        assertEquals( name1, list.get( 1 ) );
+        assertEquals( name2, list.get( 2 ) );
+        assertEquals( name5, list.get( 3 ) );
+        assertEquals( name3, list.get( 4 ) );
+        assertEquals( name4, list.get( 5 ) );
+    }
 
 
-   /**
-    * Test a endsWith an empty LdapDN
-    */
-   @Test public void testLdapDNEndsWithEmpty() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.endsWith( new LdapDN() ) );
-   }
+    /**
+     * Class to test for size
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testSize() throws Exception
+    {
+        Name name0 = new LdapDN( "" );
+        Name name1 = new LdapDN( "ou=East" );
+        Name name2 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name4 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name5 = new LdapDN( "cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+        Name name6 = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+
+        assertEquals( 0, name0.size() );
+        assertEquals( 1, name1.size() );
+        assertEquals( 2, name2.size() );
+        assertEquals( 3, name3.size() );
+        assertEquals( 4, name4.size() );
+        assertEquals( 5, name5.size() );
+        assertEquals( 6, name6.size() );
+    }
 
 
-   /**
-    * Test a endsWith an simple LdapDN
-    */
-   @Test public void testLdapDNEndsWithSimple() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.endsWith( new LdapDN( "a=b" ) ) );
-   }
+    /**
+     * Class to test for isEmpty
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testIsEmpty() throws Exception
+    {
+        Name name0 = new LdapDN( "" );
+        Name name1 = new LdapDN( "ou=East" );
+        Name name2 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name4 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name5 = new LdapDN( "cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+        Name name6 = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+
+        assertEquals( true, name0.isEmpty() );
+        assertEquals( false, name1.isEmpty() );
+        assertEquals( false, name2.isEmpty() );
+        assertEquals( false, name3.isEmpty() );
+        assertEquals( false, name4.isEmpty() );
+        assertEquals( false, name5.isEmpty() );
+        assertEquals( false, name6.isEmpty() );
+    }
 
 
-   /**
-    * Test a endsWith a complex LdapDN
-    */
-   @Test public void testLdapDNEndsWithComplex() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.endsWith( new LdapDN( "a =  b, c =  d" ) ) );
-   }
+    /**
+     * Class to test for getAll
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testGetAll() throws Exception
+    {
+        Name name0 = new LdapDN( "" );
+        Name name1 = new LdapDN( "ou=East" );
+        Name name2 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name4 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name5 = new LdapDN( "cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+        Name name6 = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
 
+        Enumeration<String> enum0 = name0.getAll();
+        assertEquals( false, enum0.hasMoreElements() );
 
-   /**
-    * Test a endsWith a complex LdapDN
-    */
-   @Test public void testLdapDNEndsWithComplexMixedCase() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( false, dn.endsWith( new LdapDN( "a =  B, C =  d" ) ) );
-   }
+        Enumeration<String> enum1 = name1.getAll();
+        assertEquals( true, enum1.hasMoreElements() );
 
+        for ( int i = 0; enum1.hasMoreElements(); i++ )
+        {
+            String element = ( String ) enum1.nextElement();
 
-   /**
-    * Test a endsWith a full LdapDN
-    */
-   @Test public void testLdapDNEndsWithFull() throws InvalidNameException
-   {
-       LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
-       assertEquals( true, dn.endsWith( new LdapDN( "a=  b; c =  d, e =  f" ) ) );
-   }
+            if ( i == 0 )
+            {
+                assertEquals( "ou=East", element );
+            }
+        }
+
+        Enumeration<String> enum2 = name2.getAll();
+        assertEquals( true, enum2.hasMoreElements() );
+
+        for ( int i = 0; enum2.hasMoreElements(); i++ )
+        {
+            String element = ( String ) enum2.nextElement();
+
+            if ( i == 0 )
+            {
+                assertEquals( "ou=East", element );
+            }
+
+            if ( i == 1 )
+            {
+                assertEquals( "ou=Marketing", element );
+            }
+        }
+
+        Enumeration<String> enum3 = name3.getAll();
+        assertEquals( true, enum3.hasMoreElements() );
+
+        for ( int i = 0; enum3.hasMoreElements(); i++ )
+        {
+            String element = ( String ) enum3.nextElement();
+
+            if ( i == 0 )
+            {
+                assertEquals( "ou=East", element );
+            }
+
+            if ( i == 1 )
+            {
+                assertEquals( "ou=Marketing", element );
+            }
+
+            if ( i == 2 )
+            {
+                assertEquals( "cn=John", element );
+            }
+        }
+
+        Enumeration<String> enum4 = name4.getAll();
+        assertEquals( true, enum4.hasMoreElements() );
+
+        for ( int i = 0; enum4.hasMoreElements(); i++ )
+        {
+            String element = ( String ) enum4.nextElement();
+
+            if ( i == 0 )
+            {
+                assertEquals( "ou=East", element );
+            }
+
+            if ( i == 1 )
+            {
+                assertEquals( "ou=Marketing", element );
+            }
+
+            if ( i == 2 )
+            {
+                assertEquals( "cn=John", element );
+            }
+
+            if ( i == 3 )
+            {
+                assertEquals( "cn=HomeDir", element );
+            }
+        }
+
+        Enumeration<String> enum5 = name5.getAll();
+        assertEquals( true, enum5.hasMoreElements() );
+
+        for ( int i = 0; enum5.hasMoreElements(); i++ )
+        {
+            String element = ( String ) enum5.nextElement();
+
+            if ( i == 0 )
+            {
+                assertEquals( "ou=West", element );
+            }
+
+            if ( i == 1 )
+            {
+                assertEquals( "ou=Marketing", element );
+            }
+
+            if ( i == 2 )
+            {
+                assertEquals( "cn=John", element );
+            }
+
+            if ( i == 3 )
+            {
+                assertEquals( "cn=HomeDir", element );
+            }
+
+            if ( i == 4 )
+            {
+                assertEquals( "cn=Website", element );
+            }
+        }
+
+        Enumeration<String> enum6 = name6.getAll();
+        assertEquals( true, enum6.hasMoreElements() );
+
+        for ( int i = 0; enum6.hasMoreElements(); i++ )
+        {
+            String element = ( String ) enum6.nextElement();
+
+            if ( i == 0 )
+            {
+                assertEquals( "ou=West", element );
+            }
+
+            if ( i == 1 )
+            {
+                assertEquals( "ou=Marketing", element );
+            }
+
+            if ( i == 2 )
+            {
+                assertEquals( "cn=John", element );
+            }
+
+            if ( i == 3 )
+            {
+                assertEquals( "cn=HomeDir", element );
+            }
+
+            if ( i == 4 )
+            {
+                assertEquals( "cn=Website", element );
+            }
+
+            if ( i == 5 )
+            {
+                assertEquals( "cn=Airline", element );
+            }
+        }
+    }
+
+
+    /**
+     * Class to test for getAllRdn
+     *
+     * @throws Exception
+     *             if anything goes wrong.
+     */
+    @Test
+    public void testGetAllRdn() throws Exception
+    {
+        LdapDN name = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+
+        Enumeration<Rdn> rdns = name.getAllRdn();
+        assertEquals( true, rdns.hasMoreElements() );
+
+        for ( int i = 0; rdns.hasMoreElements(); i++ )
+        {
+            Rdn element = ( Rdn ) rdns.nextElement();
+
+            if ( i == 0 )
+            {
+                assertEquals( "ou=West", element.toString() );
+            }
+
+            if ( i == 1 )
+            {
+                assertEquals( "ou=Marketing", element.toString() );
+            }
+
+            if ( i == 2 )
+            {
+                assertEquals( "cn=John", element.toString() );
+            }
+
+            if ( i == 3 )
+            {
+                assertEquals( "cn=HomeDir", element.toString() );
+            }
+
+            if ( i == 4 )
+            {
+                assertEquals( "cn=Website", element.toString() );
+            }
+
+            if ( i == 5 )
+            {
+                assertEquals( "cn=Airline", element.toString() );
+            }
+        }
+    }
+
+
+    /**
+     * Class to test for get
+     *
+     * @throws Exception
+     *             anything goes wrong
+     */
+    @Test
+    public void testGet() throws Exception
+    {
+        Name name = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        assertEquals( "cn=HomeDir", name.get( 3 ) );
+        assertEquals( "cn=John", name.get( 2 ) );
+        assertEquals( "ou=Marketing", name.get( 1 ) );
+        assertEquals( "ou=East", name.get( 0 ) );
+    }
+
+
+    /**
+     * Class to test for getSuffix
+     *
+     * @throws Exception
+     *             anything goes wrong
+     */
+    @Test
+    public void testGetXSuffix() throws Exception
+    {
+        Name name = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        assertEquals( "", name.getSuffix( 4 ).toString() );
+        assertEquals( "cn=HomeDir", name.getSuffix( 3 ).toString() );
+        assertEquals( "cn=HomeDir,cn=John", name.getSuffix( 2 ).toString() );
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing", name.getSuffix( 1 ).toString() );
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.getSuffix( 0 ).toString() );
+    }
+
+
+    /**
+     * Class to test for getPrefix
+     *
+     * @throws Exception
+     *             anything goes wrong
+     */
+    @Test
+    public void testGetPrefix() throws Exception
+    {
+        Name name = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+
+        assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.getPrefix( 4 ).toString() );
+        assertEquals( "cn=John,ou=Marketing,ou=East", name.getPrefix( 3 ).toString() );
+        assertEquals( "ou=Marketing,ou=East", name.getPrefix( 2 ).toString() );
+        assertEquals( "ou=East", name.getPrefix( 1 ).toString() );
+        assertEquals( "", name.getPrefix( 0 ).toString() );
+    }
+
+
+    /**
+     * Class to test for startsWith
+     *
+     * @throws Exception
+     *             anything goes wrong
+     */
+    @Test
+    public void testStartsWith() throws Exception
+    {
+        Name name0 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name2 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name4 = new LdapDN( "ou=East" );
+        Name name5 = new LdapDN( "" );
+
+        Name name6 = new LdapDN( "cn=HomeDir" );
+        Name name7 = new LdapDN( "cn=HomeDir,cn=John" );
+        Name name8 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing" );
+
+        assertTrue( name0.startsWith( name1 ) );
+        assertTrue( name0.startsWith( name2 ) );
+        assertTrue( name0.startsWith( name3 ) );
+        assertTrue( name0.startsWith( name4 ) );
+        assertTrue( name0.startsWith( name5 ) );
+
+        assertTrue( !name0.startsWith( name6 ) );
+        assertTrue( !name0.startsWith( name7 ) );
+        assertTrue( !name0.startsWith( name8 ) );
+    }
+
+
+    /**
+     * Class to test for endsWith
+     *
+     * @throws Exception
+     *             anything goes wrong
+     */
+    @Test
+    public void testEndsWith() throws Exception
+    {
+        Name name0 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        Name name2 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        Name name3 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name4 = new LdapDN( "ou=East" );
+        Name name5 = new LdapDN( "" );
+
+        Name name6 = new LdapDN( "cn=HomeDir" );
+        Name name7 = new LdapDN( "cn=HomeDir,cn=John" );
+        Name name8 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing" );
+
+        assertTrue( name0.endsWith( name1 ) );
+        assertTrue( !name0.endsWith( name2 ) );
+        assertTrue( !name0.endsWith( name3 ) );
+        assertTrue( !name0.endsWith( name4 ) );
+        assertTrue( name0.endsWith( name5 ) );
+
+        assertTrue( name0.endsWith( name6 ) );
+        assertTrue( name0.endsWith( name7 ) );
+        assertTrue( name0.endsWith( name8 ) );
+    }
+
+
+    /**
+     * Class to test for Name addAll(Name)
+     *
+     * @throws Exception
+     *             when anything goes wrong
+     */
+    @Test
+    public void testAddAllName0() throws Exception
+    {
+        Name name = new LdapDN();
+        Name name0 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        assertTrue( name0.equals( name.addAll( name0 ) ) );
+    }
+
+
+    /**
+     * Class to test for Name addAll(Name)
+     *
+     * @throws Exception
+     *             when anything goes wrong
+     */
+    @Test
+    public void testAddAllNameExisting0() throws Exception
+    {
+        Name name1 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name2 = new LdapDN( "cn=HomeDir,cn=John" );
+        Name nameAdded = new LdapDN( "cn=HomeDir,cn=John, ou=Marketing,ou=East" );
+        assertTrue( nameAdded.equals( name1.addAll( name2 ) ) );
+    }
+
+
+    /**
+     * Class to test for Name addAll(Name)
+     *
+     * @throws Exception
+     *             when anything goes wrong
+     */
+    @Test
+    public void testAddAllName1() throws Exception
+    {
+        Name name = new LdapDN();
+        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=HomeDir,cn=John" );
+        Name name2 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+
+        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        assertTrue( name2.equals( name.addAll( name1 ) ) );
+    }
+
+
+    /**
+     * Class to test for Name addAll(int, Name)
+     *
+     * @throws Exception
+     *             when something goes wrong
+     */
+    @Test
+    public void testAddAllintName0() throws Exception
+    {
+        Name name = new LdapDN();
+        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=HomeDir,cn=John" );
+        Name name2 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+
+        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
+    }
+
+
+    /**
+     * Class to test for Name addAll(int, Name)
+     *
+     * @throws Exception
+     *             when something goes wrong
+     */
+    @Test
+    public void testAddAllintName1() throws Exception
+    {
+        Name name = new LdapDN();
+        Name name0 = new LdapDN( "cn=HomeDir,ou=Marketing,ou=East" );
+        Name name1 = new LdapDN( "cn=John" );
+        Name name2 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+
+        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
+
+        Name name3 = new LdapDN( "cn=Airport" );
+        Name name4 = new LdapDN( "cn=Airport,cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+
+        assertTrue( name4.equals( name.addAll( 4, name3 ) ) );
+
+        Name name5 = new LdapDN( "cn=ABC123" );
+        Name name6 = new LdapDN( "cn=Airport,cn=HomeDir,cn=ABC123,cn=John,ou=Marketing,ou=East" );
+
+        assertTrue( name6.equals( name.addAll( 3, name5 ) ) );
+    }
+
+
+    /**
+     * Class to test for Name add(String)
+     *
+     * @throws Exception
+     *             when something goes wrong
+     */
+    @Test
+    public void testAddString() throws Exception
+    {
+        Name name = new LdapDN();
+        assertEquals( name, new LdapDN( "" ) );
+
+        Name name4 = new LdapDN( "ou=East" );
+        name.add( "ou=East" );
+        assertEquals( name4, name );
+
+        Name name3 = new LdapDN( "ou=Marketing,ou=East" );
+        name.add( "ou=Marketing" );
+        assertEquals( name3, name );
+
+        Name name2 = new LdapDN( "cn=John,ou=Marketing,ou=East" );
+        name.add( "cn=John" );
+        assertEquals( name2, name );
+
+        Name name0 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
+        name.add( "cn=HomeDir" );
+        assertEquals( name0, name );
+    }
+
+
+    /**
+     * Class to test for Name add(int, String)

[... 2376 lines stripped ...]