directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r612325 [2/2] - in /directory/shared/branches/bigbang/ldap/src: main/java/org/apache/directory/shared/ldap/entry/ main/java/org/apache/directory/shared/ldap/entry/client/ main/java/org/apache/directory/shared/ldap/name/ test/java/org/apache...
Date Wed, 16 Jan 2008 00:33:12 GMT
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=612325&r1=612324&r2=612325&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 Jan 15 16:33:09 2008
@@ -42,15 +42,20 @@
 import javax.naming.NamingException;
 import javax.naming.ldap.LdapName;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.LdapDnParser;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertSame;
 
 
 /**
@@ -58,8 +63,39 @@
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapDNTest extends TestCase
+public class LdapDNTest
 {
+    private Map<String, OidNormalizer> oids;
+    private Map<String, OidNormalizer> oidOids;
+
+    /**
+     * Initialize OIDs maps for normalization
+     */
+    @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( "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 --------------------------------------------------
@@ -67,7 +103,7 @@
    /**
     * Test a null DN
     */
-   public void testLdapDNNull()
+   @Test public void testLdapDNNull()
    {
        LdapDN dn = new LdapDN();
        assertEquals( "", dn.getUpName() );
@@ -78,7 +114,7 @@
    /**
     * test an empty DN
     */
-   public void testLdapDNEmpty() throws InvalidNameException
+   @Test public void testLdapDNEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "" );
        assertEquals( "", dn.getUpName() );
@@ -89,7 +125,7 @@
    /**
     * test a simple DN : a = b
     */
-   public void testLdapDNSimple() throws InvalidNameException
+   @Test public void testLdapDNSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
 
@@ -101,7 +137,7 @@
    /**
     * test a simple DN with some spaces : "a = b  "
     */
-   public void testLdapDNSimpleWithSpaces() throws InvalidNameException
+   @Test public void testLdapDNSimpleWithSpaces() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b  " );
        
@@ -114,7 +150,7 @@
    /**
     * test a composite DN : a = b, d = e
     */
-   public void testLdapDNComposite() throws InvalidNameException
+   @Test public void testLdapDNComposite() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b, c = d" );
 
@@ -126,7 +162,7 @@
    /**
     * test a composite DN with spaces : a = b  , d = e
     */
-   public void testLdapDNCompositeWithSpaces() throws InvalidNameException
+   @Test public void testLdapDNCompositeWithSpaces() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b  , c = d" );
 
@@ -139,7 +175,7 @@
    /**
     * test a composite DN with or without spaces: a=b, a =b, a= b, a = b, a = b
     */
-   public void testLdapDNCompositeWithSpace() throws InvalidNameException
+   @Test public void testLdapDNCompositeWithSpace() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, a =b, a= b, a = b, a  =  b" );
 
@@ -153,7 +189,7 @@
     * 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 ',')
     */
-   public void testLdapDNCompositeSepators() throws InvalidNameException
+   @Test public void testLdapDNCompositeSepators() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b;c=d,e=f" );
 
@@ -166,7 +202,7 @@
    /**
     * test a simple DN with multiple NameComponents : a = b + c = d
     */
-   public void testLdapDNSimpleMultivaluedAttribute() throws InvalidNameException
+   @Test public void testLdapDNSimpleMultivaluedAttribute() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b + c = d" );
 
@@ -180,7 +216,7 @@
     * test a composite DN with multiple NC and separators : a=b+c=d, e=f + g=h +
     * i=j
     */
-   public void testLdapDNCompositeMultivaluedAttribute() throws InvalidNameException
+   @Test public void testLdapDNCompositeMultivaluedAttribute() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b+c=d, e=f + g=h + i=j" );
 
@@ -193,7 +229,7 @@
    /**
    * Test to see if a DN with multiRdn values is preserved after an addAll.
    */
-   public void testAddAllWithMultivaluedAttribute() throws InvalidNameException
+   @Test public void testAddAllWithMultivaluedAttribute() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "cn=Kate Bush+sn=Bush,ou=system" );
        LdapDN target = new LdapDN();
@@ -208,7 +244,7 @@
    /**
     * test a simple DN with an oid prefix (uppercase) : OID.12.34.56 = azerty
     */
-   public void testLdapDNOidUpper() throws InvalidNameException
+   @Test public void testLdapDNOidUpper() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "OID.12.34.56 = azerty" );
 
@@ -221,7 +257,7 @@
    /**
     * test a simple DN with an oid prefix (lowercase) : oid.12.34.56 = azerty
     */
-   public void testLdapDNOidLower() throws InvalidNameException
+   @Test public void testLdapDNOidLower() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "oid.12.34.56 = azerty" );
 
@@ -235,7 +271,7 @@
     * test a simple DN with an oid attribut without oid prefix : 12.34.56 =
     * azerty
     */
-   public void testLdapDNOidWithoutPrefix() throws InvalidNameException
+   @Test public void testLdapDNOidWithoutPrefix() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "12.34.56 = azerty" );
 
@@ -249,7 +285,7 @@
     * test a composite DN with an oid attribut wiithout oid prefix : 12.34.56 =
     * azerty; 7.8 = test
     */
-   public void testLdapDNCompositeOidWithoutPrefix() throws InvalidNameException
+   @Test public void testLdapDNCompositeOidWithoutPrefix() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "12.34.56 = azerty; 7.8 = test" );
 
@@ -262,7 +298,7 @@
    /**
     * test a simple DN with pair char attribute value : a = \,\=\+\<\>\#\;\\\"\C4\8D"
     */
-   public void testLdapDNPairCharAttributeValue() throws InvalidNameException
+   @Test public void testLdapDNPairCharAttributeValue() throws InvalidNameException
    {
        
        LdapDN dn = new LdapDN( "a = \\,\\=\\+\\<\\>\\#\\;\\\\\\\"\\C4\\8D" );
@@ -275,7 +311,7 @@
    /**
     * test a simple DN with pair char attribute value : "SN=Lu\C4\8Di\C4\87"
     */
-   public void testLdapDNRFC253_Lucic() throws InvalidNameException
+   @Test public void testLdapDNRFC253_Lucic() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "SN=Lu\\C4\\8Di\\C4\\87" );
 
@@ -287,7 +323,7 @@
    /**
     * test a simple DN with hexString attribute value : a = #0010A0AAFF
     */
-   public void testLdapDNHexStringAttributeValue() throws InvalidNameException
+   @Test public void testLdapDNHexStringAttributeValue() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = #0010A0AAFF" );
 
@@ -299,7 +335,7 @@
    /**
     * test a simple DN with a # on first position
     */
-   public void testLdapDNSharpFirst() throws InvalidNameException
+   @Test public void testLdapDNSharpFirst() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = \\#this is a sharp" );
 
