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

svn commit: r964361 [1/5] - in /directory/shared/trunk: ldap-schema-manager-tests/ ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheck...

Author: elecharny
Date: Thu Jul 15 10:04:06 2010
New Revision: 964361

URL: http://svn.apache.org/viewvc?rev=964361&view=rev
Log:
o Moved back the ACI and Subtree parser into shared-ldap.
o Moved the associated tests into shared-schame-manager-tests

Added:
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/UserClass_NameTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/UserClass_SubtreeTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
      - copied unchanged from r963531, directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxCheckerTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
      - copied unchanged from r963531, directory/shared/trunk/ldap-aci/src/test/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxCheckerTest.java
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/subtree/
    directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParserTest.java
    directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
    directory/shared/trunk/ldap/src/main/antlr/ACIItemChecker.g
    directory/shared/trunk/ldap/src/main/antlr/SubtreeSpecificationChecker.g
    directory/shared/trunk/ldap/src/main/antlr/subtree-specification.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACIItemParser.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/GrantAndDenial.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemFirstACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ItemPermission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/MicroOperation.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/Permission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ReusableAntlrACIItemChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ReusableAntlrACIItemCheckerLexer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ReusableAntlrACIItemLexer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ReusableAntlrACIItemParser.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserFirstACIItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserPermission.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/AbstractAttributeTypeProtectedItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/AllAttributeValuesItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/AllUserAttributeTypesAndValuesItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/AllUserAttributeTypesItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeTypeItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeValueItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/ClassesItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/EntryItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxImmSubItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountElem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RangeOfValuesItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByElem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/SelfValueItem.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/ACIItemSyntaxChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntaxCheckers/SubtreeSpecificationSyntaxChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/AndRefinement.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/BaseSubtreeSpecification.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/ItemRefinement.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/NotRefinement.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/OrRefinement.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/Refinement.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/ReusableAntlrSubtreeSpecificationChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/ReusableAntlrSubtreeSpecificationCheckerLexer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/ReusableAntlrSubtreeSpecificationLexer.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/ReusableAntlrSubtreeSpecificationParser.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecification.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationChecker.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationModifier.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/subtree/SubtreeSpecificationParser.java
Modified:
    directory/shared/trunk/ldap-schema-manager-tests/pom.xml
    directory/shared/trunk/ldap/pom.xml

Modified: directory/shared/trunk/ldap-schema-manager-tests/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/pom.xml?rev=964361&r1=964360&r2=964361&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/pom.xml (original)
+++ directory/shared/trunk/ldap-schema-manager-tests/pom.xml Thu Jul 15 10:04:06 2010
@@ -63,11 +63,6 @@
     </dependency>
     
     <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>shared-ldap-aci</artifactId>
