directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r906639 - in /directory/clients/ldap/trunk: ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
Date Thu, 04 Feb 2010 20:20:59 GMT
Author: elecharny
Date: Thu Feb  4 20:20:59 2010
New Revision: 906639

URL: http://svn.apache.org/viewvc?rev=906639&view=rev
Log:
The BindResponse should be added to the respQueue even if we are in asynchronous mode

Modified:
    directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
    directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java

Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=906639&r1=906638&r2=906639&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
Thu Feb  4 20:20:59 2010
@@ -1586,11 +1586,9 @@
                 {
                     bindListener.bindCompleted( this, bindResponse );
                 }
-                else
-                {
-                    // Store the response into the responseQueue
-                    addToRespQueueAndRemoveQueueRef( messageId, bindResponse );
-                }
+
+                // Store the response into the responseQueue
+                addToRespQueueAndRemoveQueueRef( messageId, bindResponse );
 
                 break;
 

Modified: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java?rev=906639&r1=906638&r2=906639&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
Thu Feb  4 20:20:59 2010
@@ -26,9 +26,12 @@
 import static org.junit.Assert.fail;
 
 import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.exception.LdapException;
+import org.apache.directory.ldap.client.api.future.BindFuture;
 import org.apache.directory.ldap.client.api.listener.BindListener;
 import org.apache.directory.ldap.client.api.message.BindRequest;
 import org.apache.directory.ldap.client.api.message.BindResponse;
@@ -123,20 +126,29 @@
             BindRequest bindRequest = new BindRequest();
             bindRequest.setName( "uid=admin,ou=system" );
             bindRequest.setCredentials( "secret" );
-            final int loop = i;
-
-            lock.acquire();
             
-            connection.bind( bindRequest, new BindListener()
+            BindFuture bindFuture = connection.bind( bindRequest, new BindListener()
             {
                 public void bindCompleted( LdapConnection connection, BindResponse bindResponse
) throws LdapException
                 {
                     assertNotNull( bindResponse );
                     assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
                     assertEquals( 1, bindResponse.getMessageId() );
-                    lock.release();
                 }
             } );
+            
+            try
+            {
+                BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
+                
+                assertNotNull( bindResponse );
+                assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
+                assertTrue( connection.isAuthenticated() );
+            }
+            catch ( TimeoutException toe )
+            {
+                fail();
+            }
         }
     }
     
@@ -181,6 +193,7 @@
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode()
);
         assertEquals( 1, bindResponse.getMessageId() );
         assertTrue( connection.isAuthenticated() );
+        assertTrue( connection.isConnected() );
     }
 
     
@@ -195,6 +208,7 @@
         assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
         assertEquals( 1, response.getMessageId() );
         assertFalse( connection.isAuthenticated() );
+        assertTrue( connection.isConnected() );
     }
 
     
@@ -209,6 +223,7 @@
         assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, ldapResult.getResultCode() );
         assertEquals( 1, response.getMessageId() );
         assertFalse( connection.isAuthenticated() );
+        assertTrue( connection.isConnected() );
     }
 
     
@@ -237,5 +252,6 @@
         assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
         assertEquals( 1, response.getMessageId() );
         assertFalse( connection.isAuthenticated() );
+        assertTrue( connection.isConnected() );
     }
 }



Mime
View raw message