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/01/24 17:22:36 UTC

svn commit: r1235328 [7/12] - in /directory/apacheds/trunk: server-annotations/src/main/java/org/apache/directory/server/annotations/ server-annotations/src/main/java/org/apache/directory/server/factory/ server-annotations/src/test/java/org/apache/dire...

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java?rev=1235328&r1=1235327&r2=1235328&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java Tue Jan 24 16:22:33 2012
@@ -59,203 +59,204 @@ import org.junit.runner.RunWith;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@RunWith ( FrameworkRunner.class ) 
-@ApplyLdifs( {
-    "dn: ou=test,ou=system", 
-    "objectClass: top", 
-    "objectClass: organizationalUnit", 
-    "ou: test", 
-
-    "dn: uid=test1,ou=test,ou=system", 
-    "objectClass: top", 
-    "objectClass: account", 
-    "uid: test1", 
-    "ou: test1", 
-
-    "dn: uid=test2,ou=test,ou=system", 
-    "objectClass: top", 
-    "objectClass: account", 
-    "uid: test2", 
-    "ou: test2", 
-
-    "dn: uid=testNoOU,ou=test,ou=system", 
-    "objectClass: top", 
-    "objectClass: account", 
-    "uid: testNoOU", 
-    
-    "dn: ou=actors,ou=system", 
-    "objectClass: top", 
-    "objectClass: organizationalUnit", 
-    "ou: actors\n", 
-
-    "dn: uid=jblack,ou=actors,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "objectClass: organizationalPerson", 
-    "objectClass: uidObject", 
-    "uid: jblack", 
-    "ou: comedy", 
-    "ou: adventure", 
-    "cn: Jack Black", 
-    "sn: Black", 
-
-    "dn: uid=bpitt,ou=actors,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "objectClass: organizationalPerson", 
-    "objectClass: uidObject", 
-    "uid: bpitt", 
-    "ou: drama", 
-    "ou: adventure", 
-    "cn: Brad Pitt", 
-    "sn: Pitt", 
-
-    "dn: uid=gcloony,ou=actors,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "objectClass: organizationalPerson", 
-    "objectClass: uidObject", 
-    "uid: gcloony", 
-    "ou: drama", 
-    "cn: Goerge Cloony", 
-    "sn: Cloony", 
-
-    "dn: uid=jnewbie,ou=actors,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "objectClass: organizationalPerson", 
-    "objectClass: uidObject", 
-    "uid: jnewbie", 
-    "cn: Joe Newbie", 
-    "sn: Newbie" 
-
-    }
-)
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" )
-    },
-    saslMechanisms = 
-    {
-        @SaslMechanism( name=SupportedSaslMechanisms.PLAIN, implClass=PlainMechanismHandler.class ),
-        @SaslMechanism( name=SupportedSaslMechanisms.CRAM_MD5, implClass=CramMd5MechanismHandler.class),
-        @SaslMechanism( name= SupportedSaslMechanisms.DIGEST_MD5, implClass=DigestMd5MechanismHandler.class),
-        @SaslMechanism( name=SupportedSaslMechanisms.GSSAPI, implClass=GssapiMechanismHandler.class),
-        @SaslMechanism( name=SupportedSaslMechanisms.NTLM, implClass=NtlmMechanismHandler.class),
-        @SaslMechanism( name=SupportedSaslMechanisms.GSS_SPNEGO, implClass=NtlmMechanismHandler.class)
-    },
-    extendedOpHandlers = 
+@RunWith(FrameworkRunner.class)
+@ApplyLdifs(
+    {
+        "dn: ou=test,ou=system",
+        "objectClass: top",
+        "objectClass: organizationalUnit",
+        "ou: test",
+
+        "dn: uid=test1,ou=test,ou=system",
+        "objectClass: top",
+        "objectClass: account",
+        "uid: test1",
+        "ou: test1",
+
+        "dn: uid=test2,ou=test,ou=system",
+        "objectClass: top",
+        "objectClass: account",
+        "uid: test2",
+        "ou: test2",
+
+        "dn: uid=testNoOU,ou=test,ou=system",
+        "objectClass: top",
+        "objectClass: account",
+        "uid: testNoOU",
+
+        "dn: ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: organizationalUnit",
+        "ou: actors\n",
+
+        "dn: uid=jblack,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: jblack",
+        "ou: comedy",
+        "ou: adventure",
+        "cn: Jack Black",
+        "sn: Black",
+
+        "dn: uid=bpitt,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: bpitt",
+        "ou: drama",
+        "ou: adventure",
+        "cn: Brad Pitt",
+        "sn: Pitt",
+
+        "dn: uid=gcloony,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: gcloony",
+        "ou: drama",
+        "cn: Goerge Cloony",
+        "sn: Cloony",
+
+        "dn: uid=jnewbie,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: jnewbie",
+        "cn: Joe Newbie",
+        "sn: Newbie"
+
+})
+@CreateLdapServer(
+transports =
+    {
+        @CreateTransport(protocol = "LDAP")
+},
+saslMechanisms =
+    {
+        @SaslMechanism(name = SupportedSaslMechanisms.PLAIN, implClass = PlainMechanismHandler.class),
+        @SaslMechanism(name = SupportedSaslMechanisms.CRAM_MD5, implClass = CramMd5MechanismHandler.class),
+        @SaslMechanism(name = SupportedSaslMechanisms.DIGEST_MD5, implClass = DigestMd5MechanismHandler.class),
+        @SaslMechanism(name = SupportedSaslMechanisms.GSSAPI, implClass = GssapiMechanismHandler.class),
+        @SaslMechanism(name = SupportedSaslMechanisms.NTLM, implClass = NtlmMechanismHandler.class),
+        @SaslMechanism(name = SupportedSaslMechanisms.GSS_SPNEGO, implClass = NtlmMechanismHandler.class)
+},
+extendedOpHandlers =
     {
         StartTlsHandler.class,
         StoredProcedureExtendedOperationHandler.class
-    })
+})
 public class IndexedNegationSearchIT extends AbstractLdapTestUnit
 {
-    @Rule
-    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
+@Rule
+public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
 
-    /**
-     * Tests to make sure a negated search for OU of "test1" returns
-     * those entries that do not have the OU attribute or do not have
-     * a "test1" value for OU if the attribute exists.
-     */
-    @Test
-    public void testSearchNotOUIndexed() throws Exception
-    {
-        Set<SearchResult> results = getResults( "(!(ou=test1))" );
-        assertFalse( contains( "uid=test1,ou=test,ou=system", results ) );
-        assertTrue( contains( "uid=test2,ou=test,ou=system", results ) );
-        assertTrue( contains( "uid=testNoOU,ou=test,ou=system", results ) );
-    }
 
-    
-    /**
-     * Tests to make sure a negated search for actors without ou
-     * with value 'drama' returns those that do not have the attribute
-     * and do not have a 'drama' value for ou if the attribute still
-     * exists.  This test DOES build an index on ou for the system
-     * partition and should have failed if the bug in DIRSERVER-951
-     * was present and reproducable.
-     */
-    @Test
-    public void testSearchNotDramaIndexed() throws Exception
-    {
-        // jack black has ou but not drama, and joe newbie has no ou what so ever
-        Set<SearchResult> results = getActorResults( "(!(ou=drama))" );
-        assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
-        assertTrue( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
-        assertEquals( 2, results.size() );
-    }
+/**
+ * Tests to make sure a negated search for OU of "test1" returns
+ * those entries that do not have the OU attribute or do not have
+ * a "test1" value for OU if the attribute exists.
+ */
+@Test
+public void testSearchNotOUIndexed() throws Exception
+{
+    Set<SearchResult> results = getResults( "(!(ou=test1))" );
+    assertFalse( contains( "uid=test1,ou=test,ou=system", results ) );
+    assertTrue( contains( "uid=test2,ou=test,ou=system", results ) );
+    assertTrue( contains( "uid=testNoOU,ou=test,ou=system", results ) );
+}
 
-    
-    boolean contains( String dn, Set<SearchResult> results )
+
+/**
+ * Tests to make sure a negated search for actors without ou
+ * with value 'drama' returns those that do not have the attribute
+ * and do not have a 'drama' value for ou if the attribute still
+ * exists.  This test DOES build an index on ou for the system
+ * partition and should have failed if the bug in DIRSERVER-951
+ * was present and reproducable.
+ */
+@Test
+public void testSearchNotDramaIndexed() throws Exception
+{
+    // jack black has ou but not drama, and joe newbie has no ou what so ever
+    Set<SearchResult> results = getActorResults( "(!(ou=drama))" );
+    assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
+    assertTrue( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
+    assertEquals( 2, results.size() );
+}
+
+
+boolean contains( String dn, Set<SearchResult> results )
+{
+    for ( SearchResult result : results )
     {
-        for ( SearchResult result : results )
+        if ( result.getNameInNamespace().equals( dn ) )
         {
-            if ( result.getNameInNamespace().equals( dn ) )
-            {
-                return true;
-            }
+            return true;
         }
-        
-        return false;
-    }
-    
-    
-    /**
-     * Tests to make sure a negated search for actors without ou
-     * with value 'drama' returns those that do not have the attribute
-     * and do not have a 'drama' value for ou if the attribute still
-     * exists.  This test DOES build an index on ou for the system
-     * partition and should have failed if the bug in DIRSERVER-951
-     * was present and reproducable.
-     */
-    @Test
-    public void testSearchNotDramaNotNewbieIndexed() throws Exception
-    {
-        // jack black has ou but not drama, and joe newbie has no ou what so ever
-        Set<SearchResult> results = getActorResults( "(& (!(uid=jnewbie)) (!(ou=drama)) )" );
-        assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
-        assertFalse( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
-        assertEquals( 1, results.size() );
     }
 
-    
-    Set<SearchResult> getActorResults( String filter ) throws Exception
+    return false;
+}
+
+
+/**
+ * Tests to make sure a negated search for actors without ou
+ * with value 'drama' returns those that do not have the attribute
+ * and do not have a 'drama' value for ou if the attribute still
+ * exists.  This test DOES build an index on ou for the system
+ * partition and should have failed if the bug in DIRSERVER-951
+ * was present and reproducable.
+ */
+@Test
+public void testSearchNotDramaNotNewbieIndexed() throws Exception
+{
+    // jack black has ou but not drama, and joe newbie has no ou what so ever
+    Set<SearchResult> results = getActorResults( "(& (!(uid=jnewbie)) (!(ou=drama)) )" );
+    assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
+    assertFalse( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
+    assertEquals( 1, results.size() );
+}
+
+
+Set<SearchResult> getActorResults( String filter ) throws Exception
+{
+    DirContext ctx = getWiredContext( getLdapServer() );
+    Set<SearchResult> results = new HashSet<SearchResult>();
+    SearchControls controls = new SearchControls();
+    controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+    NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
+    while ( namingEnumeration.hasMore() )
     {
-        DirContext ctx = getWiredContext( getLdapServer() );
-        Set<SearchResult> results = new HashSet<SearchResult>();
-        SearchControls controls = new SearchControls();
-        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
-        while( namingEnumeration.hasMore() )
-        {
-            results.add( namingEnumeration.next() );
-        }
-        
-        namingEnumeration.close();
-        ctx.close();
-        
-        return results;
+        results.add( namingEnumeration.next() );
     }
 
-    
-    Set<SearchResult> getResults( String filter ) throws Exception
+    namingEnumeration.close();
+    ctx.close();
+
+    return results;
+}
+
+
+Set<SearchResult> getResults( String filter ) throws Exception
+{
+    DirContext ctx = getWiredContext( getLdapServer() );
+    Set<SearchResult> results = new HashSet<SearchResult>();
+    SearchControls controls = new SearchControls();
+    controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+    NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=system", filter, controls );
+    while ( namingEnumeration.hasMore() )
     {
-        DirContext ctx = getWiredContext( getLdapServer() );
-        Set<SearchResult> results = new HashSet<SearchResult>();
-        SearchControls controls = new SearchControls();
-        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=system", filter, controls );
-        while( namingEnumeration.hasMore() )
-        {
-            results.add( namingEnumeration.next() );
-        }
-        
-        namingEnumeration.close();
-        ctx.close();
-        
-        return results;
+        results.add( namingEnumeration.next() );
     }
+
+    namingEnumeration.close();
+    ctx.close();
+
+    return results;
+}
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/NegationSearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/NegationSearchIT.java?rev=1235328&r1=1235327&r2=1235328&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/NegationSearchIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/NegationSearchIT.java Tue Jan 24 16:22:33 2012
@@ -52,131 +52,132 @@ import org.junit.runner.RunWith;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@RunWith ( FrameworkRunner.class ) 
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" )
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(
+    transports =
+        {
+            @CreateTransport(protocol = "LDAP")
     })
-@ApplyLdifs( {
-    "dn: ou=actors,ou=system",
-    "objectClass: top",
-    "objectClass: organizationalUnit",
-    "ou: actors",
-
-    "dn: uid=jblack,ou=actors,ou=system",
-    "objectClass: top",
-    "objectClass: person",
-    "objectClass: organizationalPerson",
-    "objectClass: uidObject",
-    "uid: jblack",
-    "ou: comedy",
-    "ou: adventure",
-    "cn: Jack Black",
-    "sn: Black",
-
-    "dn: uid=bpitt,ou=actors,ou=system",
-    "objectClass: top",
-    "objectClass: person",
-    "objectClass: organizationalPerson",
-    "objectClass: uidObject",
-    "uid: bpitt",
-    "ou: drama",
-    "ou: adventure",
-    "cn: Brad Pitt",
-    "sn: Pitt",
-
-    "dn: uid=gcloony,ou=actors,ou=system",
-    "objectClass: top",
-    "objectClass: person",
-    "objectClass: organizationalPerson",
-    "objectClass: uidObject",
-    "uid: gcloony",
-    "ou: drama",
-    "cn: Goerge Cloony",
-    "sn: Cloony",
-
-    "dn: uid=jnewbie,ou=actors,ou=system",
-    "objectClass: top",
-    "objectClass: person",
-    "objectClass: organizationalPerson",
-    "objectClass: uidObject",
-    "uid: jnewbie",
-    "cn: Joe Newbie",
-    "sn: Newbie" 
+@ApplyLdifs(
+    {
+        "dn: ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: organizationalUnit",
+        "ou: actors",
+
+        "dn: uid=jblack,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: jblack",
+        "ou: comedy",
+        "ou: adventure",
+        "cn: Jack Black",
+        "sn: Black",
+
+        "dn: uid=bpitt,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: bpitt",
+        "ou: drama",
+        "ou: adventure",
+        "cn: Brad Pitt",
+        "sn: Pitt",
+
+        "dn: uid=gcloony,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: gcloony",
+        "ou: drama",
+        "cn: Goerge Cloony",
+        "sn: Cloony",
+
+        "dn: uid=jnewbie,ou=actors,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "objectClass: organizationalPerson",
+        "objectClass: uidObject",
+        "uid: jnewbie",
+        "cn: Joe Newbie",
+        "sn: Newbie"
 
-    }
-)
-public class NegationSearchIT extends AbstractLdapTestUnit 
+})
+public class NegationSearchIT extends AbstractLdapTestUnit
 {
-    @Rule
-    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
+@Rule
+public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
 
-    /**
-     * Tests to make sure a negated search for actors without ou
-     * with value 'drama' returns those that do not have the attribute
-     * and do not have a 'drama' value for ou if the attribute still
-     * exists.  This test does not build an index on ou for the system
-     * partition.
-     */
-    @Test
-    public void testSearchNotDrama() throws Exception
-    {
-        // jack black has ou but not drama, and joe newbie has no ou what so ever
-        Set<SearchResult> results = getResults( "(!(ou=drama))" );
-        assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
-        assertTrue( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
-        assertEquals( 2, results.size() );
-    }
 
-    
-    /**
-     * Tests to make sure a negated search for actors without ou
-     * with value 'drama' returns those that do not have the attribute
-     * and do not have a 'drama' value for ou if the attribute still
-     * exists.  This test does not build an index on ou for the system
-     * partition.
-     */
-    @Test
-    public void testSearchNotDramaNotNewbie() throws Exception
-    {
-        // jack black has ou but not drama, and joe newbie has no ou what so ever
-        Set<SearchResult> results = getResults( "(& (!(uid=jnewbie)) (!(ou=drama)) )" );
-        assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
-        assertFalse( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
-        assertEquals( 1, results.size() );
-    }
+/**
+ * Tests to make sure a negated search for actors without ou
+ * with value 'drama' returns those that do not have the attribute
+ * and do not have a 'drama' value for ou if the attribute still
+ * exists.  This test does not build an index on ou for the system
+ * partition.
+ */
+@Test
+public void testSearchNotDrama() throws Exception
+{
+    // jack black has ou but not drama, and joe newbie has no ou what so ever
+    Set<SearchResult> results = getResults( "(!(ou=drama))" );
+    assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
+    assertTrue( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
+    assertEquals( 2, results.size() );
+}
+
+
+/**
+ * Tests to make sure a negated search for actors without ou
+ * with value 'drama' returns those that do not have the attribute
+ * and do not have a 'drama' value for ou if the attribute still
+ * exists.  This test does not build an index on ou for the system
+ * partition.
+ */
+@Test
+public void testSearchNotDramaNotNewbie() throws Exception
+{
+    // jack black has ou but not drama, and joe newbie has no ou what so ever
+    Set<SearchResult> results = getResults( "(& (!(uid=jnewbie)) (!(ou=drama)) )" );
+    assertTrue( contains( "uid=jblack,ou=actors,ou=system", results ) );
+    assertFalse( contains( "uid=jnewbie,ou=actors,ou=system", results ) );
+    assertEquals( 1, results.size() );
+}
 
-    
-    boolean contains( String dn, Set<SearchResult> results )
+
+boolean contains( String dn, Set<SearchResult> results )
+{
+    for ( SearchResult result : results )
     {
-        for ( SearchResult result : results )
+        if ( result.getNameInNamespace().equals( dn ) )
         {
-            if ( result.getNameInNamespace().equals( dn ) )
-            {
-                return true;
-            }
+            return true;
         }
-        
-        return false;
     }
-    
-    
-    Set<SearchResult> getResults( String filter ) throws Exception
+
+    return false;
+}
+
+
+Set<SearchResult> getResults( String filter ) throws Exception
+{
+    DirContext ctx = getWiredContext( getLdapServer() );
+    Set<SearchResult> results = new HashSet<SearchResult>();
+    SearchControls controls = new SearchControls();
+    controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+    NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
+    while ( namingEnumeration.hasMore() )
     {
-        DirContext ctx = getWiredContext( getLdapServer() );
-        Set<SearchResult> results = new HashSet<SearchResult>();
-        SearchControls controls = new SearchControls();
-        controls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system", filter, controls );
-        while( namingEnumeration.hasMore() )
-        {
-            results.add( namingEnumeration.next() );
-        }
-        
-        namingEnumeration.close();
-        ctx.close();
-        
-        return results;
+        results.add( namingEnumeration.next() );
     }
+
+    namingEnumeration.close();
+    ctx.close();
+
+    return results;
+}
 }

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=1235328&r1=1235327&r2=1235328&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 Tue Jan 24 16:22:33 2012
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.server.operations.search;
 
- 
+
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -113,1018 +113,1018 @@ import org.junit.runner.RunWith;
  *</pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@RunWith ( FrameworkRunner.class )
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" )
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(
+    transports =
+        {
+            @CreateTransport(protocol = "LDAP")
     })
-@ApplyLdifs( {
-    // Add 10 new entries
-    "dn: dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: domain", 
-    "dc: users", 
-    //
-    "dn: cn=user0,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user0", 
-    "sn: user 0", 
-    //
-    "dn: cn=user1,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user1", 
-    "sn: user 1", 
-    //
-    "dn: cn=user2,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user2", 
-    "sn: user 2", 
-    //
-    "dn: cn=user3,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user3", 
-    "sn: user 3", 
-    //
-    "dn: cn=user4,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user4", 
-    "sn: user 4", 
-    //
-    "dn: cn=user5,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user5", 
-    "sn: user 5", 
-    //
-    "dn: cn=user6,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user6", 
-    "sn: user 6", 
-    //
-    "dn: cn=user7,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user7", 
-    "sn: user 7", 
-    //
-    "dn: cn=user8,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user8", 
-    "sn: user 8", 
-    // 
-    "dn: cn=user9,dc=users,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user9", 
-    "sn: user 9", 
-    "", 
-    // Add another user for non admin tests
-    "dn: cn=user,ou=system", 
-    "objectClass: top", 
-    "objectClass: person", 
-    "cn: user", 
-    "userPassword: secret", 
-    "sn: user"
-    }
-)
+@ApplyLdifs(
+    {
+        // Add 10 new entries
+        "dn: dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: domain",
+        "dc: users",
+        //
+        "dn: cn=user0,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user0",
+        "sn: user 0",
+        //
+        "dn: cn=user1,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user1",
+        "sn: user 1",
+        //
+        "dn: cn=user2,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user2",
+        "sn: user 2",
+        //
+        "dn: cn=user3,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user3",
+        "sn: user 3",
+        //
+        "dn: cn=user4,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user4",
+        "sn: user 4",
+        //
+        "dn: cn=user5,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user5",
+        "sn: user 5",
+        //
+        "dn: cn=user6,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user6",
+        "sn: user 6",
+        //
+        "dn: cn=user7,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user7",
+        "sn: user 7",
+        //
+        "dn: cn=user8,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user8",
+        "sn: user 8",
+        // 
+        "dn: cn=user9,dc=users,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user9",
+        "sn: user 9",
+        "",
+        // Add another user for non admin tests
+        "dn: cn=user,ou=system",
+        "objectClass: top",
+        "objectClass: person",
+        "cn: user",
+        "userPassword: secret",
+        "sn: user"
+})
 public class PagedSearchIT extends AbstractLdapTestUnit
 {
-    @Rule
-    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.THREADSAFE );
+@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
+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++ )
     {
-        assertEquals( expectedSize, results.size() );
-        
-        // check that we have correctly read all the entries
-        for ( int i = 0; i < expectedSize; i++ )
-        {
-            SearchResult entry = results.get( i );
-            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
-        }
+        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
+}
+
+
+/**
+ * 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 over all the elements
-        int loop = 0;
-        boolean hasSizeLimitException = false;
-        List<SearchResult> results = new ArrayList<SearchResult>();
-        
-        while ( true )
+        loop++;
+        NamingEnumeration<SearchResult> list = null;
+
+        try
         {
-            loop++;
-            NamingEnumeration<SearchResult> list = null;
+            list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
 
-            try
-            {
-                list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
-    
-                while ( list.hasMore() )
-                {
-                    SearchResult result = list.next();
-                    results.add( result );
-                }
-            }
-            catch ( SizeLimitExceededException e )
+            while ( list.hasMore() )
             {
-                hasSizeLimitException = true;
-                break;
+                SearchResult result = list.next();
+                results.add( result );
             }
-            finally
+        }
+        catch ( SizeLimitExceededException e )
+        {
+            hasSizeLimitException = true;
+            break;
+        }
+        finally
+        {
+            // Close the NamingEnumeration
+            if ( list != null )
             {
-                // Close the NamingEnumeration
-                if ( list != null )
-                {
-                    list.close();
-                }
+                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 );
+        // 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;
         }
-        
-        assertEquals( expectedException, hasSizeLimitException );
-        assertEquals( expectedLoop, loop );
-        checkResults( results, expectedNbEntries );
-        
-        // And close the connection
-        closeConnection( ctx );
+
+        // Prepare the next iteration
+        createNextSearchControls( ctx, responseControl.getCookie(), pagedSizeLimit );
     }
-    
-    
-    /**
-     * Close a connection, and wait a bit to be sure it's done
-     */
-    private void closeConnection( DirContext ctx ) throws NamingException
+
+    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 )
     {
-        if ( ctx != null )
+        ctx.close();
+
+        try
+        {
+            Thread.sleep( 10 );
+        }
+        catch ( Exception e )
         {
-            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 = 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 );
 
-    
-    /**
-     * 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 );
-    }
+    doLoop( ctx, controls, 3, 4, 10, false );
+}
 
-    
-    /**
-     * 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 = 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 );
 
-    
-    /**
-     * 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 );
-    }
+    doLoop( ctx, controls, 5, 2, 10, false );
+}
 
-    
-    /**
-     * 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
+/**
+ * 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 )
     {
-        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++;
+
+        try
         {
-            loop++;
+            NamingEnumeration<SearchResult> list =
+                ctx.search( "dc=users,ou=system", "(cn=*)", controls );
 
-            try
-            {
-                NamingEnumeration<SearchResult> list = 
-                    ctx.search( "dc=users,ou=system", "(cn=*)", controls );
-    
-                while ( list.hasMore() )
-                {
-                    SearchResult result = list.next();
-                    results.add( result );
-                }
-            }
-            catch ( OperationNotSupportedException onse )
+            while ( list.hasMore() )
             {
-                hasUnwillingToPerform = true;
-                break;
+                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 );
+        // 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;
         }
-        
-        assertTrue( hasUnwillingToPerform );
+
+        // Prepare the next iteration, sending a bad cookie
+        createNextSearchControls( ctx, "test".getBytes( "UTF-8" ), 3 );
     }
 
-    
-    
-    /**
-     * 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
+    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 )
     {
-        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() )
         {
-            loop++;
+            SearchResult result = list.next();
+            results.add( result );
+        }
 
-            NamingEnumeration<SearchResult> list = 
-                ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        // Now read the next ones
+        javax.naming.ldap.Control[] responseControls = ( ( LdapContext ) ctx ).getResponseControls();
 
-            while ( list.hasMore() )
-            {
-                SearchResult result = list.next();
-                results.add( result );
-            }
+        PagedResultsResponseControl responseControl =
+            ( PagedResultsResponseControl ) responseControls[0];
+        assertEquals( 0, responseControl.getResultSize() );
 
-            // 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() );
+        // check if this is over
+        byte[] cookie = responseControl.getCookie();
+
+        if ( Strings.isEmpty( cookie ) )
+        {
+            // If so, exit the loop
+            break;
         }
-        
-        assertEquals( 4, loop );
-        checkResults( results, 10 );
+
+        // 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 );
+}
 }
\ No newline at end of file