directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r726858 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java
Date Mon, 15 Dec 2008 22:29:44 GMT
Author: elecharny
Date: Mon Dec 15 14:29:44 2008
New Revision: 726858

URL: http://svn.apache.org/viewvc?rev=726858&view=rev
Log:
Added na bunch of tests for paged searches, plus the associated code in the server. Seems to work so far, but it's not over !

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=726858&r1=726857&r2=726858&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Mon Dec 15 14:29:44 2008
@@ -310,69 +310,39 @@
     }
     
     
-    private int getSearchSizeLimits( SearchRequest req, LdapSession session )
+    private void readResults( LdapSession session, SearchRequest req, LdapResult ldapResult,
+    EntryFilteringCursor cursor, int sizeLimit ) throws Exception
     {
-        LOG.debug( "req size limit = {}, server size limit = {}", req.getSizeLimit(), 
-            ldapService.getMaxSizeLimit() );
-        
-        // Don't bother setting size limits for administrators that don't ask for it
-        if ( session.getCoreSession().isAnAdministrator() )
+        int count = 0;
+
+        while ( (count < sizeLimit ) && cursor.next() )
         {
-            if ( req.getSizeLimit() == NO_SIZE_LIMIT )
-            {
-                return Integer.MAX_VALUE;
-            }
-            else
+            if ( session.getIoSession().isClosing() )
             {
-                return req.getSizeLimit();
+                break;
             }
+            
+            ClonedServerEntry entry = cursor.get();
+            session.getIoSession().write( generateResponse( session, req, entry ) );
+            count++;
         }
         
-        /*
-         * Non administrator based searches are limited by size if the server 
-         * has been configured with unlimited size and the request specifies 
-         * unlimited search size
-         */
-        if ( ldapService.getMaxSizeLimit() == NO_SIZE_LIMIT && req.getSizeLimit() == NO_SIZE_LIMIT )
-        {
-            return Integer.MAX_VALUE;
-        }
-        
-        /*
-         * If the non-administrator user specifies unlimited size but the server 
-         * is configured to limit the search size then we limit by the max size
-         * allowed by the configuration 
-         */
-        if ( req.getSizeLimit() == NO_SIZE_LIMIT )
-        {
-            return ldapService.getMaxSizeLimit();
-        }
-        
-        if ( ldapService.getMaxSizeLimit() == NO_SIZE_LIMIT )
-        {
-            return req.getSizeLimit();
-        }
-        
-        /*
-         * If the non-administrative user specifies a size limit equal to or 
-         * less than the maximum limit configured in the server then we 
-         * constrain search by the amount specified in the request
-         */
-        if ( ldapService.getMaxSizeLimit() >= req.getSizeLimit() )
+        // DO NOT WRITE THE RESPONSE - JUST RETURN IT
+        ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
+
+        if ( ( count >= sizeLimit ) && ( cursor.next() ) )
         {
-            return req.getSizeLimit();
+            // We have reached the limit
+            // Move backward on the cursor to restore the previous position, as we moved forward
+            // to check if there is one more entry available
+            cursor.previous();
+            // Special case if the user has requested more elements than the request size limit
+            ldapResult.setResultCode( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
         }
-        
-        /*
-         * Here the non-administrative user's requested size limit is greater 
-         * than what the server's configured maximum limit allows so we limit
-         * the search to the configured limit
-         */
-        return ldapService.getMaxSizeLimit();
     }
     
     
-    private void readResults( LdapSession session, SearchRequest req, LdapResult ldapResult,  
+    private void readPagedResults( LdapSession session, SearchRequest req, LdapResult ldapResult,  
         EntryFilteringCursor cursor, int sizeLimit, int pagedLimit, boolean isPaged, 
         PagedSearchCookie cookieInstance, PagedResultsControl pagedResultsControl ) throws Exception
     {
@@ -509,6 +479,22 @@
     
     
     /**
+     * Remove a cookie instance from the session, if it exists.
+     */
+    private PagedSearchCookie removeCookie( LdapSession session, PagedSearchCookie cookieInstance )
+    {
+        if ( cookieInstance == null )
+        {
+            return null;
+        }
+        
+        int cookieValue = cookieInstance.getCookieValue();
+        
+        return (PagedSearchCookie)session.getIoSession().removeAttribute( cookieValue );
+    }
+    
+    
+    /**
      * Handle a Paged Search request.
      */
     private SearchResponseDone doPagedSearch( LdapSession session, SearchRequest req, PagedSearchControl control )
@@ -570,7 +556,8 @@
                     // Position the cursor at the beginning
                     cursor.beforeFirst();
                     
-                    readResults( session, req, ldapResult, cursor, serverLimit, requestLimit, true, cookieInstance, pagedResultsControl );
+                    // And read the entries
+                    readResults( session, req, ldapResult, cursor, sizeLimit );
                 }
                 finally
                 {
@@ -584,6 +571,8 @@
                     }
                 }
                 
+                // If we had a cookie in the session, remove it
+                removeCookie( session, cookieInstance );
                 return ( SearchResponseDone ) req.getResultResponse();
             }
             else
