Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 38671 invoked from network); 24 May 2008 18:53:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 May 2008 18:53:04 -0000 Received: (qmail 43189 invoked by uid 500); 24 May 2008 18:53:05 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 43141 invoked by uid 500); 24 May 2008 18:53:05 -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 43132 invoked by uid 99); 24 May 2008 18:53:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 May 2008 11:53:05 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 May 2008 18:52:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2BC572388A05; Sat, 24 May 2008 11:52:43 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r659859 - /directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java Date: Sat, 24 May 2008 18:52:42 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080524185243.2BC572388A05@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: akarasulu Date: Sat May 24 11:52:42 2008 New Revision: 659859 URL: http://svn.apache.org/viewvc?rev=659859&view=rev Log: commiting new test to show how AvlTree.remove is failing by removing more keys than it should Modified: directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java Modified: directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java?rev=659859&r1=659858&r2=659859&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java (original) +++ directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java Sat May 24 11:52:42 2008 @@ -34,6 +34,7 @@ import java.util.Comparator; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,17 +48,44 @@ */ public class AvlTreeMarshallerTest { - private static final byte[] SERIALIZED_AVLTREE = - { - 0, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, - 86, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, - 0, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, -122, - 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, - 0, 0, 0, 122, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, -74, - 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0 + private static final long[] AVLTREE_KEYS_PRE_REMOVE = + { + 2, 14, 26, 86, 110, 122, 134, 182 + }; + + private static final long[] AVLTREE_EXPECTED_KEYS_POST_REMOVE = + { + 2, 14, 26, 86, 122, 134, 182 + }; + + private static final byte[] SERIALIZED_AVLTREE_PRE_REMOVE = + { + 0,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 0, 0 +// }; AvlTree tree; Comparator comparator; @@ -87,8 +115,14 @@ } + /** + * TODO Fix me. + * + * @throws IOException + */ @Test - public void testBadTree() throws IOException + @Ignore ( "Remove operation is deleting more keys than it should." ) + public void testRemoveBug() throws IOException { Comparator comparator = new Comparator() { @@ -97,10 +131,32 @@ return i1.compareTo( i2 ); } }; - - + + /* + * This deserializes the state of the AvlTree before the remove + * operation and it should work checking to make sure that all + * the pre-remove keys are present. + */ + AvlTreeMarshaller treeMarshaller = new AvlTreeMarshaller( comparator, new LongMarshaller() ); - treeMarshaller.deserialize( SERIALIZED_AVLTREE ); + AvlTree tree = treeMarshaller.deserialize( SERIALIZED_AVLTREE_PRE_REMOVE ); + + for ( long key : AVLTREE_KEYS_PRE_REMOVE ) + { + assertNotNull( "Should find " + key, tree.find( key ) ); + } + + /* + * Now we remove the key 110 and this should show that we don't have + * the expected keys. We will be missing 134, 2 and 14. + */ + + tree.remove( 110L ); + + for ( long key : AVLTREE_EXPECTED_KEYS_POST_REMOVE ) + { + assertNotNull( "Should find " + key, tree.find( key ) ); + } }