directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1083238 [1/2] - in /directory: apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/ shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/ shared/trunk/i18n/src/main/resources/org/apache/directory/sh...
Date Sat, 19 Mar 2011 17:51:07 GMT
Author: elecharny
Date: Sat Mar 19 17:51:06 2011
New Revision: 1083238

URL: http://svn.apache.org/viewvc?rev=1083238&view=rev
Log:
o Modified some error message
o Correctly injecting the SchemaManager in Rdn when normalizing it
o Fixed the tests to use valid RDN and DN (DN and RDN that can be parsed by a schema manager aware parser)
o Moved some tests in shared-integ

Added:
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
      - copied, changed from r1083163, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java
      - copied, changed from r1083106, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java
      - copied, changed from r1082924, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java
      - copied, changed from r1083011, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareDnSerializationTest.java
      - copied, changed from r1083106, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareDnSerializationTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnSerializationTest.java
      - copied, changed from r1083011, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnTest.java
Removed:
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/
Modified:
    directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/ComplexDnParser.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java?rev=1083238&r1=1083237&r2=1083238&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedUserClassFilterTest.java Sat Mar 19 17:51:06 2011
@@ -290,7 +290,7 @@ public class RelatedUserClassFilterTest
             
             try
             {
-                names.add( new Dn( schemaManager, "dummy=dummy" ) );
+                names.add( new Dn( schemaManager, "cn=dummy" ) );
             }
             catch ( LdapInvalidDnException e )
             {

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=1083238&r1=1083237&r2=1083238&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Sat Mar 19 17:51:06 2011
@@ -343,7 +343,7 @@ public enum I18n
     ERR_04206( "ERR_04206" ),
     ERR_04207( "ERR_04207" ),
     ERR_04208( "ERR_04208" ),
-    ERR_04209( "ERR_04209" ),
+    ERR_04209_EMPTY_TYPE_NOT_ALLOWED( "ERR_04209_EMPTY_TYPE_NOT_ALLOWED" ),
     ERR_04210( "ERR_04210" ),
     ERR_04211( "ERR_04211" ),
     ERR_04212( "ERR_04212" ),
@@ -402,7 +402,7 @@ public enum I18n
     ERR_04265( "ERR_04265" ),
     ERR_04266( "ERR_04266" ),
     ERR_04267( "ERR_04267" ),
-    ERR_04268( "ERR_04268" ),
+    ERR_04268_OID_NOT_FOUND( "ERR_04268_OID_NOT_FOUND" ),
     ERR_04269( "ERR_04269" ),
     ERR_04270( "ERR_04270" ),
     ERR_04271( "ERR_04271" ),
@@ -576,7 +576,7 @@ public enum I18n
     ERR_04439( "ERR_04439" ),
     ERR_04440( "ERR_04440" ),
     ERR_04441( "ERR_04441" ),
-    ERR_04442_NULL_AT_NOT_ALLOWED( "ERR_04442_NULL_AT_NOT_ALLOWED" ),
+    ERR_04442_NOT_EXISTING_ATRIBUTE_TYPE( "ERR_04442_NOT_EXISTING_ATRIBUTE_TYPE" ),
     ERR_04443( "ERR_04443" ),
     ERR_04444( "ERR_04444" ),
     ERR_04445( "ERR_04445" ),

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=1083238&r1=1083237&r2=1083238&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties (original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties Sat Mar 19 17:51:06 2011
@@ -308,7 +308,7 @@ ERR_04182=Count not invoke the Provider'
 ERR_04183=Count not invoke the Provider's factory method: {0}.getProvider() - it does seem to be a public method!
 ERR_04184=Call to Provider's factory method\: {0}.getProvider() threw the following exception\:\n{1}
 ERR_04185=RFC 2251 [Section 4.11]: Abandon, Bind, Unbind, and StartTLS operations cannot be abandoned.
-ERR_04186=Unrecogniced value ''{0}'' for {1} JNDI property.\nExpected a value of either always, never, searching, or finding.
+ERR_04186=Unrecognized value ''{0}'' for {1} JNDI property.\nExpected a value of either always, never, searching, or finding.
 ERR_04187=Class has bug: check for valid enumeration values
 ERR_04188=The type cannot be empty or null
 ERR_04189=The User Provided type cannot be empty or null
@@ -331,7 +331,7 @@ ERR_04205=Exceeded number of elements in
 ERR_04206=The posn({0}) should be in the range [0, {1}]
 ERR_04207=The clone operation has failed
 ERR_04208=Assertion failure : cannot clone the object
-ERR_04209=Empty type not allowed in a DN
+ERR_04209_EMPTY_TYPE_NOT_ALLOWED=Empty type not allowed in a DN
 ERR_04210=Cannot serialize a NULL DN
 ERR_04211=The DN should have been normalized before being serialized
 ERR_04212=The DN should have been normalized before being serialized {0}
@@ -390,7 +390,7 @@ ERR_04264=DITStructureRule with RuleId {
 ERR_04265=DITStructureRule for ruleId {0} does not exist!
 ERR_04266=name cannot be null
 ERR_04267=Looks like the arg is not a numeric OID
-ERR_04268=OID {0} not found in oid to schema name map!
+ERR_04268_OID_NOT_FOUND=OID '{0}' not found in oid to schema name map!
 ERR_04269={0} for OID {1} does not exist!
 ERR_04270={0} with OID {1} already registered!
 ERR_04271={0} with name {1} already registered!
@@ -564,7 +564,7 @@ ERR_04438=The style must not be null
 ERR_04439=Usage - java org.mortbay.util.UnixCrypt <key> <salt>
 ERR_04440=Crypt={0}
 ERR_04441=Cannot modify the SchemaObject {0}, it has been locked
-ERR_04442_NULL_AT_NOT_ALLOWED=The AttributeType parameter should not be null
+ERR_04442_NOT_EXISTING_ATRIBUTE_TYPE=The AttributeType {0} does not exist
 ERR_04443=Failed to compare normalized values for {0} and {1}
 ERR_04444=I don't really know how to compare anything other than ServerBinaryValues at this point in time.
 ERR_04445=There is no Syntax associated with this attributeType

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java?rev=1083238&r1=1083237&r2=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java Sat Mar 19 17:51:06 2011
@@ -25,8 +25,6 @@ import static org.junit.Assert.fail;
 
 import java.text.ParseException;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schemaloader.JarLdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
@@ -34,6 +32,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Unit tests class for ACIItem checker (wrapper).
@@ -93,7 +94,7 @@ public class ACIItemChekerTest
             "         userClasses " +
             "         {" +
             "           allUsers  , " +
-            "           userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } ," +
+            "           userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } ," +
             "           subtree { { base \"ou=people\" } } " +
             "         }   , " +
             "         grantsAndDenials  {  denyCompare  , grantModify } " +
@@ -103,7 +104,7 @@ public class ACIItemChekerTest
             "         userClasses " +
             "         {" +
             "           allUsers  , " +
-            "           userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } ," +
+            "           userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } ," +
             "           subtree { { base \"ou=people\" } } " +
             "         }   , " +
             "         grantsAndDenials  {  denyCompare  , grantModify } " +
@@ -126,7 +127,7 @@ public class ACIItemChekerTest
             + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
 
         checker.parse( spec );
@@ -162,9 +163,9 @@ public class ACIItemChekerTest
             + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry , "
             + " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
             + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "itemPermissions { { userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "{ precedence 10, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
 
         checker.parse( spec );
@@ -178,7 +179,7 @@ public class ACIItemChekerTest
             + "itemOrUserFirst userFirst:  { userClasses {  name { \"ou=people,cn=ersin\" }, allUsers, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {dc=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
 
         checker.parse( spec );
@@ -192,9 +193,9 @@ public class ACIItemChekerTest
             + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry , "
             + " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
             + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { grantsAndDenials  {  denyCompare  , grantModify }, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "itemPermissions { { grantsAndDenials  {  denyCompare  , grantModify }, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "{ precedence 10, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
 
         checker.parse( spec );
@@ -208,7 +209,7 @@ public class ACIItemChekerTest
             + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
 
         checker.parse( spec );
@@ -221,7 +222,7 @@ public class ACIItemChekerTest
         String spec = "{   itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }, "
             + " identificationTag \"id2\"   , authenticationLevel none, precedence 14 }   ";
 

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=1083238&r1=1083237&r2=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java Sat Mar 19 17:51:06 2011
@@ -27,8 +27,6 @@ import static org.junit.Assert.fail;
 
 import java.text.ParseException;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schemaloader.JarLdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
@@ -36,6 +34,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 /**
  * Unit tests class for ACIItem parser (wrapper).
  * 
@@ -120,7 +121,7 @@ public class ACIItemParserTest
             "      userClasses " +
             "        {" +
             "          allUsers  , " +
-            "          userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } , " +
+            "          userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } , " +
             "          subtree { { base \"ou=people\" } } " +
             "        }   , " +
             "      grantsAndDenials  {  denyCompare  , grantModify } " +
@@ -130,7 +131,7 @@ public class ACIItemParserTest
             "      userClasses " +
             "      {" +
             "        allUsers  , " +
-            "        userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } ," +
+            "        userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } ," +
             "        subtree { { base \"ou=people\" } } " +
             "      }   , " +
             "      grantsAndDenials  {  denyCompare  , grantModify } } " +
@@ -149,12 +150,42 @@ public class ACIItemParserTest
     @Test 
     public void testUserFirst() throws Exception
     {
-        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
-            + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
-            + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-            + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
-            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
+        String spec = 
+            "{ " +
+            "  identificationTag \"id2\"   , " +
+            "  precedence 14, " +
+            "  authenticationLevel none  , " +
+            "  itemOrUserFirst userFirst:  " +
+            "  { " +
+            "    userClasses " +
+            "    {  " +
+            "      allUsers  , " +
+            "      name { \"ou=people,cn=ersin\" }, " +
+            "      subtree " +
+            "      {" +
+            "        { base \"ou=system\" }, " +
+            "        { " +
+            "          base \"ou=ORGANIZATIONUNIT\"," +
+            "          minimum  1, " +
+            "          maximum   2 " +
+            "        } " +
+            "      } " +
+            "    }  , " +
+            "    userPermissions " +
+            "    { " +
+            "      { " +
+            "        protectedItems" +
+            "        { " +
+            "          entry  , " +
+            "          attributeType { cn  , ou }  , " +
+            "          attributeValue {cn=y,sn=n,dc=l} , " +
+            "          rangeOfValues (cn=ErsinEr) " +
+            "        }  , " +
+            "        grantsAndDenials { grantBrowse } " +
+            "      } " +
+            "    } " +
+            "  }  " +
+            "}   ";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );
@@ -188,14 +219,54 @@ public class ACIItemParserTest
     @Test 
     public void testOrderOfProtectedItemsDoesNotMatter() throws Exception
     {
-        String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel simple  , "
-            + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry , "
-            + " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
-            + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
-            + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
-            + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
+        String spec = 
+            " {  " +
+            "   identificationTag  \"id1\" , " +
+            "   precedence 114  , " +
+            "   authenticationLevel simple  , " +
+            "   itemOrUserFirst itemFirst  :" +
+            "   { " +
+            "     protectedItems  " +
+            "     { " +
+            "       attributeType { 2.5.4.3    , ou }, " +
+            "       entry , " +
+            "       rangeOfValues (cn=ErsinEr) , " +
+            "       attributeValue { ou=people  , cn=Ersin  }," +
+            "       classes and : " +
+            "       { item: xyz , or:{item:X,item:Y}   }" +
+            "     }  , " +
+            "     itemPermissions " +
+            "     { " +
+            "       { " +
+            "         userClasses " +
+            "         {" +
+            "           allUsers  , " +
+            "           userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,sn=d\" } " +
+            "           , " +
+            "           subtree " +
+            "           { " +
+            "             { base \"ou=people\" } " +
+            "           } " +
+            "         }   , " +
+            "         grantsAndDenials  " +
+            "         {  " +
+            "           denyCompare  , " +
+            "           grantModify " +
+            "         } " +
+            "       }," +
+            "       { " +
+            "         precedence 10, " +
+            "         userClasses " +
+            "         {" +
+            "           allUsers  , " +
+            "           userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } " +
+            "           , subtree { { base \"ou=people\" } } " +
+            "         }   , " +
+            "         grantsAndDenials  {  denyCompare  , grantModify } " +
+            "       } " +
+            "     } " +
+            "   }" +
+            " }";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );
@@ -205,12 +276,42 @@ public class ACIItemParserTest
     @Test 
     public void testOrderOfUserClassesDoesNotMatter() throws Exception
     {
-        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
-            + "itemOrUserFirst userFirst:  { userClasses {  name { \"ou=people,cn=ersin\" }, allUsers, "
-            + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-            + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
-            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
+        String spec = 
+            "{ " +
+            "  identificationTag \"id2\"   , " +
+            "  precedence 14, " +
+            "  authenticationLevel none  , " +
+            "  itemOrUserFirst userFirst:  " +
+            "  { " +
+            "    userClasses " +
+            "    {  " +
+            "      name { \"ou=people,cn=ersin\" }, " +
+            "      allUsers, " +
+            "      subtree " +
+            "      {" +
+            "        { base \"ou=system\" }, " +
+            "        { " +
+            "          base \"ou=ORGANIZATIONUNIT\"," +
+            "          minimum  1, " +
+            "          maximum   2 " +
+            "        } " +
+            "      } " +
+            "    }  , " +
+            "    userPermissions " +
+            "    { " +
+            "      { " +
+            "        protectedItems" +
+            "        { " +
+            "          entry  , " +
+            "          attributeType { cn  , ou }  , " +
+            "          attributeValue {cn=y,sn=n,dc=l} , " +
+            "          rangeOfValues (cn=ErsinEr) " +
+            "        }  , " +
+            "        grantsAndDenials { grantBrowse } " +
+            "      } " +
+            "    } " +
+            "  }  " +
+            "}";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );
@@ -266,14 +367,48 @@ public class ACIItemParserTest
     @Test 
     public void testItemPermissionComponentsOrderDoesNotMatter() throws Exception
     {
-        String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel simple  , "
-            + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry , "
-            + " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
-            + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { grantsAndDenials  {  denyCompare  , grantModify }, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
-            + " , subtree { { base \"ou=people\" } } }   },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
-            + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
+        String spec = 
+            " {  " +
+            "   identificationTag  \"id1\" , " +
+            "   precedence 114  , " +
+            "   authenticationLevel simple  , " +
+            "   itemOrUserFirst itemFirst  :" +
+            "   { " +
+            "     protectedItems  " +
+            "     { " +
+            "       attributeType { 2.5.4.3    , ou }, " +
+            "       entry , " +
+            "       rangeOfValues (cn=ErsinEr) , " +
+            "       attributeValue { ou=people  , cn=Ersin  }," +
+            "       classes and : { item: xyz , or:{item:X,item:Y}   }" +
+            "     }  , " +
+            "     itemPermissions " +
+            "     { " +
+            "       { " +
+            "         grantsAndDenials  " +
+            "         {  " +
+            "           denyCompare  , grantModify " +
+            "         }, " +
+            "         userClasses " +
+            "         {" +
+            "           allUsers  , " +
+            "           userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } " +
+            "           , subtree { { base \"ou=people\" } } " +
+            "         }   " +
+            "       }," +
+            "       { " +
+            "         precedence 10, " +
+            "         userClasses " +
+            "         {" +
+            "           allUsers  , " +
+            "           userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } " +
+            "           , subtree { { base \"ou=people\" } } " +
+            "         }   , " +
+            "         grantsAndDenials  {  denyCompare  , grantModify } " +
+            "       } " +
+            "     } " +
+            "   }" +
+            " }";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );
@@ -308,12 +443,42 @@ public class ACIItemParserTest
     @Test 
     public void testUserPermissionComponentsOrderDoesNotMatter() throws Exception
     {
-        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
-            + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
-            + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-            + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
-            + "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
+        String spec = 
+            "{ " +
+            "  identificationTag \"id2\"   , " +
+            "  precedence 14, " +
+            "  authenticationLevel none  , " +
+            "  itemOrUserFirst userFirst:  " +
+            "  { " +
+            "    userClasses " +
+            "    {  " +
+            "      allUsers  , " +
+            "      name { \"ou=people,cn=ersin\" }, " +
+            "      subtree " +
+            "      {" +
+            "        { base \"ou=system\" }, " +
+            "        { " +
+            "          base \"ou=ORGANIZATIONUNIT\"," +
+            "          minimum  1, " +
+            "          maximum   2 " +
+            "        } " +
+            "      } " +
+            "    }  , " +
+            "    userPermissions " +
+            "    { " +
+            "      { " +
+            "        grantsAndDenials { grantBrowse }, " +
+            "        protectedItems" +
+            "        { " +
+            "          entry  , " +
+            "          attributeType { cn  , ou }  , " +
+            "          attributeValue {cn=y,sn=n,dc=l} , " +
+            "          rangeOfValues (cn=ErsinEr) " +
+            "        }  " +
+            "      } " +
+            "    } " +
+            "  }  " +
+            "}   ";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );
@@ -345,12 +510,42 @@ public class ACIItemParserTest
     @Test 
     public void testOrderOfMainACIComponentsDoesNotMatter() throws Exception
     {
-        String spec = "{   itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
-            + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-            + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
-            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }, "
-            + " identificationTag \"id2\"   , authenticationLevel none, precedence 14 }   ";
+        String spec = 
+            "{   " +
+            "  itemOrUserFirst userFirst:  " +
+            "  { " +
+            "    userClasses " +
+            "    {  " +
+            "      allUsers  , " +
+            "      name { \"ou=people,cn=ersin\" }, " +
+            "      subtree " +
+            "      {" +
+            "        { base \"ou=system\" }, " +
+            "        { " +
+            "          base \"ou=ORGANIZATIONUNIT\"," +
+            "          minimum  1, " +
+            "          maximum   2 " +
+            "        } " +
+            "      } " +
+            "    }  , " +
+            "    userPermissions " +
+            "    { " +
+            "      { " +
+            "        protectedItems" +
+            "        { " +
+            "          entry  , " +
+            "          attributeType { cn  , ou }  , " +
+            "          attributeValue {cn=y,sn=n,dc=l} , " +
+            "          rangeOfValues (cn=ErsinEr) " +
+            "        }  , " +
+            "        grantsAndDenials { grantBrowse } " +
+            "      } " +
+            "    } " +
+            "  }, " +
+            "  identificationTag \"id2\"   , " +
+            "  authenticationLevel none, " +
+            "  precedence 14 " +
+            "}   ";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );
@@ -536,12 +731,42 @@ public class ACIItemParserTest
     @Test 
     public void testUserClassParentOfEntry() throws Exception
     {
-        String spec = "{ identificationTag \"id\"   , precedence 10, authenticationLevel none  , "
-            + "itemOrUserFirst userFirst:  { userClasses {  parentOfEntry  , name { \"cn=ersin,ou=people\" }, "
-            + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
-            + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
-            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
+        String spec = 
+            "{ " +
+            "  identificationTag \"id\"   , " +
+            "  precedence 10, " +
+            "  authenticationLevel none  , " +
+            "  itemOrUserFirst userFirst:  " +
+            "  { " +
+            "    userClasses " +
+            "    {  " +
+            "      parentOfEntry  , " +
+            "      name { \"cn=ersin,ou=people\" }, " +
+            "      subtree " +
+            "      {" +
+            "        { base \"ou=system\" }, " +
+            "        { " +
+            "          base \"ou=ORGANIZATIONUNIT\"," +
+            "          minimum  1, " +
+            "          maximum   2 " +
+            "        } " +
+            "      } " +
+            "    }  , " +
+            "    userPermissions " +
+            "    { " +
+            "      { " +
+            "        protectedItems" +
+            "        { " +
+            "          entry  , " +
+            "          attributeType { cn  , ou }  , " +
+            "          attributeValue {cn=y,sn=n,dc=l} , " +
+            "          rangeOfValues (cn=ErsinEr) " +
+            "        }  , " +
+            "        grantsAndDenials { grantBrowse } " +
+            "      } " +
+            "    } " +
+            "  } " +
+            "}   ";
 
         ACIItem item = parser.parse( spec );
         checkItemToString( spec, item );

Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java (from r1083163, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java&r1=1083163&r2=1083238&rev=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/AvaTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java Sat Mar 19 17:51:06 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.name;
+package org.apache.directory.shared.ldap.model.name;
 
 
 import static org.junit.Assert.assertEquals;

Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java (from r1083106, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java&r1=1083106&r2=1083238&rev=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/DnTest.java Sat Mar 19 17:51:06 2011
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.directory.shared.ldap.name;
+package org.apache.directory.shared.ldap.model.name;
 
 
 import static junit.framework.Assert.assertNotNull;

Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java (from r1082924, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java&r1=1082924&r2=1083238&rev=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/MultiThreadedTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/MultiThreadedTest.java Sat Mar 19 17:51:06 2011
@@ -17,7 +17,7 @@
  *  under the License.
  *
  */
-package org.apache.directory.shared.ldap.name;
+package org.apache.directory.shared.ldap.model.name;
 
 
 import static org.junit.Assert.assertEquals;

Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java (from r1083011, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java&r1=1083011&r2=1083238&rev=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareAvaSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java Sat Mar 19 17:51:06 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.name;
+package org.apache.directory.shared.ldap.model.name;
 
 
 import static org.junit.Assert.assertEquals;

Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareDnSerializationTest.java (from r1083106, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareDnSerializationTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareDnSerializationTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareDnSerializationTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareDnSerializationTest.java&r1=1083106&r2=1083238&rev=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareDnSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareDnSerializationTest.java Sat Mar 19 17:51:06 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.name;
+package org.apache.directory.shared.ldap.model.name;
 
 import static org.junit.Assert.assertEquals;
 

Copied: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnSerializationTest.java (from r1083011, directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnSerializationTest.java?p2=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnSerializationTest.java&p1=directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java&r1=1083011&r2=1083238&rev=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/name/SchemaAwareRdnSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnSerializationTest.java Sat Mar 19 17:51:06 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.name;
+package org.apache.directory.shared.ldap.model.name;
 
 import static org.junit.Assert.assertEquals;
 

Added: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnTest.java?rev=1083238&view=auto
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnTest.java (added)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareRdnTest.java Sat Mar 19 17:51:06 2011
@@ -0,0 +1,1227 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.model.name;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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 org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.util.Strings;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
+
+/**
+ * Test the Schema aware Rdn class
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrency()
+public class SchemaAwareRdnTest
+{
+    /** A null schemaManager used in tests */
+    private static SchemaManager schemaManager;
+    
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+        schemaManager = new DefaultSchemaManager();
+    }
+    
+
+    /**
+     * Test a null Rdn
+     */
+    @Test
+    public void testRdnNull()
+    {
+        assertEquals( "", new Rdn( schemaManager ).toString() );
+    }
+
+
+    /**
+     * test an empty Rdn
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnEmpty() throws LdapException
+    {
+        assertEquals( "", new Rdn( schemaManager, "" ).toString() );
+    }
+
+
+    /**
+     * test a simple Rdn : cn = b
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnSimple() throws LdapException
+    {
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn = b" ).getNormName() );
+    }
+
+
+    /**
+     * test a composite Rdn : cn = b, sn = e
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnComposite() throws LdapException
+    {
+        assertEquals( "2.5.4.3=b+2.5.4.4=d", new Rdn( schemaManager, "cn = b + sn = d" ).getNormName() );
+    }
+
+
+    /**
+     * test a composite Rdn with or without spaces: cn=b, cn =b, cn= b, cn = b, cn =
+     * b
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnCompositeWithSpace() throws LdapException
+    {
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn=b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn=b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn =b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn= b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn=b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn =b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn= b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn=b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn = b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn =b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn= b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn = b" ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn =b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn= b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, "cn = b " ).getNormName() );
+        assertEquals( "2.5.4.3=b", new Rdn( schemaManager, " cn = b " ).getNormName() );
+    }
+
+
+    /**
+     * test a simple Rdn with differents separators : cn = b + sn = d
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnSimpleMultivaluedAttribute() throws LdapException
+    {
+        String result = new Rdn( schemaManager, "cn = b + sn = d" ).getNormName();
+        assertEquals( "2.5.4.3=b+2.5.4.4=d", result );
+    }
+
+
+    /**
+     * test a composite Rdn with differents separators : cn=b+sn=d, gn=f + l=h +
+     * c=j
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnCompositeMultivaluedAttribute() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager, "cn =b+sn=d + gn=f + l  =h + c =j " );
+
+        // NameComponent are not ordered
+        assertEquals( "b", rdn.getValue( "CommonName" ) );
+        assertEquals( "d", rdn.getValue( "2.5.4.4" ) );
+        assertEquals( "f", rdn.getValue( "  gn  " ) );
+        assertEquals( "h", rdn.getValue( "L" ) );
+        assertEquals( "j", rdn.getValue( "c" ) );
+    }
+
+
+    /**
+     * test a simple Rdn with an oid prefix (uppercase) : OID.2.5.4.3 = azerty
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnOidUpper() throws LdapException
+    {
+        assertEquals( "2.5.4.3=azerty", new Rdn( schemaManager, "OID.2.5.4.3 =  azerty" ).getNormName() );
+    }
+
+
+    /**
+     * test a simple Rdn with an oid prefix (lowercase) : oid.12.34.56 = azerty
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnOidLower() throws LdapException
+    {
+        assertEquals( "2.5.4.3=azerty", new Rdn( schemaManager, "oid.2.5.4.3 = azerty" ).getNormName() );
+    }
+
+
+    /**
+     * test a simple Rdn with an oid attribut wiithout oid prefix : 2.5.4.3 =
+     * azerty
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnOidWithoutPrefix() throws LdapException
+    {
+        assertEquals( "2.5.4.3=azerty", new Rdn( schemaManager, "2.5.4.3 = azerty" ).getNormName() );
+    }
+
+
+    /**
+     * test a composite Rdn with an oid attribut wiithout oid prefix : 2.5.4.3 =
+     * azerty; 2.5.4.4 = test
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnCompositeOidWithoutPrefix() throws LdapException
+    {
+        String result = new Rdn( schemaManager, "2.5.4.3 = azerty + 2.5.4.4 = test" ).getNormName();
+        assertEquals( "2.5.4.3=azerty+2.5.4.4=test", result );
+    }
+
+
+    /**
+     * test a simple Rdn with pair char attribute value : l = \,\=\+\<\>\#\;\\\"\C3\A9"
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnPairCharAttributeValue() throws LdapException
+    {
+        String rdn = Strings.utf8ToString(new byte[]
+                {'l', '=', '\\', ',', '=', '\\', '+', '\\', '<', '\\', '>', '#', '\\', ';', '\\', '\\', '\\', '"', '\\',
+                        'C', '3', '\\', 'A', '9'});
+        assertEquals( "2.5.4.7=\\,=\\+\\<\\>#\\;\\\\\\\"\u00E9", new Rdn( schemaManager, rdn ).getNormName() );
+    }
+
+
+    /**
+     * test a simple Rdn with hexString attribute value : userCertificate = #0010A0AAFF
+     */
+    @Test
+    public void testRdnHexStringAttributeValue() throws LdapException
+    {
+        assertEquals( "2.5.4.36=#0010A0AAFF", new Rdn( schemaManager, "userCertificate = #0010A0AAFF" ).getNormName() );
+    }
+
+    /**
+     * test exception from illegal hexString attribute value : cn=#zz.
+     */
+    @Test
+    public void testBadRdnHexStringAttributeValue() throws LdapException
+    {
+        try
+        {
+            new Rdn( schemaManager, "cn=#zz" );
+            fail();
+        }
+        catch ( LdapException ine )
+        {
+            assertTrue( true );
+        }
+    }
+
+    /**
+     * test a simple Rdn with quoted attribute value : cn = "quoted \"value"
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRdnQuotedAttributeValue() throws LdapException
+    {
+        assertEquals( "2.5.4.3=quoted \\\"value", new Rdn( schemaManager, "cn = quoted \\\"value" ).getNormName() );
+    }
+
+
+    /**
+     * Test the clone method for a Rdn.
+     */
+    @Test
+    public void testParseRDNNull()
+    {
+        Rdn rdn = null;
+
+        try
+        {
+            RdnParser.parse( "cn=d", rdn );
+            fail();
+        }
+        catch ( LdapException ine )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    /**
+     * Test the clone method for a Rdn.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCloningOneNameComponent() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager, "CN", "cn", "B", "b" );
+
+        Rdn rdnClone = (Rdn) rdn.clone();
+
+        RdnParser.parse( "cn=d", rdn );
+
+        assertEquals( "b", rdnClone.getValue( "Cn" ) );
+    }
+
+
+    /**
+     * Test teh creation of a new Rdn
+     * 
+     * @throws org.apache.directory.shared.ldap.model.exception.LdapException
+     */
+    @Test
+    public void testRDNCreation() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager, "CN", "  b  " );
+        assertEquals( "2.5.4.3=b", rdn.getNormName() );
+        assertEquals( "CN=  b  ", rdn.getName() );
+    }
+
+
+    /**
+     * Test the clone method for a Rdn.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCloningTwoNameComponent() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager, "cn = b + sn = bb" );
+
+        Rdn rdnClone = (Rdn) rdn.clone();
+
+        rdn.clear();
+        RdnParser.parse( "l=d", rdn );
+
+        assertEquals( "b", rdnClone.getValue( "2.5.4.3" ) );
+        assertEquals( "bb", rdnClone.getValue( "SN" ) );
+        assertEquals( "", rdnClone.getValue( "l" ) );
+    }
+
+
+    /**
+     * Test the equals method for a Rdn.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNull() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager, " cn = b + sn = d + l = f + gn = h " );
+        Rdn rdn2 = null;
+        assertFalse( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a composite NC to a single NC.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNCS2NC() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager, " cn = b + sn = d + l = f + gn = h " );
+        Rdn rdn2 = new Rdn( schemaManager, " cn = b " );
+        assertFalse( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a single NC to a composite NC.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNC2NCS() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager, " sn = b " );
+        Rdn rdn2 = new Rdn( schemaManager, " cn = b + sn = d + l = f + gn = h " );
+
+        assertFalse( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a composite NCS to a composite NCS in the same order.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNCS2NCSOrdered() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager, " cn = b + sn = d + gn = f + l = h " );
+        Rdn rdn2 = new Rdn( schemaManager, " cn = b + sn = d + gn = f + l = h " );
+
+        assertTrue( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a composite NCS to a composite NCS in a different order.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNCS2NCSUnordered() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager, " cn = b + gn = f + l = h + sn = d " );
+        Rdn rdn2 = new Rdn( schemaManager, " cn = b + sn = d + gn = f + l = h " );
+
+        assertTrue( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a composite NCS to a different composite NCS.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNCS2NCSNotEquals() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager, " cn = f + sn = h + l = d " );
+        Rdn rdn2 = new Rdn( schemaManager, " l = d + cn = h + sn = h " );
+
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+    }
+
+
+    /**
+     * Test for DIRSHARED-2.
+     * The first ATAV is equal, the second or following ATAV differs.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testCompareSecondAtav() throws LdapException
+    {
+        // the second ATAV differs
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b + sn = d " );
+        Rdn rdn2 = new Rdn( schemaManager,  " cn = b + sn = y " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+
+        // the third ATAV differs
+        Rdn rdn3 = new Rdn( schemaManager,  " cn = b + sn = d + l = f " );
+        Rdn rdn4 = new Rdn( schemaManager,  " cn = b + sn = d + l = y " );
+        assertFalse( rdn3.equals( rdn4 ) );
+        assertFalse( rdn4.equals( rdn3 ) );
+
+        // the second ATAV differs in value only
+        Rdn rdn5 = new Rdn( schemaManager,  " cn = b + sn = c " );
+        Rdn rdn6 = new Rdn( schemaManager,  " cn = b + sn = y " );
+        assertFalse( rdn5.equals( rdn6 ) );
+        assertFalse( rdn6.equals( rdn5 ) );
+    }
+
+
+    /**
+     * Test for DIRSHARED-2.
+     * The compare operation should return a correct value (1 or -1)
+     * depending on the ATAVs, not on their position.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testCompareIndependentFromOrder() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b + sn = d " );
+        Rdn rdn2 = new Rdn( schemaManager,  " sn = d + cn = b " );
+        assertTrue( rdn1.equals( rdn2 ) );
+
+        rdn1 = new Rdn( schemaManager,  " cn = b + sn = e " );
+        rdn2 = new Rdn( schemaManager,  " sn = d + cn = b " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+
+        rdn1 = new Rdn( schemaManager,  " cn = b + sn = d " );
+        rdn2 = new Rdn( schemaManager,  " l = f + gn = h " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+    }
+
+
+    /**
+     * Test for DIRSHARED-3.
+     * Tests that equals() is invertable for single-valued RDNs.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testCompareInvertableNC2NC() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b " );
+        Rdn rdn2 = new Rdn( schemaManager,  " cn = c " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+
+    }
+
+
+    /**
+     * Test for DIRSHARED-3.
+     * Tests that equals() is invertable for multi-valued RDNs with different values.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testCompareInvertableNCS2NCSDifferentValues() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b + sn = c " );
+        Rdn rdn2 = new Rdn( schemaManager,  " cn = b + sn = y " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+    }
+
+
+    /**
+     * Test for DIRSHARED-3.
+     * Tests that equals() is invertable for multi-valued RDNs with different types.
+     * 
+     * @throws org.apache.directory.shared.ldap.model.exception.LdapException
+     */
+    @Test
+    public void testCompareInvertableNCS2NCSDifferentTypes() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b + sn = d  " );
+        Rdn rdn2 = new Rdn( schemaManager,  " l = f + gn = h " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+    }
+
+
+    /**
+     * Test for DIRSHARED-3.
+     * Tests that equals() is invertable for multi-valued RDNs with different order.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testCompareInvertableNCS2NCSUnordered() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " sn = d + cn = b " );
+        Rdn rdn2 = new Rdn( schemaManager,  " cn = b + l = f " );
+        assertFalse( rdn1.equals( rdn2 ) );
+        assertFalse( rdn2.equals( rdn1 ) );
+    }
+
+
+    /**
+     * Compares with a null Rdn.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNullRdn() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b " );
+
+        assertFalse( rdn1.equals( null ) );
+    }
+
+
+    /**
+     * Compares a simple NC to a simple NC.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNC2NC() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b " );
+        Rdn rdn2 = new Rdn( schemaManager,  " cn = b " );
+
+        assertTrue( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a simple NC to a simple NC in UperCase.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNC2NCUperCase() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b " );
+        Rdn rdn2 = new Rdn( schemaManager,  " CN = b " );
+
+        assertTrue( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * Compares a simple NC to a different simple NC.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testRDNCompareToNC2NCNotEquals() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  " cn = b " );
+        Rdn rdn2 = new Rdn( schemaManager,  " CN = d " );
+
+        assertFalse( rdn1.equals( rdn2 ) );
+    }
+
+
+    /**
+     * 
+     * Test the getValue method.
+     *
+     * @throws LdapException
+     */
+    @Test
+    public void testGetValue() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " cn = b + sn = f + gn = h + l = d " );
+
+        assertEquals( "b", rdn.getNormValue().getString() );
+    }
+
+
+    /**
+     * 
+     * Test the getType method.
+     *
+     * @throws LdapException
+     */
+    @Test
+    public void testGetType() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " cn = b + sn = f + gn = h + l = d " );
+
+        assertEquals( "2.5.4.3", rdn.getNormType() );
+    }
+
+
+    /**
+     * Test the getSize method.
+     *
+     * @throws LdapException
+     */
+    @Test
+    public void testGetSize() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " cn = b + sn = f + gn = h + l = d " );
+
+        assertEquals( 4, rdn.size() );
+    }
+
+
+    /**
+     * Test the getSize method.
+     *
+     */
+    @Test
+    public void testGetSize0()
+    {
+        Rdn rdn = new Rdn( schemaManager );
+
+        assertEquals( 0, rdn.size() );
+    }
+
+
+    /**
+     * Test the equals method
+     *
+     * @throws LdapException
+     */
+    @Test
+    public void testEquals() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "cn=b + sn=d + gn=f" );
+
+        assertFalse( rdn.equals( null ) );
+        assertFalse( rdn.equals( "test" ) );
+        assertFalse( rdn.equals( new Rdn( schemaManager,  "cn=c + sn=d + gn=f" ) ) );
+        assertFalse( rdn.equals( new Rdn( schemaManager,  "cn=b" ) ) );
+        assertTrue( rdn.equals( new Rdn( schemaManager,  "cn=b + sn=d + gn=f" ) ) );
+        assertTrue( rdn.equals( new Rdn( schemaManager,  "cn=b + SN=d + GN=f" ) ) );
+        assertTrue( rdn.equals( new Rdn( schemaManager,  "sn=d + gn=f + CN=b" ) ) );
+    }
+
+
+    @Test
+    public void testUnescapeValueHexa()
+    {
+        byte[] res = ( byte[] ) Rdn.unescapeValue("#fF");
+
+        assertEquals( "0xFF ", Strings.dumpBytes(res) );
+
+        res = ( byte[] ) Rdn.unescapeValue("#0123456789aBCDEF");
+        assertEquals( "0x01 0x23 0x45 0x67 0x89 0xAB 0xCD 0xEF ", Strings.dumpBytes(res) );
+    }
+
+
+    @Test
+    public void testUnescapeValueHexaWrong()
+    {
+        try
+        {
+            Rdn.unescapeValue("#fF1");
+            fail(); // Should not happen
+        }
+        catch ( IllegalArgumentException iae )
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    @Test
+    public void testUnescapeValueString()
+    {
+        String res = ( String ) Rdn.unescapeValue("azerty");
+
+        assertEquals( "azerty", res );
+    }
+
+
+    @Test
+    public void testUnescapeValueStringSpecial()
+    {
+        String res = ( String ) Rdn.unescapeValue("\\\\\\#\\,\\+\\;\\<\\>\\=\\\"\\ ");
+
+        assertEquals( "\\#,+;<>=\" ", res );
+    }
+
+
+    @Test
+    public void testUnescapeValueStringWithSpaceInTheMiddle()
+    {
+        String res = ( String ) Rdn.unescapeValue("a b");
+
+        assertEquals( "a b", res );
+    }
+
+
+    @Test
+    public void testUnescapeValueStringWithSpaceInAtTheBeginning()
+    {
+        String res = ( String ) Rdn.unescapeValue("\\ a b");
+
+        assertEquals( " a b", res );
+    }
+
+
+    @Test
+    public void testUnescapeValueStringWithSpaceInAtTheEnd()
+    {
+        String res = ( String ) Rdn.unescapeValue("a b\\ ");
+
+        assertEquals( "a b ", res );
+    }
+    
+    
+    @Test
+    public void testUnescapeValueStringWithPoundInTheMiddle()
+    {
+        String res = ( String ) Rdn.unescapeValue("a#b");
+
+        assertEquals( "a#b", res );
+    }
+    
+    
+    @Test
+    public void testUnescapeValueStringWithPoundAtTheEnd()
+    {
+        String res = ( String ) Rdn.unescapeValue("ab#");
+
+        assertEquals( "ab#", res );
+    }
+    
+    
+    @Test
+    public void testEscapeValueString()
+    {
+        String res = Rdn.escapeValue(Strings.getBytesUtf8("azerty"));
+
+        assertEquals( "azerty", res );
+    }
+
+
+    @Test
+    public void testEscapeValueStringSpecial()
+    {
+        String res = Rdn.escapeValue(Strings.getBytesUtf8("\\#,+;<>=\" "));
+
+        assertEquals( "\\\\#\\,\\+\\;\\<\\>\\=\\\"\\ ", res );
+    }
+
+
+    @Test
+    public void testEscapeValueNumeric()
+    {
+        String res = Rdn.escapeValue(new byte[]
+                {'-', 0x00, '-', 0x1F, '-', 0x7F, '-'});
+
+        assertEquals( "-\\00-\\1F-\\7F-", res );
+    }
+
+
+    @Test
+    public void testEscapeValueMix()
+    {
+        String res = Rdn.escapeValue(new byte[]
+                {'\\', 0x00, '-', '+', '#', 0x7F, '-'});
+
+        assertEquals( "\\\\\\00-\\+#\\7F-", res );
+    }
+
+
+    @Test
+    public void testDIRSERVER_703() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "cn=Kate Bush+sn=Bush" );
+        assertEquals( "cn=Kate Bush+sn=Bush", rdn.getName() );
+    }
+
+
+    @Test
+    public void testMultiValuedIterator() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "cn=Kate Bush+sn=Bush" );
+        Iterator<Ava> iterator = rdn.iterator();
+        assertNotNull( iterator );
+        assertTrue( iterator.hasNext() );
+        assertNotNull( iterator.next() );
+        assertTrue( iterator.hasNext() );
+        assertNotNull( iterator.next() );
+        assertFalse( iterator.hasNext() );
+    }
+
+
+    @Test
+    public void testSingleValuedIterator() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "cn=Kate Bush" );
+        Iterator<Ava> iterator = rdn.iterator();
+        assertNotNull( iterator );
+        assertTrue( iterator.hasNext() );
+        assertNotNull( iterator.next() );
+        assertFalse( iterator.hasNext() );
+    }
+
+
+    @Test
+    public void testEmptyIterator()
+    {
+        Rdn rdn = new Rdn( schemaManager );
+        Iterator<Ava> iterator = rdn.iterator();
+        assertNotNull( iterator );
+        assertFalse( iterator.hasNext() );
+    }
+
+
+    @Test
+    public void testRdnWithSpaces() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "cn=a\\ b\\ c" );
+        assertEquals( "2.5.4.3=a b c", rdn.getNormName() );
+    }
+
+
+    @Test
+    public void testEscapedSpaceInValue() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  "cn=a b c" );
+        Rdn rdn2 = new Rdn( schemaManager,  "cn=a\\ b\\ c" );
+        assertEquals( "2.5.4.3=a b c", rdn1.getNormName() );
+        assertEquals( "2.5.4.3=a b c", rdn2.getNormName() );
+        assertTrue( rdn1.equals( rdn2 ) );
+
+        Rdn rdn3 = new Rdn( schemaManager,  "cn=\\ a b c\\ " );
+        Rdn rdn4 = new Rdn( schemaManager,  "cn=\\ a\\ b\\ c\\ " );
+        assertEquals( "2.5.4.3=a b c", rdn3.getNormName() );
+        assertEquals( "cn=\\ a b c\\ ", rdn3.getName() );
+        assertEquals( "2.5.4.3=a b c", rdn4.getNormName() );
+        assertEquals( "cn=\\ a\\ b\\ c\\ ", rdn4.getName() );
+        assertTrue( rdn3.equals( rdn4 ) );
+    }
+
+
+    @Test
+    public void testEscapedHashInValue() throws LdapException
+    {
+        Rdn rdn1 = new Rdn( schemaManager,  "cn=a#b#c" );
+        Rdn rdn2 = new Rdn( schemaManager,  "cn=a\\#b\\#c" );
+        assertEquals( "2.5.4.3=a#b#c", rdn1.getNormName() );
+        assertEquals( "2.5.4.3=a#b#c", rdn2.getNormName() );
+        assertTrue( rdn1.equals( rdn2 ) );
+
+        Rdn rdn3 = new Rdn( schemaManager,  "cn=\\#a#b#c\\#" );
+        Rdn rdn4 = new Rdn( schemaManager,  "cn=\\#a\\#b\\#c\\#" );
+        assertEquals( "2.5.4.3=\\#a#b#c#", rdn3.getNormName() );
+        assertEquals( "2.5.4.3=\\#a#b#c#", rdn4.getNormName() );
+        assertTrue( rdn3.equals( rdn4 ) );
+    }
+
+
+    @Test
+    public void testEscapedAttributeValue()
+    {
+        // space doesn't need to be escaped in the middle of a string
+        assertEquals( "a b", Rdn.escapeValue("a b") );
+        assertEquals( "a b c", Rdn.escapeValue("a b c") );
+        assertEquals( "a b c d", Rdn.escapeValue("a b c d") );
+
+        // space must be escaped at the beginning and the end of a string
+        assertEquals( "\\ a b", Rdn.escapeValue(" a b") );
+        assertEquals( "a b\\ ", Rdn.escapeValue("a b ") );
+        assertEquals( "\\ a b\\ ", Rdn.escapeValue(" a b ") );
+        assertEquals( "\\  a  b \\ ", Rdn.escapeValue("  a  b  ") );
+
+        // hash doesn't need to be escaped in the middle and the end of a string
+        assertEquals( "a#b", Rdn.escapeValue("a#b") );
+        assertEquals( "a#b#", Rdn.escapeValue("a#b#") );
+        assertEquals( "a#b#c", Rdn.escapeValue("a#b#c") );
+        assertEquals( "a#b#c#", Rdn.escapeValue("a#b#c#") );
+        assertEquals( "a#b#c#d", Rdn.escapeValue("a#b#c#d") );
+        assertEquals( "a#b#c#d#", Rdn.escapeValue("a#b#c#d#") );
+
+        // 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 LdapException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "" );
+
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        out.writeObject( rdn );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = (Rdn)in.readObject();
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    @Test
+    public void testNullRdnSerialization() throws IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager );
+
+        rdn.normalize();
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream( baos );
+
+        out.writeObject( rdn );
+
+        ObjectInputStream in = null;
+
+        byte[] data = baos.toByteArray();
+        in = new ObjectInputStream( new ByteArrayInputStream( data ) );
+
+        Rdn rdn2 = (Rdn)in.readObject();
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn
+     */
+    @Test
+    public void testSimpleRdnSerialization() throws LdapException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  "cn=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( schemaManager );
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn
+     */
+    @Test
+    public void testSimpleRdn2Serialization() throws LdapException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " CN  = 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( schemaManager );
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn with no value
+     */
+    @Test
+    public void testSimpleRdnNoValueSerialization() throws LdapException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " CN  =" );
+        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( schemaManager );
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn with one value
+     */
+    @Test
+    public void testSimpleRdnOneValueSerialization() throws LdapException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " CN  = 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( schemaManager );
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn with three values
+     */
+    @Test
+    public void testSimpleRdnThreeValuesSerialization() throws LdapException, IOException, ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " CN = a + SN = b + GN = 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( schemaManager );
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * Test serialization of a simple Rdn with three unordered values
+     */
+    @Test
+    public void testSimpleRdnThreeValuesUnorderedSerialization() throws LdapException, IOException,
+        ClassNotFoundException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " CN = b + SN = a + GN = 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( schemaManager );
+        rdn2.readExternal( in );
+
+        assertEquals( rdn, rdn2 );
+    }
+
+
+    /**
+     * test an Rdn with empty value
+     */
+    @Test
+    public void testRdnWithEmptyValue() throws LdapException
+    {
+        assertTrue( RdnParser.isValid("cn=") );
+        assertTrue( RdnParser.isValid( "cn=\"\"" ) );
+        assertEquals( "2.5.4.3=", new Rdn( schemaManager,  "cn=\"\"" ).getNormName() );
+        assertEquals( "2.5.4.3=", new Rdn( schemaManager,  "cn=" ).getNormName() );
+    }
+
+
+    /**
+     * test an Rdn with escaped comma
+     */
+    @Test
+    public void testRdnWithEscapedComa() throws LdapException
+    {
+        assertTrue( RdnParser.isValid( "cn=b\\,c" ) );
+        assertEquals( "2.5.4.3=b\\,c", new Rdn( schemaManager,  "cn=b\\,c" ).getNormName() );
+
+        assertTrue( RdnParser.isValid( "cn=\"b,c\"" ) );
+        assertEquals( "2.5.4.3=b\\,c", new Rdn( schemaManager,  "cn=\"b,c\"" ).getNormName() );
+        assertEquals( "cn=\"b,c\"", new Rdn( schemaManager,  "cn=\"b,c\"" ).getName() );
+
+        assertTrue( RdnParser.isValid( "cn=\"b\\,c\"" ) );
+        Rdn rdn = new Rdn( schemaManager,  "cn=\"b\\,c\"" );
+        assertEquals( "cn=\"b\\,c\"", rdn.getName() );
+        assertEquals( "2.5.4.3=b\\,c", rdn.getNormName() );
+    }
+
+
+    /**
+     * Tests the equals and equals results of cloned multi-valued RDNs.
+     * Test for DIRSHARED-9.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testComparingOfClonedMultiValuedRDNs() throws LdapException
+    {
+        // Use upper case attribute types to test if normalized types are used 
+        // for comparison
+        Rdn rdn = new Rdn( schemaManager,  " CN = b + SN = d" );
+        Rdn clonedRdn = (Rdn) rdn.clone();
+
+        assertTrue( rdn.equals( clonedRdn ) );
+    }
+
+
+    /**
+     * Tests the equals and equals results of copy constructed multi-valued RDNs.
+     * Test for DIRSHARED-9.
+     * 
+     * @throws LdapException
+     */
+    @Test
+    public void testComparingOfCopyConstructedMultiValuedRDNs() throws LdapException
+    {
+        // Use upper case attribute types to test if normalized types are used 
+        // for comparison
+        Rdn rdn = new Rdn( schemaManager,  " CN = b + SN = d" );
+        Rdn copiedRdn = new Rdn( rdn );
+
+        assertTrue( rdn.equals( copiedRdn ) );
+    }
+
+
+    /**
+     * test the UpName method on a Rdn with more than one atav
+     */
+    @Test 
+    public void testGetUpNameMultipleAtav() throws LdapException
+    {
+        Rdn rdn = new Rdn( schemaManager,  " CN = b + SN = d " );
+        
+        assertEquals( " CN = b + SN = d ", rdn.getName() );
+    }
+}

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java?rev=1083238&r1=1083237&r2=1083238&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java Sat Mar 19 17:51:06 2011
@@ -23,16 +23,17 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.aci.ACIItemSyntaxChecker;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schemaloader.JarLdifSchemaLoader;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test cases for ACIItemSyntaxChecker.
@@ -89,9 +90,9 @@ public class ACIItemSyntaxCheckerTest
             + "itemOrUserFirst itemFirst  :{ protectedItems  { entry  , attributeType { 1.2.3    , ou }  , "
             + " attributeValue { ou=people  , cn=Ersin  }  , rangeOfValues (cn=ErsinEr) , "
             + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "itemPermissions { { userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "{ precedence 10, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
 
         assertTrue( checker.isValidSyntax( spec ) );
@@ -108,7 +109,7 @@ public class ACIItemSyntaxCheckerTest
             + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
 
         assertTrue( checker.isValidSyntax( spec ) );
@@ -144,9 +145,9 @@ public class ACIItemSyntaxCheckerTest
             + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry , "
             + " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
             + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "itemPermissions { { userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "{ precedence 10, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
 
         assertTrue( checker.isValidSyntax( spec ) );
@@ -160,7 +161,7 @@ public class ACIItemSyntaxCheckerTest
             + "itemOrUserFirst userFirst:  { userClasses {  name { \"ou=people,cn=ersin\" }, allUsers, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }  }   ";
 
         assertTrue( checker.isValidSyntax( spec ) );
@@ -174,9 +175,9 @@ public class ACIItemSyntaxCheckerTest
             + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry , "
             + " rangeOfValues (cn=ErsinEr) , attributeValue { ou=people  , cn=Ersin  },"
             + "classes and : { item: xyz , or:{item:X,item:Y}   }}  , "
-            + "itemPermissions { { grantsAndDenials  {  denyCompare  , grantModify }, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "itemPermissions { { grantsAndDenials  {  denyCompare  , grantModify }, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   },"
-            + "{ precedence 10, userClasses {allUsers  , userGroup { \"1.2=y,z=t\"  , \"a=b,c=d\" } "
+            + "{ precedence 10, userClasses {allUsers  , userGroup { \"2.5.4.3=y,dc=t\"  , \"cn=b,dc=d\" } "
             + " , subtree { { base \"ou=people\" } } }   , grantsAndDenials  {  denyCompare  , grantModify } } } }}";
 
         assertTrue( checker.isValidSyntax( spec ) );
@@ -190,7 +191,7 @@ public class ACIItemSyntaxCheckerTest
             + "itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { grantsAndDenials { grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
 
         assertTrue( checker.isValidSyntax( spec ) );
@@ -203,7 +204,7 @@ public class ACIItemSyntaxCheckerTest
         String spec = "{   itemOrUserFirst userFirst:  { userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
             + "subtree {{ base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
             + "minimum  1, maximum   2 } } }  , "
-            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {cn=y,sn=n,dc=l} , "
             + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } } }, "
             + " identificationTag \"id2\"   , authenticationLevel none, precedence 14 }   ";
 



Mime
View raw message