@@ -311,7 +347,7 @@
    /**
     * test a simple DN with a wrong hexString attribute value : a = #0010Z0AAFF
     */
-   public void testLdapDNWrongHexStringAttributeValue()
+   @Test public void testLdapDNWrongHexStringAttributeValue()
    {
        try
        {
@@ -329,7 +365,7 @@
    /**
     * test a simple DN with a wrong hexString attribute value : a = #AABBCCDD3
     */
-   public void testLdapDNWrongHexStringAttributeValue2()
+   @Test public void testLdapDNWrongHexStringAttributeValue2()
    {
        try
        {
@@ -346,7 +382,7 @@
    /**
     * test a simple DN with a quote in attribute value : a = quoted \"value\"
     */
-   public void testLdapDNQuoteInAttributeValue() throws InvalidNameException
+   @Test public void testLdapDNQuoteInAttributeValue() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = quoted \\\"value\\\"" );
 
@@ -358,7 +394,7 @@
    /**
     * test a simple DN with quoted attribute value : a = \" quoted value \"
     */
-   public void testLdapDNQuotedAttributeValue() throws InvalidNameException
+   @Test public void testLdapDNQuotedAttributeValue() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = \\\" quoted value \\\"" );
 
@@ -370,7 +406,7 @@
    /**
     * test a simple DN with a comma at the end
     */
-   public void testLdapDNComaAtEnd()
+   @Test public void testLdapDNComaAtEnd()
    {
        assertFalse( LdapDN.isValid( "a = b,"  ) );
        assertFalse( LdapDN.isValid( "a = b, "  ) );
@@ -392,7 +428,7 @@
    /**
     * test a remove from position 0
     */
-   public void testLdapDNRemove0() throws InvalidNameException
+   @Test public void testLdapDNRemove0() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
@@ -406,7 +442,7 @@
    /**
     * test a remove from position 1
     */
-   public void testLdapDNRemove1() throws InvalidNameException
+   @Test public void testLdapDNRemove1() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
@@ -419,7 +455,7 @@
    /**
     * test a remove from position 2
     */
-   public void testLdapDNRemove2() throws InvalidNameException
+   @Test public void testLdapDNRemove2() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
@@ -432,7 +468,7 @@
    /**
     * test a remove from position 1 whith semi colon
     */
-   public void testLdapDNRemove1WithSemiColon() throws InvalidNameException
+   @Test public void testLdapDNRemove1WithSemiColon() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d; e=f" );
 
@@ -445,7 +481,7 @@
    /**
     * test a remove out of bound
     */
-   public void testLdapDNRemoveOutOfBound() throws InvalidNameException
+   @Test public void testLdapDNRemoveOutOfBound() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d; e=f" );
 
@@ -455,7 +491,7 @@
        {
            dn.remove( 4 );
            // We whould never reach this point
-           Assert.fail();
+           fail();
        }
        catch ( ArrayIndexOutOfBoundsException aoobe )
        {
@@ -468,7 +504,7 @@
    /**
     * test a 0 size
     */
-   public void testLdapDNSize0()
+   @Test public void testLdapDNSize0()
    {
        LdapDN dn = new LdapDN();
 
@@ -480,7 +516,7 @@
    /**
     * test a 1 size
     */
-   public void testLdapDNSize1() throws InvalidNameException
+   @Test public void testLdapDNSize1() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b" );
 
@@ -492,7 +528,7 @@
    /**
     * test a 3 size
     */
-   public void testLdapDNSize3() throws InvalidNameException
+   @Test public void testLdapDNSize3() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d, e=f" );
 
@@ -504,7 +540,7 @@
    /**
     * test a 3 size with NameComponents
     */
-   public void testLdapDNSize3NC() throws InvalidNameException
+   @Test public void testLdapDNSize3NC() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b+c=d, c=d, e=f" );
 
@@ -516,7 +552,7 @@
    /**
     * test size after operations
     */
-   public void testLdapResizing() throws InvalidNameException
+   @Test public void testLdapResizing() throws InvalidNameException
    {
        LdapDN dn = new LdapDN();
        assertEquals( 0, dn.size() );
@@ -539,7 +575,7 @@
    /**
     * test Add on a new LdapDN
     */
-   public void testLdapEmptyAdd() throws InvalidNameException
+   @Test public void testLdapEmptyAdd() throws InvalidNameException
    {
        LdapDN dn = new LdapDN();
 
@@ -553,7 +589,7 @@
    /**
     * test Add to an existing LdapDN
     */
-   public void testLdapDNAdd() throws InvalidNameException
+   @Test public void testLdapDNAdd() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d" );
 
@@ -567,7 +603,7 @@
    /**
     * test Add a composite RDN to an existing LdapDN
     */
-   public void testLdapDNAddComposite() throws InvalidNameException
+   @Test public void testLdapDNAddComposite() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d" );
 
@@ -584,7 +620,7 @@
    /**
     * test Add at the end of an existing LdapDN
     */
-   public void testLdapDNAddEnd() throws InvalidNameException
+   @Test public void testLdapDNAddEnd() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d" );
 
@@ -597,7 +633,7 @@
    /**
     * test Add at the start of an existing LdapDN
     */
-   public void testLdapDNAddStart() throws InvalidNameException
+   @Test public void testLdapDNAddStart() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d" );
 
@@ -610,7 +646,7 @@
    /**
     * test Add at the middle of an existing LdapDN
     */
-   public void testLdapDNAddMiddle() throws InvalidNameException
+   @Test public void testLdapDNAddMiddle() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d" );
 
@@ -626,7 +662,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAddAll() throws InvalidNameException
+   @Test public void testLdapDNAddAll() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
        LdapDN dn2 = new LdapDN( "c = d" );
@@ -640,7 +676,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAddAllAddedNameEmpty() throws InvalidNameException
+   @Test public void testLdapDNAddAllAddedNameEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
        LdapDN dn2 = new LdapDN();
@@ -655,7 +691,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAddAllNameEmpty() throws InvalidNameException
+   @Test public void testLdapDNAddAllNameEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN();
        LdapDN dn2 = new LdapDN( "a = b" );
@@ -669,7 +705,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAt0AddAll() throws InvalidNameException
+   @Test public void testLdapDNAt0AddAll() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
        LdapDN dn2 = new LdapDN( "c = d" );
@@ -683,7 +719,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAt1AddAll() throws InvalidNameException
+   @Test public void testLdapDNAt1AddAll() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
        LdapDN dn2 = new LdapDN( "c = d" );
@@ -697,7 +733,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAtTheMiddleAddAll() throws InvalidNameException
+   @Test public void testLdapDNAtTheMiddleAddAll() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b, c = d" );
        LdapDN dn2 = new LdapDN( "e = f" );
@@ -711,7 +747,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAddAllAt0AddedNameEmpty() throws InvalidNameException
+   @Test public void testLdapDNAddAllAt0AddedNameEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
        LdapDN dn2 = new LdapDN();
@@ -726,7 +762,7 @@
     *
     * @throws InvalidNameException
     */
-   public void testLdapDNAddAllAt0NameEmpty() throws InvalidNameException
+   @Test public void testLdapDNAddAllAt0NameEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN();
        LdapDN dn2 = new LdapDN( "a = b" );
@@ -739,7 +775,7 @@
    /**
     * Get the prefix at pos 0
     */
-   public void testLdapDNGetPrefixPos0() throws InvalidNameException
+   @Test public void testLdapDNGetPrefixPos0() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 0 ) );
@@ -750,7 +786,7 @@
    /**
     * Get the prefix at pos 1
     */
-   public void testLdapDNGetPrefixPos1() throws InvalidNameException
+   @Test public void testLdapDNGetPrefixPos1() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 1 ) );
@@ -761,7 +797,7 @@
    /**
     * Get the prefix at pos 2
     */
-   public void testLdapDNGetPrefixPos2() throws InvalidNameException
+   @Test public void testLdapDNGetPrefixPos2() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 2 ) );
@@ -772,7 +808,7 @@
    /**
     * Get the prefix at pos 3
     */
-   public void testLdapDNGetPrefixPos3() throws InvalidNameException
+   @Test public void testLdapDNGetPrefixPos3() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 3 ) );
@@ -783,7 +819,7 @@
    /**
     * Get the prefix out of bound
     */
