directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r688458 - 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/SearchLimitsIT.java
Date Sun, 24 Aug 2008 07:35:21 GMT
Author: seelmann
Date: Sun Aug 24 00:35:21 2008
New Revision: 688458

URL: http://svn.apache.org/viewvc?rev=688458&view=rev
Log:
Fix for DIRSERVER-1235: changed the way how a sizeLimitExceeded is detected, added tests.

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/SearchLimitsIT.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=688458&r1=688457&r2=688458&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
Sun Aug 24 00:35:21 2008
@@ -364,18 +364,20 @@
             else
             {
                 int count = 0;
-                while ( cursor.next() && count < sizeLimit )
+                while ( cursor.next() )
                 {
-                    ClonedServerEntry entry = cursor.get();
-                    session.getIoSession().write( generateResponse( session, req, entry )
);
-                    count++;
-                }
-                
-                if ( count >= sizeLimit )
-                {
-                    // DO NOT WRITE THE RESPONSE - JUST RETURN IT
-                    ldapResult.setResultCode( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
-                    return ( SearchResponseDone ) req.getResultResponse();
+                    if ( count < sizeLimit )
+                    {
+                        ClonedServerEntry entry = cursor.get();
+                        session.getIoSession().write( generateResponse( session, req, entry
) );
+                        count++;
+                    }
+                    else
+                    {
+                        // DO NOT WRITE THE RESPONSE - JUST RETURN IT
+                        ldapResult.setResultCode( ResultCodeEnum.SIZE_LIMIT_EXCEEDED );
+                        return ( SearchResponseDone ) req.getResultResponse();
+                    }  
                 }
             }
     

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java?rev=688458&r1=688457&r2=688458&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchLimitsIT.java
Sun Aug 24 00:35:21 2008
@@ -330,7 +330,75 @@
         getActorsWithLimitNonAdmin( "(objectClass=*)", 0, 0 );
     }
 
-    
+
+    /**
+     * Test for DIRSERVER-1235.
+     * Sets up the server with unlimited search size limit but constrains size
+     * by request size limit value. The request size limit is less than the
+     * expected number of result entries, so exception expected.
+     */
+    @Test(expected = SizeLimitExceededException.class)
+    public void testRequestConstraintedLessThanExpectedSize() throws Exception
+    {
+        ldapServer.setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        getActorsWithLimit( "(objectClass=*)", 0, 3 );
+    }
+
+
+    /**
+     * Test for DIRSERVER-1235.
+     * Sets up the server with unlimited search size limit but constrains size
+     * by request size limit value. The request size limit is equal to the
+     * expected number of result entries so no exception expected.
+     */
+    @Test
+    public void testRequestConstraintedEqualToExpectedSize() throws Exception
+    {
+        ldapServer.setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        Set<String> set = getActorsWithLimit( "(objectClass=*)", 0, 4 );
+        assertEquals( 4, set.size() );
+    }
+
+
+    /**
+     * Test for DIRSERVER-1235.
+     * Sets up the server with unlimited search size limit but constrains size
+     * by request size limit value. The request size limit is greater than the
+     * expected number of result entries so no exception expected.
+     */
+    @Test
+    public void testRequestConstraintedGreaterThanExpectedSize() throws Exception
+    {
+        ldapServer.setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+        Set<String> set = getActorsWithLimit( "(objectClass=*)", 0, 5 );
+        assertEquals( 4, set.size() );
+    }
+
+
+    /**
+     * Test for DIRSERVER-1235.
+     * Reads an entry using object scope and size limit 1, no exception
+     * expected.
+     */
+    @Test
+    public void testRequestObjectScopeAndSizeLimit() throws Exception
+    {
+        ldapServer.setMaxSizeLimit( LdapServer.NO_SIZE_LIMIT );
+
+        DirContext ctx = getWiredContext( ldapServer );
+        String filter = "(objectClass=*)";
+        SearchControls controls = new SearchControls();
+        controls.setTimeLimit( 0 );
+        controls.setCountLimit( 1 );
+        controls.setSearchScope( SearchControls.OBJECT_SCOPE );
+
+        NamingEnumeration<SearchResult> namingEnumeration = ctx.search( "ou=actors,ou=system",
filter, controls );
+        assertTrue( namingEnumeration.hasMore() );
+        namingEnumeration.next();
+        assertFalse( namingEnumeration.hasMore() );
+    }
+
+
     // -----------------------------------------------------------------------
     // Utility Methods
     // -----------------------------------------------------------------------



Mime
View raw message