Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 87925 invoked from network); 2 Oct 2007 15:38:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Oct 2007 15:38:47 -0000 Received: (qmail 54100 invoked by uid 500); 2 Oct 2007 15:38:37 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 54056 invoked by uid 500); 2 Oct 2007 15:38:37 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 54045 invoked by uid 99); 2 Oct 2007 15:38:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Oct 2007 08:38:37 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Oct 2007 15:38:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9763B1A983A; Tue, 2 Oct 2007 08:37:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r581282 - /directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/common/ServerAttributeImplTest.java Date: Tue, 02 Oct 2007 15:37:56 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071002153756.9763B1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Tue Oct 2 08:37:55 2007 New Revision: 581282 URL: http://svn.apache.org/viewvc?rev=581282&view=rev Log: Added some tests for equals method Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/common/ServerAttributeImplTest.java Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/common/ServerAttributeImplTest.java URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/common/ServerAttributeImplTest.java?rev=581282&r1=581281&r2=581282&view=diff ============================================================================== --- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/common/ServerAttributeImplTest.java (original) +++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/common/ServerAttributeImplTest.java Tue Oct 2 08:37:55 2007 @@ -442,6 +442,7 @@ assertFalse( attr2.contains( StringTools.getBytesUtf8( "test3" ) ) ); } + /** * Test the clone method */ @@ -515,5 +516,59 @@ } assertEquals( i, attr.size() ); + } + + + /** + * Test the equals method + */ + @Test public void testEquals() throws NamingException + { + ServerAttribute attr1 = new ServerAttributeImpl( "string1", "test1" ); + attr1.add( "test2" ); + attr1.add( (String)null ); + + ServerAttribute attr2 = new ServerAttributeImpl( "string2", "test1" ); + attr2.add( "test2" ); + attr2.add( (String)null ); + + ServerAttribute attr3 = new ServerAttributeImpl( "string1", "a1" ); + attr1.add( "a2" ); + attr1.add( (String)null ); + + // Test reflexivity + assertEquals( attr1, attr1 ); + assertEquals( attr2, attr2 ); + assertEquals( attr3, attr3 ); + + // Compare != attrs + assertNotSame( attr1, attr2 ); + assertNotSame( attr1, attr3 ); + assertNotSame( attr2, attr3 ); + + // Compare cloned attrs + ServerAttribute attr4 = attr1.clone(); + + assertEquals( attr1, attr4 ); + + // Compare clone & modified attrs + ServerAttribute attr5 = attr1.clone(); + attr5.remove( "test2" ); + + assertNotSame( attr1, attr5 ); + + // Compare attr containing null values + attr5.remove( "test1" ); + + assertEquals( 1, attr5.size() ); + assertTrue( attr5.contains( (String)null ) ); + assertNotSame( attr1, attr5 ); + + attr1.remove( "test1" ); + attr1.remove( "test2" ); + + assertEquals( 1, attr1.size() ); + assertTrue( attr1.contains( (String)null ) ); + assertEquals( attr1, attr5 ); } }