directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r620589 - /directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmNoDupsCursorTest.java
Date Mon, 11 Feb 2008 19:38:58 GMT
Author: akarasulu
Date: Mon Feb 11 11:38:57 2008
New Revision: 620589

URL: http://svn.apache.org/viewvc?rev=620589&view=rev
Log:
DIRSERVER-1126: Applying patch from Kiran Ayyagari for testing jdbm cursors

Modified:
    directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmNoDupsCursorTest.java

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmNoDupsCursorTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmNoDupsCursorTest.java?rev=620589&r1=620588&r2=620589&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmNoDupsCursorTest.java
(original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmNoDupsCursorTest.java
Mon Feb 11 11:38:57 2008
@@ -24,6 +24,7 @@
 import org.apache.directory.server.core.partition.impl.btree.Table;
 import org.apache.directory.server.core.partition.impl.btree.Tuple;
 import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
 import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.server.schema.registries.ComparatorRegistry;
 import org.apache.directory.shared.ldap.schema.syntax.ComparatorDescription;
@@ -94,7 +95,7 @@
     }
 
 
-    @Test
+    @Test( expected=InvalidCursorPositionException.class )
     public void testOnEmptyTable() throws Exception
     {
         Cursor<Tuple<Integer,Integer>> cursor = table.cursor();
@@ -102,6 +103,9 @@
         
         assertFalse( cursor.available() );
         assertFalse( cursor.isClosed() );
+        assertTrue( cursor.isElementReused() );
+        cursor.after( new Tuple<Integer,Integer>(7,7) );
+        cursor.get();
     }
 
 
@@ -116,19 +120,22 @@
         assertTrue( tuple.getKey().equals( 1 ) );
         assertTrue( tuple.getValue().equals( 1 ) );
     
-        assertFalse( cursor.next() );
+        cursor.beforeFirst();
+        assertFalse( cursor.previous() );
+        assertTrue( cursor.next() );
     }
 
     
     @Test
     public void testOnTableWithMultipleEntries() throws Exception
     {
-        for( int i=0; i < 10; i++ )
+        for( int i=1; i < 10; i++ )
         {
             table.put( i, i );
         }
     
         Cursor<Tuple<Integer,Integer>> cursor = table.cursor();
+        
         cursor.after( new Tuple<Integer,Integer>( 2,2 ) );
         assertTrue( cursor.next() );
     
@@ -151,11 +158,24 @@
         cursor.beforeFirst();
         cursor.next();
         tuple = cursor.get();
-        assertTrue( tuple.getKey().equals( 0 ) );
-        assertTrue( tuple.getValue().equals( 0 ) );
+        assertTrue( tuple.getKey().equals( 1 ) );
+        assertTrue( tuple.getValue().equals( 1 ) );
     
         cursor.afterLast();
         assertFalse( cursor.next() );
+
+        cursor.beforeFirst();
+        assertFalse( cursor.previous() );
+        
+        // just to clear the jdbmTuple value so that line 127 inside after(tuple) method
+        // can be executed as part of the below after(tuple) call
+        cursor.before(new Tuple<Integer,Integer>( 1,1 )); 
+        cursor.after( new Tuple<Integer,Integer>( 0,0 ) );
+        
+        cursor.next();
+        tuple = cursor.get();
+        assertTrue( tuple.getKey().equals( 1 ) );
+        assertTrue( tuple.getValue().equals( 1 ) );
     }
     
     



Mime
View raw message