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 2008/05/24 20:52:42 UTC
svn commit: r659859 -
/directory/apacheds/branches/bigbang/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMarshallerTest.java
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, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
+ 110, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0,
+ 0, 0, 0, 0, 26, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0,
+ 8, 0, 0, 0, 0, 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,
+ 14, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 4, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0,
+ 3, 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, 6, 0, 0, 0,
+ 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 122, 0, 0, 0,
+ 5, 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, 7, 0, 0, 0,
+ 0, 0, 0, 0, 0
};
+
+// private static final byte[] SERIALIZED_AVLTREE_POST_REMOVE =
+// {
+// 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
+// };
AvlTree<Integer> tree;
Comparator<Integer> 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<Long> comparator = new Comparator<Long>()
{
@@ -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<Long> treeMarshaller = new AvlTreeMarshaller<Long>( comparator, new LongMarshaller() );
- treeMarshaller.deserialize( SERIALIZED_AVLTREE );
+ AvlTree<Long> 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 ) );
+ }
}