directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1397811 - in /directory/apacheds/trunk/ldap-client-test: pom.xml src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
Date Sat, 13 Oct 2012 11:03:26 GMT
Author: seelmann
Date: Sat Oct 13 11:03:26 2012
New Revision: 1397811

URL: http://svn.apache.org/viewvc?rev=1397811&view=rev
Log:
* Moved code that injects 100 entries to setup
* Added MultiThreadedMultiInvoker to demonstrate occasional failures of testAbandonSearch()

Modified:
    directory/apacheds/trunk/ldap-client-test/pom.xml
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java

Modified: directory/apacheds/trunk/ldap-client-test/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/pom.xml?rev=1397811&r1=1397810&r2=1397811&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/pom.xml (original)
+++ directory/apacheds/trunk/ldap-client-test/pom.xml Sat Oct 13 11:03:26 2012
@@ -86,6 +86,12 @@
       <groupId>org.apache.directory.shared</groupId>
       <artifactId>shared-ldap-client-api</artifactId>
     </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.junit</groupId>
+      <artifactId>junit-addons</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <profiles>

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java?rev=1397811&r1=1397810&r2=1397811&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
Sat Oct 13 11:03:26 2012
@@ -24,6 +24,7 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -47,6 +48,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -61,35 +63,28 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientAbandonRequestTest extends AbstractLdapTestUnit
 {
-
+    @Rule
+    public MultiThreadedMultiInvoker i = new MultiThreadedMultiInvoker( MultiThreadedMultiInvoker.NOT_THREADSAFE
);
+    private static final int numEntries = 100;
     private LdapNetworkConnection connection;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
-    }
-
-
-    @After
-    public void shutdown() throws Exception
-    {
-        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer()
);
-    }
+        connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection(
getLdapServer() );
 
-
-    @Test
-    public void testCancelSearch() throws Exception
-    {
         // injecting some values to keep the
         // followed search operation to run for a while
-        final int numEntries = 100;
-
         for ( int i = 0; i < numEntries; i++ )
         {
             String s = String.valueOf( i );
             Dn dn = new Dn( "cn=" + s + ",ou=system" );
+            if ( connection.exists( dn ) )
+            {
+                break;
+            }
+
             Entry entry = new DefaultEntry( dn );
             entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
             entry.add( SchemaConstants.CN_AT, s );
@@ -97,7 +92,19 @@ public class ClientAbandonRequestTest ex
 
             connection.add( entry );
         }
+    }
+
 
+    @After
+    public void shutdown() throws Exception
+    {
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer()
);
+    }
+
+
+    @Test
+    public void testCancelSearch() throws Exception
+    {
         SearchRequest sr = new SearchRequestImpl();
         sr.setFilter( "(cn=*)" );
         sr.setBase( new Dn( "ou=system" ) );
@@ -145,22 +152,6 @@ public class ClientAbandonRequestTest ex
     @Test
     public void testAbandonSearch() throws Exception
     {
-        // injecting some values to keep the
-        // followed search operation to run for a while
-        final int numEntries = 100;
-
-        for ( int i = 0; i < numEntries; i++ )
-        {
-            String s = String.valueOf( i );
-            Dn dn = new Dn( "cn=" + s + ",ou=system" );
-            Entry entry = new DefaultEntry( dn );
-            entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
-            entry.add( SchemaConstants.CN_AT, s );
-            entry.add( SchemaConstants.SN_AT, s );
-
-            connection.add( entry );
-        }
-
         // Launch the search now
         EntryCursor cursor = connection.search( new Dn( "ou=system" ), "(cn=*)", SearchScope.ONELEVEL,
"*" );
 



Mime
View raw message