directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1067639 - in /directory/apacheds/trunk/ldap-client-test: ./ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/directory/ src/main/java/org/apache/directory/shared/ src/main/java/org/apache/directory/shared/client/ src/m...
Date Sun, 06 Feb 2011 11:00:11 GMT
Author: seelmann
Date: Sun Feb  6 11:00:10 2011
New Revision: 1067639

URL: http://svn.apache.org/viewvc?rev=1067639&view=rev
Log:
Fixed LDAP API integration test issues
o Added LdapApiIntegrationUtils which provides a pooled connections
o Use pooled connections in tests where possible to reduce number of opened sockets
o Use a Suite for all test
o These steps reduced test run from 40s to 20s
o Removed catched exceptions in tests, better show them to see what went wrong


Added:
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java
Modified:
    directory/apacheds/trunk/ldap-client-test/pom.xml
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/NetworkSchemaLoaderTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.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=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/pom.xml (original)
+++ directory/apacheds/trunk/ldap-client-test/pom.xml Sun Feb  6 11:00:10 2011
@@ -99,6 +99,7 @@
               </includes>
               <excludes>
                 <exclude>**/*Test.java</exclude>
+                <exclude>**/*ISuite.java</exclude>
               </excludes>
             </configuration>
           </plugin>
@@ -116,10 +117,14 @@
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
+              <includes>
+                <include>**/*ISuite.java</include>
+              </includes>
               <excludes>
                 <exclude>**/Abstract*</exclude>
                 <exclude>**/*RegressionTest*</exclude>
                 <exclude>**/TestClientApiPerf.java</exclude>
+                <exclude>**/*Test.java</exclude>
               </excludes>
             </configuration>
           </plugin>

Added: directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java?rev=1067639&view=auto
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java (added)
+++ directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java Sun Feb  6 11:00:10 2011
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.shared.client.api;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.directory.ldap.client.api.LdapConnectionConfig;
+import org.apache.directory.ldap.client.api.LdapConnectionPool;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.PoolableLdapConnectionFactory;
+import org.apache.directory.server.constants.ServerDNConstants;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The Class LdapApiIntegrationUtils.
+ */
+public class LdapApiIntegrationUtils
+{
+
+    /** The class logger. */
+    private static final Logger LOG = LoggerFactory.getLogger( LdapApiIntegrationUtils.class );
+
+    /** The Constant DEFAULT_HOST. */
+    private static final String DEFAULT_HOST = "localhost";
+
+    /** The Constant DEFAULT_ADMIN. */
+    private static final String DEFAULT_ADMIN = ServerDNConstants.ADMIN_SYSTEM_DN;
+
+    /** The Constant DEFAULT_PASSWORD. */
+    private static final String DEFAULT_PASSWORD = "secret";
+
+    /** The pools. */
+    private static Map<Integer, LdapConnectionPool> pools = new HashMap<Integer, LdapConnectionPool>();
+
+
+    /**
+     * Creates a new {@link LdapNetworkConnection} and authenticates as admin user.
+     * The caller is responsible for closing the connection, use closeConnection().
+     *
+     * @param ldapServer the LDAP server instance, used to obtain the port used
+     * @return the created connection
+     * @throws LdapException the LDAP exception
+     * @throws IOException Signals that an I/O exception has occurred.
+     */
+    public static LdapNetworkConnection createAdminConnection( LdapServer ldapServer ) throws LdapException,
+        IOException
+    {
+        LdapNetworkConnection conn = new LdapNetworkConnection( DEFAULT_HOST, ldapServer.getPort() );
+        conn.bind( DEFAULT_ADMIN, DEFAULT_PASSWORD );
+        return conn;
+    }
+
+
+    /**
+     * Closes the {@link LdapNetworkConnection}.
+     *
+     * @param conn the connection to close
+     * @throws LdapException the LDAP exception
+     * @throws IOException Signals that an I/O exception has occurred.
+     */
+    public static void closeConnection( LdapNetworkConnection conn ) throws LdapException, IOException
+    {
+        if ( conn != null )
+        {
+            conn.unBind();
+            conn.close();
+        }
+    }
+
+
+    /**
+     * Gets the pooled {@link LdapConnectionPool}, authenticated as admin user.
+     * The caller is reponsible for releasing the connection, use releasePooledConnection().
+     *
+     * @param ldapServer the LDAP server instance, used to obtain the port used
+     * @return the pooled admin connection
+     * @throws Exception the exception
+     */
+    public static LdapNetworkConnection getPooledAdminConnection( LdapServer ldapServer ) throws Exception
+    {
+        return getAdminPool( ldapServer ).getConnection();
+    }
+
+
+    /**
+     * Releases a pooled connection back to the pool.
+     *
+     * @param conn the connection to release
+     * @param ldapServer the LDAP server instance, used to obtain the port used
+     * @throws Exception the exception
+     */
+    public static void releasePooledAdminConnection( LdapNetworkConnection conn, LdapServer ldapServer )
+        throws Exception
+    {
+        getAdminPool( ldapServer ).releaseConnection( conn );
+    }
+
+
+    /**
+     * Gets the admin pool.
+     *
+     * @param ldapServer the ldap server
+     * @return the admin pool
+     */
+    private static LdapConnectionPool getAdminPool( LdapServer ldapServer )
+    {
+        int port = ldapServer.getPort();
+        if ( !pools.containsKey( port ) )
+        {
+            LdapConnectionConfig config = new LdapConnectionConfig();
+            config.setLdapHost( DEFAULT_HOST );
+            config.setLdapPort( port );
+            config.setName( DEFAULT_ADMIN );
+            config.setCredentials( DEFAULT_PASSWORD );
+            PoolableLdapConnectionFactory factory = new PoolableLdapConnectionFactory( config );
+            LdapConnectionPool pool = new LdapConnectionPool( factory );
+            pool.setTestOnBorrow( true );
+            pools.put( port, pool );
+        }
+
+        return pools.get( port );
+    }
+
+}

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Sun Feb  6 11:00:10 2011
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -42,7 +41,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.StringValue;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.filter.EqualityNode;
 import org.apache.directory.shared.ldap.model.filter.SearchScope;
 import org.apache.directory.shared.ldap.model.message.BindResponse;
