You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/04/07 01:16:43 UTC

svn commit: r1310632 - in /directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm: ./ impl/avl/ search/impl/

Author: elecharny
Date: Fri Apr  6 23:16:42 2012
New Revision: 1310632

URL: http://svn.apache.org/viewvc?rev=1310632&view=rev
Log:
Closed many cursors that were not closed in tests

Modified:
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
    directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java Fri Apr  6 23:16:42 2012
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import org.apache.directory.shared.ldap.model.cursor.CursorClosedException;
 import org.apache.directory.shared.ldap.model.cursor.DefaultClosureMonitor;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -49,6 +50,16 @@ public class AbstractIndexCursorTest
     {
         indexCursor = new EmptyIndexCursor<String, Entry, Long>();
     }
+    
+    
+    @After
+    public void cleanup() throws Exception
+    {
+        if ( !indexCursor.isClosed() )
+        {
+            indexCursor.close();
+        }
+    }
 
 
     @Test(expected = IllegalArgumentException.class)

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java Fri Apr  6 23:16:42 2012
@@ -24,6 +24,7 @@ import static junit.framework.Assert.ass
 
 import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -44,12 +45,24 @@ public class EmptyIndexCursorTest
     {
         indexCursor = new EmptyIndexCursor<String, Entry, Long>();
     }
+    
+    
+    @After
+    public void cleanup() throws Exception
+    {
+        if ( !indexCursor.isClosed() )
+        {
+            indexCursor.close();
+        }
+    }
 
 
     @Test
-    public void testConstructor()
+    public void testConstructor() throws Exception
     {
-        new EmptyIndexCursor<String, Entry, Long>();
+        EmptyIndexCursor<String, Entry, Long> cursor = new EmptyIndexCursor<String, Entry, Long>();
+        
+        cursor.close();
     }
 
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java Fri Apr  6 23:16:42 2012
@@ -24,8 +24,10 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertTrue;
 
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -51,12 +53,21 @@ public class SingletonIndexCursorTest
         indexEntry.setValue( "test" );
         indexCursor = new SingletonIndexCursor<String, Long>( indexEntry );
     }
+    
+    
+    @After
+    public void cleanup() throws Exception
+    {
+        indexCursor.close();
+    }
 
 
     @Test
-    public void testConstructor()
+    public void testConstructor() throws Exception
     {
-        new SingletonIndexCursor<String, Long>( indexEntry );
+        Cursor cursor = new SingletonIndexCursor<String, Long>( indexEntry );
+        
+        cursor.close();
     }
 
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java Fri Apr  6 23:16:42 2012
@@ -429,6 +429,7 @@ public class AvlPartitionTest
         partition.add( addContext );
 
         partition.delete( 12L );
+        cursor.close();
     }
 
 
@@ -542,6 +543,8 @@ public class AvlPartitionTest
         assertEquals( 3, ( long ) cursor.get().getId() );
 
         assertFalse( cursor.previous() );
+        
+        cursor.close();
     }
 
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java Fri Apr  6 23:16:42 2012
@@ -305,6 +305,8 @@ public class AvlRdnIndexTest
         assertEquals( 2, ( long ) e3.getId() );
         assertEquals( "cn=key2", e3.getValue().getRdns()[0].getName() );
         assertEquals( 2, e3.getValue().getParentId().longValue() );
+
+        cursor.close();
     }
 
     //    @Test

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java Fri Apr  6 23:16:42 2012
@@ -111,6 +111,7 @@ public class AvlTableTest
         assertEquals( 10, tuple.getValue().intValue() );
 
         assertFalse( cursor.next() );
+        cursor.close();
     }
 
 
@@ -255,6 +256,7 @@ public class AvlTableTest
         assertNotNull( tuple );
         assertEquals( 23, tuple.getKey().intValue() );
         assertEquals( 8934, tuple.getValue().intValue() );
+        cursor.close();
     }
 
 
@@ -295,6 +297,7 @@ public class AvlTableTest
         assertNotNull( tuple );
         assertEquals( 23, tuple.getKey().intValue() );
         assertEquals( 8934, tuple.getValue().intValue() );
+        cursor.close();
     }
 
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java Fri Apr  6 23:16:42 2012
@@ -299,6 +299,8 @@ public class AndCursorTest
         {
         }
 
+        cursor.close();
+        wrapped.close();
     }
 
 }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java Fri Apr  6 23:16:42 2012
