directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r945036 - /directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java
Date Mon, 17 May 2010 09:10:17 GMT
Author: elecharny
Date: Mon May 17 09:10:16 2010
New Revision: 945036

URL: http://svn.apache.org/viewvc?rev=945036&view=rev
Log:
o Added a connection close after every test
o Added some delay after the connection is closed so that the unbind request is correctly
sent
o Also closing the NamingEnumeration

Modified:
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java

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=945036&r1=945035&r2=945036&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 May 17 09:10:16 2010
@@ -256,11 +256,11 @@ public class PagedSearchIT extends Abstr
         while ( true )
         {
             loop++;
+            NamingEnumeration<SearchResult> list = null;
 
             try
             {
-                NamingEnumeration<SearchResult> list = 
-                    ctx.search( "dc=users,ou=system", "(cn=*)", controls );
+                list = ctx.search( "dc=users,ou=system", "(cn=*)", controls );
     
                 while ( list.hasMore() )
                 {
@@ -270,10 +270,17 @@ public class PagedSearchIT extends Abstr
             }
             catch ( SizeLimitExceededException e )
             {
-                // e.printStackTrace();
                 hasSizeLimitException = true;
                 break;
             }
+            finally
+            {
+                // Close the NamingEnumeration
+                if ( list != null )
+                {
+                    list.close();
+                }
+            }
 
             // Now read the next ones
             javax.naming.ldap.Control[] responseControls = ((LdapContext)ctx).getResponseControls();
@@ -298,6 +305,9 @@ public class PagedSearchIT extends Abstr
         assertEquals( expectedException, hasSizeLimitException );
         assertEquals( expectedLoop, loop );
         checkResults( results, expectedNbEntries );
+        
+        // And close the connection
+        closeConnection( ctx );
     }
     
     
@@ -312,6 +322,26 @@ public class PagedSearchIT extends Abstr
     
     
     /**
+     * Close a connection, and wait a bit to be sure it's done
+     */
+    private void closeConnection( DirContext ctx ) throws NamingException
+    {
+        if ( ctx != null )
+        {
+            ctx.close();
+            
+            try
+            {
+                Thread.sleep(10);
+            }
+            catch ( Exception e )
+            {
+            }
+        }
+    }
+    
+    
+    /**
      * Admin = yes <br>
      * SL = none<br>
      * RL = none<br>



Mime
View raw message