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 [3/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...

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/server:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosProtocolCodecFactory.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosProtocolCodecFactory.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/Checksum.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptionKey.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/crypto/checksum/ChecksumType.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/flags:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-codec/src/test/java/org/apache/directory/server:r1304337-1324714

Propchange: directory/apacheds/trunk/kerberos-test/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/kerberos-test:r1304337-1324714

Propchange: directory/apacheds/trunk/ldap-client-test/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/ldap-client-test:r1304337-1324714

Propchange: directory/apacheds/trunk/ldif-partition/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/ldif-partition:r1304337-1324714

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java Wed Apr 11 12:51:45 2012
@@ -24,9 +24,7 @@ package org.apache.directory.server.core
 import java.io.File;
 import java.io.IOException;
 import java.io.RandomAccessFile;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.UUID;
 
 import javax.naming.InvalidNameException;
@@ -37,8 +35,10 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.ParentIdAndRdn;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -49,6 +49,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifReader;
 import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
@@ -298,22 +299,18 @@ public class SingleFileLdifPartition ext
                     return;
                 }
 
-                IndexCursor<Long, Entry, Long> cursor = getOneLevelIndex().forwardCursor( suffixId );
-
-                appendLdif( lookup( suffixId ) );
-
-                while ( cursor.next() )
+                ParentIdAndRdn<Long> suffixEntry = rdnIdx.reverseLookup( suffixId );
+                
+                if ( suffixEntry != null )
                 {
-                    Long childId = cursor.get().getId();
-
-                    Entry entry = lookup( childId );
+                    Entry entry = master.get( suffixId );
+                    entry.setDn( suffixDn );
 
                     appendLdif( entry );
-
-                    appendRecursive( childId, null );
+                    
+                    appendRecursive( suffixId, suffixEntry.getNbChildren() );
                 }
 
-                cursor.close();
                 dirty = false;
             }
             catch ( LdapException e )
@@ -327,57 +324,37 @@ public class SingleFileLdifPartition ext
         }
     }
 
-
-    /**
-     * appends all the entries present under a given entry, recursively
-     *
-     * @param entryId the base entry's id
-     * @param cursorMap the open cursor map
-     * @throws Exception
-     */
-    private void appendRecursive( Long entryId, Map<Long, IndexCursor<Long, Entry, Long>> cursorMap ) throws Exception
+    
+    private void appendRecursive( Long id, int nbSibbling ) throws Exception
     {
-        synchronized ( lock )
-        {
-
-            IndexCursor<Long, Entry, Long> cursor = null;
-            if ( cursorMap == null )
+        // Start with the root
+        IndexCursor<ParentIdAndRdn<Long>,Entry,Long> cursor = rdnIdx.forwardCursor();
+        
+        IndexEntry<ParentIdAndRdn<Long>, Long> startingPos = new ForwardIndexEntry<ParentIdAndRdn<Long>, Long>();
+        startingPos.setValue( new ParentIdAndRdn<Long>( id, (Rdn[]) null ) );
+        cursor.before( startingPos );
+        int countChildren = 0;
+        
+        while ( cursor.next() && ( countChildren < nbSibbling ) )
+        {
+            IndexEntry<ParentIdAndRdn<Long>, Long> element = cursor.get();
+            Long childId = element.getId();
+            Entry entry = lookup( childId );
+
+            appendLdif( entry );
+
+            countChildren++;
+            
+            // And now, the children
+            int nbChildren = element.getValue().getNbChildren();
+            
+            if ( nbChildren > 0 )
             {
-                cursorMap = new HashMap<Long, IndexCursor<Long, Entry, Long>>();
-            }
-
-            cursor = cursorMap.get( entryId );
-
-            if ( cursor == null )
-            {
-                cursor = getOneLevelIndex().forwardCursor( entryId );
-                cursor.beforeFirst();
-                cursorMap.put( entryId, cursor );
-            }
-
-            if ( !cursor.next() ) // if this is a leaf entry's Dn
-            {
-                cursorMap.remove( entryId );
-                cursor.close();
-            }
-            else
-            {
-                do
-                {
-                    IndexEntry<Long, Long> idxEntry = cursor.get();
-                    Entry entry = lookup( idxEntry.getId() );
-
-                    Long childId = getEntryId( entry.getDn() );
-
-                    appendLdif( entry );
-
-                    appendRecursive( childId, cursorMap );
-                }
-                while ( cursor.next() );
-                cursorMap.remove( entryId );
-                cursor.close();
+                appendRecursive( childId, nbChildren );
             }
         }
+        
+        cursor.close();
     }
 
 

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java Wed Apr 11 12:51:45 2012
@@ -424,6 +424,8 @@ public class LdifPartitionTest
 
         assertEquals( 3, nbRes );
         assertEquals( 0, expectedDns.size() );
+        
+        cursor.close();
     }
 
 

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java Wed Apr 11 12:51:45 2012
@@ -51,6 +51,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.api.normalization.FilterNormalizingVisitor;
+import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.shared.ldap.model.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -676,14 +677,16 @@ public class SingleFileLdifPartitionTest
 
         assertEquals( 3, nbRes );
         assertEquals( 0, expectedDns.size() );