@@ -651,7 +640,7 @@
          */
         try
         {
-            readResults( session, req, ldapResult, cursor, sizeLimit, pagedLimit, true, cookieInstance, pagedResultsControl );
+            readPagedResults( session, req, ldapResult, cursor, sizeLimit, pagedLimit, true, cookieInstance, pagedResultsControl );
         }
         catch ( Exception e )
         {
@@ -687,7 +676,6 @@
         throws Exception
     {
         LdapResult ldapResult = req.getResultResponse().getLdapResult();
-        PagedResultsControl pagedResultsControl = null;
         
         // Check if we are using the Paged Search Control
         Object control = req.getControls().get( PagedSearchControl.CONTROL_OID );
@@ -723,6 +711,9 @@
             setTimeLimitsOnCursor( req, session, cursor );
             LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit );
             int sizeLimit = min( requestLimit, serverLimit );
+            
+            readResults( session, req, ldapResult, cursor, sizeLimit );
+            /*
             int count = 0;
             
             
@@ -750,6 +741,8 @@
                 // Special case if the user has requested more elements than the request size limit
                 ldapResult.setResultCode( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
             }
+            
+            */
         }
         finally
         {

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=726858&r1=726857&r2=726858&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 Mon Dec 15 14:29:44 2008
@@ -40,17 +40,70 @@
 
 import org.apache.directory.server.ldap.LdapService;
 import org.apache.directory.shared.ldap.message.control.PagedSearchControl;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 
 /**
- * Test the PagedSearchControl
- *
+ * Test the PagedSearchControl. The following tables covers all the
+ * possible cases for both an admin and a simple user, combining the
+ * Server SizeLimit (SL), the requested SizeLimit (SL) and the paged
+ * size limit (PL). The 'X' column tells if we are supposed to receive
+ * a SizeLimitExceededException.<br>
+ * <br>
+ * Administrator<br>
+ * <pre>
+ * +-------+----+----+----+---------------------+----+---+<br>
+ * |test   | SL | RL | PL | Nb of responses     | nb | X |<br>
+ * +-------+----+----+----+---------------------+----+---+<br>
+ * |test1  | 0  | 0  | 3  | 4 ( 3 + 3 + 3 + 1 ) | 10 |   |<br>
+ * |test2  | 0  | 0  | 5  | 2 ( 5 + 5 )         | 10 |   |<br>
+ * |test3  | 3  | 0  | 5  | 2 ( 5 + 5 )         | 10 |   |<br>
+ * |test4  | 0  | 3  | 5  | 1 ( 3 )             | 3  | Y |<br>
+ * |test5  | 5  | 0  | 3  | 4 ( 3 + 3 + 3 + 1 ) | 10 |   |<br>
+ * |test6  | 0  | 9  | 5  | 2 ( 5 + 4 )         | 5  | Y |<br>
+ * |test7  | 5  | 0  | 5  | 2 ( 5 + 5 )         | 10 |   |<br>
+ * |test8  | 0  | 5  | 5  | 1 ( 5 )             | 5  | Y |<br>
+ * |test9  | 5  | 4  | 3  | 2 ( 3 + 1 )         | 4  | Y |<br>
+ * |test10 | 4  | 5  | 3  | 2 ( 3 + 2 )         | 5  | Y |<br>
+ * |test11 | 5  | 3  | 4  | 1 ( 3 )             | 3  | Y |<br>
+ * |test12 | 5  | 4  | 3  | 2 ( 3 + 1 )         | 4  | Y |<br>
+ * |test13 | 4  | 5  | 3  | 2 ( 3 + 2 )         | 5  | Y |<br>
+ * |test14 | 4  | 3  | 5  | 1 ( 3 )             | 3  | Y |<br>
+ * |test15 | 3  | 5  | 4  | 2 ( 4 + 1 )         | 5  | Y |<br>
+ * |test16 | 3  | 4  | 5  | 1 ( 4 )             | 4  | Y |<br>
+ * |test17 | 5  | 5  | 5  | 1 ( 5 )             | 5  | Y |<br>
+ * +-------+----+----+----+---------------------+----+---+<br>
+ * <br>
+ * Simple user<br>
+ * <br>
+ * +-------+----+----+----+---------------------+----+---+<br>
+ * |test   | SL | RL | PL | Nb of responses     | nb | X |<br>
+ * +-------+----+----+----+---------------------+----+---+<br>
+ * |test18 | 0  | 0  | 3  | 4 ( 3 + 3 + 3 + 1 ) | 10 |   |<br>
+ * |test19  | 0  | 0  | 5  | 2 ( 5 + 5 )         | 10 |   |<br>
+ * |test20  | 3  | 0  | 5  | 1 ( 3 )             | 3  | Y |<br>
+ * |test21 | 0  | 3  | 5  | 1 ( 3 )             | 3  | Y |<br>
+ * |test22 | 5  | 0  | 3  | 2 ( 3 + 2 )         | 5  | Y |<br>
+ * |test23 | 0  | 9  | 5  | 2 ( 5 + 4 )         | 9  | Y |<br>
+ * |test24 | 5  | 0  | 5  | 1 ( 5 )             | 5  | Y |<br>
+ * |test25 | 0  | 5  | 5  | 1 ( 5 )             | 5  | Y |<br>
+ * |test26 | 5  | 4  | 3  | 2 ( 3 + 1 )         | 4  | Y |<br>
+ * |test27 | 4  | 5  | 3  | 2 ( 3 + 1 )         | 4  | Y |<br>
+ * |test28 | 5  | 3  | 4  | 1 ( 3 )             | 3  | Y |<br>
+ * |test29 | 5  | 4  | 3  | 2 ( 3 + 1 )         | 4  | Y |<br>
+ * |test30 | 4  | 5  | 3  | 2 ( 3 + 1 )         | 4  | Y |<br>
+ * |test31 | 4  | 3  | 5  | 1 ( 3 )             | 3  | Y |<br>
+ * |test32 | 3  | 5  | 4  | 1 ( 3 )             | 3  | Y |<br>
+ * |test33 | 3  | 4  | 5  | 1 ( 3 )             | 3  | Y |<br>
+ * |test34 | 5  | 5  | 5  | 1 ( 5 )             | 5  | Y |<br>
+ * +-------+----+----+----+---------------------+----+---+<br>
+ *</pre>
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 545029 $
  */
@@ -121,6 +174,14 @@
     "objectClass: person\n" +
     "cn: user9\n" +
     "sn: user 9\n" +
+    "\n" +
+    // Add another user for non admin tests
+    "dn: cn=user,ou=system\n" +
+    "objectClass: top\n" +
+    "objectClass: person\n" +
+    "cn: user\n" +
+    "userPassword: secret\n" +
+    "sn: user\n" +
     "\n"
     }
 )