@@ -491,6 +491,8 @@ public class GreaterEqTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
+        assertTrue( cursor.isClosed() );
 
         // ---------- test last() ----------
 
@@ -514,12 +516,15 @@ public class GreaterEqTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
+        assertTrue( cursor.isClosed() );
 
         // ---------- test before() ----------
 
         cursor = new GreaterEqCursor( store, evaluator );
         ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
         indexEntry.setValue( "2" );
+        
         try
         {
             cursor.before( indexEntry );
@@ -527,6 +532,8 @@ public class GreaterEqTest
         }
         catch ( UnsupportedOperationException e )
         {
+            cursor.close();
+            assertTrue( cursor.isClosed() );
         }
 
         // ---------- test after() ----------
@@ -541,6 +548,8 @@ public class GreaterEqTest
         }
         catch ( UnsupportedOperationException e )
         {
+            cursor.close();
+            assertTrue( cursor.isClosed() );
         }
     }
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java Fri Apr  6 23:16:42 2012
@@ -434,7 +434,6 @@ public class LessEqTest
         assertFalse( cursor.isClosed() );
 
         // ---------- test bad get() ----------
-
         try
         {
             cursor.get();
@@ -455,6 +454,7 @@ public class LessEqTest
             assertTrue( cursor.available() );
             set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
@@ -469,7 +469,6 @@ public class LessEqTest
         assertTrue( cursor.isClosed() );
 
         // ---------- test beforeFirst() ----------
-
         set.clear();
         cursor = new LessEqCursor( store, evaluator );
         cursor.first();
@@ -482,6 +481,7 @@ public class LessEqTest
             assertTrue( cursor.available() );
             set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
@@ -496,7 +496,6 @@ public class LessEqTest
         assertTrue( cursor.isClosed() );
 
         // ---------- test afterLast() ----------
-
         set.clear();
         cursor = new LessEqCursor( store, evaluator );
         cursor.afterLast();
@@ -507,6 +506,7 @@ public class LessEqTest
             assertTrue( cursor.available() );
             set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
@@ -516,6 +516,8 @@ public class LessEqTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
+        assertTrue( cursor.isClosed() );
 
         // ---------- test last() ----------
 
@@ -531,6 +533,7 @@ public class LessEqTest
             assertTrue( cursor.available() );
             set.add( new Tuple<String, Long>( cursor.get().getValue(), cursor.get().getId() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 1L ) ) );
         assertTrue( set.contains( new Tuple<String, Long>( "1", 2L ) ) );
@@ -540,12 +543,15 @@ public class LessEqTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
+        assertTrue( cursor.isClosed() );
 
         // ---------- test before() ----------
 
         cursor = new LessEqCursor( store, evaluator );
         ForwardIndexEntry<String, Long> indexEntry = new ForwardIndexEntry<String, Long>();
         indexEntry.setValue( "2" );
+        
         try
         {
             cursor.before( indexEntry );
@@ -553,6 +559,8 @@ public class LessEqTest
         }
         catch ( UnsupportedOperationException e )
         {
+            cursor.close();
+            assertTrue( cursor.isClosed() );
         }
 
         // ---------- test after() ----------
@@ -567,6 +575,8 @@ public class LessEqTest
         }
         catch ( UnsupportedOperationException e )
         {
+            cursor.close();
+            assertTrue( cursor.isClosed() );
         }
     }
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java Fri Apr  6 23:16:42 2012
@@ -156,6 +156,7 @@ public class NestedFilterTest
         }
 
         store = null;
+        
         if ( wkdir != null )
         {
             FileUtils.deleteDirectory( wkdir );
@@ -192,6 +193,7 @@ public class NestedFilterTest
         assertEquals( "apache", cursor.get().getValue() );
 
         assertFalse( cursor.next() );
+        cursor.close();
     }
 
 
@@ -211,6 +213,7 @@ public class NestedFilterTest
         assertEquals( "walker", cursor.get().getValue() );
 
         assertFalse( cursor.next() );
+        cursor.close();
     }
 
 
@@ -227,17 +230,20 @@ public class NestedFilterTest
         IndexCursor<?, Entry, Long> cursor = cursorBuilder.build( exprNode );
 
         Set<Long> set = new HashSet<Long>();
+        
         while ( cursor.next() )
         {
             assertTrue( cursor.available() );
             set.add( cursor.get().getId() );
             assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
         }
+        
         assertEquals( 2, set.size() );
         assertTrue( set.contains( 7L ) );
         assertTrue( set.contains( 8L ) );
 
         assertFalse( cursor.next() );