@@ -69,24 +67,20 @@ public class LdapConnectionTest extends 
 
     private static final String ADMIN_DN = "uid=admin,ou=system";
 
-    private static LdapConnection connection;
+    private LdapNetworkConnection connection;
 
 
     @Before
-    public void bindConnection() throws Exception
+    public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        connection.bind( ADMIN_DN, "secret" );
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
     }
 
 
     @After
-    public void unbindConnection() throws Exception
+    public void shutdown() throws Exception
     {
-        if ( connection != null )
-        {
-            connection.close();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
@@ -107,24 +101,12 @@ public class LdapConnectionTest extends 
 
             //connection.unBind();
         }
-        catch ( LdapException le )
-        {
-            fail();
-        }
-        catch ( IOException ioe )
-        {
-            fail();
-        }
         finally
         {
-            try
+            if ( connection != null )
             {
                 connection.close();
             }
-            catch ( IOException ioe )
-            {
-                fail();
-            }
         }
     }
 
@@ -233,10 +215,10 @@ public class LdapConnectionTest extends 
     @Test
     public void testAnonBind() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        LdapNetworkConnection conn = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
         
-        BindResponse resp = connection.bind();
+        BindResponse resp = conn.bind();
         assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );
-        connection.close();
+        conn.close();
     }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java Sun Feb  6 11:00:10 2011
@@ -22,7 +22,6 @@ package org.apache.directory.shared.clie
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.util.List;
@@ -115,14 +114,12 @@ public class LdapSSLConnectionTest exten
 
             assertNotNull( bindResponse );
         }
-        catch ( Exception le )
-        {
-            le.printStackTrace();
-            fail();
-        }
         finally
         {
-            connection.close();
+            if ( connection != null )
+            {
+                connection.close();
+            }
         }
     }
 
@@ -163,13 +160,12 @@ public class LdapSSLConnectionTest exten
 
             connection.unBind();
         }
