directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r760451 - /directory/apacheds/branches/ldif-partition/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsCursorTest.java
Date Tue, 31 Mar 2009 13:51:36 GMT
Author: kayyagari
Date: Tue Mar 31 13:51:31 2009
New Revision: 760451

URL: http://svn.apache.org/viewvc?rev=760451&view=rev
Log:
o enabled dups on the tree under test
o added a test case to check the duplicate values of a key are stored in a AvlTree value

Modified:
    directory/apacheds/branches/ldif-partition/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsCursorTest.java

Modified: directory/apacheds/branches/ldif-partition/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsCursorTest.java?rev=760451&r1=760450&r2=760451&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsCursorTest.java
(original)
+++ directory/apacheds/branches/ldif-partition/core-avl/src/test/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsCursorTest.java
Tue Mar 31 13:51:31 2009
@@ -61,7 +61,7 @@
 
         };
 
-        tree = new AvlTreeMap<Integer, Integer>( comparator, comparator );
+        tree = new AvlTreeMap<Integer, Integer>( comparator, comparator, true );
 
         cursor = new AvlTreeMapNoDupsCursor<Integer, Integer>( tree );
     }
@@ -186,8 +186,6 @@
         tree.insert( 10, 10 );
         tree.insert( 11, 11 );
 
-        tree.insert( 3, 2 ); // try inserting a duplicate
-
         assertFalse( cursor.isClosed() );
         assertFalse( cursor.available() );
         assertTrue( cursor.isElementReused() );
@@ -289,4 +287,36 @@
         cursor.beforeValue( 0, 0 );
     }
 
+    
+    @Test
+    public void testCursorWithDupValues() throws Exception
+    {
+        tree.insert( 3, 3 );
+        tree.insert( 3, 7 );
+        tree.insert( 3, 10 );
+        tree.insert( 11, 11 );
+
+        cursor.next();
+        Tuple t = cursor.get();
+     
+        assertEquals( 3, t.getKey() );
+        
+        assertEquals( AvlTree.class, t.getValue().getClass() );
+        
+        AvlTree dupsTree = ( AvlTree ) t.getValue();
+        assertEquals( 3, dupsTree.getSize() );
+        
+        AvlTreeCursor valCursor = new AvlTreeCursor<Integer>( dupsTree );
+        
+        assertTrue( valCursor.next() );
+        assertEquals( 3, valCursor.get() );
+        
+        assertTrue( valCursor.next() );
+        assertEquals( 7, valCursor.get() );
+        
+        assertTrue( valCursor.next() );
+        assertEquals( 10, valCursor.get() );
+
+        assertFalse( valCursor.next() );
+    }
 }



Mime
View raw message