+        cursor.close();
     }
 
 
@@ -250,5 +256,6 @@ public class NestedFilterTest
         optimizer.annotate( exprNode );
 
         IndexCursor<?, Entry, Long> cursor = cursorBuilder.build( exprNode );
+        cursor.close();
     }
 }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java Fri Apr  6 23:16:42 2012
@@ -180,12 +180,14 @@ public class NotCursorTest
         cursor.beforeFirst();
 
         Set<Long> set = new HashSet<Long>();
+        
         while ( cursor.next() )
         {
             assertTrue( cursor.available() );
             set.add( cursor.get().getId() );
             assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( 1L ) );
         assertTrue( set.contains( 2L ) );
@@ -215,12 +217,14 @@ public class NotCursorTest
         cursor.beforeFirst();
 
         Set<Long> set = new HashSet<Long>();
+        
         while ( cursor.next() )
         {
             assertTrue( cursor.available() );
             set.add( cursor.get().getId() );
             assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( 1L ) );
         assertTrue( set.contains( 2L ) );
@@ -234,12 +238,14 @@ public class NotCursorTest
         cursor.afterLast();
 
         set.clear();
+        
         while ( cursor.previous() )
         {
             assertTrue( cursor.available() );
             set.add( cursor.get().getId() );
             assertTrue( uuidSynChecker.isValidSyntax( cursor.get().getValue() ) );
         }
+        
         assertEquals( 5, set.size() );
         assertTrue( set.contains( 1L ) );
         assertTrue( set.contains( 2L ) );
@@ -276,6 +282,7 @@ public class NotCursorTest
         catch ( UnsupportedOperationException uoe )
         {
         }
+        
+        cursor.close();
     }
-
 }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java Fri Apr  6 23:16:42 2012
@@ -186,6 +186,8 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -209,6 +211,8 @@ public class OneLevelScopeTest
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
+        cursor.close();
+
         // --------- Test afterLast() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
