You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/08/23 03:33:48 UTC
svn commit: rev 36732 - incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message
Author: akarasulu
Date: Sun Aug 22 18:33:47 2004
New Revision: 36732
Added:
incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/
incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java
Log:
Added the test case to make sure the equals() method works correctly.
Added: incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java
==============================================================================
--- (empty file)
+++ incubator/directory/ldap/trunk/common/src/test/org/apache/ldap/common/message/ReferralImplTest.java Sun Aug 22 18:33:47 2004
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.common.message;
+
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests the ReferralImpl class.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ * Project</a> $Rev$
+ */
+public class ReferralImplTest extends TestCase
+{
+ /**
+ * Tests to make sure the equals method works for the same exact object.
+ */
+ public void testEqualsSameObject()
+ {
+ ReferralImpl refs = new ReferralImpl( null );
+ assertTrue( "equals method should work for the same object",
+ refs.equals( refs ) );
+ }
+
+
+ /**
+ * Tests to make sure the equals method works for two objects that are the
+ * same exact copy of one another.
+ */
+ public void testEqualsExactCopy()
+ {
+ ReferralImpl refs0 = new ReferralImpl( null );
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ ReferralImpl refs1 = new ReferralImpl( null );
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ assertTrue( "exact copies of Referrals should be equal",
+ refs0.equals( refs1 ) ) ;
+ assertTrue( "exact copies of Referrals should be equal",
+ refs1.equals( refs0 ) ) ;
+ }
+
+
+ /**
+ * Tests to make sure the equals method works for two objects that are the
+ * same exact copy of one another but there are redundant entries.
+ */
+ public void testEqualsExactCopyWithRedundancy()
+ {
+ ReferralImpl refs0 = new ReferralImpl( null );
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ ReferralImpl refs1 = new ReferralImpl( null );
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ assertTrue( "exact copies of Referrals should be equal",
+ refs0.equals( refs1 ) ) ;
+ assertTrue( "exact copies of Referrals should be equal",
+ refs1.equals( refs0 ) ) ;
+ }
+
+
+ /**
+ * Tests to make sure the equals method works for two objects that are the
+ * same exact copy of one another but there are redundant entries.
+ */
+ public void testEqualsSameButWithRedundancyInOne()
+ {
+ ReferralImpl refs0 = new ReferralImpl( null );
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ ReferralImpl refs1 = new ReferralImpl( null );
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ assertTrue( "Same Referrals should be equal even if one has redundancy",
+ refs0.equals( refs1 ) ) ;
+ assertTrue( "Same Referrals should be equal even if one has redundancy",
+ refs1.equals( refs0 ) ) ;
+ }
+
+
+ /**
+ * Tests to make sure the equals method works for two objects that are the
+ * not exact copies of one another but have the same number of URLs.
+ */
+ public void testEqualsSameNumberButDifferentUrls()
+ {
+ ReferralImpl refs0 = new ReferralImpl( null );
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ refs0.addLdapUrl( "ldap://blah3" );
+ ReferralImpl refs1 = new ReferralImpl( null );
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ refs1.addLdapUrl( "ldap://blah2" );
+ refs1.addLdapUrl( "ldap://blah4" );
+ assertFalse( "Referrals should not be equal",
+ refs0.equals( refs1 ) ) ;
+ assertFalse( "Referrals should not be equal",
+ refs1.equals( refs0 ) ) ;
+ }
+
+
+ /**
+ * Tests to make sure the equals method works for two objects that are the
+ * not exact copies of one another and one has a subset of the urls of the
+ * other.
+ */
+ public void testEqualsSubset()
+ {
+ ReferralImpl refs0 = new ReferralImpl( null );
+ refs0.addLdapUrl( "ldap://blah0" );
+ refs0.addLdapUrl( "ldap://blah1" );
+ refs0.addLdapUrl( "ldap://blah2" );
+ refs0.addLdapUrl( "ldap://blah3" );
+ ReferralImpl refs1 = new ReferralImpl( null );
+ refs1.addLdapUrl( "ldap://blah0" );
+ refs1.addLdapUrl( "ldap://blah1" );
+ assertFalse( "Referrals should not be equal",
+ refs0.equals( refs1 ) ) ;
+ assertFalse( "Referrals should not be equal",
+ refs1.equals( refs0 ) ) ;
+ }
+}