-        catch ( Exception le )
-        {
-            fail();
-        }
         finally
         {
-            connection.close();
+            if ( connection != null )
+            {
+                connection.close();
+            }
         }
     }
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/NetworkSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/NetworkSchemaLoaderTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/NetworkSchemaLoaderTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/NetworkSchemaLoaderTest.java Sun Feb  6 11:00:10 2011
@@ -23,7 +23,6 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.NetworkSchemaLoader;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -33,6 +32,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
 import org.apache.directory.shared.util.exception.Exceptions;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -46,12 +47,26 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class NetworkSchemaLoaderTest extends AbstractLdapTestUnit
 {
+    private LdapNetworkConnection connection;
+
+
+    @Before
+    public void setup() throws Exception
+    {
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
+    }
+
+
+    @After
+    public void shutdown() throws Exception
+    {
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
+    }
+
+
     @Test
     public void testNetworkSchemaLoader() throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        connection.bind( "uid=admin,ou=system", "secret" );
-
         NetworkSchemaLoader loader = new NetworkSchemaLoader( connection );
 
         SchemaManager sm = new DefaultSchemaManager( loader );
@@ -64,8 +79,6 @@ public class NetworkSchemaLoaderTest ext
         }
 
         assertTrue( sm.getRegistries().getAttributeTypeRegistry().contains( "cn" ) );
-
-        connection.close();
     }
 
 }

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=1067639&r1=1067638&r2=1067639&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 Sun Feb  6 11:00:10 2011
@@ -23,16 +23,14 @@ package org.apache.directory.shared.clie
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
@@ -60,37 +58,20 @@ import org.junit.runner.RunWith;
 public class ClientAbandonRequestTest extends AbstractLdapTestUnit
 {
 
-    private LdapAsyncConnection connection;
-
-    private CoreSession session;
+    private LdapNetworkConnection connection;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java Sun Feb  6 11:00:10 2011
@@ -24,13 +24,10 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.AddFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -39,6 +36,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.csn.CsnFactory;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
@@ -66,38 +64,22 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientAddRequestTest extends AbstractLdapTestUnit
 {
-    private LdapAsyncConnection connection;
+    private LdapNetworkConnection connection;
     private CoreSession session;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
-
-        session = ldapServer.getDirectoryService().getSession();
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
+        session = ldapServer.getDirectoryService().getAdminSession();
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
@@ -135,19 +117,12 @@ public class ClientAddRequestTest extend
 
         AddFuture addFuture = connection.addAsync( addRequest );
 
-        try
-        {
-            AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );
-
-            assertNotNull( addResponse );
-            assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
-            assertTrue( connection.isAuthenticated() );
-            assertTrue( session.exists( dn ) );
-        }
-        catch ( TimeoutException toe )
-        {
-            fail();
-        }
+        AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );
+
+        assertNotNull( addResponse );
+        assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
+        assertTrue( connection.isAuthenticated() );
+        assertTrue( session.exists( dn ) );
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java Sun Feb  6 11:00:10 2011
@@ -23,12 +23,9 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.CompareFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -36,6 +33,7 @@ import org.apache.directory.server.annot
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.message.CompareRequest;
 import org.apache.directory.shared.ldap.model.message.CompareRequestImpl;
@@ -58,39 +56,22 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientCompareRequestTest extends AbstractLdapTestUnit
 {
-    private LdapAsyncConnection connection;
-
+    private LdapNetworkConnection connection;
     private CoreSession session;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
-
-        session = ldapServer.getDirectoryService().getSession();
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
+        session = ldapServer.getDirectoryService().getAdminSession();
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
@@ -125,16 +106,9 @@ public class ClientCompareRequestTest ex
 
         CompareFuture compareFuture = connection.compareAsync( compareRequest );
 
-        try
-        {
-            CompareResponse compareResponse = compareFuture.get( 1000, TimeUnit.MILLISECONDS );
-
-            assertNotNull( compareResponse );
-            assertEquals( ResultCodeEnum.COMPARE_TRUE, compareResponse.getLdapResult().getResultCode() );
-        }
-        catch ( TimeoutException toe )
-        {
-            fail();
-        }
+        CompareResponse compareResponse = compareFuture.get( 1000, TimeUnit.MILLISECONDS );
+
+        assertNotNull( compareResponse );
+        assertEquals( ResultCodeEnum.COMPARE_TRUE, compareResponse.getLdapResult().getResultCode() );
     }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java Sun Feb  6 11:00:10 2011
@@ -30,7 +30,6 @@ import static org.junit.Assert.fail;
 import java.lang.reflect.Method;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
@@ -41,6 +40,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.message.DeleteRequest;
 import org.apache.directory.shared.ldap.model.message.DeleteRequestImpl;
