directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1050491 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/aci/protectedItem/ test/java/org/apache/directory/shared/ldap/aci/protectedItem/ test/java/org/apache/directory/shared/ldap/filter/
Date Fri, 17 Dec 2010 21:02:05 GMT
Author: felixk
Date: Fri Dec 17 21:02:04 2010
New Revision: 1050491

URL: http://svn.apache.org/viewvc?rev=1050491&view=rev
Log:
Fix some equals/hashCode methods found by new test cases

Added:
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeValueItemTest.java
  (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/ClassesItemTest.java
  (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxImmSubItemTest.java
  (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountItemTest.java
  (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByItemTest.java
  (with props)
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/UndefinedNodeTest.java
  (with props)
Modified:
    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/RestrictedByElem.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountElem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountElem.java?rev=1050491&r1=1050490&r2=1050491&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountElem.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountElem.java
Fri Dec 17 21:02:04 2010
@@ -70,6 +70,55 @@ public class MaxValueCountElem
         return maxCount;
     }
 
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode()
+    {
+        int hash = 37;
+        hash = hash * 17 + maxCount;
+        hash = hash * 17 + attributeType.hashCode();
+        return hash;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object o )
+    {
+        if (o == null)
+        {
+            return false;
+        }
+        
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( o instanceof MaxValueCountElem )
+        {
+            MaxValueCountElem that = ( MaxValueCountElem ) o;
+            if ( this.maxCount == that.maxCount )
+            {
+                if ( this.attributeType == null )
+                {
+                    return that.attributeType == null;
+                }
+                else
+                {
+                    return this.attributeType.equals( that.attributeType );
+                }
+            }
+        }
+        return false;
+    }
+
 
     /**
      * {@inheritDoc}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByElem.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByElem.java?rev=1050491&r1=1050490&r2=1050491&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByElem.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByElem.java
Fri Dec 17 21:02:04 2010
@@ -75,6 +75,73 @@ public class RestrictedByElem
      * {@inheritDoc}
      */
     @Override
+    public int hashCode()
+    {
+        int hash = 37;
+        hash = hash * 17 + attributeType.hashCode();
+        hash = hash * 17 + valuesIn.hashCode();
+        return hash;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object o )
+    {
+        if (o == null)
+        {
+            return false;
+        }
+        
+        if ( this == o )
+        {
+            return true;
+        }
+        
+        if ( o instanceof RestrictedByElem )
+        {
+            RestrictedByElem that = ( RestrictedByElem ) o;
+            if ( this.attributeType == null )
+            {
+                if ( that.attributeType == null )
+                {
+                    if ( this.valuesIn == null )
+                    {
+                        return that.valuesIn == null;
+                    }
+                    else
+                    {
+                        return this.valuesIn.equals( that.valuesIn );
+                    }
+                }
+                return false;
+            }
+            else
+            {
+                if ( this.attributeType.equals( that.attributeType ))
+                {
+                    if ( this.valuesIn == null )
+                    {
+                        return that.valuesIn == null;
+                    }
+                    else
+                    {
+                        return this.valuesIn.equals( that.valuesIn );
+                    }
+                }
+                return false;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public String toString()
     {
         return "{ type " + attributeType.getName() + ", valuesIn " + valuesIn.getName() +
" }";

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeValueItemTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeValueItemTest.java?rev=1050491&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeValueItemTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/AttributeValueItemTest.java
Fri Dec 17 21:02:04 2010
@@ -0,0 +1,160 @@
+/*
+ *  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.protectedItem;
+
+
+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.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.filter.UndefinedNode;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class AttributeValueItem.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class AttributeValueItemTest
+{
+    AttributeValueItem attributeValueItemA;
+    AttributeValueItem attributeValueItemACopy;
+    AttributeValueItem attributeValueItemB;
+    AttributeValueItem attributeValueItemC;
+    AttributeValueItem attributeValueItemD;
+    Set<EntryAttribute> attributeA;
+    Set<EntryAttribute> attributeB;
+    Set<EntryAttribute> attributeC;
+    Set<EntryAttribute> attributeD;
+
+
+    /**
+     * Initialize maxValueCountItem instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        attributeA = new HashSet<EntryAttribute>();
+        attributeA.add( new DefaultEntryAttribute( "aa", "aa" ) );
+        attributeA.add( new DefaultEntryAttribute( "aa", "bb" ) );
+        attributeA.add( new DefaultEntryAttribute( "aa", "cc" ) );
+        // Sets aren't ordered, so adding order must not matter
+        attributeB = new HashSet<EntryAttribute>();
+        attributeB.add( new DefaultEntryAttribute( "aa", "bb" ) );
+        attributeB.add( new DefaultEntryAttribute( "aa", "cc" ) );
+        attributeB.add( new DefaultEntryAttribute( "aa", "aa" ) );
+        attributeC = new HashSet<EntryAttribute>();
+        attributeC.add( new DefaultEntryAttribute( "aa", "aa" ) );
+        attributeC.add( new DefaultEntryAttribute( "bb", "bb" ) );
+        attributeC.add( new DefaultEntryAttribute( "aa", "cc" ) );
+        attributeD = new HashSet<EntryAttribute>();
+        attributeD.add( new DefaultEntryAttribute( "aa", "aa" ) );
+        attributeD.add( new DefaultEntryAttribute( "aa", "bb" ) );
+        attributeD.add( new DefaultEntryAttribute( "aa", "dd" ) );
+        attributeValueItemA = new AttributeValueItem( attributeA );
+        attributeValueItemACopy = new AttributeValueItem( attributeA );
+        attributeValueItemB = new AttributeValueItem( attributeB );
+        attributeValueItemC = new AttributeValueItem( attributeC );
+        attributeValueItemD = new AttributeValueItem( attributeD );
+    }
+
+
+    @Test
+    public void testEqualsNotInstanceOf() throws Exception
+    {
+        assertFalse( attributeValueItemA.equals( UndefinedNode.UNDEFINED_NODE ) );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( attributeValueItemA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( attributeValueItemA, attributeValueItemA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( attributeValueItemA.hashCode(), attributeValueItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( attributeValueItemA, attributeValueItemACopy );
+        assertEquals( attributeValueItemACopy, attributeValueItemA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( attributeValueItemA.hashCode(), attributeValueItemACopy.hashCode()
);
+        assertEquals( attributeValueItemACopy.hashCode(), attributeValueItemA.hashCode()
);
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( attributeValueItemA, attributeValueItemACopy );
+        assertEquals( attributeValueItemACopy, attributeValueItemB );
+        assertEquals( attributeValueItemA, attributeValueItemB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( attributeValueItemA.hashCode(), attributeValueItemACopy.hashCode()
);
+        assertEquals( attributeValueItemACopy.hashCode(), attributeValueItemB.hashCode()
);
+        assertEquals( attributeValueItemA.hashCode(), attributeValueItemB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( attributeValueItemA.equals( attributeValueItemC ) );
+        assertFalse( attributeValueItemC.equals( attributeValueItemA ) );
+        assertFalse( attributeValueItemA.equals( attributeValueItemD ) );
+        assertFalse( attributeValueItemD.equals( attributeValueItemA ) );
+    }
+}

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

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/ClassesItemTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/ClassesItemTest.java?rev=1050491&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/ClassesItemTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/ClassesItemTest.java
Fri Dec 17 21:02:04 2010
@@ -0,0 +1,131 @@
+/*
+ *  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.protectedItem;
+
+
+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.filter.SubstringNode;
+import org.apache.directory.shared.ldap.filter.UndefinedNode;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class ClassesItem.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class ClassesItemTest
+{
+    ClassesItem classesItemA;
+    ClassesItem classesItemACopy;
+    ClassesItem classesItemB;
+    ClassesItem classesItemC;
+
+
+    /**
+     * Initialize classesItem instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        classesItemA = new ClassesItem( new SubstringNode( "aa" ) );
+        classesItemACopy = new ClassesItem( new SubstringNode( "aa" ) );
+        classesItemB = new ClassesItem( new SubstringNode( "aa" ) );
+        classesItemC = new ClassesItem( new SubstringNode( "cc" ) );
+    }
+
+
+    @Test
+    public void testEqualsNotInstanceOf() throws Exception
+    {
+        assertFalse( classesItemA.equals( UndefinedNode.UNDEFINED_NODE ) );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( classesItemA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( classesItemA, classesItemA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( classesItemA.hashCode(), classesItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( classesItemA, classesItemACopy );
+        assertEquals( classesItemACopy, classesItemA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( classesItemA.hashCode(), classesItemACopy.hashCode() );
+        assertEquals( classesItemACopy.hashCode(), classesItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( classesItemA, classesItemACopy );
+        assertEquals( classesItemACopy, classesItemB );
+        assertEquals( classesItemA, classesItemB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( classesItemA.hashCode(), classesItemACopy.hashCode() );
+        assertEquals( classesItemACopy.hashCode(), classesItemB.hashCode() );
+        assertEquals( classesItemA.hashCode(), classesItemB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( classesItemA.equals( classesItemC ) );
+        assertFalse( classesItemC.equals( classesItemA ) );
+    }
+}

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

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxImmSubItemTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxImmSubItemTest.java?rev=1050491&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxImmSubItemTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxImmSubItemTest.java
Fri Dec 17 21:02:04 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.protectedItem;
+
+
+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.filter.UndefinedNode;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class MaxImmSubItem.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class MaxImmSubItemTest
+{
+    MaxImmSubItem maxImmSubItemA;
+    MaxImmSubItem maxImmSubItemACopy;
+    MaxImmSubItem maxImmSubItemB;
+    MaxImmSubItem maxImmSubItemC;
+
+
+    /**
+     * Initialize maxImmSubItem instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        maxImmSubItemA = new MaxImmSubItem( 1 );
+        maxImmSubItemACopy = new MaxImmSubItem( 1 );
+        maxImmSubItemB = new MaxImmSubItem( 1 );
+        maxImmSubItemC = new MaxImmSubItem( 2 );
+    }
+
+
+    @Test
+    public void testEqualsNotInstanceOf() throws Exception
+    {
+        assertFalse( maxImmSubItemA.equals( UndefinedNode.UNDEFINED_NODE ) );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( maxImmSubItemA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( maxImmSubItemA, maxImmSubItemA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( maxImmSubItemA, maxImmSubItemACopy );
+        assertEquals( maxImmSubItemACopy, maxImmSubItemA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemACopy.hashCode() );
+        assertEquals( maxImmSubItemACopy.hashCode(), maxImmSubItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( maxImmSubItemA, maxImmSubItemACopy );
+        assertEquals( maxImmSubItemACopy, maxImmSubItemB );
+        assertEquals( maxImmSubItemA, maxImmSubItemB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemACopy.hashCode() );
+        assertEquals( maxImmSubItemACopy.hashCode(), maxImmSubItemB.hashCode() );
+        assertEquals( maxImmSubItemA.hashCode(), maxImmSubItemB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( maxImmSubItemA.equals( maxImmSubItemC ) );
+        assertFalse( maxImmSubItemC.equals( maxImmSubItemA ) );
+    }
+}

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

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountItemTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountItemTest.java?rev=1050491&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountItemTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/MaxValueCountItemTest.java
Fri Dec 17 21:02:04 2010
@@ -0,0 +1,159 @@
+/*
+ *  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.protectedItem;
+
+
+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.filter.UndefinedNode;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class MaxValueCountItem.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class MaxValueCountItemTest
+{
+    MaxValueCountItem maxValueCountItemA;
+    MaxValueCountItem maxValueCountItemACopy;
+    MaxValueCountItem maxValueCountItemB;
+    MaxValueCountItem maxValueCountItemC;
+    MaxValueCountItem maxValueCountItemD;
+    Set<MaxValueCountElem> itemsA;
+    Set<MaxValueCountElem> itemsB;
+    Set<MaxValueCountElem> itemsC;
+    Set<MaxValueCountElem> itemsD;
+
+
+    /**
+     * Initialize maxValueCountItem instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        itemsA = new HashSet<MaxValueCountElem>();
+        itemsA.add( new MaxValueCountElem( new AttributeType("aa"), 1 ) );
+        itemsA.add( new MaxValueCountElem( new AttributeType("aa"), 2 ) );
+        itemsA.add( new MaxValueCountElem( new AttributeType("aa"), 3 ) );
+        // Sets aren't ordered, so adding order must not matter
+        itemsB = new HashSet<MaxValueCountElem>();
+        itemsB.add( new MaxValueCountElem( new AttributeType("aa"), 2 ) );
+        itemsB.add( new MaxValueCountElem( new AttributeType("aa"), 3 ) );
+        itemsB.add( new MaxValueCountElem( new AttributeType("aa"), 1 ) );
+        itemsC = new HashSet<MaxValueCountElem>();
+        itemsC.add( new MaxValueCountElem( new AttributeType("aa"), 1 ) );
+        itemsC.add( new MaxValueCountElem( new AttributeType("bb"), 2 ) );
+        itemsC.add( new MaxValueCountElem( new AttributeType("aa"), 3 ) );
+        itemsD = new HashSet<MaxValueCountElem>();
+        itemsD.add( new MaxValueCountElem( new AttributeType("aa"), 1 ) );
+        itemsD.add( new MaxValueCountElem( new AttributeType("aa"), 2 ) );
+        itemsD.add( new MaxValueCountElem( new AttributeType("aa"), 4 ) );
+        maxValueCountItemA = new MaxValueCountItem( itemsA );
+        maxValueCountItemACopy = new MaxValueCountItem( itemsA );
+        maxValueCountItemB = new MaxValueCountItem( itemsB );
+        maxValueCountItemC = new MaxValueCountItem( itemsC );
+        maxValueCountItemD = new MaxValueCountItem( itemsD );
+    }
+
+
+    @Test
+    public void testEqualsNotInstanceOf() throws Exception
+    {
+        assertFalse( maxValueCountItemA.equals( UndefinedNode.UNDEFINED_NODE ) );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( maxValueCountItemA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( maxValueCountItemA, maxValueCountItemA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountItemA, maxValueCountItemACopy );
+        assertEquals( maxValueCountItemACopy, maxValueCountItemA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemACopy.hashCode() );
+        assertEquals( maxValueCountItemACopy.hashCode(), maxValueCountItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( maxValueCountItemA, maxValueCountItemACopy );
+        assertEquals( maxValueCountItemACopy, maxValueCountItemB );
+        assertEquals( maxValueCountItemA, maxValueCountItemB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemACopy.hashCode() );
+        assertEquals( maxValueCountItemACopy.hashCode(), maxValueCountItemB.hashCode() );
+        assertEquals( maxValueCountItemA.hashCode(), maxValueCountItemB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( maxValueCountItemA.equals( maxValueCountItemC ) );
+        assertFalse( maxValueCountItemC.equals( maxValueCountItemA ) );
+        assertFalse( maxValueCountItemA.equals( maxValueCountItemD ) );
+        assertFalse( maxValueCountItemD.equals( maxValueCountItemA ) );
+    }
+}

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

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByItemTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByItemTest.java?rev=1050491&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByItemTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/aci/protectedItem/RestrictedByItemTest.java
Fri Dec 17 21:02:04 2010
@@ -0,0 +1,159 @@
+/*
+ *  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.protectedItem;
+
+
+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.filter.UndefinedNode;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class RestrictedByItem.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class RestrictedByItemTest
+{
+    RestrictedByItem restrictedByItemA;
+    RestrictedByItem restrictedByItemACopy;
+    RestrictedByItem restrictedByItemB;
+    RestrictedByItem restrictedByItemC;
+    RestrictedByItem restrictedByItemD;
+    Set<RestrictedByElem> elemsA;
+    Set<RestrictedByElem> elemsB;
+    Set<RestrictedByElem> elemsC;
+    Set<RestrictedByElem> elemsD;
+
+
+    /**
+     * Initialize maxValueCountItem instances
+     */
+    @Before
+    public void initNames() throws Exception
+    {
+        elemsA = new HashSet<RestrictedByElem>();
+        elemsA.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("aa")
) );
+        elemsA.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("bb")
) );
+        elemsA.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("cc")
) );
+        // Sets aren't ordered, so adding order must not matter
+        elemsB = new HashSet<RestrictedByElem>();
+        elemsB.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("bb")
) );
+        elemsB.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("cc")
) );
+        elemsB.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("aa")
) );
+        elemsC = new HashSet<RestrictedByElem>();
+        elemsC.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("aa")
) );
+        elemsC.add( new RestrictedByElem( new AttributeType("bb"), new AttributeType("bb")
) );
+        elemsC.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("cc")
) );
+        elemsD = new HashSet<RestrictedByElem>();
+        elemsD.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("aa")
) );
+        elemsD.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("bb")
) );
+        elemsD.add( new RestrictedByElem( new AttributeType("aa"), new AttributeType("dd")
) );
+        restrictedByItemA = new RestrictedByItem( elemsA );
+        restrictedByItemACopy = new RestrictedByItem( elemsA );
+        restrictedByItemB = new RestrictedByItem( elemsB );
+        restrictedByItemC = new RestrictedByItem( elemsC );
+        restrictedByItemD = new RestrictedByItem( elemsD );
+    }
+
+
+    @Test
+    public void testEqualsNotInstanceOf() throws Exception
+    {
+        assertFalse( restrictedByItemA.equals( UndefinedNode.UNDEFINED_NODE ) );
+    }
+
+
+    @Test
+    public void testEqualsNull() throws Exception
+    {
+        assertFalse( restrictedByItemA.equals( null ) );
+    }
+
+
+    @Test
+    public void testEqualsReflexive() throws Exception
+    {
+        assertEquals( restrictedByItemA, restrictedByItemA );
+    }
+
+
+    @Test
+    public void testHashCodeReflexive() throws Exception
+    {
+        assertEquals( restrictedByItemA.hashCode(), restrictedByItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsSymmetric() throws Exception
+    {
+        assertEquals( restrictedByItemA, restrictedByItemACopy );
+        assertEquals( restrictedByItemACopy, restrictedByItemA );
+    }
+
+
+    @Test
+    public void testHashCodeSymmetric() throws Exception
+    {
+        assertEquals( restrictedByItemA.hashCode(), restrictedByItemACopy.hashCode() );
+        assertEquals( restrictedByItemACopy.hashCode(), restrictedByItemA.hashCode() );
+    }
+
+
+    @Test
+    public void testEqualsTransitive() throws Exception
+    {
+        assertEquals( restrictedByItemA, restrictedByItemACopy );
+        assertEquals( restrictedByItemACopy, restrictedByItemB );
+        assertEquals( restrictedByItemA, restrictedByItemB );
+    }
+
+
+    @Test
+    public void testHashCodeTransitive() throws Exception
+    {
+        assertEquals( restrictedByItemA.hashCode(), restrictedByItemACopy.hashCode() );
+        assertEquals( restrictedByItemACopy.hashCode(), restrictedByItemB.hashCode() );
+        assertEquals( restrictedByItemA.hashCode(), restrictedByItemB.hashCode() );
+    }
+
+
+    @Test
+    public void testNotEqualDiffValue() throws Exception
+    {
+        assertFalse( restrictedByItemA.equals( restrictedByItemC ) );
+        assertFalse( restrictedByItemC.equals( restrictedByItemA ) );
+        assertFalse( restrictedByItemA.equals( restrictedByItemD ) );
+        assertFalse( restrictedByItemD.equals( restrictedByItemA ) );
+    }
+}

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

Added: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/UndefinedNodeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/UndefinedNodeTest.java?rev=1050491&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/UndefinedNodeTest.java
(added)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/filter/UndefinedNodeTest.java
Fri Dec 17 21:02:04 2010
@@ -0,0 +1,101 @@
+/*
+ *   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.filter;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+import java.util.List;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Unit tests class UndefinedNode.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class UndefinedNodeTest
+{
+
+    ExprNode undefinedNode = UndefinedNode.UNDEFINED_NODE;
+
+
+    @Test
+    public void testIsLeaf() throws Exception
+    {
+        assertFalse( undefinedNode.isLeaf() );
+    }
+
+
+    @Test
+    public void testIsSchemaAware() throws Exception
+    {
+        assertFalse( undefinedNode.isSchemaAware() );
+    }
+
+
+    @Test
+    public void testAssertationType() throws Exception
+    {
+        assertEquals( undefinedNode.getAssertionType(), AssertionType.UNDEFINED );
+    }
+
+
+    @Test
+    public void testAccept() throws Exception
+    {
+        assertNull( undefinedNode.accept( new FilterVisitor()
+        {
+
+            public Object visit( ExprNode node )
+            {
+                return null;
+            }
+
+
+            public boolean isPrefix()
+            {
+                return false;
+            }
+
+
+            public List<ExprNode> getOrder( BranchNode node, List<ExprNode> children
)
+            {
+                return null;
+            }
+
+
+            public boolean canVisit( ExprNode node )
+            {
+                return false;
+            }
+        } ) );
+    }
+
+}

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



Mime
View raw message