directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36735 - incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message
Date Mon, 23 Aug 2004 01:46:20 GMT
Author: akarasulu
Date: Sun Aug 22 18:46:19 2004
New Revision: 36735

Modified:
   incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java
Log:
Added test to see that equals works regardless of the Referral's parent Lockable
and regardless of the implementation so long as it implements a Referral and
follows the expected semantics for equal.


Modified: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java
(original)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java
Sun Aug 22 18:46:19 2004
@@ -18,6 +18,12 @@
 
 
 import junit.framework.TestCase;
+import org.apache.ldap.common.Lockable;
+import org.apache.ldap.common.AbstractLockable;
+import org.apache.ldap.common.LockException;
+
+import java.util.Collection;
+import java.util.Collections;
 
 
 /**
@@ -147,5 +153,81 @@
                 refs0.equals( refs1 ) ) ;
         assertFalse( "Referrals should not be equal",
                 refs1.equals( refs0 ) ) ;
+    }
+
+
+    /**
+     * Make sure the lockable parent being different does not effect equality.
+     */
+    public void testEqualsDifferentLockableParents()
+    {
+        ReferralImpl refs0 = new ReferralImpl( new AbstractLockable(){} );
+        ReferralImpl refs1 = new ReferralImpl( null );
+
+        assertTrue( "Empty Referrals should be equal",
+                refs0.equals( refs1 ) ) ;
+        assertTrue( "Empty Referrals should be equal",
+                refs1.equals( refs0 ) ) ;
+
+        refs0.addLdapUrl( "ldap://blah0" );
+        refs0.addLdapUrl( "ldap://blah1" );
+        refs1.addLdapUrl( "ldap://blah0" );
+        refs1.addLdapUrl( "ldap://blah1" );
+
+        assertTrue( "exact copies of Referrals should be equal",
+                refs0.equals( refs1 ) ) ;
+        assertTrue( "exact copies of Referrals should be equal",
+                refs1.equals( refs0 ) ) ;
+    }
+
+
+    public void testEqualsDifferentImpls()
+    {
+        Referral refs0 = new Referral()
+        {
+            public Collection getLdapUrls()
+            {
+                return Collections.EMPTY_LIST;
+            }
+
+            public void addLdapUrl( String a_url )
+            {
+            }
+
+            public void removeLdapUrl( String a_url )
+            {
+            }
+
+            public Lockable getParent()
+            {
+                return null;
+            }
+
+            public boolean isLocked()
+            {
+                return false;
+            }
+
+            public boolean getLocked()
+            {
+                return false;
+            }
+
+            public void setLocked( boolean a_isLocked ) throws LockException
+            {
+            }
+
+            public boolean isUnlockable()
+            {
+                return false;
+            }
+        };
+
+        ReferralImpl refs1 = new ReferralImpl( null );
+
+        assertFalse( "Object.equals() in effect because we did not redefine "
+                + " equals for the new impl above", refs0.equals( refs1 ) ) ;
+        assertTrue( "Empty Referrals should be equal even if they are different"
+                + " implementation classes", refs1.equals( refs0 ) ) ;
     }
 }

Mime
View raw message