-   public void testLdapDNGetPrefixPos4() throws InvalidNameException
+   @Test public void testLdapDNGetPrefixPos4() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
 
@@ -791,7 +827,7 @@
        {
            dn.getPrefix( 4 );
            // We should not reach this point.
-           Assert.fail();
+           fail();
        }
        catch ( ArrayIndexOutOfBoundsException aoobe )
        {
@@ -803,7 +839,7 @@
    /**
     * Get the prefix of an empty LdapName
     */
-   public void testLdapDNGetPrefixEmptyDN()
+   @Test public void testLdapDNGetPrefixEmptyDN()
    {
        LdapDN dn = new LdapDN();
        LdapDN newDn = ( ( LdapDN ) dn.getPrefix( 0 ) );
@@ -815,7 +851,7 @@
    /**
     * Get the suffix at pos 0
     */
-   public void testLdapDNGetSuffixPos0() throws InvalidNameException
+   @Test public void testLdapDNGetSuffixPos0() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 0 ) );
@@ -826,7 +862,7 @@
    /**
     * Get the suffix at pos 1
     */
-   public void testLdapDNGetSuffixPos1() throws InvalidNameException
+   @Test public void testLdapDNGetSuffixPos1() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 1 ) );
@@ -837,7 +873,7 @@
    /**
     * Get the suffix at pos 2
     */
-   public void testLdapDNGetSuffixPos2() throws InvalidNameException
+   @Test public void testLdapDNGetSuffixPos2() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 2 ) );
@@ -848,7 +884,7 @@
    /**
     * Get the suffix at pos 3
     */
-   public void testLdapDNGetSuffixPos3() throws InvalidNameException
+   @Test public void testLdapDNGetSuffixPos3() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 3 ) );
@@ -859,7 +895,7 @@
    /**
     * Get the suffix out of bound
     */
-   public void testLdapDNGetSuffixPos4() throws InvalidNameException
+   @Test public void testLdapDNGetSuffixPos4() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
 