-    </dependency>
-    
-    <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <scope>test</scope>

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemChekerTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,355 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.fail;
+
+import java.text.ParseException;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.ACIItemChecker;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class for ACIItem checker (wrapper).
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ACIItemChekerTest
+{
+    /** the ACIItem checker wrapper */
+    static private ACIItemChecker checker;
+
+
+    /**
+     * Initialization
+     */
+    @BeforeClass
+    public static void init() throws Exception
+    {
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+        schemaManager.loadAllEnabled();
+
+        checker = new ACIItemChecker( schemaManager );
+    }
+
+
+    /**
+     * Tests the checker with an ACIItem of ItemFirst main component.
+     */
+    @Test
+    public void testItemFirst() throws Exception
+    {
+        String spec = 
+            " {  " +
+            "   identificationTag  \"id1\" , " +
+            "   precedence 114  , " +
+            "   authenticationLevel simple  , " +
+            "   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\" } ," +
+            "           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 } " +
+            "       } " +
+            "     } " +
+            "   }" +
+            " }";
+
+        checker.parse( spec );
+    }
+
+
+    /**
+     * Tests the checker with an ACIItem of UserFirst main component.
+     */
+    @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 } } } }  }   ";
+
+        checker.parse( spec );
+    }
+
+
+    @Test
+    public void testAllowAddAllUsers() throws Exception
+    {
+        String spec = "{ identificationTag \"addAci\", " + "precedence 14, " + "authenticationLevel none, "
+            + "itemOrUserFirst userFirst: { " + "userClasses { allUsers }, "
+            + "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd } } } } }";
+
+        checker.parse( spec );
+    }
+
+
+    @Test
+    public void testCombo() throws Exception
+    {
+        String spec = "{ identificationTag \"addAci\", " + "precedence 14, " + "authenticationLevel none, "
+            + "itemOrUserFirst userFirst: { " + "userClasses { allUsers, name { \"ou=blah\" } }, "
+            + "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd } } } } }";
+
+        checker.parse( spec );
+    }
+
+
+    @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 } } } }}";
+
+        checker.parse( spec );
+    }
+
+
+    @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 } } } }  }   ";
+
+        checker.parse( spec );
+    }
+
+
+    @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 } } } }}";
+
+        checker.parse( spec );
+    }
+
+
+    @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) }  } } }  }   ";
+
+        checker.parse( spec );
+    }
+
+
+    @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 }   ";
+
+        checker.parse( spec );
+    }
+
+
+    @Test
+    public void testRestrictedValueComponentsOrderDoesNotMatter() 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  , "
+            + "maxValueCount { { type 10.11.12, maxCount 10 }, { maxCount 20, type 11.12.13  } } "
+            + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
+
+        checker.parse( spec );
+    }
+
+
+    @Test
+    public void testMaxValueCountComponentsOrderDoesNotMatter() 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  , "
+            + "restrictedBy { { type 10.11.12, valuesIn ou }, { valuesIn cn, type 11.12.13  } } "
+            + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
+
+        checker.parse( spec );
+    }
+
+
+    /**
+     * Test case for DIRSERVER-891
+     */
+    @Test
+    public void testInvalidAttributeValue()
+    {
+        String spec;
+        
+        // no name-value-pair
+        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
+            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue { must_be_a_name_value_pair } , "
+            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
+            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+            + " maximum   2, minimum  1 } } }  }  }   ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair }'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        // no name-value-pair
+        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
+            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue { x=y,m=n,k=l,x } , "
+            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
+            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+            + " maximum   2, minimum  1 } } }  }  }   ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair }'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+    }
+    
+    
+    /**
+     * Test case for DIRSERVER-891
+     */
+    @Test
+    public void testIncomplete()
+    {
+        String spec;
+        
+        spec = "{ }";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\" }";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\", precedence 14 } ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\", precedence 14, authenticationLevel none } ";
+        try
+        {
+            checker.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ACIItemParserTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,645 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.text.ParseException;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.ACIItem;
+import org.apache.directory.shared.ldap.aci.ACIItemParser;
+import org.apache.directory.shared.ldap.aci.UserFirstACIItem;
+import org.apache.directory.shared.ldap.aci.UserPermission;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Unit tests class for ACIItem parser (wrapper).
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ACIItemParserTest
+{
+
+    /** the ACIItem parser wrapper */
+    private static ACIItemParser parser;
+
+
+    /**
+     * Initialization
+     */
+    @BeforeClass
+    public static void init() throws Exception
+    {
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+        schemaManager.loadAllEnabled();
+
+        parser = new ACIItemParser( schemaManager );
+    }
+
+
+    private void checkItemToString( String spec, ACIItem item ) throws Exception
+    {
+        // try to parse the result of item.toString() again
+        parser.parse( item.toString() );
+    }
+
+
+    /**
+     * Tests the parser with a rangeOfValues with a nested filter.
+     */
+    @Test
+    public void testRangeOfValues() throws Exception
+    {
+        String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel simple  , "
+            + "itemOrUserFirst itemFirst  :{ protectedItems  "
+            + "{ rangeOfValues (&(&(|(|(cn=ccc)(!(cn=ddd))(&(cn=aaa)(cn=bbb)))))) " + "}  , itemPermissions {  } } }";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+        
+        
+        spec = " { identificationTag \"id8\", precedence 0, authenticationLevel simple "
+            + ", itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { "
+            + " { protectedItems { rangeOfValues (&(cn=test)(sn=test)) }, grantsAndDenials { grantAdd } }, "
+            + "{ protectedItems { rangeOfValues (|(!(cn=aaa))(sn=bbb)) }, grantsAndDenials { grantAdd } } "
+            + " } } }";
+        
+        item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    /**
+     * Tests the parser with an ACIItem of ItemFirst main component.
+     */
+    @Test
+    public void testItemFirst() throws Exception
+    {
+        String spec = 
+            "{  " +
+            "  identificationTag  \"id1\" , " +
+            "  precedence 114  , " +
+            "  authenticationLevel simple  , " +
+            "  itemOrUserFirst itemFirst  :" +
+            "  { " +
+            "    protectedItems  { entry  , attributeType { 2.5.4.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\" } , " +
+            "          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 } } " +
+            "    } " +
+            "  }" +
+            "}";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    /**
+     * Tests the parser with an ACIItem of UserFirst main component.
+     */
+    @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 } } } }  }   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testAllowAddAllUsers() throws Exception
+    {
+        String spec = "{ identificationTag \"addAci\", " + "precedence 14, " + "authenticationLevel none, "
+            + "itemOrUserFirst userFirst: { " + "userClasses { allUsers }, "
+            + "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd } } } } }";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testCombo() throws Exception
+    {
+        String spec = "{ identificationTag \"addAci\", " + "precedence 14, " + "authenticationLevel none, "
+            + "itemOrUserFirst userFirst: { " + "userClasses { allUsers, name { \"ou=blah\" } }, "
+            + "userPermissions { { protectedItems {entry}, " + "grantsAndDenials { grantAdd } } } } }";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @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 } } } }}";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @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 } } } }  }   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testOrderOfProtectedItemsDoesNotMatterButDuplicatesMatter() throws Exception
+    {
+        String spec = " {  identificationTag  \"id1\" , precedence 114  , authenticationLevel simple  , "
+            + "itemOrUserFirst itemFirst  :{ protectedItems  { attributeType { 1.2.3    , ou }, entry, 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 } } } }}";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testItemFirstOrderOfProtectedItemsDoesNotMatterButDuplicatesMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @Test 
+    public void testOrderOfUserClassesDoesNotMatterButDuplicatesMatter() throws Exception
+    {
+        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
+            + "itemOrUserFirst userFirst:  { userClasses {  name { \"ou=people,cn=ersin\" }, allUsers, 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 } } } }  }   ";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testUserFirstOrderOfUserClassesDoesNotMatterButDuplicatesMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @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 } } } }}";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testItemPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() 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 }, 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 } } } }}";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testItemPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @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) }  } } }  }   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testUserPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() 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 }, grantsAndDenials { grantBrowse }, protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue {x=y,m=n,k=l} , "
+            + "rangeOfValues (cn=ErsinEr) }  } } }  }   ";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testUserPermissionComponentsOrderDoesNotMatterButDuplicatesMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @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 }   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testOrderOfMainACIComponentsDoesNotMatterButDuplicatesMatter() 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, authenticationLevel simple, precedence 14 }   ";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testOrderOfMainACIComponentsDoesNotMatterButDuplicatesMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @Test 
+    public void testOrderOfMainACIComponentsDoesNotMatterButMissingsMatter() 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\"   , precedence 14 }   ";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testOrderOfMainACIComponentsDoesNotMatterButMissingsMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @Test 
+    public void testGrantAndDenialBitsOrderDoesNotMatterButDuplicatesMatter() throws Exception
+    {
+        String spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
+            + "itemOrUserFirst userFirst:  { userClasses {  allUsers }  , "
+            + "userPermissions { { protectedItems{ entry  }  , grantsAndDenials { grantBrowse, grantInvoke, denyAdd, grantBrowse } } } }  }";
+
+        try
+        {
+            parser.parse( spec );
+            fail( "testGrantAndDenialBitsOrderDoesNotMatterButDuplicatesMatter() should not have run this line." );
+        }
+        catch ( ParseException e )
+        {
+            assertNotNull( e );
+        }
+    }
+
+
+    @Test 
+    public void testMaxValueCountComponentsOrderDoesNotMatter() 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  , " +
+            "          maxValueCount " +
+            "          { " +
+            "            { type 2.5.4.3, maxCount 10 }, " +
+            "            { maxCount 20, type 2.5.4.3  } " +
+            "          } " +
+            "        }  , " +
+            "        grantsAndDenials { grantBrowse } " +
+            "      } " +
+            "    } " +
+            "  } " +
+            "}   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testRestrictedValueComponentsOrderDoesNotMatter() 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  , "
+            + "restrictedBy { { type 2.5.4.3, valuesIn ou }, { valuesIn cn, type 2.5.4.3  } } "
+            + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    @Test 
+    public void testMaxImmSubComponentsOrderDoesNotMatter() 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  , maxImmSub 5 "
+            + " }  , grantsAndDenials { grantBrowse } } } }  }   ";
+        
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+    
+    
+    /**
+     * Test case for DIRSERVER-891
+     */
+    @Test 
+    public void testInvalidAttributeValue()
+    {
+        String spec;
+        
+        // no name-value-pair
+        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
+            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue { must_be_a_name_value_pair } , "
+            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
+            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+            + " maximum   2, minimum  1 } } }  }  }   ";
+        try
+        {
+            parser.parse( spec );
+            fail("Expected ParseException, invalid protected item 'attributeValue { must_be_a_name_value_pair }'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        // no name-value-pair
+        spec = "{ identificationTag \"id2\"   , precedence 14, authenticationLevel none  , "
+            + "itemOrUserFirst userFirst:  { userPermissions { { protectedItems{ entry  , attributeType { cn  , ou }  , attributeValue { x=y,m=n,k=l,x } , "
+            + "rangeOfValues (cn=ErsinEr) }  , grantsAndDenials { grantBrowse } } }, userClasses {  allUsers  , name { \"ou=people,cn=ersin\" }, "
+            + "subtree {{ minimum 7, maximum 9, base \"ou=system\" }, { base \"ou=ORGANIZATIONUNIT\","
+            + " maximum   2, minimum  1 } } }  }  }   ";
+        try
+        {
+            parser.parse( spec );
+            fail("Expected ParseException, invalid protected item 'attributeValue { x=y,m=n,k=l,x }'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+    }
+    
+    @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 } } } }  }   ";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+    }
+
+
+    /**
+     * Test case for DIRSTUDIO-440
+     */
+    @Test 
+    public void testPrecedenceOfUserFirst() throws Exception
+    {
+        String spec = "{ identificationTag \"test\", precedence 14, authenticationLevel simple, "
+            + "itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { "
+            + "precedence 1, protectedItems { attributeType { userPassword } }, grantsAndDenials "
+            + "{ denyRead, denyReturnDN, denyBrowse } }, { precedence 2, protectedItems "
+            + "{ entry, allUserAttributeTypesAndValues }, grantsAndDenials "
+            + "{ grantReturnDN, grantRead, grantBrowse } } } } }";
+
+        ACIItem item = parser.parse( spec );
+        checkItemToString( spec, item );
+
+        UserFirstACIItem userFirstItem = ( UserFirstACIItem ) item;
+        int aciPrecedence = userFirstItem.getPrecedence();
+        assertEquals( 14, aciPrecedence );
+        for ( UserPermission permission : userFirstItem.getUserPermission() )
+        {
+            int precedence = permission.getPrecedence();
+            if ( precedence == 1 )
+            {
+                assertEquals( 1, precedence );
+            }
+            else if ( precedence == 2 )
+            {
+                assertEquals( 2, precedence );
+            }
+            else
+            {
+                fail( "Got precedence " + precedence + ", expected precedence 1 or 2." );
+            }
+        }
+    }
+
+
+    /**
+     * Test case for DIRSERVER-891
+     */
+    @Test 
+    public void testIncomplete()
+    {
+        String spec;
+        
+        spec = "{ }";
+        try
+        {
+            parser.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\" }";
+        try
+        {
+            parser.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\", precedence 14 } ";
+        try
+        {
+            parser.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+        
+        spec = "{ identificationTag \"id2\", precedence 14, authenticationLevel none } ";
+        try
+        {
+            parser.parse( spec );
+            fail("Expected ParseException, ACIItem is incomplete'");
+        }
+        catch ( ParseException e )
+        {
+            // Expected
+        }
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,140 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.AllAttributeValuesItem;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.AllAttributeValues.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_AllAttributeValuesTest
+{
+    AllAttributeValuesItem allAttributeValuesA;
+    AllAttributeValuesItem allAttributeValuesACopy;
+    AllAttributeValuesItem allAttributeValuesB;
+    AllAttributeValuesItem allAttributeValuesC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        Set<AttributeType> colA = new HashSet<AttributeType>();
+        colA.add( new AttributeType( "aa" ) );
+        colA.add( new AttributeType( "bb" ) );
+        colA.add( new AttributeType( "cc" ) );
+        Set<AttributeType> colB = new HashSet<AttributeType>();
+        colB.add( new AttributeType( "aa" ) );
+        colB.add( new AttributeType( "bb" ) );
+        colB.add( new AttributeType( "cc" ) );
+        Set<AttributeType> colC = new HashSet<AttributeType>();
+        colC.add( new AttributeType( "bb" ) );
+        colC.add( new AttributeType( "cc" ) );
+        colC.add( new AttributeType( "dd" ) );
+
+        allAttributeValuesA = new AllAttributeValuesItem( colA );
+        allAttributeValuesACopy = new AllAttributeValuesItem( colA );
+        allAttributeValuesB = new AllAttributeValuesItem( colB );
+        allAttributeValuesC = new AllAttributeValuesItem( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( allAttributeValuesA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( allAttributeValuesA, allAttributeValuesA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( allAttributeValuesA.hashCode(), allAttributeValuesA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( allAttributeValuesA, allAttributeValuesACopy );
+        assertEquals( allAttributeValuesACopy, allAttributeValuesA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( allAttributeValuesA.hashCode(), allAttributeValuesACopy.hashCode() );
+        assertEquals( allAttributeValuesACopy.hashCode(), allAttributeValuesA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( allAttributeValuesA, allAttributeValuesACopy );
+        assertEquals( allAttributeValuesACopy, allAttributeValuesB );
+        assertEquals( allAttributeValuesA, allAttributeValuesB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( allAttributeValuesA.hashCode(), allAttributeValuesACopy.hashCode() );
+        assertEquals( allAttributeValuesACopy.hashCode(), allAttributeValuesB.hashCode() );
+        assertEquals( allAttributeValuesA.hashCode(), allAttributeValuesB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( allAttributeValuesA.equals( allAttributeValuesC ) );
+        assertFalse( allAttributeValuesC.equals( allAttributeValuesA ) );
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,140 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.AttributeTypeItem;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.AttributeType.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_AttributeTypeTest
+{
+    AttributeTypeItem attributeTypeA;
+    AttributeTypeItem attributeTypeACopy;
+    AttributeTypeItem attributeTypeB;
+    AttributeTypeItem attributeTypeC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        Set<AttributeType> colA = new HashSet<AttributeType>();
+        colA.add( new AttributeType( "aa" ) );
+        colA.add( new AttributeType( "bb" ) );
+        colA.add( new AttributeType( "cc" ) );
+        Set<AttributeType> colB = new HashSet<AttributeType>();
+        colB.add( new AttributeType( "aa" ) );
+        colB.add( new AttributeType( "bb" ) );
+        colB.add( new AttributeType( "cc" ) );
+        Set<AttributeType> colC = new HashSet<AttributeType>();
+        colC.add( new AttributeType( "bb" ) );
+        colC.add( new AttributeType( "cc" ) );
+        colC.add( new AttributeType( "dd" ) );
+
+        attributeTypeA = new AttributeTypeItem( colA );
+        attributeTypeACopy = new AttributeTypeItem( colA );
+        attributeTypeB = new AttributeTypeItem( colB );
+        attributeTypeC = new AttributeTypeItem( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( attributeTypeA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( attributeTypeA, attributeTypeA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( attributeTypeA.hashCode(), attributeTypeA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( attributeTypeA, attributeTypeACopy );
+        assertEquals( attributeTypeACopy, attributeTypeA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( attributeTypeA.hashCode(), attributeTypeACopy.hashCode() );
+        assertEquals( attributeTypeACopy.hashCode(), attributeTypeA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( attributeTypeA, attributeTypeACopy );
+        assertEquals( attributeTypeACopy, attributeTypeB );
+        assertEquals( attributeTypeA, attributeTypeB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( attributeTypeA.hashCode(), attributeTypeACopy.hashCode() );
+        assertEquals( attributeTypeACopy.hashCode(), attributeTypeB.hashCode() );
+        assertEquals( attributeTypeA.hashCode(), attributeTypeB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( attributeTypeA.equals( attributeTypeC ) );
+        assertFalse( attributeTypeC.equals( attributeTypeA ) );
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,151 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.AttributeValueItem;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.AttributeValue.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_AttributeValueTest
+{
+    AttributeValueItem attributeValueA;
+    AttributeValueItem attributeValueACopy;
+    AttributeValueItem attributeValueB;
+    AttributeValueItem attributeValueC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+
+        EntryAttribute attrA = new DefaultEntryAttribute( "aa" );
+        attrA.add( "aa" );
+        EntryAttribute attrB = new DefaultEntryAttribute( "bb" );
+        attrB.add( "bb" );
+        EntryAttribute attrC = new DefaultEntryAttribute( "cc" );
+        attrC.add( "cc" );
+        EntryAttribute attrD = new DefaultEntryAttribute( "dd" );
+        attrD.add( "dd" );
+
+        Set<EntryAttribute> colA = new HashSet<EntryAttribute>();
+        colA.add( attrA );
+        colA.add( attrB );
+        colA.add( attrC );
+        Set<EntryAttribute> colB = new HashSet<EntryAttribute>();
+        colB.add( attrA );
+        colB.add( attrB );
+        colB.add( attrC );
+        Set<EntryAttribute> colC = new HashSet<EntryAttribute>();
+        colC.add( attrB );
+        colC.add( attrC );
+        colC.add( attrD );
+
+        attributeValueA = new AttributeValueItem( colA );
+        attributeValueACopy = new AttributeValueItem( colA );
+        attributeValueB = new AttributeValueItem( colB );
+        attributeValueC = new AttributeValueItem( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( attributeValueA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( attributeValueA, attributeValueA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( attributeValueA.hashCode(), attributeValueA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( attributeValueA, attributeValueACopy );
+        assertEquals( attributeValueACopy, attributeValueA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( attributeValueA.hashCode(), attributeValueACopy.hashCode() );
+        assertEquals( attributeValueACopy.hashCode(), attributeValueA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( attributeValueA, attributeValueACopy );
+        assertEquals( attributeValueACopy, attributeValueB );
+        assertEquals( attributeValueA, attributeValueB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( attributeValueA.hashCode(), attributeValueACopy.hashCode() );
+        assertEquals( attributeValueACopy.hashCode(), attributeValueB.hashCode() );
+        assertEquals( attributeValueA.hashCode(), attributeValueB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( attributeValueA.equals( attributeValueC ) );
+        assertFalse( attributeValueC.equals( attributeValueA ) );
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,128 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.ClassesItem;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.Classes.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_ClassesTest
+{
+    ClassesItem classesA;
+    ClassesItem classesACopy;
+    ClassesItem classesB;
+    ClassesItem classesC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        ExprNode filterA = FilterParser.parse( "(&(cn=test)(sn=test))" );
+        ExprNode filterB = FilterParser.parse( "(&(cn=test)(sn=test))" );
+        ExprNode filterC = FilterParser.parse( "(&(cn=sample)(sn=sample))" );
+        classesA = new ClassesItem( filterA );
+        classesACopy = new ClassesItem( filterA );
+        classesB = new ClassesItem( filterB );
+        classesC = new ClassesItem( filterC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( classesA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( classesA, classesA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( classesA.hashCode(), classesA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( classesA, classesACopy );
+        assertEquals( classesACopy, classesA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( classesA.hashCode(), classesACopy.hashCode() );
+        assertEquals( classesACopy.hashCode(), classesA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( classesA, classesACopy );
+        assertEquals( classesACopy, classesB );
+        assertEquals( classesA, classesB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( classesA.hashCode(), classesACopy.hashCode() );
+        assertEquals( classesACopy.hashCode(), classesB.hashCode() );
+        assertEquals( classesA.hashCode(), classesB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( classesA.equals( classesC ) );
+        assertFalse( classesC.equals( classesA ) );
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,127 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.MaxImmSubItem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.MaxImmSub.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_MaxImmSubTest
+{
+    MaxImmSubItem maxValueCountA;
+    MaxImmSubItem maxValueCountACopy;
+    MaxImmSubItem maxValueCountB;
+    MaxImmSubItem maxValueCountC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        MaxImmSubItem misA = new MaxImmSubItem( 1 );
+        MaxImmSubItem misB = new MaxImmSubItem( 1 );
+        MaxImmSubItem misC = new MaxImmSubItem( 2 );
+
+        maxValueCountA = misA;
+        maxValueCountACopy = misA;
+        maxValueCountB = misB;
+        maxValueCountC = misC;
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( maxValueCountA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountACopy );
+        assertEquals( maxValueCountACopy, maxValueCountA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountACopy.hashCode() );
+        assertEquals( maxValueCountACopy.hashCode(), maxValueCountA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountACopy );
+        assertEquals( maxValueCountACopy, maxValueCountB );
+        assertEquals( maxValueCountA, maxValueCountB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountACopy.hashCode() );
+        assertEquals( maxValueCountACopy.hashCode(), maxValueCountB.hashCode() );
+        assertEquals( maxValueCountA.hashCode(), maxValueCountB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( maxValueCountA.equals( maxValueCountC ) );
+        assertFalse( maxValueCountC.equals( maxValueCountA ) );
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,147 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.MaxValueCountElem;
+import org.apache.directory.shared.ldap.aci.protectedItem.MaxValueCountItem;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.MaxValueCount.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_MaxValueCountTest
+{
+    MaxValueCountItem maxValueCountA;
+    MaxValueCountItem maxValueCountACopy;
+    MaxValueCountItem maxValueCountB;
+    MaxValueCountItem maxValueCountC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+
+        MaxValueCountElem mvciA = new MaxValueCountElem( new AttributeType( "aa" ), 1 );
+        MaxValueCountElem mvciB = new MaxValueCountElem( new AttributeType( "bb" ), 2 );
+        MaxValueCountElem mvciC = new MaxValueCountElem( new AttributeType( "cc" ), 3 );
+        MaxValueCountElem mvciD = new MaxValueCountElem( new AttributeType( "dd" ), 4 );
+
+        Set<MaxValueCountElem> colA = new HashSet<MaxValueCountElem>();
+        colA.add( mvciA );
+        colA.add( mvciB );
+        colA.add( mvciC );
+        Set<MaxValueCountElem> colB = new HashSet<MaxValueCountElem>();
+        colB.add( mvciA );
+        colB.add( mvciB );
+        colB.add( mvciC );
+        Set<MaxValueCountElem> colC = new HashSet<MaxValueCountElem>();
+        colC.add( mvciB );
+        colC.add( mvciC );
+        colC.add( mvciD );
+
+        maxValueCountA = new MaxValueCountItem( colA );
+        maxValueCountACopy = new MaxValueCountItem( colA );
+        maxValueCountB = new MaxValueCountItem( colB );
+        maxValueCountC = new MaxValueCountItem( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( maxValueCountA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountACopy );
+        assertEquals( maxValueCountACopy, maxValueCountA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountACopy.hashCode() );
+        assertEquals( maxValueCountACopy.hashCode(), maxValueCountA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountACopy );
+        assertEquals( maxValueCountACopy, maxValueCountB );
+        assertEquals( maxValueCountA, maxValueCountB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountACopy.hashCode() );
+        assertEquals( maxValueCountACopy.hashCode(), maxValueCountB.hashCode() );
+        assertEquals( maxValueCountA.hashCode(), maxValueCountB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( maxValueCountA.equals( maxValueCountC ) );
+        assertFalse( maxValueCountC.equals( maxValueCountA ) );
+    }
+}

Added: directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java?rev=964361&view=auto
==============================================================================
--- directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java (added)
+++ directory/shared/trunk/ldap-schema-manager-tests/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java Thu Jul 15 10:04:06 2010
@@ -0,0 +1,130 @@
+/*
+ *  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.aci;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.ldap.aci.protectedItem.RangeOfValuesItem;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ProtectedItem.RangeOfValues.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ProtectedItem_RangeOfValuesTest
+{
+    RangeOfValuesItem rangeOfValuesA;
+    RangeOfValuesItem rangeOfValuesACopy;
+    RangeOfValuesItem rangeOfValuesB;
+    RangeOfValuesItem rangeOfValuesC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+
+        ExprNode filterA = FilterParser.parse( "(&(cn=test)(sn=test))" );
+        ExprNode filterB = FilterParser.parse( "(&(cn=test)(sn=test))" );
+        ExprNode filterC = FilterParser.parse( "(&(cn=sample)(sn=sample))" );
+
+        rangeOfValuesA = new RangeOfValuesItem( filterA );
+        rangeOfValuesACopy = new RangeOfValuesItem( filterA );
+        rangeOfValuesB = new RangeOfValuesItem( filterB );
+        rangeOfValuesC = new RangeOfValuesItem( filterC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( rangeOfValuesA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( rangeOfValuesA, rangeOfValuesA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( rangeOfValuesA.hashCode(), rangeOfValuesA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( rangeOfValuesA, rangeOfValuesACopy );
+        assertEquals( rangeOfValuesACopy, rangeOfValuesA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( rangeOfValuesA.hashCode(), rangeOfValuesACopy.hashCode() );
+        assertEquals( rangeOfValuesACopy.hashCode(), rangeOfValuesA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( rangeOfValuesA, rangeOfValuesACopy );
+        assertEquals( rangeOfValuesACopy, rangeOfValuesB );
+        assertEquals( rangeOfValuesA, rangeOfValuesB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( rangeOfValuesA.hashCode(), rangeOfValuesACopy.hashCode() );
+        assertEquals( rangeOfValuesACopy.hashCode(), rangeOfValuesB.hashCode() );
+        assertEquals( rangeOfValuesA.hashCode(), rangeOfValuesB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( rangeOfValuesA.equals( rangeOfValuesC ) );
+        assertFalse( rangeOfValuesC.equals( rangeOfValuesA ) );
+    }
+}