@@ -85,39 +85,21 @@ import org.junit.runner.RunWith;
 public class ClientDeleteRequestTest extends AbstractLdapTestUnit
 {
     private LdapNetworkConnection connection;
-
     private CoreSession session;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
-
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
         session = ldapServer.getDirectoryService().getAdminSession();
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
@@ -239,18 +221,11 @@ public class ClientDeleteRequestTest ext
 
         DeleteFuture deleteFuture = connection.deleteAsync( deleteRequest );
 
-        try
-        {
-            DeleteResponse deleteResponse = deleteFuture.get( 1000, TimeUnit.MILLISECONDS );
+        DeleteResponse deleteResponse = deleteFuture.get( 1000, TimeUnit.MILLISECONDS );
 
-            assertNotNull( deleteResponse );
-            assertEquals( ResultCodeEnum.SUCCESS, deleteResponse.getLdapResult().getResultCode() );
-            assertTrue( connection.isAuthenticated() );
-            assertFalse( session.exists( dn ) );
-        }
-        catch ( TimeoutException toe )
-        {
-            fail();
-        }
+        assertNotNull( deleteResponse );
+        assertEquals( ResultCodeEnum.SUCCESS, deleteResponse.getLdapResult().getResultCode() );
+        assertTrue( connection.isAuthenticated() );
+        assertFalse( session.exists( dn ) );
     }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientExtendedRequestTest.java Sun Feb  6 11:00:10 2011
