directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r946658 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/aci/ test/java/org/apache/directory/shared/ldap/aci/
Date Thu, 20 May 2010 15:00:29 GMT
Author: felixk
Date: Thu May 20 15:00:28 2010
New Revision: 946658

URL: http://svn.apache.org/viewvc?rev=946658&view=rev
Log:
- Override hashCode when overriding equals
- Adding simple testcases

Some tests are ignored because I'm not sure if the equals method really does what is wanted:
A Collection is compared by collection1.equals(collection2) which is "false" in almost every case as a reference comparision is done [1].
I'm not sure if this is really wanted. If so, the tests annotated with @ignore can be removed. Otherwise a fix for the related equals method is needed.

[1] http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html#equals%28java.lang.Object%29

Added:
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java   (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java   (with props)
Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java?rev=946658&r1=946657&r2=946658&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ProtectedItem.java Thu May 20 15:00:28 2010
@@ -40,6 +40,8 @@ import org.apache.directory.shared.ldap.
  */
 public abstract class ProtectedItem implements Serializable
 {
+    private static final long serialVersionUID = 4727233664478810613L;
+
     /**
      * The entry contents as a whole. In case of a family member, it also means
      * the entry content of each subordinate family member within the same
@@ -103,6 +105,23 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + getClass().getName().hashCode();
+
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( this == o )
@@ -203,6 +222,8 @@ public abstract class ProtectedItem impl
      */
     private abstract static class AttributeTypeProtectedItem extends ProtectedItem
     {
+        private static final long serialVersionUID = 8425056384389605434L;
+
         protected final Collection<String> attributeTypes;
 
 
@@ -226,6 +247,23 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + attributeTypes.hashCode();
+
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( this == o )
@@ -391,6 +429,24 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + attributes.hashCode();
+            hash = hash * 17 + super.hashCode();
+
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( !super.equals( o ) )
@@ -480,6 +536,23 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + items.hashCode();
+
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( !super.equals( o ) )
@@ -562,6 +635,23 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + filter.hashCode();
+
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( this == o )
@@ -628,6 +718,22 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + value;
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( this == o )
@@ -687,6 +793,24 @@ public abstract class ProtectedItem impl
         }
 
 
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public int hashCode()
+        {
+            int hash = 37;
+            hash = hash * 17 + items.hashCode();
+            hash = hash * 17 + super.hashCode();
+
+            return hash;
+        }
+
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
         public boolean equals( Object o )
         {
             if ( !super.equals( o ) )

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java Thu May 20 15:00:28 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.ArrayList;
+import java.util.Collection;
+
+import org.apache.directory.shared.ldap.aci.ProtectedItem.AllAttributeValues;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.AllAttributeValues.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_AllAttributeValuesTest
+{
+    AllAttributeValues allAttributeValuesA;
+    AllAttributeValues allAttributeValuesACopy;
+    AllAttributeValues allAttributeValuesB;
+    AllAttributeValues allAttributeValuesC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        Collection<String> colA = new ArrayList<String>();
+        colA.add( "aa" );
+        colA.add( "bb" );
+        colA.add( "cc" );
+        Collection<String> colB = new ArrayList<String>();
+        colB.add( "aa" );
+        colB.add( "bb" );
+        colB.add( "cc" );
+        Collection<String> colC = new ArrayList<String>();
+        colC.add( "bb" );
+        colC.add( "cc" );
+        colC.add( "aa" );
+
+        allAttributeValuesA = new AllAttributeValues( colA );
+        allAttributeValuesACopy = new AllAttributeValues( colA );
+        allAttributeValuesB = new AllAttributeValues( colB );
+        allAttributeValuesC = new AllAttributeValues( 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
+    @Ignore
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( allAttributeValuesA, allAttributeValuesACopy );
+        assertEquals( allAttributeValuesACopy, allAttributeValuesA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( allAttributeValuesA.hashCode(), allAttributeValuesACopy.hashCode() );
+        assertEquals( allAttributeValuesACopy.hashCode(), allAttributeValuesA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( allAttributeValuesA, allAttributeValuesACopy );
+        assertEquals( allAttributeValuesACopy, allAttributeValuesB );
+        assertEquals( allAttributeValuesA, allAttributeValuesB );
+    }
+
+
+    @Test
+    @Ignore
+    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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AllAttributeValuesTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java Thu May 20 15:00:28 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.ArrayList;
+import java.util.Collection;
+
+import org.apache.directory.shared.ldap.aci.ProtectedItem.AttributeType;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.AttributeType.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_AttributeTypeTest
+{
+    AttributeType attributeTypeA;
+    AttributeType attributeTypeACopy;
+    AttributeType attributeTypeB;
+    AttributeType attributeTypeC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        Collection<String> colA = new ArrayList<String>();
+        colA.add( "aa" );
+        colA.add( "bb" );
+        colA.add( "cc" );
+        Collection<String> colB = new ArrayList<String>();
+        colB.add( "aa" );
+        colB.add( "bb" );
+        colB.add( "cc" );
+        Collection<String> colC = new ArrayList<String>();
+        colC.add( "bb" );
+        colC.add( "cc" );
+        colC.add( "aa" );
+
+        attributeTypeA = new AttributeType( colA );
+        attributeTypeACopy = new AttributeType( colA );
+        attributeTypeB = new AttributeType( colB );
+        attributeTypeC = new AttributeType( 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
+    @Ignore
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( attributeTypeA, attributeTypeACopy );
+        assertEquals( attributeTypeACopy, attributeTypeA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( attributeTypeA.hashCode(), attributeTypeACopy.hashCode() );
+        assertEquals( attributeTypeACopy.hashCode(), attributeTypeA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( attributeTypeA, attributeTypeACopy );
+        assertEquals( attributeTypeACopy, attributeTypeB );
+        assertEquals( attributeTypeA, attributeTypeB );
+    }
+
+
+    @Test
+    @Ignore
+    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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java Thu May 20 15:00:28 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.ArrayList;
+import java.util.Collection;
+
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+
+import org.apache.directory.shared.ldap.aci.ProtectedItem.AttributeValue;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.AttributeValue.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_AttributeValueTest
+{
+    AttributeValue attributeValueA;
+    AttributeValue attributeValueACopy;
+    AttributeValue attributeValueB;
+    AttributeValue attributeValueC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+
+        Attribute attrA = new BasicAttribute( "aa" );
+        attrA.add( "aa" );
+        Attribute attrB = new BasicAttribute( "bb" );
+        attrB.add( "bb" );
+        Attribute attrC = new BasicAttribute( "cc" );
+        attrC.add( "cc" );
+
+        Collection<Attribute> colA = new ArrayList<Attribute>();
+        colA.add( attrA );
+        colA.add( attrB );
+        colA.add( attrC );
+        Collection<Attribute> colB = new ArrayList<Attribute>();
+        colB.add( attrA );
+        colB.add( attrB );
+        colB.add( attrC );
+        Collection<Attribute> colC = new ArrayList<Attribute>();
+        colC.add( attrB );
+        colC.add( attrC );
+        colC.add( attrA );
+
+        attributeValueA = new AttributeValue( colA );
+        attributeValueACopy = new AttributeValue( colA );
+        attributeValueB = new AttributeValue( colB );
+        attributeValueC = new AttributeValue( 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
+    @Ignore
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( attributeValueA, attributeValueACopy );
+        assertEquals( attributeValueACopy, attributeValueA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( attributeValueA.hashCode(), attributeValueACopy.hashCode() );
+        assertEquals( attributeValueACopy.hashCode(), attributeValueA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( attributeValueA, attributeValueACopy );
+        assertEquals( attributeValueACopy, attributeValueB );
+        assertEquals( attributeValueA, attributeValueB );
+    }
+
+
+    @Test
+    @Ignore
+    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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_AttributeValueTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java Thu May 20 15:00:28 2010
@@ -0,0 +1,124 @@
+/*
+ *  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.shared.ldap.aci.ProtectedItem.Classes;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.Classes.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_ClassesTest
+{
+    Classes classesA;
+    Classes classesACopy;
+    Classes classesB;
+    Classes 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 Classes( filterA );
+        classesACopy = new Classes( filterA );
+        classesB = new Classes( filterB );
+        classesC = new Classes( 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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_ClassesTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java Thu May 20 15:00:28 2010
@@ -0,0 +1,124 @@
+/*
+ *  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.shared.ldap.aci.ProtectedItem.MaxImmSub;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.MaxImmSub.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_MaxImmSubTest
+{
+    MaxImmSub maxValueCountA;
+    MaxImmSub maxValueCountACopy;
+    MaxImmSub maxValueCountB;
+    MaxImmSub maxValueCountC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+
+        MaxImmSub misA = new MaxImmSub( 1 );
+        MaxImmSub misB = new MaxImmSub( 1 );
+        MaxImmSub misC = new MaxImmSub( 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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxImmSubTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java Thu May 20 15:00:28 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.ArrayList;
+import java.util.Collection;
+
+import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCount;
+import org.apache.directory.shared.ldap.aci.ProtectedItem.MaxValueCountItem;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.MaxValueCount.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_MaxValueCountTest
+{
+    MaxValueCount maxValueCountA;
+    MaxValueCount maxValueCountACopy;
+    MaxValueCount maxValueCountB;
+    MaxValueCount maxValueCountC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+
+        MaxValueCountItem mvciA = new MaxValueCountItem( "aa", 1 );
+        MaxValueCountItem mvciB = new MaxValueCountItem( "bb", 2 );
+        MaxValueCountItem mvciC = new MaxValueCountItem( "cc", 3 );
+
+        Collection<MaxValueCountItem> colA = new ArrayList<MaxValueCountItem>();
+        colA.add( mvciA );
+        colA.add( mvciB );
+        colA.add( mvciC );
+        Collection<MaxValueCountItem> colB = new ArrayList<MaxValueCountItem>();
+        colB.add( mvciA );
+        colB.add( mvciB );
+        colB.add( mvciC );
+        Collection<MaxValueCountItem> colC = new ArrayList<MaxValueCountItem>();
+        colC.add( mvciB );
+        colC.add( mvciC );
+        colC.add( mvciA );
+
+        maxValueCountA = new MaxValueCount( colA );
+        maxValueCountACopy = new MaxValueCount( colA );
+        maxValueCountB = new MaxValueCount( colB );
+        maxValueCountC = new MaxValueCount( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( maxValueCountA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountACopy );
+        assertEquals( maxValueCountACopy, maxValueCountA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountA.hashCode(), maxValueCountACopy.hashCode() );
+        assertEquals( maxValueCountACopy.hashCode(), maxValueCountA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( maxValueCountA, maxValueCountACopy );
+        assertEquals( maxValueCountACopy, maxValueCountB );
+        assertEquals( maxValueCountA, maxValueCountB );
+    }
+
+
+    @Test
+    @Ignore
+    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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_MaxValueCountTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java Thu May 20 15:00:28 2010
@@ -0,0 +1,126 @@
+/*
+ *  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.shared.ldap.aci.ProtectedItem.RangeOfValues;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.RangeOfValues.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_RangeOfValuesTest
+{
+    RangeOfValues rangeOfValuesA;
+    RangeOfValues rangeOfValuesACopy;
+    RangeOfValues rangeOfValuesB;
+    RangeOfValues 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 RangeOfValues( filterA );
+        rangeOfValuesACopy = new RangeOfValues( filterA );
+        rangeOfValuesB = new RangeOfValues( filterB );
+        rangeOfValuesC = new RangeOfValues( 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 ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RangeOfValuesTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java Thu May 20 15:00:28 2010
@@ -0,0 +1,145 @@
+/*
+ *  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.ArrayList;
+import java.util.Collection;
+
+import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedBy;
+import org.apache.directory.shared.ldap.aci.ProtectedItem.RestrictedByItem;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.RestrictedBy.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_RestrictedByTest
+{
+    RestrictedBy restrictedByA;
+    RestrictedBy restrictedByACopy;
+    RestrictedBy restrictedByB;
+    RestrictedBy restrictedByC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        RestrictedByItem rbiA = new RestrictedByItem( "aa", "aa" );
+        RestrictedByItem rbiB = new RestrictedByItem( "bb", "bb" );
+        RestrictedByItem rbiC = new RestrictedByItem( "cc", "cc" );
+
+        Collection<RestrictedByItem> colA = new ArrayList<RestrictedByItem>();
+        colA.add( rbiA );
+        colA.add( rbiB );
+        colA.add( rbiC );
+        Collection<RestrictedByItem> colB = new ArrayList<RestrictedByItem>();
+        colB.add( rbiA );
+        colB.add( rbiB );
+        colB.add( rbiC );
+        Collection<RestrictedByItem> colC = new ArrayList<RestrictedByItem>();
+        colC.add( rbiB );
+        colC.add( rbiC );
+        colC.add( rbiA );
+
+        restrictedByA = new RestrictedBy( colA );
+        restrictedByACopy = new RestrictedBy( colA );
+        restrictedByB = new RestrictedBy( colB );
+        restrictedByC = new RestrictedBy( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( restrictedByA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( restrictedByA, restrictedByA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( restrictedByA.hashCode(), restrictedByA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( restrictedByA, restrictedByACopy );
+        assertEquals( restrictedByACopy, restrictedByA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( restrictedByA.hashCode(), restrictedByACopy.hashCode() );
+        assertEquals( restrictedByACopy.hashCode(), restrictedByA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( restrictedByA, restrictedByACopy );
+        assertEquals( restrictedByACopy, restrictedByB );
+        assertEquals( restrictedByA, restrictedByB );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( restrictedByA.hashCode(), restrictedByACopy.hashCode() );
+        assertEquals( restrictedByACopy.hashCode(), restrictedByB.hashCode() );
+        assertEquals( restrictedByA.hashCode(), restrictedByB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( restrictedByA.equals( restrictedByC ) );
+        assertFalse( restrictedByC.equals( restrictedByA ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_RestrictedByTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java?rev=946658&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java (added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java Thu May 20 15:00:28 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.ArrayList;
+import java.util.Collection;
+
+import org.apache.directory.shared.ldap.aci.ProtectedItem.SelfValue;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+/**
+ * Unit tests class ProtectedItem.SelfValue.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ProtectedItem_SelfValueTest
+{
+    SelfValue selfValueA;
+    SelfValue selfValueACopy;
+    SelfValue selfValueB;
+    SelfValue selfValueC;
+
+
+    /**
+     * Initialize name instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        Collection<String> colA = new ArrayList<String>();
+        colA.add( "aa" );
+        colA.add( "bb" );
+        colA.add( "cc" );
+        Collection<String> colB = new ArrayList<String>();
+        colB.add( "aa" );
+        colB.add( "bb" );
+        colB.add( "cc" );
+        Collection<String> colC = new ArrayList<String>();
+        colC.add( "bb" );
+        colC.add( "cc" );
+        colC.add( "aa" );
+
+        selfValueA = new SelfValue( colA );
+        selfValueACopy = new SelfValue( colA );
+        selfValueB = new SelfValue( colB );
+        selfValueC = new SelfValue( colC );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( selfValueA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( selfValueA, selfValueA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( selfValueA.hashCode(), selfValueA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( selfValueA, selfValueACopy );
+        assertEquals( selfValueACopy, selfValueA );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( selfValueA.hashCode(), selfValueACopy.hashCode() );
+        assertEquals( selfValueACopy.hashCode(), selfValueA.hashCode() );
+    }
+
+
+    @Test
+    @Ignore
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( selfValueA, selfValueACopy );
+        assertEquals( selfValueACopy, selfValueB );
+        assertEquals( selfValueA, selfValueB );
+    }
+
+
+    @Test
+    @Ignore
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( selfValueA.hashCode(), selfValueACopy.hashCode() );
+        assertEquals( selfValueACopy.hashCode(), selfValueB.hashCode() );
+        assertEquals( selfValueA.hashCode(), selfValueB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( selfValueA.equals( selfValueC ) );
+        assertFalse( selfValueC.equals( selfValueA ) );
+    }
+}

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/ProtectedItem_SelfValueTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message