@@ -867,7 +903,7 @@
        {
            dn.getSuffix( 4 );
            // We should not reach this point.
-           Assert.fail();
+           fail();
        }
        catch ( ArrayIndexOutOfBoundsException aoobe )
        {
@@ -879,7 +915,7 @@
    /**
     * Get the suffix of an empty LdapName
     */
-   public void testLdapDNGetSuffixEmptyDN()
+   @Test public void testLdapDNGetSuffixEmptyDN()
    {
        LdapDN dn = new LdapDN();
        LdapDN newDn = ( ( LdapDN ) dn.getSuffix( 0 ) );
@@ -891,7 +927,7 @@
    /**
     * Test that a LdapDN is empty
     */
-   public void testLdapDNIsEmpty()
+   @Test public void testLdapDNIsEmpty()
    {
        LdapDN dn = new LdapDN();
        assertEquals( true, dn.isEmpty() );
@@ -901,7 +937,7 @@
    /**
     * Test that a LdapDN is empty
     */
-   public void testLdapDNNotEmpty() throws InvalidNameException
+   @Test public void testLdapDNNotEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b" );
        assertEquals( false, dn.isEmpty() );
@@ -911,7 +947,7 @@
    /**
     * Test that a LdapDN is empty
     */
-   public void testLdapDNRemoveIsEmpty() throws InvalidNameException
+   @Test public void testLdapDNRemoveIsEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d" );
        dn.remove( 0 );
@@ -925,7 +961,7 @@
    /**
     * Test a startsWith a null LdapDN
     */
-   public void testLdapDNStartsWithNull() throws InvalidNameException
+   @Test public void testLdapDNStartsWithNull() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        assertEquals( true, dn.startsWith( null ) );
@@ -935,7 +971,7 @@
    /**
     * Test a startsWith an empty LdapDN
     */
-   public void testLdapDNStartsWithEmpty() throws InvalidNameException
+   @Test public void testLdapDNStartsWithEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        assertEquals( true, dn.startsWith( new LdapDN() ) );
@@ -945,7 +981,7 @@
    /**
     * Test a startsWith an simple LdapDN
     */
-   public void testLdapDNStartsWithSimple() throws InvalidNameException
+   @Test public void testLdapDNStartsWithSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        assertEquals( true, dn.startsWith( new LdapDN( "e=f" ) ) );
@@ -955,7 +991,7 @@
    /**
     * Test a startsWith a complex LdapDN
     */
-   public void testLdapDNStartsWithComplex() throws InvalidNameException
+   @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" ) ) );
@@ -965,7 +1001,7 @@
    /**
     * Test a startsWith a complex LdapDN
     */
-   public void testLdapDNStartsWithComplexMixedCase() throws InvalidNameException
+   @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" ) ) );
@@ -975,7 +1011,7 @@
    /**
     * Test a startsWith a full LdapDN
     */
-   public void testLdapDNStartsWithFull() throws InvalidNameException
+   @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" ) ) );
@@ -985,7 +1021,7 @@
    /**
     * Test a startsWith which returns false
     */
-   public void testLdapDNStartsWithWrong() throws InvalidNameException
+   @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" ) ) );
@@ -996,7 +1032,7 @@
    /**
     * Test a endsWith a null LdapDN
     */
-   public void testLdapDNEndsWithNull() throws InvalidNameException
+   @Test public void testLdapDNEndsWithNull() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        assertEquals( true, dn.endsWith( null ) );
@@ -1006,7 +1042,7 @@
    /**
     * Test a endsWith an empty LdapDN
     */
-   public void testLdapDNEndsWithEmpty() throws InvalidNameException
+   @Test public void testLdapDNEndsWithEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        assertEquals( true, dn.endsWith( new LdapDN() ) );
@@ -1016,7 +1052,7 @@
    /**
     * Test a endsWith an simple LdapDN
     */
-   public void testLdapDNEndsWithSimple() throws InvalidNameException
+   @Test public void testLdapDNEndsWithSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b, c=d,e = f" );
        assertEquals( true, dn.endsWith( new LdapDN( "a=b" ) ) );
@@ -1026,7 +1062,7 @@
    /**
     * Test a endsWith a complex LdapDN
     */
-   public void testLdapDNEndsWithComplex() throws InvalidNameException
+   @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" ) ) );
@@ -1036,7 +1072,7 @@
    /**
     * Test a endsWith a complex LdapDN
     */
-   public void testLdapDNEndsWithComplexMixedCase() throws InvalidNameException
+   @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" ) ) );
@@ -1046,7 +1082,7 @@
    /**
     * Test a endsWith a full LdapDN
     */
-   public void testLdapDNEndsWithFull() throws InvalidNameException
+   @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" ) ) );
@@ -1056,7 +1092,7 @@
    /**
     * Test a endsWith which returns false
     */
-   public void testLdapDNEndsWithWrong() throws InvalidNameException
+   @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" ) ) );
@@ -1067,7 +1103,7 @@
    /**
     * test a getAll operation on a null DN
     */
-   public void testLdapDNGetAllNull()
+   @Test public void testLdapDNGetAllNull()
    {
        LdapDN dn = new LdapDN();
        Enumeration<String> nc = dn.getAll();
@@ -1079,7 +1115,7 @@
    /**
     * test a getAll operation on an empty DN
     */
-   public void testLdapDNGetAllEmpty() throws InvalidNameException
+   @Test public void testLdapDNGetAllEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "" );
        Enumeration<String> nc = dn.getAll();
@@ -1091,7 +1127,7 @@
    /**
     * test a getAll operation on a simple DN
     */
-   public void testLdapDNGetAllSimple() throws InvalidNameException
+   @Test public void testLdapDNGetAllSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b" );
        Enumeration<String> nc = dn.getAll();
@@ -1105,7 +1141,7 @@
    /**
     * test a getAll operation on a complex DN
     */
-   public void testLdapDNGetAllComplex() throws InvalidNameException
+   @Test public void testLdapDNGetAllComplex() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "e=f+g=h,a=b,c=d" );
        Enumeration<String> nc = dn.getAll();
@@ -1123,7 +1159,7 @@
    /**
     * test a getAll operation on a complex DN
     */
-   public void testLdapDNGetAllComplexOrdered() throws InvalidNameException
+   @Test public void testLdapDNGetAllComplexOrdered() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "g=h+e=f,a=b,c=d" );
        Enumeration<String> nc = dn.getAll();
@@ -1144,7 +1180,7 @@
    /**
     * test a clone operation on a empty DN
     */
-   public void testLdapDNCloneEmpty()
+   @Test public void testLdapDNCloneEmpty()
    {
        LdapDN dn = new LdapDN();
        LdapDN clone = ( LdapDN ) dn.clone();
@@ -1156,7 +1192,7 @@
    /**
     * test a clone operation on a simple DN
     */
-   public void testLdapDNCloneSimple() throws InvalidNameException
+   @Test public void testLdapDNCloneSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a=b" );
        LdapDN clone = ( LdapDN ) dn.clone();
@@ -1170,7 +1206,7 @@
    /**
     * test a clone operation on a complex DN
     */
-   public void testLdapDNCloneComplex() throws InvalidNameException
+   @Test public void testLdapDNCloneComplex() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "e=f+g=h,a=b,c=d" );
        LdapDN clone = ( LdapDN ) dn.clone();
@@ -1185,7 +1221,7 @@
    /**
     * test a get in a null DN
     */
-   public void testLdapDNGetNull()
+   @Test public void testLdapDNGetNull()
    {
        LdapDN dn = new LdapDN();
        assertEquals( "", dn.get( 0 ) );
@@ -1195,7 +1231,7 @@
    /**
     * test a get in an empty DN
     */
-   public void testLdapDNGetEmpty() throws InvalidNameException
+   @Test public void testLdapDNGetEmpty() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "" );
        assertEquals( "", dn.get( 0 ) );
@@ -1205,7 +1241,7 @@
    /**
     * test a get in a simple DN
     */
-   public void testLdapDNGetSimple() throws InvalidNameException
+   @Test public void testLdapDNGetSimple() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b" );
        assertEquals( "a=b", dn.get( 0 ) );
@@ -1215,7 +1251,7 @@
    /**
     * test a get in a complex DN
     */
-   public void testLdapDNGetComplex() throws InvalidNameException
+   @Test public void testLdapDNGetComplex() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b + c= d, e= f; g =h" );
        assertEquals( "g=h", dn.get( 0 ) );
@@ -1227,14 +1263,14 @@
    /**
     * test a get out of bound
     */
-   public void testLdapDNGetOutOfBound() throws InvalidNameException
+   @Test public void testLdapDNGetOutOfBound() throws InvalidNameException
    {
        LdapDN dn = new LdapDN( "a = b + c= d, e= f; g =h" );
 
        try
        {
            dn.get( 4 );
-           Assert.fail();
+           fail();
        }
        catch ( ArrayIndexOutOfBoundsException aioob )
        {
@@ -1250,7 +1286,7 @@
     * @throws Exception
     *             if anything goes wrong
     */
-   public void testJNDITutorialExample() throws Exception
+   @Test public void testJNDITutorialExample() throws Exception
    {
        // Parse the name
        Name name = new LdapDN( "cn=John,ou=People,ou=Marketing" );
@@ -1258,7 +1294,6 @@
        // Remove the second component from the head: ou=People
        String out = name.remove( 1 ).toString();
 
-       // System.out.println( l_out ) ;
        assertEquals( "ou=People", out );
 
        // Add to the head (first): cn=John,ou=Marketing,ou=East
@@ -1273,7 +1308,7 @@
    }
 
 
-   public void testAttributeEqualsIsCaseInSensitive() throws Exception
+   @Test public void testAttributeEqualsIsCaseInSensitive() throws Exception
    {
        Name name1 = new LdapDN( "cn=HomeDir" );
        Name name2 = new LdapDN( "CN=HomeDir" );
@@ -1282,7 +1317,7 @@
    }
 
 
-   public void testAttributeTypeEqualsIsCaseInsensitive() throws Exception
+   @Test public void testAttributeTypeEqualsIsCaseInsensitive() throws Exception
    {
        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
        Name name2 = new LdapDN( "cn=HomeDir+CN=WorkDir" );
@@ -1291,7 +1326,7 @@
    }
 
 
-   public void testNameEqualsIsInsensitiveToAttributesOrder() throws Exception
+   @Test public void testNameEqualsIsInsensitiveToAttributesOrder() throws Exception
    {
 
        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
@@ -1301,7 +1336,7 @@
    }
 
 
-   public void testAttributeComparisonIsCaseInSensitive() throws Exception
+   @Test public void testAttributeComparisonIsCaseInSensitive() throws Exception
    {
        Name name1 = new LdapDN( "cn=HomeDir" );
        Name name2 = new LdapDN( "CN=HomeDir" );
@@ -1310,7 +1345,7 @@
    }
 
 
-   public void testAttributeTypeComparisonIsCaseInsensitive() throws Exception
+   @Test public void testAttributeTypeComparisonIsCaseInsensitive() throws Exception
    {
        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
        Name name2 = new LdapDN( "cn=HomeDir+CN=WorkDir" );
@@ -1319,7 +1354,7 @@
    }
 
 
-   public void testNameComparisonIsInsensitiveToAttributesOrder() throws Exception
+   @Test public void testNameComparisonIsInsensitiveToAttributesOrder() throws Exception
    {
 
        Name name1 = new LdapDN( "cn=HomeDir+cn=WorkDir" );
@@ -1329,7 +1364,7 @@
    }
 
 
-   public void testNameComparisonIsInsensitiveToAttributesOrderFailure() throws Exception
+   @Test public void testNameComparisonIsInsensitiveToAttributesOrderFailure() throws Exception
    {
 
        Name name1 = new LdapDN( "cn= HomeDir+cn=Workdir" );
@@ -1342,7 +1377,7 @@
    /**
     * Test the encoding of a LdanDN
     */
-   public void testNameToBytes() throws Exception
+   @Test public void testNameToBytes() throws Exception
    {
        LdapDN dn = new LdapDN( "cn = John, ou = People, OU = Marketing" );
 
@@ -1353,7 +1388,7 @@
    }
 
 
-   public void testStringParser() throws Exception
+   @Test public void testStringParser() throws Exception
    {
        
        String dn = StringTools.utf8ToString( new byte[]{'C', 'N', ' ', '=', ' ', 'E', 'm', 'm', 'a', 'n', 'u', 'e', 
@@ -1372,7 +1407,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testLdapNameString() throws Exception
+   @Test public void testLdapNameString() throws Exception
    {
        Name name = new LdapDN( "" );
        Name name50 = new LdapDN();
@@ -1404,7 +1439,7 @@
    /**
     * Class to test for void LdapName()
     */
-   public void testLdapName()
+   @Test public void testLdapName()
    {
        Name name = new LdapDN();
        assertTrue( name.toString().equals( "" ) );
@@ -1414,7 +1449,7 @@
    /**
     * Class to test for void LdapName(List)
     */
-   public void testLdapNameList() throws InvalidNameException
+   @Test public void testLdapNameList() throws InvalidNameException
    {
        List<String> list = new ArrayList<String>();
        list.add( "ou=People" );
@@ -1428,7 +1463,7 @@
    /**
     * Class to test for void LdapName(Iterator)
     */
-   public void testLdapNameIterator() throws InvalidNameException
+   @Test public void testLdapNameIterator() throws InvalidNameException
    {
        List<String> list = new ArrayList<String>();
        list.add( "ou=People" );
@@ -1445,7 +1480,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testClone() throws Exception
+   @Test public void testClone() throws Exception
    {
        String strName = "cn=HomeDir,cn=John,ou=Marketing,ou=East";
        Name name = new LdapDN( strName );
@@ -1459,7 +1494,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testCompareTo() throws Exception
+   @Test public void testCompareTo() throws Exception
    {
        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
        Name copy = new LdapDN( "ou=Marketing,ou=East" );
@@ -1529,7 +1564,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testSize() throws Exception
+   @Test public void testSize() throws Exception
    {
        Name name0 = new LdapDN( "" );
        Name name1 = new LdapDN( "ou=East" );
@@ -1555,7 +1590,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testIsEmpty() throws Exception
+   @Test public void testIsEmpty() throws Exception
    {
        Name name0 = new LdapDN( "" );
        Name name1 = new LdapDN( "ou=East" );
@@ -1581,7 +1616,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testGetAll() throws Exception
+   @Test public void testGetAll() throws Exception
    {
        Name name0 = new LdapDN( "" );
        Name name1 = new LdapDN( "ou=East" );
@@ -1755,7 +1790,7 @@
     * @throws Exception
     *             if anything goes wrong.
     */
-   public void testGetAllRdn() throws Exception
+   @Test public void testGetAllRdn() throws Exception
    {
        LdapDN name = new LdapDN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
 
@@ -1805,7 +1840,7 @@
     * @throws Exception
     *             anything goes wrong
     */
-   public void testGet() throws Exception
+   @Test public void testGet() throws Exception
    {
        Name name = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
        assertEquals( "cn=HomeDir", name.get( 3 ) );
@@ -1821,7 +1856,7 @@
     * @throws Exception
     *             anything goes wrong
     */
-   public void testGetXSuffix() throws Exception
+   @Test public void testGetXSuffix() throws Exception
    {
        Name name = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
        assertEquals( "", name.getSuffix( 4 ).toString() );
@@ -1838,7 +1873,7 @@
     * @throws Exception
     *             anything goes wrong
     */
-   public void testGetPrefix() throws Exception
+   @Test public void testGetPrefix() throws Exception
    {
        Name name = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
@@ -1856,7 +1891,7 @@
     * @throws Exception
     *             anything goes wrong
     */
-   public void testStartsWith() throws Exception
+   @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" );
@@ -1887,7 +1922,7 @@
     * @throws Exception
     *             anything goes wrong
     */
-   public void testEndsWith() throws Exception
+   @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" );
@@ -1918,7 +1953,7 @@
     * @throws Exception
     *             when anything goes wrong
     */
-   public void testAddAllName0() throws Exception
+   @Test public void testAddAllName0() throws Exception
    {
        Name name = new LdapDN();
        Name name0 = new LdapDN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
@@ -1932,7 +1967,7 @@
     * @throws Exception
     *             when anything goes wrong
     */
-   public void testAddAllNameExisting0() throws Exception
+   @Test public void testAddAllNameExisting0() throws Exception
    {
        Name name1 = new LdapDN( "ou=Marketing,ou=East" );
        Name name2 = new LdapDN( "cn=HomeDir,cn=John" );
@@ -1947,7 +1982,7 @@
     * @throws Exception
     *             when anything goes wrong
     */
-   public void testAddAllName1() throws Exception
+   @Test public void testAddAllName1() throws Exception
    {
        Name name = new LdapDN();
        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
@@ -1965,7 +2000,7 @@
     * @throws Exception
     *             when something goes wrong
     */
-   public void testAddAllintName0() throws Exception
+   @Test public void testAddAllintName0() throws Exception
    {
        Name name = new LdapDN();
        Name name0 = new LdapDN( "ou=Marketing,ou=East" );
@@ -1983,7 +2018,7 @@
     * @throws Exception
     *             when something goes wrong
     */
-   public void testAddAllintName1() throws Exception
+   @Test public void testAddAllintName1() throws Exception
    {
        Name name = new LdapDN();
        Name name0 = new LdapDN( "cn=HomeDir,ou=Marketing,ou=East" );
@@ -2011,7 +2046,7 @@
     * @throws Exception
     *             when something goes wrong
     */
-   public void testAddString() throws Exception
+   @Test public void testAddString() throws Exception
    {
        Name name = new LdapDN();
        assertEquals( name, new LdapDN( "" ) );
@@ -2040,7 +2075,7 @@
     * @throws Exception
     *             if anything goes wrong
     */
-   public void testAddintString() throws Exception
+   @Test public void testAddintString() throws Exception
    {
        Name name = new LdapDN();
        assertEquals( name, new LdapDN( "" ) );
@@ -2081,7 +2116,7 @@
     * @throws Exception
     *             if anything goes wrong
     */
-   public void testRemove() throws Exception
+   @Test public void testRemove() throws Exception
    {
        Name name = new LdapDN();
        assertEquals( new LdapDN( "" ), name );
@@ -2118,7 +2153,7 @@
     * @throws Exception
     *             if anything goes wrong
     */
-   public void testToString() throws Exception
+   @Test public void testToString() throws Exception
    {
        Name name = new LdapDN();
        assertEquals( "", name.toString() );
@@ -2143,7 +2178,7 @@
     * @throws Exception
     *             if anything goes wrong
     */
-   public void testEqualsObject() throws Exception
+   @Test public void testEqualsObject() throws Exception
    {
        assertTrue( new LdapDN( "ou=People" ).equals( new LdapDN( "ou=People" ) ) );
 
@@ -2153,7 +2188,7 @@
    }
 
 
-   public void testNameFrenchChars() throws Exception
+   @Test public void testNameFrenchChars() throws Exception
    {
        String cn = new String( new byte[]
            { 'c', 'n', '=', 0x4A, ( byte ) 0xC3, ( byte ) 0xA9, 0x72, ( byte ) 0xC3, ( byte ) 0xB4, 0x6D, 0x65 }, "UTF-8" );
@@ -2164,7 +2199,7 @@
    }
 
 
-   public void testNameGermanChars() throws Exception
+   @Test public void testNameGermanChars() throws Exception
    {
        String cn = new String( new byte[]
            { 'c', 'n', '=', ( byte ) 0xC3, ( byte ) 0x84, ( byte ) 0xC3, ( byte ) 0x96, ( byte ) 0xC3, ( byte ) 0x9C,
@@ -2177,7 +2212,7 @@
    }
 
 
-   public void testNameTurkishChars() throws Exception
+   @Test public void testNameTurkishChars() throws Exception
    {
        String cn = new String( new byte[]
            { 'c', 'n', '=', ( byte ) 0xC4, ( byte ) 0xB0, ( byte ) 0xC4, ( byte ) 0xB1, ( byte ) 0xC5, ( byte ) 0x9E,
@@ -2194,7 +2229,7 @@
    /**
     * Class to test for toOid( Name, Map)
     */
-   public void testLdapNameToName() throws Exception
+   @Test public void testLdapNameToName() throws Exception
    {
        List<String> list = new ArrayList<String>();
        list.add( "ou= Some   People   " );
@@ -2202,15 +2237,6 @@
        list.add( "dc= cOm" );
        LdapDN name = new LdapDN( list.iterator() );
 
-       Map<String, OidNormalizer> 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() ) );
-
        assertTrue( name.getUpName().equals( "ou= Some   People   ,dc = eXample,dc= cOm" ) );
 
        Name result = LdapDN.normalize( name, oids );
@@ -2218,7 +2244,7 @@
        assertTrue( result.toString().equals( "ou=some people,dc=example,dc=com" ) );
    }
 
-   public void testRdnGetTypeUpName() throws Exception
+   @Test public void testRdnGetTypeUpName() throws Exception
    {
        List<String> list = new ArrayList<String>();
        list.add( "ou= Some   People   " );
@@ -2226,27 +2252,15 @@
        list.add( "dc= cOm" );
        LdapDN name = new LdapDN( list.iterator() );
 
-       Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
-
-       oids.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-
        assertTrue( name.getUpName().equals( "ou= Some   People   ,dc = eXample,dc= cOm" ) );
 
        Rdn rdn = name.getRdn();
        
        assertEquals( "ou= Some   People   ", rdn.getUpName() );
-       //assertEquals( "2.5.4.11=some people", rdn.getNormName() );
        assertEquals( "ou", rdn.getNormType() );
        assertEquals( "ou", rdn.getUpType() );
-       //assertEquals( "some people", rdn.getNormalizedValue() );
-       //assertEquals( "ou= Some   People   ", rdn.getUpValue() );
 
-       LdapDN result = LdapDN.normalize( name, oids );
+       LdapDN result = LdapDN.normalize( name, oidOids );
 
        assertTrue( result.getNormName().equals( "2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com" ) );
        assertTrue( name.getUpName().equals( "ou= Some   People   ,dc = eXample,dc= cOm" ) );
@@ -2254,29 +2268,17 @@
        Rdn rdn2 = result.getRdn();
        
        assertEquals( "ou= Some   People   ", rdn2.getUpName() );
-       //assertEquals( "2.5.4.11=some people", rdn2.getNormName() );
        assertEquals( "2.5.4.11", rdn2.getNormType() );
        assertEquals( "ou", rdn2.getUpType() );
-       //assertEquals( "some people", rdn2.getNormalizedValue() );
-       //assertEquals( "ou= Some   People   ", rdn2.getUpValue() );
    }
 
    /**
     * Class to test for toOid( Name, Map) with a NULL dn
     */
-   public void testLdapNameToNameEmpty() throws Exception
+   @Test public void testLdapNameToNameEmpty() throws Exception
    {
        LdapDN name = new LdapDN();
 
-       Map<String, OidNormalizer> 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() ) );
-
        Name result = LdapDN.normalize( name, oids );
        assertTrue( result.toString().equals( "" ) );
    }
@@ -2285,21 +2287,12 @@
    /**
     * Class to test for toOid( Name, Map) with a multiple NameComponent
     */
-   public void testLdapNameToNameMultiNC() throws Exception
+   @Test public void testLdapNameToNameMultiNC() throws Exception
    {
        LdapDN name = new LdapDN(
            "2.5.4.11= Some   People   + 0.9.2342.19200300.100.1.25=  And   Some anImAls,0.9.2342.19200300.100.1.25 = eXample,dc= cOm" );
 
-       Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
-
-       oids.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-
-       Name result = LdapDN.normalize( name, oids );
+       Name result = LdapDN.normalize( name, oidOids );
 
        assertEquals( result.toString(), "0.9.2342.19200300.100.1.25=and some animals+2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com" );
        assertTrue( ( ( LdapDN ) result )
@@ -2312,21 +2305,12 @@
    /**
     * Class to test for toOid( Name, Map) with a multiple NameComponent
     */
-   public void testLdapNameToNameAliasMultiNC() throws Exception
+   @Test public void testLdapNameToNameAliasMultiNC() throws Exception
    {
        LdapDN name = new LdapDN(
            "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent = eXample,0.9.2342.19200300.100.1.25= cOm" );
 
-       Map<String, OidNormalizer> oids = new HashMap<String, OidNormalizer>();
-
-       oids.put( "dc", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "domaincomponent", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "0.9.2342.19200300.100.1.25", new OidNormalizer( "0.9.2342.19200300.100.1.25", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "ou", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "organizationalUnitName", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-       oids.put( "2.5.4.11", new OidNormalizer( "2.5.4.11", new DeepTrimToLowerNormalizer() ) );
-
-       LdapDN result = LdapDN.normalize( name, oids );
+       LdapDN result = LdapDN.normalize( name, oidOids );
 
        assertTrue( result.toString().equals( "0.9.2342.19200300.100.1.25=and some animals+2.5.4.11=some people,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com" ) );
        assertTrue( result
@@ -2341,9 +2325,10 @@
     *
     * @throws Exception
     */
-   public void testNameSerialization() throws Exception
+   @Test public void testNameSerialization() throws Exception
    {
        LdapDN name = new LdapDN( "ou= Some   People   + dc=  And   Some anImAls,dc = eXample,dc= cOm" );
+       name.normalize( oids );
 
        FileOutputStream fOut = null;
        ObjectOutputStream oOut = null;
@@ -2420,23 +2405,21 @@
    }
 
    /**
-    * Class to test for hashCode(). Commmented as the values are not normalized.
+    * Class to test for hashCode().
     */
-   //public void testLdapNameHashCode() throws Exception
-   //{
-   //    Name name1 = new LdapDN(
-   //        "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent = eXample,0.9.2342.19200300.100.1.25= cOm" );
-   //
-   //    Name name2 = new LdapDN(
-   //        "2.5.4.11=some people+domainComponent=and some animals,DomainComponent=example,0.9.2342.19200300.100.1.25=com" );
-   //
-   //    assertEquals( name1.hashCode(), name2.hashCode() );
-   //}
+   @Test public void testLdapNameHashCode() throws Exception
+   {
+       Name name1 = LdapDN.normalize( "2.5.4.11= Some   People   + domainComponent=  And   Some anImAls,DomainComponent = eXample,0.9.2342.19200300.100.1.25= cOm", oids );
+       
+       Name name2 = LdapDN.normalize( "2.5.4.11=some people+domainComponent=and some animals,DomainComponent=example,0.9.2342.19200300.100.1.25=com", oids );
+   
+       assertEquals( name1.hashCode(), name2.hashCode() );
+   }
 
    /**
     * Test for DIRSERVER-191
     */
-   public void testName() throws NamingException
+   @Test public void testName() throws NamingException
    {
        Name jName = new javax.naming.ldap.LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2448,7 +2431,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testGetPrefixName() throws NamingException
+   @Test public void testGetPrefixName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2463,7 +2446,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testGetSuffix() throws NamingException
+   @Test public void testGetSuffix() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2478,7 +2461,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testAddStringName() throws NamingException
+   @Test public void testAddStringName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2491,7 +2474,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testAddIntString() throws NamingException
+   @Test public void testAddIntString() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2512,7 +2495,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testAddAllName() throws NamingException
+   @Test public void testAddAllName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2525,7 +2508,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testAddAllIntName() throws NamingException
+   @Test public void testAddAllIntName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2548,7 +2531,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testStartsWithName() throws NamingException
+   @Test public void testStartsWithName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2562,7 +2545,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testEndsWithName() throws NamingException
+   @Test public void testEndsWithName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2576,7 +2559,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testRemoveName() throws NamingException
+   @Test public void testRemoveName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2591,7 +2574,7 @@
    /**
     * Test for DIRSERVER-191
     */
-   public void testGetAllName() throws NamingException
+   @Test public void testGetAllName() throws NamingException
    {
        Name jName = new LdapName("cn=four,cn=three,cn=two,cn=one");
        Name aName = new LdapDN("cn=four,cn=three,cn=two,cn=one");
@@ -2609,7 +2592,7 @@
     * Test for DIRSERVER-642
     * @throws NamingException
     */
-   public void testDoubleQuoteInNameDIRSERVER_642() throws NamingException
+   @Test public void testDoubleQuoteInNameDIRSERVER_642() throws NamingException
    {
        Name name1 = new LdapDN( "cn=\"Kylie Minogue\",dc=example,dc=com" );
        Name name2 = new LdapName( "cn=\"Kylie Minogue\",dc=example,dc=com" );
@@ -2628,7 +2611,7 @@
     * Test for DIRSERVER-642
     * @throws NamingException
     */
-   public void testDoubleQuoteInNameDIRSERVER_642_1() throws NamingException
+   @Test public void testDoubleQuoteInNameDIRSERVER_642_1() throws NamingException
    {
        LdapDN dn = new LdapDN( "cn=\" Kylie Minogue \",dc=example,dc=com" );
 
@@ -2641,7 +2624,7 @@
     * Test for DIRSTUDIO-250
     * @throws NamingException
     */
-   public void testDoubleQuoteWithSpecialCharsInNameDIRSERVER_250() throws NamingException
+   @Test public void testDoubleQuoteWithSpecialCharsInNameDIRSERVER_250() throws NamingException
    {
        LdapDN dn = new LdapDN( "a=\"b,c\"" );
 
@@ -2654,7 +2637,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testLeadingAndTrailingSpacesDIRSERVER_184() throws NamingException
+   @Test public void testLeadingAndTrailingSpacesDIRSERVER_184() throws NamingException
    {
        LdapDN name = new LdapDN( "dn= \\ four spaces leading and 3 trailing \\  " );
 
@@ -2666,7 +2649,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_1()
+   @Test public void testDIRSERVER_184_1()
    {
        try
        {
@@ -2682,7 +2665,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_2()
+   @Test public void testDIRSERVER_184_2()
    {
        try
        {
@@ -2698,7 +2681,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_3() throws NamingException
+   @Test public void testDIRSERVER_184_3() throws NamingException
    {
        LdapDN name = new LdapDN( "dn=\\# a leading pound" );
 
@@ -2710,7 +2693,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_4() throws NamingException
+   @Test public void testDIRSERVER_184_4() throws NamingException
    {
        LdapDN name = new LdapDN( "dn=a middle \\# pound" );
 
@@ -2722,7 +2705,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_5() throws NamingException
+   @Test public void testDIRSERVER_184_5() throws NamingException
    {
        LdapDN name = new LdapDN( "dn=a trailing pound \\#" );
 
@@ -2734,7 +2717,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_6()
+   @Test public void testDIRSERVER_184_6()
    {
        try
        {
@@ -2750,7 +2733,7 @@
     * Test for DIRSERVER-184
     * @throws NamingException
     */
-   public void testDIRSERVER_184_7()
+   @Test public void testDIRSERVER_184_7()
    {
        try
        {
@@ -2762,7 +2745,7 @@
        }
    }
 
-   public void testDIRSERVER_631_1() throws NamingException
+   @Test public void testDIRSERVER_631_1() throws NamingException
    {
        LdapDN name = new LdapDN( "cn=Bush\\, Kate,dc=example,dc=com" );
 
@@ -2777,7 +2760,7 @@
     * which are OIDs, and with one RDN which has more than one atav.
     * @throws NamingException
     */
-   public void testDNWithMultiOidsRDN() throws NamingException
+   @Test public void testDNWithMultiOidsRDN() throws NamingException
    {
        LdapDN name = new LdapDN( "0.9.2342.19200300.100.1.1=00123456789+2.5.4.3=pablo picasso,2.5.4.11=search,2.5.4.10=imc,2.5.4.6=us" );
        assertEquals( "0.9.2342.19200300.100.1.1=00123456789+2.5.4.3=pablo picasso,2.5.4.11=search,2.5.4.10=imc,2.5.4.6=us", name.toString() );
@@ -2785,7 +2768,7 @@
    }
    
    
-   public void testNameAddAll() throws NamingException
+   @Test public void testNameAddAll() throws NamingException
    {
        Properties props = new Properties();
        props.setProperty( "jndi.syntax.direction", "right_to_left" );
@@ -2803,12 +2786,11 @@
        ldapDn = new LdapDN( "cn=xyz" );
        ldapDn.addAll( 0, dn );
        
-       System.out.println( ldapDn.toString() );
        assertEquals( "cn=xyz,cn=blah,dc=example,dc=com", ldapDn.toString() );
    }
    
    
-   public void testDNEquals() throws NamingException
+   @Test public void testDNEquals() throws NamingException
    {
        LdapDN dn1 = new LdapDN( "a=b,c=d,e=f" );
        LdapDN dn2 = new LdapDN( "a=b\\,c\\=d,e=f" );
@@ -2817,7 +2799,7 @@
    }
    
    
-   public void testDNAddEmptyString() throws NamingException
+   @Test public void testDNAddEmptyString() throws NamingException
    {
        LdapDN dn = new LdapDN();
        assertTrue( dn.size() == 0 );
@@ -2828,7 +2810,7 @@
    /**
     * This leads to the bug in DIRSERVER-832.
     */
-   public void testPreserveAttributeIdCase() throws NamingException
+   @Test public void testPreserveAttributeIdCase() throws NamingException
    {
        LdapDN dn = new LdapDN( "uID=kevin" );
        assertEquals( "uID", dn.getRdn().getUpType() );
@@ -2838,7 +2820,7 @@
     /**
      * Tests the LdapDN.isValid() method.
      */
-    public void testIsValid()
+    @Test public void testIsValid()
     {
         assertTrue( LdapDN.isValid( "" ) );
 
@@ -2852,5 +2834,4 @@
         assertFalse( LdapDN.isValid( " = " ) );
         assertFalse( LdapDN.isValid( " = a" ) );
     }
-
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java?rev=612325&r1=612324&r2=612325&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDnParserTest.java Tue Jan 15 16:33:09 2008
@@ -574,15 +574,13 @@
 
         try
         {
-            String res = parser.parse( input ).toString();
-            System.out.println( res );
+            parser.parse( input ).toString();
+            fail( "Should never rech this point" );
         }
         catch ( NamingException ne )
         {
             assertTrue( true );
             return;
         }
-
-        fail( "Should never rech this point" );
     }
 }

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java?rev=612325&r1=612324&r2=612325&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java (original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/RdnTest.java Tue Jan 15 16:33:09 2008
@@ -20,6 +20,11 @@
 package org.apache.directory.shared.ldap.name;
 
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.util.Iterator;
 
 import javax.naming.InvalidNameException;
@@ -33,6 +38,7 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.name.RdnParser;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
 
 
 /**
@@ -611,5 +617,214 @@
         // hash must be escaped at the beginning of a string
         assertEquals( "\\#a#b", Rdn.escapeValue( "#a#b" ) );
         assertEquals( "\\##a#b", Rdn.escapeValue( "##a#b" ) );
+    }
+
+
+    /** Serialization tests ------------------------------------------------- */
+
+    /**
+     * Test serialization of an empty RDN
+     */
+    @Test
+    public void testEmptyRDNSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( "" );
+
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    @Test
+    public void testNullRdnSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn();
+
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn
+     */
+    @Test
+    public void testSimpleRdnSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( "a=b" );
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn
+     */
+    @Test
+    public void testSimpleRdn2Serialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( " ABC  = DEF " );
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+    
+    /**
+     * Test serialization of a simple Rdn with no value
+     */
+    @Test
+    public void testSimpleRdnNoValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( " ABC  =" );
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+    
+    /**
+     * Test serialization of a simple Rdn with one value
+     */
+    @Test
+    public void testSimpleRdnOneValueSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( " ABC  = def " );
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+    
+    /**
+     * Test serialization of a simple Rdn with three values
+     */
+    @Test
+    public void testSimpleRdnThreeValuesSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( " A = a + B = b + C = c " );
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+    
+    /**
+     * Test serialization of a simple Rdn with three unordered values
+     */
+    @Test
+    public void testSimpleRdnThreeValuesUnorderedSerialization() throws NamingException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( " B = b + A = a + C = c " );
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        rdn.writeExternal( out );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = new Rdn();
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
     }
 }



Mime
View raw message