+        
+        cursor.close();
     }
-
-
+    
+    
     @Test
     public void testLdifMoveEntry() throws Exception
     {
         SingleFileLdifPartition partition = injectEntries();
-
+        
         Entry childEntry1 = partition.lookup( partition.getEntryId( new Dn( schemaManager,
             "dc=child1,ou=test,ou=system" ) ) );
         Entry childEntry2 = partition.lookup( partition.getEntryId( new Dn( schemaManager,

Propchange: directory/apacheds/trunk/protocol-changepw/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-changepw:r1304337-1324714

Propchange: directory/apacheds/trunk/protocol-dhcp/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-dhcp:r1304337-1324714

Propchange: directory/apacheds/trunk/protocol-dns/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-dns:r1304337-1324714

Propchange: directory/apacheds/trunk/protocol-kerberos/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-kerberos:r1304337-1324714

Propchange: directory/apacheds/trunk/protocol-ldap/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-ldap:r1304337-1324714

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapSession.java Wed Apr 11 12:51:45 2012
@@ -31,6 +31,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.ldap.handlers.controls.PagedSearchContext;
+import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.message.AbandonableRequest;
 import org.apache.directory.shared.ldap.model.message.BindStatus;
 import org.apache.mina.core.session.IoSession;
@@ -458,6 +459,26 @@ public class LdapSession
         return pagedSearchContexts.remove( contextId );
     }
 
+    
+    /**
+     * Close all the pending cursors for all the pending PagedSearches
+     * 
+     * @throws Exception If we've got an exception.
+     */
+    public void closeAllPagedSearches() throws Exception
+    {
+        for ( int contextId : pagedSearchContexts.keySet() )
+        {
+            PagedSearchContext context = pagedSearchContexts.get( contextId );
+            
+            EntryFilteringCursor cursor = context.getCursor();
+            
+            if ( cursor != null )
+            {
+                cursor.close();
+            }
+        }
+    }
 
     /**
      * Get paged search context associated with an ID 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/UnbindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/UnbindHandler.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/UnbindHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/UnbindHandler.java Wed Apr 11 12:51:45 2012
@@ -45,6 +45,7 @@ public class UnbindHandler extends LdapR
 
         try
         {
+            session.closeAllPagedSearches();
             session.getCoreSession().unbind( unbindRequest );
             session.getIoSession().close( true );
             ldapServer.getLdapSessionManager().removeLdapSession( session.getIoSession() );

Propchange: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java:r1304337-1324714

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaJournalCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaJournalCursor.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaJournalCursor.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/provider/ReplicaJournalCursor.java Wed Apr 11 12:51:45 2012
@@ -43,6 +43,9 @@ public class ReplicaJournalCursor extend
     /** Logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( ReplicaJournalCursor.class );
 
+    /** A dedicated log for cursors */
+    private static final Logger LOG_CURSOR = LoggerFactory.getLogger( "CURSOR" );
+
     /** the underlying journal's cursor */
     private Cursor<Tuple<String, ReplicaEventMessage>> tupleCursor;
 
@@ -63,6 +66,7 @@ public class ReplicaJournalCursor extend
      */
     public ReplicaJournalCursor( JdbmTable<String, ReplicaEventMessage> journal, String consumerCsn ) throws Exception
     {
+        LOG_CURSOR.debug( "Creating ReplicaJournalCursor {}", this );
         this.journal = journal;
         this.tupleCursor = journal.cursor();
         this.consumerCsn = consumerCsn;
@@ -212,6 +216,7 @@ public class ReplicaJournalCursor extend
     @Override
     public void close() throws Exception
     {
+        LOG_CURSOR.debug( "Closing ReplicaJournalCursor {}", this );
         tupleCursor.close();
         super.close();
     }
@@ -223,6 +228,7 @@ public class ReplicaJournalCursor extend
     @Override
     public void close( Exception cause ) throws Exception
     {
+        LOG_CURSOR.debug( "Closing ReplicaJournalCursor {}", this );
         tupleCursor.close();
         super.close( cause );
     }

Modified: directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/test/java/org/apache/directory/server/ldap/JournalTest.java Wed Apr 11 12:51:45 2012
@@ -226,6 +226,8 @@ public class JournalTest
 
             pos++;
         }
+        
+        cursor.close();
     }
 
 
@@ -270,6 +272,8 @@ public class JournalTest
             journal.sync();
             deleted++;
         }
+        
+        deleteCursor.close();
 
         // Now check that the first mod is the 501th
         assertEquals( 500, journal.count() );
@@ -282,6 +286,8 @@ public class JournalTest
         ReplicaEventMessage replicaEventMessage = tuple.getValue();
         assertEquals( ChangeType.ADD, replicaEventMessage.getChangeType() );
         assertEquals( "test500", replicaEventMessage.getEntry().get( "ou" ).getString() );
+        
+        cursor.close();
     }
 
 

Propchange: directory/apacheds/trunk/protocol-ntp/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-ntp:r1304337-1324714

Propchange: directory/apacheds/trunk/protocol-shared/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/protocol-shared:r1304337-1324714