@@ -222,6 +226,7 @@ public class OneLevelScopeTest
         catch ( UnsupportedOperationException uoe )
         {
             // expected
+            cursor.close();
         }
         
         /*
@@ -259,6 +264,7 @@ public class OneLevelScopeTest
         catch ( UnsupportedOperationException uoe )
         {
             // expected
+            cursor.close();
         }
 
         /*
@@ -292,6 +298,7 @@ public class OneLevelScopeTest
         catch ( UnsupportedOperationException uoe )
         {
             // expected
+            cursor.close();
         }
         
         /*
@@ -335,6 +342,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -367,6 +375,8 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -389,6 +399,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -402,6 +413,7 @@ public class OneLevelScopeTest
         catch ( UnsupportedOperationException uoe )
         {
             // expected
+            cursor.close();
         }
 
         /*
@@ -438,6 +450,7 @@ public class OneLevelScopeTest
         catch ( UnsupportedOperationException uoe )
         {
             // expected
+            cursor.close();
         }
 
         /*
@@ -471,6 +484,7 @@ public class OneLevelScopeTest
         catch ( UnsupportedOperationException uoe )
         {
             // expected
+            cursor.close();
         }
 
         /*
@@ -512,6 +526,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -545,7 +560,8 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
-
+        cursor.close();
+        
         // --------- Test first() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
@@ -567,6 +583,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -580,6 +597,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertTrue( cursor.previous() );
@@ -604,6 +622,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertTrue( cursor.previous() );
@@ -628,6 +647,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertTrue( cursor.previous() );
@@ -667,6 +687,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -682,6 +703,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -695,6 +717,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 7L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertFalse( cursor.previous() );
@@ -712,6 +735,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 7L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertFalse( cursor.previous() );
@@ -729,6 +753,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 7L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertFalse( cursor.previous() );
@@ -809,6 +834,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -845,6 +871,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -865,6 +892,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertTrue( cursor.previous() );
@@ -896,6 +924,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 8L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertTrue( cursor.previous() );
@@ -942,6 +971,7 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
         /*
         assertTrue( cursor.previous() );
@@ -997,6 +1027,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -1049,44 +1080,71 @@ public class OneLevelScopeTest
     @Test(expected = InvalidCursorPositionException.class)
     public void testInvalidCursorPositionException() throws Exception
     {
-        ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
-            + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL );
-        OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry, Long>( store,
-            node );
-        OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store, evaluator );
-        cursor.get();
+        OneLevelScopeCursor<Long> cursor = null;
+        
+        try
+        {
+            ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
+                + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL );
+            OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry, Long>( store,
+                node );
+            cursor = new OneLevelScopeCursor<Long>( store, evaluator );
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportBeforeWithoutIndex() throws Exception
     {
-        ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
-            + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL );
-        OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry, Long>( store,
-            node );
-        OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store, evaluator );
-
-        // test before()
-        ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
-        entry.setValue( 3L );
-        cursor.before( entry );
+        OneLevelScopeCursor<Long> cursor = null;
+        
+        try
+        {
+            ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
+                + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL );
+            OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry, Long>( store,
+                node );
+            cursor = new OneLevelScopeCursor<Long>( store, evaluator );
+    
+            // test before()
+            ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
+            entry.setValue( 3L );
+            cursor.before( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportAfterWithoutIndex() throws Exception
     {
-        ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
-            + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL );
-        OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry, Long>( store,
-            node );
-        OneLevelScopeCursor<Long> cursor = new OneLevelScopeCursor<Long>( store, evaluator );
-
-        // test after()
-        ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
-        entry.setValue( 3L );
-        cursor.after( entry );
+        OneLevelScopeCursor<Long> cursor = null;
+        
+        try
+        {
+            ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
+                + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.ONELEVEL );
+            OneLevelScopeEvaluator<Entry, Long> evaluator = new OneLevelScopeEvaluator<Entry, Long>( store,
+                node );
+            cursor = new OneLevelScopeCursor<Long>( store, evaluator );
+    
+            // test after()
+            ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
+            entry.setValue( 3L );
+            cursor.after( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java Fri Apr  6 23:16:42 2012
@@ -378,6 +378,13 @@ public class OrCursorTest
         {
         }
 
-        cursor.get();
+        try
+        {
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java Fri Apr  6 23:16:42 2012
@@ -221,6 +221,7 @@ public class PresenceTest
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         assertEquals( SchemaConstants.CN_AT_OID, cursor.get().getValue() );
+        cursor.close();
 
         node = new PresenceNode( schemaManager.getAttributeType( "ou" ) );
         evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
@@ -283,13 +284,17 @@ public class PresenceTest
         cursor.beforeFirst();
 
         List<Long> ids = new ArrayList<Long>();
+        
         while ( cursor.next() && cursor.available() )
         {
             ids.add( cursor.get().getId() );
         }
+        
         assertEquals( 11, ids.size() );
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
     }
 
 
@@ -305,12 +310,14 @@ public class PresenceTest
         cursor.beforeFirst();
 
         Set<Long> set = new HashSet<Long>();
+        
         while ( cursor.next() )
         {
             assertTrue( cursor.available() );
             assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
             set.add( cursor.get().getId() );
         }
+        
         assertEquals( 3, set.size() );
         assertTrue( set.contains( 5L ) );
         assertTrue( set.contains( 6L ) );
@@ -347,6 +354,7 @@ public class PresenceTest
             assertEquals( SchemaConstants.SN_AT_OID, cursor.get().getValue() );
             set.add( cursor.get().getId() );
         }
+        
         assertEquals( 3, set.size() );
         assertTrue( set.contains( 5L ) );
         assertTrue( set.contains( 6L ) );
@@ -354,6 +362,8 @@ public class PresenceTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // ----------- organizationName attribute
 
@@ -459,47 +469,83 @@ public class PresenceTest
     @Test(expected = InvalidCursorPositionException.class)
     public void testInvalidCursorPositionException() throws Exception
     {
-        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
-        PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
-        PresenceCursor<Long> cursor = new PresenceCursor<Long>( store, evaluator );
-        cursor.get();
+        PresenceCursor<Long> cursor = null;
+    
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+            PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+            cursor = new PresenceCursor<Long>( store, evaluator );
+            cursor.get();
+        }
+        finally 
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = InvalidCursorPositionException.class)
     public void testInvalidCursorPositionException2() throws Exception
     {
-        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "cn" ) );
-        PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
-        PresenceCursor<Long> cursor = new PresenceCursor<Long>( store, evaluator );
-        cursor.get();
+        PresenceCursor<Long> cursor = null;
+        
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "cn" ) );
+            PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+            cursor = new PresenceCursor<Long>( store, evaluator );
+            cursor.get();
+        }
+        finally 
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportBeforeWithoutIndex() throws Exception
     {
-        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
-        PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
-        PresenceCursor<Long> cursor = new PresenceCursor<Long>( store, evaluator );
-
-        // test before()
-        ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
-        entry.setValue( SchemaConstants.SN_AT_OID );
-        cursor.before( entry );
+        PresenceCursor<Long> cursor = null;
+        
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+            PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+            cursor = new PresenceCursor<Long>( store, evaluator );
+    
+            // test before()
+            ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
+            entry.setValue( SchemaConstants.SN_AT_OID );
+            cursor.before( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportAfterWithoutIndex() throws Exception
     {
-        PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
-        PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
-        PresenceCursor<Long> cursor = new PresenceCursor<Long>( store, evaluator );
-
-        // test before()
-        ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
-        entry.setValue( SchemaConstants.SN_AT_OID );
-        cursor.after( entry );
+        PresenceCursor<Long> cursor = null;
+        
+        try
+        {
+            PresenceNode node = new PresenceNode( schemaManager.getAttributeType( "sn" ) );
+            PresenceEvaluator<Long> evaluator = new PresenceEvaluator<Long>( node, store, schemaManager );
+            cursor = new PresenceCursor<Long>( store, evaluator );
+    
+            // test before()
+            ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
+            entry.setValue( SchemaConstants.SN_AT_OID );
+            cursor.after( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java Fri Apr  6 23:16:42 2012
@@ -227,6 +227,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test afterLast ----------
 
@@ -263,6 +264,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test last ----------
 
@@ -297,6 +299,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -326,6 +329,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test first ----------
 
@@ -346,6 +350,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test afterLast ----------
 
@@ -368,6 +373,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test last ----------
 
@@ -388,6 +394,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -417,6 +424,8 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // ---------- test first ----------
 
@@ -437,6 +446,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test afterLast ----------
 
@@ -459,6 +469,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test last ----------
 
@@ -479,6 +490,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -513,6 +525,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test afterLast ----------
 
@@ -527,6 +540,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test last ----------
 
@@ -540,6 +554,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -561,6 +576,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test first ----------
 
@@ -573,6 +589,7 @@ public class SubstringTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test afterLast ----------
 
@@ -587,6 +604,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // ---------- test last ----------
 
@@ -600,6 +618,7 @@ public class SubstringTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -692,47 +711,83 @@ public class SubstringTest
     @Test(expected = InvalidCursorPositionException.class)
     public void testInvalidCursorPositionException() throws Exception
     {
-        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "b", null );
-        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
-        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );
-        cursor.get();
+        SubstringCursor<Long> cursor = null;
+    
+        try
+        {
+            SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "b", null );
+            SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
+            cursor = new SubstringCursor<Long>( store, evaluator );
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = InvalidCursorPositionException.class)
     public void testInvalidCursorPositionException2() throws Exception
     {
-        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "j", null );
-        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
-        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );
-        cursor.get();
+        SubstringCursor<Long> cursor = null;
+        
+        try
+        {
+            SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "cn" ), "j", null );
+            SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
+            cursor = new SubstringCursor<Long>( store, evaluator );
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportBeforeWithoutIndex() throws Exception
     {
-        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "j", null );
-        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
-        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );
-
-        // test before()
-        ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
-        entry.setValue( SchemaConstants.SN_AT_OID );
-        cursor.before( entry );
+        SubstringCursor<Long> cursor = null;
+        
+        try
+        {
+            SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "j", null );
+            SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
+            cursor = new SubstringCursor<Long>( store, evaluator );
+    
+            // test before()
+            ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
+            entry.setValue( SchemaConstants.SN_AT_OID );
+            cursor.before( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportAfterWithoutIndex() throws Exception
     {
-        SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "j", null );
-        SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
-        SubstringCursor<Long> cursor = new SubstringCursor<Long>( store, evaluator );
-
-        // test before()
-        ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
-        entry.setValue( SchemaConstants.SN_AT_OID );
-        cursor.after( entry );
+        SubstringCursor<Long> cursor = null;
+        
+        try
+        {
+            SubstringNode node = new SubstringNode( schemaManager.getAttributeType( "sn" ), "j", null );
+            SubstringEvaluator<Long> evaluator = new SubstringEvaluator<Long>( node, store, schemaManager );
+            cursor = new SubstringCursor<Long>( store, evaluator );
+    
+            // test before()
+            ForwardIndexEntry<String, Long> entry = new ForwardIndexEntry<String, Long>();
+            entry.setValue( SchemaConstants.SN_AT_OID );
+            cursor.after( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java?rev=1310632&r1=1310631&r2=1310632&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java Fri Apr  6 23:16:42 2012
@@ -193,6 +193,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -222,6 +223,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -252,6 +254,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test last() ---------
 
@@ -281,6 +284,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test previous() before positioning ---------
 
@@ -310,7 +314,8 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
-    }
+        cursor.close();
+}
 
 
     @Test
@@ -528,6 +533,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -550,6 +556,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -573,6 +580,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test last() ---------
 
@@ -595,6 +603,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test previous() before positioning ---------
 
@@ -617,6 +626,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -627,12 +637,13 @@ public class SubtreeScopeTest
             + "=board of directors,"
             + SchemaConstants.O_AT_OID + "=good times co." );
 
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "alias", "extensibleObject" );
-        entry.add( "cn", "jd" );
-        entry.add( "aliasedObjectName", "cn=Jack Daniels,ou=Engineering,o=Good Times Co." );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: alias", 
+            "objectClass: extensibleObject",
+            "cn: jd",
+            "aliasedObjectName: cn=Jack Daniels,ou=Engineering,o=Good Times Co.",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         ( ( Partition ) store ).add( addContext );
@@ -641,18 +652,20 @@ public class SubtreeScopeTest
             + "=board of directors,"
             + SchemaConstants.O_AT_OID + "=good times co." );
 
-        entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "person" );
-        entry.add( "cn", "jdoe" );
-        entry.add( "sn", "doe" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: person",
+            "cn: jdoe",
+            "sn: doe",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         addContext = new AddOperationContext( null, entry );
         ( ( Partition ) store ).add( addContext );
 
-        ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING, new Dn( SchemaConstants.OU_AT_OID
-            + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
+        ScopeNode node = new ScopeNode( 
+            AliasDerefMode.DEREF_IN_SEARCHING, 
+            new Dn( SchemaConstants.OU_AT_OID + "=board of directors," + SchemaConstants.O_AT_OID + "=good times co." ), 
+            SearchScope.SUBTREE );
         SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
         SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store, evaluator );
 
@@ -698,6 +711,8 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -735,6 +750,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -779,6 +795,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test last() ---------
 
@@ -822,6 +839,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test previous() before positioning ---------
 
@@ -865,6 +883,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test next() before positioning ---------
 
@@ -908,6 +927,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -953,41 +973,68 @@ public class SubtreeScopeTest
     @Test(expected = InvalidCursorPositionException.class)
     public void testInvalidCursorPositionException() throws Exception
     {
-        ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
-            + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
-        SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
-        SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store, evaluator );
-        cursor.get();
+        SubtreeScopeCursor<Long> cursor = null;
+        
+        try
+        {
+            ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
+                + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
+            SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
+            cursor = new SubtreeScopeCursor<Long>( store, evaluator );
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportBeforeWithoutIndex() throws Exception
     {
-        ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
-            + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
-        SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
-        SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store, evaluator );
-
-        // test before()
-        ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
-        entry.setValue( 3L );
-        cursor.before( entry );
+        SubtreeScopeCursor<Long> cursor = null;
+        
+        try
+        {
+            ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
+                + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
+            SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
+            cursor = new SubtreeScopeCursor<Long>( store, evaluator );
+    
+            // test before()
+            ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
+            entry.setValue( 3L );
+            cursor.before( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 
 
     @Test(expected = UnsupportedOperationException.class)
     public void testUnsupportAfterWithoutIndex() throws Exception
     {
-        ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
-            + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
-        SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
-        SubtreeScopeCursor<Long> cursor = new SubtreeScopeCursor<Long>( store, evaluator );
-
-        // test after()
-        ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
-        entry.setValue( 3L );
-        cursor.after( entry );
+        SubtreeScopeCursor<Long> cursor = null;
+        
+        try
+        {
+            ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, new Dn( SchemaConstants.OU_AT_OID
+                + "=sales," + SchemaConstants.O_AT_OID + "=good times co." ), SearchScope.SUBTREE );
+            SubtreeScopeEvaluator<Entry, Long> evaluator = new SubtreeScopeEvaluator<Entry, Long>( store, node );
+            cursor = new SubtreeScopeCursor<Long>( store, evaluator );
+    
+            // test after()
+            ForwardIndexEntry<Long, Long> entry = new ForwardIndexEntry<Long, Long>();
+            entry.setValue( 3L );
+            cursor.after( entry );
+        }
+        finally
+        {
+            cursor.close();
+        }
     }