@@ -23,27 +23,23 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 import javax.naming.ldap.StartTlsRequest;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.ExtendedFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
 import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -61,69 +57,61 @@ import org.junit.runner.RunWith;
     { StartTlsHandler.class })
 public class ClientExtendedRequestTest extends AbstractLdapTestUnit
 {
-    private LdapAsyncConnection connection;
-    private CoreSession session;
+    private LdapNetworkConnection connection;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
-
-        session = ldapServer.getDirectoryService().getSession();
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
     @Test
     public void testExtended() throws Exception
     {
-        ExtendedResponse response = connection.extended( StartTlsRequest.OID );
-        assertNotNull( response );
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        try
+        {
+            ExtendedResponse response = connection.extended( StartTlsRequest.OID );
+            assertNotNull( response );
+            assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        }
+        finally
+        {
+            // close connection to stop TLS
+            connection.close();
+        }
     }
 
 
     @Test
     public void testExtendedAsync() throws Exception
     {
-        ExtendedRequest extendedRequest = new ExtendedRequestImpl();
-        extendedRequest.setRequestName( StartTlsRequest.OID );
-
-        ExtendedFuture extendedFuture = connection.extendedAsync( extendedRequest );
-
         try
         {
-            ExtendedResponse extendedResponse = (ExtendedResponse) extendedFuture.get( 1000, TimeUnit.MILLISECONDS );
+            ExtendedRequest extendedRequest = new ExtendedRequestImpl();
+            extendedRequest.setRequestName( StartTlsRequest.OID );
+
+            ExtendedFuture extendedFuture = connection.extendedAsync( extendedRequest );
+
+            ExtendedResponse extendedResponse = ( ExtendedResponse ) extendedFuture.get( 1000, TimeUnit.MILLISECONDS );
 
             assertNotNull( extendedResponse );
             assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
             assertTrue( connection.isAuthenticated() );
         }
-        catch ( TimeoutException toe )
+        finally
         {
-            fail();
+            // close connection to stop TLS
+            connection.close();
         }
+
     }
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java Sun Feb  6 11:00:10 2011
@@ -24,12 +24,9 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.ModifyDnFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -38,6 +35,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.message.ModifyDnRequest;
 import org.apache.directory.shared.ldap.model.message.ModifyDnRequestImpl;
@@ -62,51 +60,32 @@ import org.junit.runner.RunWith;
     { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientModifyDnRequestTest extends AbstractLdapTestUnit
 {
-    private LdapAsyncConnection connection;
-
+    private static final String DN = "cn=modDn,ou=system";
+    private LdapNetworkConnection connection;
     private CoreSession session;
 
-    private String dn = "cn=modDn,ou=system";
-
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
-
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
         session = ldapServer.getDirectoryService().getAdminSession();
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
     @Test
     public void testRename() throws Exception
     {
-        ModifyDnResponse resp = connection.rename( dn, "cn=modifyDnWithString" );
+        ModifyDnResponse resp = connection.rename( DN, "cn=modifyDnWithString" );
         assertNotNull( resp );
-        assertFalse( session.exists( new Dn( dn ) ) );
+        assertFalse( session.exists( new Dn( DN ) ) );
         assertTrue( session.exists( new Dn( "cn=modifyDnWithString,ou=system" ) ) );
     }
 
@@ -114,10 +93,10 @@ public class ClientModifyDnRequestTest e
     @Test
     public void testRenameWithoutDeleteOldRdn() throws Exception
     {
-        ModifyDnResponse resp = connection.rename( dn, "cn=modifyDnWithString", false );
+        ModifyDnResponse resp = connection.rename( DN, "cn=modifyDnWithString", false );
         assertNotNull( resp );
 
-        Dn oldDn = new Dn( dn );
+        Dn oldDn = new Dn( DN );
         assertFalse( session.exists( oldDn ) );
 
         Entry entry = session.lookup( new Dn( "cn=modifyDnWithString,ou=system" ) );
@@ -131,10 +110,10 @@ public class ClientModifyDnRequestTest e
     @Test
     public void testMove() throws Exception
     {
-        ModifyDnResponse resp = connection.move( dn, "ou=users,ou=system" );
+        ModifyDnResponse resp = connection.move( DN, "ou=users,ou=system" );
         assertNotNull( resp );
 
-        Dn oldDn = new Dn( dn );
+        Dn oldDn = new Dn( DN );
         assertFalse( session.exists( oldDn ) );
 
         assertTrue( session.exists( new Dn( "cn=modDn,ou=users,ou=system" ) ) );
@@ -144,7 +123,7 @@ public class ClientModifyDnRequestTest e
     @Test
     public void testModifyDnAsync() throws Exception
     {
-        Dn oldDn = new Dn( dn );
+        Dn oldDn = new Dn( DN );
         Dn newDn = new Dn( "cn=modifyDnWithString,ou=system" );
 
         ModifyDnRequest modDnReq = new ModifyDnRequestImpl();
@@ -154,20 +133,13 @@ public class ClientModifyDnRequestTest e
 
         ModifyDnFuture modifyDnFuture = connection.modifyDnAsync( modDnReq );
 
-        try
-        {
-            ModifyDnResponse response = modifyDnFuture.get( 1000, TimeUnit.MILLISECONDS );
-
-            assertNotNull( response );
-
-            assertTrue( connection.isAuthenticated() );
-            assertFalse( session.exists( oldDn ) );
-            assertTrue( session.exists( newDn ) );
-        }
-        catch ( TimeoutException toe )
-        {
-            fail();
-        }
+        ModifyDnResponse response = modifyDnFuture.get( 1000, TimeUnit.MILLISECONDS );
+
+        assertNotNull( response );
+
+        assertTrue( connection.isAuthenticated() );
+        assertFalse( session.exists( oldDn ) );
+        assertTrue( session.exists( newDn ) );
 
         assertTrue( session.exists( new Dn( "cn=modifyDnWithString,ou=system" ) ) );
     }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java Sun Feb  6 11:00:10 2011
@@ -24,13 +24,10 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.ModifyFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -39,6 +36,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.csn.CsnFactory;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
@@ -77,40 +75,22 @@ import org.junit.runner.RunWith;
 })
 public class ClientModifyRequestTest extends AbstractLdapTestUnit
 {
-    private LdapAsyncConnection connection;
-
+    private LdapNetworkConnection connection;
     private CoreSession session;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
-
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
         session = ldapServer.getDirectoryService().getAdminSession();
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
@@ -202,25 +182,18 @@ public class ClientModifyRequestTest ext
 
         ModifyFuture modifyFuture = connection.modifyAsync( modifyRequest );
 
-        try
-        {
-            ModifyResponse response = modifyFuture.get( 1000, TimeUnit.MILLISECONDS );
+        ModifyResponse response = modifyFuture.get( 1000, TimeUnit.MILLISECONDS );
 
-            assertNotNull( response );
+        assertNotNull( response );
 
-            Entry entry = session.lookup( dn );
+        Entry entry = session.lookup( dn );
 
-            String actual = entry.get( SchemaConstants.SN_AT ).getString();
+        String actual = entry.get( SchemaConstants.SN_AT ).getString();
 
-            assertEquals( expected, actual );
+        assertEquals( expected, actual );
 
-            assertTrue( connection.isAuthenticated() );
-            assertTrue( session.exists( dn ) );
-        }
-        catch ( TimeoutException toe )
-        {
-            fail();
-        }
+        assertTrue( connection.isAuthenticated() );
+        assertTrue( session.exists( dn ) );
     }
 
 
@@ -246,17 +219,17 @@ public class ClientModifyRequestTest ext
         // admin can modify the entryCsn
         modResp = connection.modify( modifyRequest );
         assertEquals( ResultCodeEnum.SUCCESS, modResp.getLdapResult().getResultCode() );
-
-        connection.close();
         
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        LdapNetworkConnection nonAdminConnection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
 
         Dn bindDn = new Dn( "uid=billyd,ou=users,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
+        nonAdminConnection.bind( bindDn.getName(), "secret" );
         
         // non-admin user cannot modify entryCSN
-        modResp = connection.modify( modifyRequest );
+        modResp = nonAdminConnection.modify( modifyRequest );
         assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, modResp.getLdapResult().getResultCode() );
+        
+        nonAdminConnection.close();
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java Sun Feb  6 11:00:10 2011
@@ -84,18 +84,11 @@ public class SimpleBindRequestTest exten
      * Close the LdapConnection
      */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
+        if ( connection != null )
         {
-            fail();
+            connection.close();
         }
     }
 
@@ -133,18 +126,11 @@ public class SimpleBindRequestTest exten
 
             BindFuture bindFuture = connection.bindAsync( bindRequest );
 
-            try
-            {
-                BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
+            BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
 
-                assertNotNull( bindResponse );
-                assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
-                assertTrue( connection.isAuthenticated() );
-            }
-            catch ( TimeoutException toe )
-            {
-                fail();
-            }
+            assertNotNull( bindResponse );
+            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
+            assertTrue( connection.isAuthenticated() );
         }
     }
 