@@ -138,7 +199,7 @@
         controls.setCountLimit( sizeLimit );
         controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
         PagedSearchControl pagedSearchControl = new PagedSearchControl();
-        pagedSearchControl.setSize( 5 );
+        pagedSearchControl.setSize( pagedSize );
         
         ((LdapContext)ctx).setRequestControls( new Control[] {pagedSearchControl} );
         
@@ -154,18 +215,229 @@
     {
         PagedSearchControl pagedSearchControl = new PagedSearchControl();
         pagedSearchControl.setCookie( cookie );
-        pagedSearchControl.setSize( 5 );
+        pagedSearchControl.setSize( pagedSize );
         ((LdapContext)ctx).setRequestControls( new Control[] {pagedSearchControl} );
     }
     
     
     /**
-     * Do a pagedSearch with a paged size of 5, and no limit otherwise
-     * @throws Exception
+     * 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++ )
+        {
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+    }
+    
+    
+    private void doLoop( DirContext ctx, SearchControls controls, int pagedSizeLimit, 
+        int expectedLoop, int expectedNbEntries, boolean expectedException ) throws NamingException
+    {
+        // Loop over all the elements
+        int loop = 0;
+        boolean hasSizeLimitException = false;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        while ( true )
+        {
+            loop++;
+
+            try
+            {
+                NamingEnumeration<SearchResult> list = 
+                    ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+    
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = 
+                (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.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 );
+    }
+    
+    
+    /**
+     * Clear the server SizeLimit
+     */
+    @Before
+    public void reinitLdapServiceMaxSizeLimit()
+    {
+        ldapService.setMaxSizeLimit( LdapService.NO_SIZE_LIMIT );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest1() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, LdapService.NO_SIZE_LIMIT, 3 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        while ( true )
+        {
+            loop++;
+            
+            try
+            {
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 3 );
+        }
+        
+        assertEquals( 4, loop );
+        checkResults( results, 10 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest2() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, LdapService.NO_SIZE_LIMIT, 5 );
+        
+        // Search the 5 first elements
+        NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            results.add( result );
+        }
+        
+        assertEquals( 5, results.size() );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 0; i < 5; i++ )
+        {
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+        
+        // Now read the 5 next ones
+        Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+        
+        PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+        assertEquals( 0, responseControl.getResultSize() );
+        
+        // Prepare the next iteration
+        createNextSearchControls( ctx, responseControl.getCookie(), 5 );
+        
+        list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        results = new ArrayList<SearchResult>();
+        
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            results.add( result );
+        }
+        
+        assertEquals( 5, results.size() );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 5; i < 10; i++ )
+        {
+            SearchResult entry = results.get( i-5 );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+    }
+    
+    
+    /**
+     * Admin = yes <br>
+     * SL = 3<br>
+     * RL = none<br>
+     * PL = 5<br>
+     * expected exception : no<br>
+     * expected number of entries returned : 10<br>
      */
     @Test