Propchange: directory/apacheds/trunk/server-annotations/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-annotations:r1304337-1324714

Propchange: directory/apacheds/trunk/server-config/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-config:r1304337-1324714

Propchange: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java:r1304337-1324714

Propchange: directory/apacheds/trunk/server-config/src/main/resources/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-config/src/main/resources:r1304337-1324714

Propchange: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java:r1304337-1324714

Propchange: directory/apacheds/trunk/server-integ/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-integ:r1304337-1324714

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/IndexTest.java Wed Apr 11 12:51:45 2012
@@ -42,6 +42,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.util.exception.Exceptions;
 import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -109,6 +110,7 @@ public class IndexTest
 
 
     @Test
+    @Ignore( "Does not work with JDBM2" )
     public void testJdbmIndex() throws Exception
     {
         doTest( jdbmIndex );
@@ -141,13 +143,14 @@ public class IndexTest
         }
 
         assertFalse( cursor1.next() );
+        
+        cursor1.close();
     }
 
 
     private void assertHasNext( IndexCursor<String, Entry, Long> cursor1, long expectedId ) throws Exception
     {
         assertTrue( cursor1.next() );
-        //System.out.println(cursor1.get());
         assertEquals( expectedId, cursor1.get().getId().longValue() );
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddAliasIT.java Wed Apr 11 12:51:45 2012
@@ -134,7 +134,6 @@ public class AddAliasIT extends Abstract
             }
             catch ( Exception e )
             {
-                e.printStackTrace();
                 assertTrue( true );
             }
 
@@ -224,8 +223,10 @@ public class AddAliasIT extends Abstract
 
             while ( cursor.next() )
             {
-                System.out.println( cursor.get().getDn() );
+                //System.out.println( cursor.get().getDn() );
             }
