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/11 14:51:51 UTC

svn commit: r1324744 [5/5] - in /directory/apacheds/trunk: ./ all/ apache-felix/ core-annotations/ core-api/ core-api/src/main/java/org/apache/directory/server/core/api/ core-api/src/main/java/org/apache/directory/server/core/api/filtering/ core-api/sr...

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringCursor.java Wed Apr 11 12:51:45 2012
@@ -29,6 +29,8 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,6 +40,9 @@ import org.apache.directory.shared.ldap.
  */
 public class SubstringCursor<ID extends Comparable<ID>> extends AbstractIndexCursor<String, Entry, ID>
 {
+    /** A dedicated log for cursors */
+    private static final Logger LOG_CURSOR = LoggerFactory.getLogger( "CURSOR" );
+
     private static final String UNSUPPORTED_MSG = I18n.err( I18n.ERR_725 );
     private final boolean hasIndex;
     private final IndexCursor<String, Entry, ID> wrapped;
@@ -49,6 +54,7 @@ public class SubstringCursor<ID extends 
     public SubstringCursor( Store<Entry, ID> store, final SubstringEvaluator<ID> substringEvaluator )
         throws Exception
     {
+        LOG_CURSOR.debug( "Creating SubstringCursor {}", this );
         evaluator = substringEvaluator;
         hasIndex = store.hasIndexOn( evaluator.getExpression().getAttributeType() );
 
@@ -208,10 +214,26 @@ public class SubstringCursor<ID extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void close() throws Exception
     {
+        LOG_CURSOR.debug( "Closing SubstringCursor {}", this );
         super.close();
         wrapped.close();
         clear();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void close( Exception cause ) throws Exception
+    {
+        LOG_CURSOR.debug( "Closing SubstringCursor {}", this );
+        super.close( cause );
+        wrapped.close( cause );
+        clear();
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java Wed Apr 11 12:51:45 2012
@@ -28,6 +28,8 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.model.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,6 +40,9 @@ import org.apache.directory.shared.ldap.
  */
 public class SubtreeScopeCursor<ID extends Comparable<ID>> extends AbstractIndexCursor<ID, Entry, ID>
 {
+    /** A dedicated log for cursors */
+    private static final Logger LOG_CURSOR = LoggerFactory.getLogger( "CURSOR" );
+
     private static final String UNSUPPORTED_MSG = I18n.err( I18n.ERR_719 );
 
     /** The Entry database/store */
@@ -68,6 +73,7 @@ public class SubtreeScopeCursor<ID exten
     public SubtreeScopeCursor( Store<Entry, ID> db, SubtreeScopeEvaluator<Entry, ID> evaluator )
         throws Exception
     {
+        LOG_CURSOR.debug( "Creating SubtreeScopeCursor {}", this );
         this.db = db;
         this.evaluator = evaluator;
 
@@ -312,8 +318,13 @@ public class SubtreeScopeCursor<ID exten
     }
 
 
-    private void closeCursors() throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void close() throws Exception
     {
+        LOG_CURSOR.debug( "Closing SubtreeScopeCursor {}", this );
+        
         if ( dereferencedCursor != null )
         {
             dereferencedCursor.close();
@@ -323,21 +334,38 @@ public class SubtreeScopeCursor<ID exten
         {
             scopeCursor.close();
         }
-    }
-
+        
+        if ( cursor != null )
+        {
+            cursor.close();
+        }
 
-    @Override
-    public void close() throws Exception
-    {
-        closeCursors();
         super.close();
     }
 
 
-    @Override
+    /**
+     * {@inheritDoc}
+     */
     public void close( Exception cause ) throws Exception
     {
-        closeCursors();
+        LOG_CURSOR.debug( "Closing SubtreeScopeCursor {}", this );
+        
+        if ( dereferencedCursor != null )
+        {
+            dereferencedCursor.close( cause );
+        }
+
+        if ( scopeCursor != null )
+        {
+            scopeCursor.close( cause );
+        }
+        
+        if ( cursor != null )
+        {
+            cursor.close( cause );
+        }
+
         super.close( cause );
     }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractIndexCursorTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/EmptyIndexCursorTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/ParentIdAndRdnTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/ParentIdAndRdnTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/ParentIdAndRdnTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/ParentIdAndRdnTest.java Wed Apr 11 12:51:45 2012
@@ -109,20 +109,20 @@ public class ParentIdAndRdnTest
         assertEquals( -2, rdn3.compareTo( rdn2 ) );
         assertEquals( 0, rdn3.compareTo( rdn3 ) );
         assertEquals( -1, rdn3.compareTo( rdn4 ) );
-        assertEquals( -2, rdn3.compareTo( rdn5 ) );
+        assertEquals( 1, rdn3.compareTo( rdn5 ) );
         
         // Forth rdn
         assertEquals( -2, rdn4.compareTo( rdn1 ) );
         assertEquals( -2, rdn4.compareTo( rdn2 ) );
         assertEquals( 1, rdn4.compareTo( rdn3 ) );
         assertEquals( 0, rdn4.compareTo( rdn4 ) );
-        assertEquals( -2, rdn4.compareTo( rdn5 ) );
+        assertEquals( 1, rdn4.compareTo( rdn5 ) );
         
         // Fifth rdn
         assertEquals( -1, rdn5.compareTo( rdn1 ) );
         assertEquals( -1, rdn5.compareTo( rdn2 ) );
-        assertEquals( 2, rdn5.compareTo( rdn3 ) );
-        assertEquals( 2, rdn5.compareTo( rdn4 ) );
+        assertEquals( -1, rdn5.compareTo( rdn3 ) );
+        assertEquals( -1, rdn5.compareTo( rdn4 ) );
         assertEquals( 0, rdn5.compareTo( rdn5 ) );
 
         // Sixth rdn

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java Wed Apr 11 12:51:45 2012
@@ -148,7 +148,6 @@ public class PartitionTest
     public void testExampleDataIndices() throws Exception
     {
         assertEquals( 11, partition.getRdnIndex().count() );
-        assertEquals( 11, partition.getOneLevelIndex().count() );
         assertEquals( 19, partition.getSubLevelIndex().count() );
         assertEquals( 3, partition.getAliasIndex().count() );
         assertEquals( 3, partition.getOneAliasIndex().count() );
@@ -370,10 +369,11 @@ public class PartitionTest
     {
         Dn dn = new Dn( schemaManager, "cn=user,ou=Sales,o=Good Times Co." );
 
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "person" );
-        entry.add( "cn", "user" );
-        entry.add( "sn", "user sn" );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: person",
+            "cn: user",
+            "sn: user sn" );
 
         // add
         StoreUtils.injectEntryInStore( partition, entry );
@@ -403,7 +403,7 @@ public class PartitionTest
 
         Attribute parentIdAt = entry.get( SchemaConstants.ENTRY_PARENT_ID_AT );
         assertNotNull( parentIdAt );
-        assertEquals( parentId.toString(), parentIdAt.getString() );
+        //assertEquals( parentId.toString(), parentIdAt.getString() );
 
         return entry;
     }

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/SingletonIndexCursorTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java Wed Apr 11 12:51:45 2012
@@ -172,10 +172,6 @@ public class AvlPartitionTest
         avlPartition.addIndex( new AvlIndex<String, Entry>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) );
         assertNotNull( avlPartition.getPresenceIndex() );
 
-        assertNull( avlPartition.getOneLevelIndex() );
-        avlPartition.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
-        assertNotNull( avlPartition.getOneLevelIndex() );
-
         assertNull( avlPartition.getSubLevelIndex() );
         avlPartition.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
         assertNotNull( avlPartition.getSubLevelIndex() );
@@ -246,17 +242,6 @@ public class AvlPartitionTest
         {
         }
 
-        assertNotNull( partition.getOneLevelIndex() );
-
-        try
-        {
-            partition.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
-            //fail();
-        }
-        catch ( IllegalStateException e )
-        {
-        }
-
         assertNotNull( partition.getSubLevelIndex() );
 
         try
@@ -317,7 +302,7 @@ public class AvlPartitionTest
 
         Iterator<String> systemIndices = partition.getSystemIndices();
 
-        for ( int i = 0; i < 10; i++ )
+        for ( int i = 0; i < 9; i++ )
         {
             assertTrue( systemIndices.hasNext() );
             assertNotNull( systemIndices.next() );
@@ -418,9 +403,9 @@ public class AvlPartitionTest
         assertNotNull( cursor );
         cursor.beforeFirst();
         assertTrue( cursor.next() );
-        assertEquals( 5L, ( long ) cursor.get().getId() );
-        assertTrue( cursor.next() );
         assertEquals( 6L, ( long ) cursor.get().getId() );
+        assertTrue( cursor.next() );
+        assertEquals( 5L, ( long ) cursor.get().getId() );
         assertFalse( cursor.next() );
         
         assertEquals( 3, partition.getChildCount( 1L ) );
@@ -432,18 +417,21 @@ public class AvlPartitionTest
 
         // add an alias and delete to test dropAliasIndices method
         Dn dn = new Dn( schemaManager, "commonName=Jack Daniels,ou=Apache,ou=Board of Directors,o=Good Times Co." );
-        DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "objectClass", "top", "alias", "extensibleObject" );
-        entry.add( "ou", "Apache" );
-        entry.add( "commonName", "Jack Daniels" );
-        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() );
+        DefaultEntry entry = new DefaultEntry( schemaManager, dn,
+            "objectClass: top", 
+            "objectClass: alias", 
+            "objectClass: extensibleObject",
+            "ou: Apache",
+            "commonName: Jack Daniels",
+            "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.add( addContext );
 
         partition.delete( 12L );
+        cursor.close();
     }
 
 
@@ -468,6 +456,8 @@ public class AvlPartitionTest
         assertFalse( cursor.next() );
 
         idx.drop( 5L );
+        
+        cursor.close();
 
         cursor = idx.forwardCursor( 2L );
 
@@ -479,14 +469,18 @@ public class AvlPartitionTest
 
         assertFalse( cursor.next() );
 
+        cursor.close();
+
         // dn id 12
         Dn martinDn = new Dn( schemaManager, "cn=Marting King,ou=Sales,o=Good Times Co." );
-        DefaultEntry entry = new DefaultEntry( schemaManager, martinDn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Sales" );
-        entry.add( "cn", "Martin King" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        DefaultEntry entry = new DefaultEntry( schemaManager, martinDn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou: Sales",
+            "cn: Martin King",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, entry );
         partition.add( addContext );
@@ -496,6 +490,8 @@ public class AvlPartitionTest
         assertTrue( cursor.previous() );
         assertEquals( 12, ( long ) cursor.get().getId() );
 
+        cursor.close();
+
         Dn newParentDn = new Dn( schemaManager, "ou=Board of Directors,o=Good Times Co." );
 
         Dn newDn = newParentDn.add( martinDn.getRdn() );
@@ -506,25 +502,30 @@ public class AvlPartitionTest
         assertTrue( cursor.previous() );
         assertEquals( 12, ( long ) cursor.get().getId() );
 
+        cursor.close();
+
         // dn id 13
         Dn marketingDn = new Dn( schemaManager, "ou=Marketing,ou=Sales,o=Good Times Co." );
-        entry = new DefaultEntry( schemaManager, marketingDn );
-        entry.add( "objectClass", "top", "organizationalUnit" );
-        entry.add( "ou", "Marketing" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry = new DefaultEntry( schemaManager, marketingDn,
+            "objectClass: top", 
+            "objectClass: organizationalUnit",
+            "ou: Marketing",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         addContext = new AddOperationContext( null, entry );
         partition.add( addContext );
 
         // dn id 14
         Dn jimmyDn = new Dn( schemaManager, "cn=Jimmy Wales,ou=Marketing, ou=Sales,o=Good Times Co." );
-        entry = new DefaultEntry( schemaManager, jimmyDn );
-        entry.add( "objectClass", "top", "person", "organizationalPerson" );
-        entry.add( "ou", "Marketing" );
-        entry.add( "cn", "Jimmy Wales" );
-        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        entry.add( "entryUUID", UUID.randomUUID().toString() );
+        entry = new DefaultEntry( schemaManager, jimmyDn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou: Marketing",
+            "cn: Jimmy Wales",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         addContext = new AddOperationContext( null, entry );
         partition.add( addContext );
@@ -557,6 +558,8 @@ public class AvlPartitionTest
         assertEquals( 3, ( long ) cursor.get().getId() );
 
         assertFalse( cursor.previous() );
+        
+        cursor.close();
     }
 
 
@@ -651,13 +654,15 @@ public class AvlPartitionTest
     @Test
     public void testMove() throws Exception
     {
-        Dn childDn = new Dn( schemaManager, "cn=Pivate Ryan,ou=Engineering,o=Good Times Co." );
-        DefaultEntry childEntry = new DefaultEntry( schemaManager, childDn );
-        childEntry.add( "objectClass", "top", "person", "organizationalPerson" );
-        childEntry.add( "ou", "Engineering" );
-        childEntry.add( "cn", "Private Ryan" );
-        childEntry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
-        childEntry.add( "entryUUID", UUID.randomUUID().toString() );
+        Dn childDn = new Dn( schemaManager, "cn=Private Ryan,ou=Engineering,o=Good Times Co." );
+        DefaultEntry childEntry = new DefaultEntry( schemaManager, childDn,
+            "objectClass: top", 
+            "objectClass: person", 
+            "objectClass: organizationalPerson",
+            "ou: Engineering",
+            "cn", "Private Ryan",
+            "entryCSN", new CsnFactory( 1 ).newInstance().toString(),
+            "entryUUID", UUID.randomUUID().toString() );
 
         AddOperationContext addContext = new AddOperationContext( null, childEntry );
         partition.add( addContext );

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlRdnIndexTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlTableTest.java Wed Apr 11 12:51:45 2012
@@ -83,6 +83,8 @@ public class AvlTableTest
         assertEquals( 1, tuple.getValue().intValue() );
 
         assertFalse( cursor.next() );
+        
+        cursor.close();
 
         // ---- on duplicates ----
 
@@ -111,6 +113,7 @@ public class AvlTableTest
         assertEquals( 10, tuple.getValue().intValue() );
 
         assertFalse( cursor.next() );
+        cursor.close();
     }
 
 
@@ -255,6 +258,7 @@ public class AvlTableTest
         assertNotNull( tuple );
         assertEquals( 23, tuple.getKey().intValue() );
         assertEquals( 8934, tuple.getValue().intValue() );
+        cursor.close();
     }
 
 
@@ -295,6 +299,7 @@ public class AvlTableTest
         assertNotNull( tuple );
         assertEquals( 23, tuple.getKey().intValue() );
         assertEquals( 8934, tuple.getValue().intValue() );
+        cursor.close();
     }
 
 

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java Wed Apr 11 12:51:45 2012
@@ -299,6 +299,8 @@ public class AndCursorTest
         {
         }
 
+        cursor.close();
+        wrapped.close();
     }
 
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java Wed Apr 11 12:51:45 2012
@@ -174,18 +174,20 @@ public class OneLevelScopeTest
         assertTrue( cursor.available() );
         IndexEntry<Long, Long> indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 5L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 2L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 5L, ( long ) indexEntry.getId() );
         assertEquals( 2L, ( long ) indexEntry.getValue() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -196,22 +198,38 @@ public class OneLevelScopeTest
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 5L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 2L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 5L, ( long ) indexEntry.getId() );
         assertEquals( 2L, ( long ) indexEntry.getValue() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
 
+        cursor.close();
+
         // --------- Test afterLast() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
+
+        
+        try
+        {
+            cursor.afterLast();
+            fail();
+        }
+        catch ( UnsupportedOperationException uoe )
+        {
+            // expected
+            cursor.close();
+        }
+        
+        /*
         cursor.afterLast();
         assertFalse( cursor.available() );
 
@@ -231,13 +249,25 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test last() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
         assertFalse( cursor.available() );
-        cursor.last();
+        
+        try
+        {
+            cursor.last();
+            fail();
+        }
+        catch ( UnsupportedOperationException uoe )
+        {
+            // expected
+            cursor.close();
+        }
 
+        /*
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
@@ -253,11 +283,25 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test previous() before positioning ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
         assertFalse( cursor.available() );
+        
+        try
+        {
+            cursor.previous();
+            fail();
+        }
+        catch ( UnsupportedOperationException uoe )
+        {
+            // expected
+            cursor.close();
+        }
+        
+        /*
         cursor.previous();
 
         assertTrue( cursor.available() );
@@ -275,6 +319,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test next() before positioning ---------
 
@@ -285,18 +330,19 @@ public class OneLevelScopeTest
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 5L, ( long ) indexEntry.getId() );
+        assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 2L, ( long ) indexEntry.getValue() );
 
         assertTrue( cursor.next() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
-        assertEquals( 6L, ( long ) indexEntry.getId() );
+        assertEquals( 5L, ( long ) indexEntry.getId() );
         assertEquals( 2L, ( long ) indexEntry.getValue() );
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -329,6 +375,8 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -351,11 +399,24 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
-        cursor.afterLast();
+        
+        try
+        {
+            cursor.afterLast();
+            fail();
+        }
+        catch ( UnsupportedOperationException uoe )
+        {
+            // expected
+            cursor.close();
+        }
+
+        /*
         assertFalse( cursor.available() );
 
         assertTrue( cursor.previous() );
@@ -374,13 +435,25 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test last() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
         assertFalse( cursor.available() );
-        cursor.last();
+        
+        try
+        {
+            cursor.last();
+            fail();
+        }
+        catch ( UnsupportedOperationException uoe )
+        {
+            // expected
+            cursor.close();
+        }
 
+        /*
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
@@ -396,13 +469,25 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test previous() before positioning ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
         assertFalse( cursor.available() );
-        cursor.previous();
+        
+        try
+        {
+            cursor.previous();
+            fail();
+        }
+        catch ( UnsupportedOperationException uoe )
+        {
+            // expected
+            cursor.close();
+        }
 
+        /*
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
         assertNotNull( indexEntry );
@@ -418,6 +503,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test next() before positioning ---------
 
@@ -440,6 +526,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -473,7 +560,8 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
-
+        cursor.close();
+        
         // --------- Test first() ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
@@ -495,6 +583,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -508,7 +597,9 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -518,6 +609,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test last() ---------
 
@@ -530,7 +622,9 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -540,6 +634,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test previous() before positioning ---------
 
@@ -552,7 +647,9 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -562,6 +659,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
     }
 
 
@@ -589,6 +687,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -604,6 +703,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -617,9 +717,12 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 7L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test last() ---------
 
@@ -632,9 +735,12 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 7L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test previous() before positioning ---------
 
@@ -647,9 +753,12 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 7L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
     }
 
 
@@ -725,6 +834,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -761,6 +871,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -781,7 +892,9 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -798,6 +911,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test last() ---------
 
@@ -810,7 +924,9 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 8L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -834,11 +950,13 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test previous() before positioning ---------
 
         cursor = new OneLevelScopeCursor<Long>( store, evaluator );
         assertFalse( cursor.available() );
+        
         cursor.previous();
 
         assertTrue( cursor.available() );
@@ -853,7 +971,9 @@ public class OneLevelScopeTest
         assertNotNull( indexEntry );
         assertEquals( 6L, ( long ) indexEntry.getId() );
         assertEquals( 3L, ( long ) indexEntry.getValue() );
+        cursor.close();
 
+        /*
         assertTrue( cursor.previous() );
         assertTrue( cursor.available() );
         indexEntry = cursor.get();
@@ -870,6 +990,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        */
 
         // --------- Test next() before positioning ---------
 
@@ -906,6 +1027,7 @@ public class OneLevelScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -958,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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java Wed Apr 11 12:51:45 2012
@@ -378,6 +378,13 @@ public class OrCursorTest
         {
         }
 
-        cursor.get();
+        try
+        {
+            cursor.get();
+        }
+        finally
+        {
+            cursor.close();
+        }
     }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java Wed Apr 11 12:51:45 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/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java Wed Apr 11 12:51:45 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
@@ -349,6 +354,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -378,6 +384,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -408,6 +415,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test last() ---------
 
@@ -437,6 +445,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test previous() before positioning ---------
 
@@ -466,6 +475,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test next() before positioning ---------
 
@@ -495,6 +505,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -528,6 +539,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -550,6 +562,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -573,6 +586,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test last() ---------
 
@@ -595,6 +609,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test previous() before positioning ---------
 
@@ -617,6 +632,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -627,12 +643,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 +658,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 +717,8 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        
+        cursor.close();
 
         // --------- Test first() ---------
 
@@ -735,6 +756,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test afterLast() ---------
 
@@ -779,6 +801,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test last() ---------
 
@@ -822,6 +845,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test previous() before positioning ---------
 
@@ -865,6 +889,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.previous() );
         assertFalse( cursor.available() );
+        cursor.close();
 
         // --------- Test next() before positioning ---------
 
@@ -908,6 +933,7 @@ public class SubtreeScopeTest
 
         assertFalse( cursor.next() );
         assertFalse( cursor.available() );
+        cursor.close();
     }
 
 
@@ -953,41 +979,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();
+        }
     }
 
 

Propchange: directory/apacheds/trunk/xdbm-tools/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/xdbm-tools:r1304337-1324714