-    public void testSearchPagedSearch5Entries() throws Exception
+    public void testSearchPagedSearchTest3() throws Exception
     {
+        ldapService.setMaxSizeLimit( 3 );
         DirContext ctx = getWiredContext( ldapService );
         SearchControls controls = createSearchControls( ctx, LdapService.NO_SIZE_LIMIT, 5 );
         
@@ -220,11 +492,116 @@
     
     
     /**
-     * Do a pagedSearch with a paged size of 5, and no limit otherwise
-     * @throws Exception
+     * 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 testSearchPagedSearchTest4() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 3, 5 );
+        
+        // Search the 5 first elements
+        NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        boolean hasSizeLimitException = false;
+        
+        try
+        {
+            while ( list.hasMore() )
+            {
+                SearchResult result = list.next();
+                results.add( result );
+            }
+        }
+        catch ( SizeLimitExceededException slee )
+        {
+            hasSizeLimitException = true;
+        }
+        
+        assertEquals( 3, results.size() );
+        assertTrue( hasSizeLimitException );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 0; i < 3; i++ )
+        {
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest5() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, LdapService.NO_SIZE_LIMIT, 3 );
+
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        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
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 3 );
+        }
+        
+        assertEquals( 4, loop );
+        checkResults( results, 10 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearch5EntriesSizeLimit9() throws Exception
+    public void testSearchPagedSearchTest6() throws Exception
     {
         DirContext ctx = getWiredContext( ldapService );
         SearchControls controls = createSearchControls( ctx, 9, 5 );
@@ -290,4 +667,1033 @@
         }
         
     }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest7() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, LdapService.NO_SIZE_LIMIT, 5 );
+        
+        // Search the 5 first elements
+        NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            results.add( result );
+        }
+        
+        assertEquals( 5, results.size() );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 0; i < 5; i++ )
+        {
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+        
+        // Now read the 5 next ones
+        Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+        
+        PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+        assertEquals( 0, responseControl.getResultSize() );
+        
+        // Prepare the next iteration
+        createNextSearchControls( ctx, responseControl.getCookie(), 5 );
+        
+        list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        results = new ArrayList<SearchResult>();
+        
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            results.add( result );
+        }
+        
+        assertEquals( 5, results.size() );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 5; i < 10; i++ )
+        {
+            SearchResult entry = results.get( i-5 );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchTest8() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+        
+        // Search the 5 first elements
+        NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        boolean hasSizeLimitException = false;
+        
+        try
+        {
+            while ( list.hasMore() )
+            {
+                SearchResult result = list.next();
+                results.add( result );
+            }
+        }
+        catch ( SizeLimitExceededException slee )
+        {
+            hasSizeLimitException = true;
+        }
+        
+        assertEquals( 5, results.size() );
+        assertTrue( hasSizeLimitException );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 0; i < 5; i++ )
+        {
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchTest9() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 4, 3 );
+        
+        // Search the 3 first elements
+        NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        
+        while ( list.hasMore() )
+        {
+            SearchResult result = list.next();
+            results.add( result );
+        }
+        
+        assertEquals( 3, results.size() );
+        
+        // check that we have correctly read the 3 first entries
+        for ( int i = 0; i < 3; i++ )
+        {
+            SearchResult entry = results.get( i );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+        
+        // Now read the last entry
+        Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+        
+        PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+        assertEquals( 0, responseControl.getResultSize() );
+
+        // Prepare the next iteration
+        createNextSearchControls( ctx, responseControl.getCookie(), 3 );
+        
+        list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+        
+        results = new ArrayList<SearchResult>();
+        
+        boolean hasSizeLimitException = false;
+        
+        try
+        {
+            while ( list.hasMore() )
+            {
+                SearchResult result = list.next();
+                results.add( result );
+            }
+        }
+        catch ( SizeLimitExceededException slee )
+        {
+            hasSizeLimitException = true;
+        }
+        
+        // We must have had a sizeLimoit exception
+        assertTrue( hasSizeLimitException );
+        
+        assertEquals( 1, results.size() );
+        
+        // check that we have correctly read the 5 first entries
+        for ( int i = 3; i < 4; i++ )
+        {
+            SearchResult entry = results.get( i-3 );
+            assertEquals( "user" + i, entry.getAttributes().get( "cn" ).get() );
+        }
+        
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest10() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 5, 3 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            try
+            {
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 3 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 2, loop );
+        checkResults( results, 5 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest11() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 3, 4 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 4 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 1, loop );
+        checkResults( results, 3 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest12() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 4, 3 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 3 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 2, loop );
+        checkResults( results, 4 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest13() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 5, 3 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 4 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 2, loop );
+        checkResults( results, 5 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest14() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 3, 5 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 5 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 1, loop );
+        checkResults( results, 3 );
+    }
+
+    
+    /**
+     * Admin = yes <br>
+     * SL = 3<br>
+     * RL = 5<br>
+     * PL = 4<br>
+     * expected exception : yes<br>
+     * expected number of entries returned : 5 <br>
+     */
+    @Test
+    public void testSearchPagedSearchtest15() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 5, 4 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 4 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 2, loop );
+        checkResults( results, 5 );
+    }
+
+    
+    /**
+     * 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 testSearchPagedSearchtest16() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 4, 5 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 5 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 1, loop );
+        checkResults( results, 4 );
+    }
+
+    
+    /**
+     * 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 testSearchPagedSearchtest17() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+        
+        // Loop over all the elements
+        int loop = 0;
+        List<SearchResult> results = new ArrayList<SearchResult>();
+        boolean hasSizeLimitException = false;
+        
+        while ( true )
+        {
+            loop++;
+
+            NamingEnumeration<SearchResult> list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+
+            try
+            {
+                while ( list.hasMore() )
+                {
+                    SearchResult result = list.next();
+                    results.add( result );
+                }
+            }
+            catch ( Exception e )
+            {
+                hasSizeLimitException = true;
+                break;
+            }
+
+            // Now read the next ones
+            Control[] responseControls = ((LdapContext)ctx).getResponseControls();
+            
+            PagedResultsResponseControl responseControl = (PagedResultsResponseControl)responseControls[0];
+            assertEquals( 0, responseControl.getResultSize() );
+            
+            // check if this is over
+            byte[] cookie = responseControl.getCookie();
+            
+            if ( StringTools.isEmpty( cookie ) )
+            {
+                // If so, exit the loop
+                break;
+            }
+            
+            // Prepare the next iteration
+            createNextSearchControls( ctx, responseControl.getCookie(), 5 );
+        }
+        
+        assertTrue( hasSizeLimitException );
+        assertEquals( 1, loop );
+        checkResults( results, 5 );
+    }
+    
+    
+    /**
+     * 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 testSearchPagedSearchtest18() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService, "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, LdapService.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 testSearchPagedSearchtest19() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService, "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, LdapService.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 testSearchPagedSearchTest20() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( ldapService, "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, LdapService.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 testSearchPagedSearchTest21() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest22() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService, "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, LdapService.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 testSearchPagedSearchTest23() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest24() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService, "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, LdapService.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 testSearchPagedSearchTest25() throws Exception
+    {
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchTest26() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest27() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest28() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest29() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest30() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest31() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 4 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest32() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest33() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 3 );
+        DirContext ctx = getWiredContext( ldapService, "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 testSearchPagedSearchtest34() throws Exception
+    {
+        ldapService.setMaxSizeLimit( 5 );
+        DirContext ctx = getWiredContext( ldapService, "cn=user,ou=system", "secret" );
+        SearchControls controls = createSearchControls( ctx, 5, 5 );
+        
+        doLoop( ctx, controls, 5, 1, 5, true );
+    }
 }
\ No newline at end of file



Mime
View raw message