+            
+            cursor.close();
         }
         finally
         {

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddingEntriesWithSpecialCharactersInRDNIT.java Wed Apr 11 12:51:45 2012
@@ -106,6 +106,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( cn.contains( "Kate#Bush" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );
@@ -144,6 +146,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( cn.contains( "Bush, Kate" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );
@@ -178,6 +182,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( cn.contains( "Mackie \"The Knife\" Messer" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );
@@ -211,6 +217,8 @@ public class AddingEntriesWithSpecialCha
             assertNotNull( ou );
             assertTrue( ou.contains( "AC\\DC" ) );
         }
+        
+        cursor.close();
 
         assertTrue( "no entry found", entryFound );
         connection.delete( dn );
@@ -249,6 +257,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( ou.contains( "East -> West" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );
@@ -287,6 +297,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( ou.contains( "Scissors 8<" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );
@@ -325,6 +337,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( ou.contains( "semicolon group;" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );
@@ -362,6 +376,8 @@ public class AddingEntriesWithSpecialCha
             assertTrue( ou.contains( "nomen=omen" ) );
         }
 
+        cursor.close();
+
         assertTrue( "entry found", entryFound );
 
         connection.delete( dn );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java Wed Apr 11 12:51:45 2012
@@ -197,934 +197,948 @@ import org.junit.runner.RunWith;
 })
 public class PagedSearchIT extends AbstractLdapTestUnit
 {
-@Rule
-public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
-
-private LdapApiService codec = LdapApiServiceFactory.getSingleton();
-
-
-/**
- * Create the searchControls with a paged size
- * @throws EncoderException on codec failures
- */
-private SearchControls createSearchControls( DirContext ctx, int sizeLimit, int pagedSize )
-    throws NamingException, EncoderException
-{
-    SearchControls controls = new SearchControls();
-    controls.setCountLimit( sizeLimit );
-    controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-    PagedResultsDecorator pagedSearchControl = new PagedResultsDecorator( codec );
-    pagedSearchControl.setSize( pagedSize );
-
-    ( ( LdapContext ) ctx ).setRequestControls( JndiUtils.toJndiControls( codec, new Control[]
-        { pagedSearchControl } ) );
-
-    return controls;
-}
-
-
-/**
- * Create the searchControls with a paged size
- * @throws EncoderException on codec failures
- */
-private void createNextSearchControls( DirContext ctx, byte[] cookie, int pagedSize )
-    throws NamingException, EncoderException
-{
-    PagedResultsDecorator pagedSearchControl = new PagedResultsDecorator( codec );
-    pagedSearchControl.setCookie( cookie );
-    pagedSearchControl.setSize( pagedSize );
-    ( ( LdapContext ) ctx ).setRequestControls( JndiUtils.toJndiControls( codec, new Control[]
-        { pagedSearchControl } ) );
-}
-
-
-/**
- * Check that we got the correct result set
- */
-private void checkResults( List<SearchResult> results, int expectedSize ) throws NamingException
-{
-    assertEquals( expectedSize, results.size() );
-
-    // check that we have correctly read all the entries
-    for ( int i = 0; i < expectedSize; i++ )
+    @Rule
+    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
+    
+    private LdapApiService codec = LdapApiServiceFactory.getSingleton();
+    
+    
+    /**
+     * Create the searchControls with a paged size
+     * @throws EncoderException on codec failures
+     */
+    private SearchControls createSearchControls( DirContext ctx, int sizeLimit, int pagedSize )
+        throws NamingException, EncoderException
     {
-        SearchResult entry = results.get( i );
-        assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        SearchControls controls = new SearchControls();
+        controls.setCountLimit( sizeLimit );
+        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        PagedResultsDecorator pagedSearchControl = new PagedResultsDecorator( codec );
+        pagedSearchControl.setSize( pagedSize );
+    
+        ( ( LdapContext ) ctx ).setRequestControls( JndiUtils.toJndiControls( codec, new Control[]
+            { pagedSearchControl } ) );
+    
+        return controls;
     }
-}
-
-
-/**
- * Do the loop over the entries, until we can't get any more, or until we
- * reach a limit. It will check that we have got all the expected entries.
- * @throws EncoderException  on codec failures
- */
-private void doLoop( DirContext ctx, SearchControls controls, int pagedSizeLimit,
-    int expectedLoop, int expectedNbEntries, boolean expectedException ) throws NamingException, EncoderException
-{
-    // Loop over all the elements
-    int loop = 0;
-    boolean hasSizeLimitException = false;
-    List<SearchResult> results = new ArrayList<SearchResult>();
-
-    while ( true )
+    
+    
+    /**
+     * Create the searchControls with a paged size
+     * @throws EncoderException on codec failures
+     */
+    private void createNextSearchControls( DirContext ctx, byte[] cookie, int pagedSize )
+        throws NamingException, EncoderException
     {
-        loop++;
-        NamingEnumeration<SearchResult> list = null;
-
-        try
+        PagedResultsDecorator pagedSearchControl = new PagedResultsDecorator( codec );
+        pagedSearchControl.setCookie( cookie );
+        pagedSearchControl.setSize( pagedSize );
+        ( ( LdapContext ) ctx ).setRequestControls( JndiUtils.toJndiControls( codec, new Control[]
+            { pagedSearchControl } ) );
+    }
+    
+    
+    /**
+     * Check that we got the correct result set
+     */
+    private void checkResults( List<SearchResult> results, int expectedSize ) throws NamingException
+    {
+        assertEquals( expectedSize, results.size() );
+    
+        // check that we have correctly read all the entries
+        for ( int i = 0; i < expectedSize; i++ )
         {
-            list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
-
-            while ( list.hasMore() )
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+    }
+    
+    
+    /**
+     * Do the loop over the entries, until we can't get any more, or until we
+     * reach a limit. It will check that we have got all the expected entries.
+     * @throws EncoderException  on codec failures
+     */
+    private void doLoop( DirContext ctx, SearchControls controls, int pagedSizeLimit,
+        int expectedLoop, int expectedNbEntries, boolean expectedException ) throws NamingException, EncoderException
+    {
+        // Loop over all the elements
+        int loop = 0;
+        boolean hasSizeLimitException = false;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+    
+        while ( true )
+        {
+            loop++;
+            NamingEnumeration<SearchResult> list = null;
+    
+            try
             {
-                SearchResult result = list.next();
-                results.add( result );
+                list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+    
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
             }
-        }
-        catch ( SizeLimitExceededException e )
-        {
-            hasSizeLimitException = true;
-            break;
-        }
-        finally
-        {
-            // Close the NamingEnumeration
-            if ( list != null )
+            catch ( SizeLimitExceededException e )
             {
-                list.close();
+                hasSizeLimitException = true;
+                break;
             }
-        }
-
-        // Now read the next ones
-        javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
-
-        PagedResultsResponseControl responseControl =
-            ( PagedResultsResponseControl ) responseControls[0];
-        assertEquals( 0, responseControl.getResultSize() );
-
-        // check if this is over
-        byte[] cookie = responseControl.getCookie();
-
-        if ( Strings.isEmpty( cookie ) )
-        {
-            // If so, exit the loop
-            break;
-        }
-
-        // Prepare the next iteration
-        createNextSearchControls( ctx, responseControl.getCookie(), pagedSizeLimit );
+            finally
+            {
+                // Close the NamingEnumeration
+                if ( list != null )
+                {
+                    list.close();
+                }
+            }
+    
+            // Now read the next ones
+            javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
+    
+            PagedResultsResponseControl responseControl =
+                ( PagedResultsResponseControl ) responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+    
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+    
+            if ( Strings.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+    
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), pagedSizeLimit );
+        }
+    
+        assertEquals( expectedException, hasSizeLimitException );
+        assertEquals( expectedLoop, loop );
+        checkResults( results, expectedNbEntries );
+    
+        // And close the connection
+        closeConnection( ctx );
     }
-
-    assertEquals( expectedException, hasSizeLimitException );
-    assertEquals( expectedLoop, loop );
-    checkResults( results, expectedNbEntries );
-
-    // And close the connection
-    closeConnection( ctx );
-}
-
-
-/**
- * Close a connection, and wait a bit to be sure it's done
- */
-private void closeConnection( DirContext ctx ) throws NamingException
-{
-    if ( ctx != null )
+    
+    
+    /**
+     * Close a connection, and wait a bit to be sure it's done
+     */
+    private void closeConnection( DirContext ctx ) throws NamingException
     {
-        ctx.close();
-
-        try
-        {
-            Thread.sleep( 10 );
-        }
-        catch ( Exception e )
+        if ( ctx != null )
         {
+            ctx.close();
+    
+            try
+            {
+                Thread.sleep( 10 );
+            }
+            catch ( Exception e )
+            {
+            }
         }
     }
-}
-
-
-/**
- * Admin = yes <br>
- * SL = none<br>
- * RL = none<br>
- * PL = 3<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 3 + 3 + 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest1() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
-
-    doLoop( ctx, controls, 3, 4, 10, false );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = none<br>
- * RL = none<br>
- * PL = 5<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 5 + 5 )<br>
- */
-@Test
-public void testPagedSearchtest2() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
-
-    doLoop( ctx, controls, 5, 2, 10, false );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 3<br>
- * RL = none<br>
- * PL = 5<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 5 + 5 )<br>
- */
-@Test
-public void testPagedSearchTest3() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 3 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
-
-    doLoop( ctx, controls, 5, 2, 10, false );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = none<br>
- * RL = 3<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3<br>
- */
-@Test
-public void testPagedSearchTest4() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 3, 5 );
-
-    doLoop( ctx, controls, 5, 1, 3, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 5<br>
- * RL = none<br>
- * PL = 3<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 3 + 3 + 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest5() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
-
-    doLoop( ctx, controls, 3, 4, 10, false );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = none<br>
- * RL = 9<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 9 ( 5 + 4 )<br>
- */
-@Test
-public void testPagedSearchTest6() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 9, 5 );
-
-    doLoop( ctx, controls, 5, 2, 9, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 5<br>
- * RL = none<br>
- * PL = 5<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 5 + 5 )<br>
- */
-@Test
-public void testPagedSearchtest7() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
-
-    doLoop( ctx, controls, 5, 2, 10, false );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = none<br>
- * RL = 5<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5<br>
- */
-@Test
-public void testPagedSearchTest8() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 5, 5 );
-
-    doLoop( ctx, controls, 5, 1, 5, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 5<br>
- * RL = 4<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 2 ( 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchTest9() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 4, 3 );
-
-    doLoop( ctx, controls, 3, 2, 4, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 4<br>
- * RL = 5<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5 ( 3 + 2 )<br>
- */
-@Test
-public void testPagedSearchtest10() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 4 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 5, 3 );
-
-    doLoop( ctx, controls, 3, 2, 5, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 5<br>
- * RL = 3<br>
- * PL = 4<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3<br>
- */
-@Test
-public void testPagedSearchtest11() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 3, 4 );
-
-    doLoop( ctx, controls, 4, 1, 3, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 5<br>
- * RL = 4<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 4 ( 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest12() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 4, 3 );
-
-    doLoop( ctx, controls, 3, 2, 4, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 4<br>
- * RL = 5<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5 ( 3 + 2 )<br>
- */
-@Test
-public void testPagedSearchtest13() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 4 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 5, 3 );
-
-    doLoop( ctx, controls, 3, 2, 5, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 4<br>
- * RL = 3<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3 <br>
- */
-@Test
-public void testPagedSearchtest14() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 4 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 3, 5 );
-
-    doLoop( ctx, controls, 5, 1, 3, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 3<br>
- * RL = 5<br>
- * PL = 4<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5 ( 4 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest15() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 3 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 5, 4 );
-
-    doLoop( ctx, controls, 4, 2, 5, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 3<br>
- * RL = 4<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 4 <br>
- */
-@Test
-public void testPagedSearchtest16() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 3 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 4, 5 );
-
-    doLoop( ctx, controls, 5, 1, 4, true );
-}
-
-
-/**
- * Admin = yes <br>
- * SL = 5<br>
- * RL = 5<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5 <br>
- */
-@Test
-public void testPagedSearchtest17() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer() );
-    SearchControls controls = createSearchControls( ctx, 5, 5 );
-
-    doLoop( ctx, controls, 5, 1, 5, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = none<br>
- * RL = none<br>
- * PL = 3<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 3 + 3 + 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest18() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
-
-    doLoop( ctx, controls, 3, 4, 10, false );
-}
-
-
-/**
- * Admin = no <br>
- * SL = none<br>
- * RL = none<br>
- * PL = 5<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 ( 5 + 5 )<br>
- */
-@Test
-public void testPagedSearchtest19() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
-
-    doLoop( ctx, controls, 5, 2, 10, false );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 3<br>
- * RL = none<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3<br>
- */
-@Test
-public void testPagedSearchTest20() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 3 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
-
-    doLoop( ctx, controls, 5, 1, 3, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = none<br>
- * RL = 3<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3<br>
- */
-@Test
-public void testPagedSearchTest21() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 3, 5 );
-
-    doLoop( ctx, controls, 5, 1, 3, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 5<br>
- * RL = none<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5 ( 3 + 2 )<br>
- */
-@Test
-public void testPagedSearchtest22() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
-
-    doLoop( ctx, controls, 3, 2, 5, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = none<br>
- * RL = 9<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 9 ( 5 + 4 )<br>
- */
-@Test
-public void testPagedSearchTest23() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 9, 5 );
-
-    doLoop( ctx, controls, 5, 2, 9, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 5<br>
- * RL = none<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5<br>
- */
-@Test
-public void testPagedSearchtest24() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
-
-    doLoop( ctx, controls, 5, 1, 5, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = none<br>
- * RL = 5<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5<br>
- */
-@Test
-public void testPagedSearchTest25() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 5, 5 );
-
-    doLoop( ctx, controls, 5, 1, 5, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 5<br>
- * RL = 4<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 2 ( 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchTest26() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 4, 3 );
-
-    doLoop( ctx, controls, 3, 2, 4, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 4<br>
- * RL = 5<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 4 ( 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest27() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 4 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 5, 3 );
-
-    doLoop( ctx, controls, 3, 2, 4, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 5<br>
- * RL = 3<br>
- * PL = 4<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3<br>
- */
-@Test
-public void testPagedSearchtest28() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 3, 4 );
-
-    doLoop( ctx, controls, 4, 1, 3, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 5<br>
- * RL = 4<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 4 ( 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest29() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 4, 3 );
-
-    doLoop( ctx, controls, 3, 2, 4, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 4<br>
- * RL = 5<br>
- * PL = 3<br>
- * expected exception : yes<br>
- * expected number of entries returned : 4 ( 3 + 1 )<br>
- */
-@Test
-public void testPagedSearchtest30() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 4 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 5, 3 );
-
-    doLoop( ctx, controls, 3, 2, 4, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 4<br>
- * RL = 3<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3 <br>
- */
-@Test
-public void testPagedSearchtest31() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 4 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 3, 5 );
-
-    doLoop( ctx, controls, 3, 1, 3, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 3<br>
- * RL = 5<br>
- * PL = 4<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3 <br>
- */
-@Test
-public void testPagedSearchtest32() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 3 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 5, 4 );
-
-    doLoop( ctx, controls, 3, 1, 3, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 3<br>
- * RL = 4<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 3 <br>
- */
-@Test
-public void testPagedSearchtest33() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 3 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 4, 5 );
-
-    doLoop( ctx, controls, 3, 1, 3, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = 5<br>
- * RL = 5<br>
- * PL = 5<br>
- * expected exception : yes<br>
- * expected number of entries returned : 5 <br>
- */
-@Test
-public void testPagedSearchtest34() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( 5 );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, 5, 5 );
-
-    doLoop( ctx, controls, 5, 1, 5, true );
-}
-
-
-/**
- * Admin = no <br>
- * SL = none<br>
- * RL = none<br>
- * PL = -2<br>
- * expected exception : no<br>
- * expected number of entries returned : 10 <br>
- */
-@Test
-public void testPagedSearchWithNegativePL() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, -2 );
-
-    doLoop( ctx, controls, -2, 1, 10, false );
-}
-
-
-/**
- * Do a test with a paged search and send a wrong cookie in the middle
- */
-@Test
-public void testPagedSearchWrongCookie() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
-
-    // Loop over all the elements
-    int loop = 0;
-    List<SearchResult> results = new ArrayList<SearchResult>();
-    boolean hasUnwillingToPerform = false;
-
-    while ( true )
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = none<br>
+     * RL = none<br>
+     * PL = 3<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 3 + 3 + 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest1() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
+    
+        doLoop( ctx, controls, 3, 4, 10, false );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = none<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 5 + 5 )<br>
+     */
+    @Test
+    public void testPagedSearchtest2() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
+    
+        doLoop( ctx, controls, 5, 2, 10, false );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 3<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 5 + 5 )<br>
+     */
+    @Test
+    public void testPagedSearchTest3() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
+    
+        doLoop( ctx, controls, 5, 2, 10, false );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = none<br>
+     * RL = 3<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3<br>
+     */
+    @Test
+    public void testPagedSearchTest4() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 3, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 5<br>
+     * RL = none<br>
+     * PL = 3<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 3 + 3 + 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest5() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
+    
+        doLoop( ctx, controls, 3, 4, 10, false );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = none<br>
+     * RL = 9<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 9 ( 5 + 4 )<br>
+     */
+    @Test
+    public void testPagedSearchTest6() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 9, 5 );
+    
+        doLoop( ctx, controls, 5, 2, 9, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 5<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 5 + 5 )<br>
+     */
+    @Test
+    public void testPagedSearchtest7() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
+    
+        doLoop( ctx, controls, 5, 2, 10, false );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = none<br>
+     * RL = 5<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5<br>
+     */
+    @Test
+    public void testPagedSearchTest8() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 5, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 5<br>
+     * RL = 4<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 2 ( 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchTest9() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 4, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 4, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 4<br>
+     * RL = 5<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 ( 3 + 2 )<br>
+     */
+    @Test
+    public void testPagedSearchtest10() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 5, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 5, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 5<br>
+     * RL = 3<br>
+     * PL = 4<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3<br>
+     */
+    @Test
+    public void testPagedSearchtest11() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 3, 4 );
+    
+        doLoop( ctx, controls, 4, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 5<br>
+     * RL = 4<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 4 ( 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest12() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 4, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 4, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 4<br>
+     * RL = 5<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 ( 3 + 2 )<br>
+     */
+    @Test
+    public void testPagedSearchtest13() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 5, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 5, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 4<br>
+     * RL = 3<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3 <br>
+     */
+    @Test
+    public void testPagedSearchtest14() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 3, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 3<br>
+     * RL = 5<br>
+     * PL = 4<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 ( 4 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest15() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 5, 4 );
+    
+        doLoop( ctx, controls, 4, 2, 5, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 3<br>
+     * RL = 4<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 4 <br>
+     */
+    @Test
+    public void testPagedSearchtest16() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 4, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 4, true );
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 5<br>
+     * RL = 5<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 <br>
+     */
+    @Test
+    public void testPagedSearchtest17() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer() );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 5, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = none<br>
+     * RL = none<br>
+     * PL = 3<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 3 + 3 + 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest18() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
+    
+        doLoop( ctx, controls, 3, 4, 10, false );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = none<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 ( 5 + 5 )<br>
+     */
+    @Test
+    public void testPagedSearchtest19() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
+    
+        doLoop( ctx, controls, 5, 2, 10, false );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 3<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3<br>
+     */
+    @Test
+    public void testPagedSearchTest20() throws Exception
     {
-        loop++;
+        getLdapServer().setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = none<br>
+     * RL = 3<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3<br>
+     */
+    @Test
+    public void testPagedSearchTest21() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 3, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 5<br>
+     * RL = none<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 ( 3 + 2 )<br>
+     */
+    @Test
+    public void testPagedSearchtest22() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 5, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = none<br>
+     * RL = 9<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 9 ( 5 + 4 )<br>
+     */
+    @Test
+    public void testPagedSearchTest23() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 9, 5 );
+    
+        doLoop( ctx, controls, 5, 2, 9, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 5<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5<br>
+     */
+    @Test
+    public void testPagedSearchtest24() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 5, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = none<br>
+     * RL = 5<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5<br>
+     */
+    @Test
+    public void testPagedSearchTest25() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 5, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 5<br>
+     * RL = 4<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 2 ( 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchTest26() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 4, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 4, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 4<br>
+     * RL = 5<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 4 ( 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest27() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 5, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 4, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 5<br>
+     * RL = 3<br>
+     * PL = 4<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3<br>
+     */
+    @Test
+    public void testPagedSearchtest28() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 3, 4 );
+    
+        doLoop( ctx, controls, 4, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 5<br>
+     * RL = 4<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 4 ( 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest29() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 4, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 4, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 4<br>
+     * RL = 5<br>
+     * PL = 3<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 4 ( 3 + 1 )<br>
+     */
+    @Test
+    public void testPagedSearchtest30() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 5, 3 );
+    
+        doLoop( ctx, controls, 3, 2, 4, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 4<br>
+     * RL = 3<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3 <br>
+     */
+    @Test
+    public void testPagedSearchtest31() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 3, 5 );
+    
+        doLoop( ctx, controls, 3, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 3<br>
+     * RL = 5<br>
+     * PL = 4<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3 <br>
+     */
+    @Test
+    public void testPagedSearchtest32() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 5, 4 );
+    
+        doLoop( ctx, controls, 3, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 3<br>
+     * RL = 4<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 3 <br>
+     */
+    @Test
+    public void testPagedSearchtest33() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 4, 5 );
+    
+        doLoop( ctx, controls, 3, 1, 3, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = 5<br>
+     * RL = 5<br>
+     * PL = 5<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 <br>
+     */
+    @Test
+    public void testPagedSearchtest34() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+    
+        doLoop( ctx, controls, 5, 1, 5, true );
+    }
+    
+    
+    /**
+     * Admin = no <br>
+     * SL = none<br>
+     * RL = none<br>
+     * PL = -2<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10 <br>
+     */
+    @Test
+    public void testPagedSearchWithNegativePL() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, -2 );
+    
+        doLoop( ctx, controls, -2, 1, 10, false );
+    }
+    
+    
+    /**
+     * Do a test with a paged search and send a wrong cookie in the middle
+     */
+    @Test
+    public void testPagedSearchWrongCookie() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 3 );
+    
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasUnwillingToPerform = false;
+    
+        while ( true )
+        {
+            loop++;
+            
+            NamingEnumeration<SearchResult> list = null;
+    
+            try
+            {
+                list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+    
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( OperationNotSupportedException onse )
+            {
+                hasUnwillingToPerform = true;
+                break;
+            }
+            finally
+            {
+                if ( list != null )
+                {
+                    list.close();
+                }
+            }
+    
+            // Now read the next ones
+            javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
+    
+            PagedResultsResponseControl responseControl =
+                ( PagedResultsResponseControl ) responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+    
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+    
+            if ( Strings.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+    
+            // Prepare the next iteration, sending a bad cookie
+            createNextSearchControls( ctx, "test".getBytes( "UTF-8" ), 3 );
+        }
 
-        try
+        assertTrue( hasUnwillingToPerform );
+        
+        // Cleanup the session
+        ctx.close();
+    
+    }
+    
+    
+    /**
+     * Do a test with a paged search, changing the number of entries to 
+     * return in the middle of the loop
+     */
+    @Test
+    public void testPagedSearchModifyingPagedLimit() throws Exception
+    {
+        getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 4 );
+    
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+    
+        // The expected size after each loop.
+        int[] expectedSize = new int[]
+            { 4, 7, 9, 10 };
+    
+        while ( true )
         {
+            loop++;
+    
             NamingEnumeration<SearchResult> list =
                 ctx.search( "dc=users,ou=system", "(cn=*)", controls );
-
+    
             while ( list.hasMore() )
             {
                 SearchResult result = list.next();
                 results.add( result );
             }
-        }
-        catch ( OperationNotSupportedException onse )
-        {
-            hasUnwillingToPerform = true;
-            break;
-        }
-
-        // Now read the next ones
-        javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
-
-        PagedResultsResponseControl responseControl =
-            ( PagedResultsResponseControl ) responseControls[0];
-        assertEquals( 0, responseControl.getResultSize() );
-
-        // check if this is over
-        byte[] cookie = responseControl.getCookie();
-
-        if ( Strings.isEmpty( cookie ) )
-        {
-            // If so, exit the loop
-            break;
-        }
-
-        // Prepare the next iteration, sending a bad cookie
-        createNextSearchControls( ctx, "test".getBytes( "UTF-8" ), 3 );
-    }
-
-    assertTrue( hasUnwillingToPerform );
-}
-
-
-/**
- * Do a test with a paged search, changing the number of entries to 
- * return in the middle of the loop
- */
-@Test
-public void testPagedSearchModifyingPagedLimit() throws Exception
-{
-    getLdapServer().setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
-    DirContext ctx = getWiredContext( getLdapServer(), "cn=user,ou=system", "secret" );
-    SearchControls controls = createSearchControls( ctx, ( int ) LdapServer.NO_SIZE_LIMIT, 4 );
-
-    // Loop over all the elements
-    int loop = 0;
-    List<SearchResult> results = new ArrayList<SearchResult>();
-
-    // The expected size after each loop.
-    int[] expectedSize = new int[]
-        { 4, 7, 9, 10 };
-
-    while ( true )
-    {
-        loop++;
-
-        NamingEnumeration<SearchResult> list =
-            ctx.search( "dc=users,ou=system", "(cn=*)", controls );
-
-        while ( list.hasMore() )
-        {
-            SearchResult result = list.next();
-            results.add( result );
-        }
-
-        // Now read the next ones
-        javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
-
-        PagedResultsResponseControl responseControl =
-            ( PagedResultsResponseControl ) responseControls[0];
-        assertEquals( 0, responseControl.getResultSize() );
-
-        // check if this is over
-        byte[] cookie = responseControl.getCookie();
-
-        if ( Strings.isEmpty( cookie ) )
-        {
-            // If so, exit the loop
-            break;
-        }
-
-        // Prepare the next iteration, sending a bad cookie
-        createNextSearchControls( ctx, responseControl.getCookie(), 4 - loop );
-
-        assertEquals( expectedSize[loop - 1], results.size() );
+            
+            list.close();
+    
+            // Now read the next ones
+            javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
+    
+            PagedResultsResponseControl responseControl =
+                ( PagedResultsResponseControl ) responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+    
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+    
+            if ( Strings.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+    
+            // Prepare the next iteration, sending a bad cookie
+            createNextSearchControls( ctx, responseControl.getCookie(), 4 - loop );
+    
+            assertEquals( expectedSize[loop - 1], results.size() );
+        }
+    
+        assertEquals( 4, loop );
+        checkResults( results, 10 );
     }
-
-    assertEquals( 4, loop );
-    checkResults( results, 10 );
-}
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=1324744&r1=1324743&r2=1324744&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java Wed Apr 11 12:51:45 2012
@@ -1615,6 +1615,7 @@ public class SearchIT extends AbstractLd
     public void testAbandonnedRequest() throws Exception
     {
         LdapConnection asyncCnx = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
+        EntryCursor cursor = null;
     
         try
         {
@@ -1636,7 +1637,7 @@ public class SearchIT extends AbstractLd
             }
     
             // Searches for all the entries in ou=system
-            EntryCursor cursor = asyncCnx.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );
+            cursor = asyncCnx.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );
     
             // Now loop on all the elements found, and abandon after 10 elements returned
             int count = 0;
@@ -1663,6 +1664,7 @@ public class SearchIT extends AbstractLd
         {
             asyncCnx.unBind();
             asyncCnx.close();
+            cursor.close();
         }
     }
     

Propchange: directory/apacheds/trunk/server-jndi/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-jndi:r1304337-1324714

Propchange: directory/apacheds/trunk/server-replication/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/server-replication:r1304337-1324714

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

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

Propchange: directory/apacheds/trunk/service-builder/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/service-builder:r1304337-1324714

Propchange: directory/apacheds/trunk/test-framework/
------------------------------------------------------------------------------
  Merged /directory/apacheds/branches/index-work/test-framework:r1304337-1324714

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