@@ -366,18 +352,11 @@ public class SimpleBindRequestTest exten
             assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
 
             // Now get back the BindResponse
-            try
-            {
-                BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
+            BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
 
-                assertNotNull( bindResponse );
-                assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
-                assertTrue( connection.isAuthenticated() );
-            }
-            catch ( TimeoutException toe )
-            {
-                fail();
-            }
+            assertNotNull( bindResponse );
+            assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
+            assertTrue( connection.isAuthenticated() );
         }
         finally
         {

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java Sun Feb  6 11:00:10 2011
@@ -23,11 +23,9 @@ package org.apache.directory.shared.clie
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 
 import java.util.concurrent.TimeUnit;
 
-import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -35,6 +33,7 @@ import org.apache.directory.server.annot
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.cursor.SearchCursor;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -84,35 +83,20 @@ import org.junit.runner.RunWith;
     })
 public class ClientSearchRequestTest extends AbstractLdapTestUnit
 {
-    private LdapAsyncConnection connection;
+    private LdapNetworkConnection connection;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
     @After
-    public void shutdown()
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 
@@ -246,6 +230,5 @@ public class ClientSearchRequestTest ext
     public void testSearchUTF8() throws Exception
     {
         connection.search( "ou=system", "(sn=Emmanuel L\u00e9charny)", SearchScope.ONELEVEL, "*", "+" );
-        fail();
     }
 }

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java?rev=1067639&r1=1067638&r2=1067639&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchRequestReturningAttributesTest.java Sun Feb  6 11:00:10 2011
@@ -25,15 +25,14 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
-import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -43,7 +42,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.junit.AfterClass;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -65,35 +64,20 @@ import org.junit.runner.RunWith;
         "objectClass: extensibleObject", "aliasedObjectName: cn=user1,ou=users,ou=system", "cn: user1-alias" })
 public class SearchRequestReturningAttributesTest extends AbstractLdapTestUnit
 {
-    private static LdapConnection connection;
+    private LdapNetworkConnection connection;
 
 
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        Dn bindDn = new Dn( "uid=admin,ou=system" );
-        connection.bind( bindDn.getName(), "secret" );
+        connection = LdapApiIntegrationUtils.getPooledAdminConnection( ldapServer );
     }
 
 
-    /**
-     * Close the LdapConnection
-     */
-    @AfterClass
-    public static void shutdown()
+    @After
+    public void shutdown() throws Exception
     {
-        try
-        {
-            if ( connection != null )
-            {
-                connection.close();
-            }
-        }
-        catch ( Exception ioe )
-        {
-            fail();
-        }
+        LdapApiIntegrationUtils.releasePooledAdminConnection( connection, ldapServer );
     }
 
 



Mime
View raw message