directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r916980 - 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 Sat, 27 Feb 2010 16:07:22 GMT
Author: elecharny
Date: Sat Feb 27 16:07:22 2010
New Revision: 916980

URL: http://svn.apache.org/viewvc?rev=916980&view=rev
Log:
o Added a test looping over 300 bind/unbind operations 
o Reseting the messageId to 0 when the connection is closed

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=916980&r1=916979&r2=916980&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
Sat Feb 27 16:07:22 2010
@@ -668,6 +668,9 @@
 
         // Store the container into the session 
         ldapSession.setAttribute( "LDAP-Container", ldapMessageContainer );
+        
+        // Initialize the MessageId 
+        messageId.set( 0 );
 
         // And return
         return true;
@@ -696,6 +699,9 @@
             connector.dispose();
             connector = null;
         }
+        
+        // Reset the messageId
+        messageId.set( 0 );
 
         return true;
     }
@@ -1584,6 +1590,9 @@
             LOG.debug( "closeFuture done" );
             connected.set( false );
         }
+        
+        // Last, not least, reset the MessageId value
+        messageId.set(0);
 
         // And get out
         LOG.debug( "Unbind successful" );

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=916980&r1=916979&r2=916980&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
Sat Feb 27 16:07:22 2010
@@ -44,7 +44,6 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -164,9 +163,12 @@
     @Test
     public void testSimpleBindAnonymous() throws Exception
     {
-        for ( int i = 0; i < 1; i++)
+        for ( int i = 0; i < 100; i++)
         {
-            System.out.print( "." );
+            //System.out.println( "------------------Create connection" + i + "-------------"
);
+            LdapConnection connection = new LdapConnection( "localhost", ldapServer.getPort()
);
+            //System.out.println( "------------------Bind" + i + "-------------" );
+            
             // Try with no parameters
             BindResponse bindResponse = connection.bind();
             
@@ -176,6 +178,7 @@
             assertEquals( 1, bindResponse.getMessageId() );
             assertTrue( connection.isAuthenticated() );
     
+            //System.out.println( "----------------Unbind" + i + "-------------" );
             connection.unBind();
             assertFalse( connection.isConnected() );
     
@@ -207,6 +210,12 @@
             assertFalse( connection.isConnected() );
 
             connection = new LdapConnection( "localhost", ldapServer.getPort() );
+            
+            
+            //System.out.println( "----------------Unbind done" + i + "-------------" );
+            assertFalse( connection.isConnected() );
+            //System.out.println( "----------------Unconnected" + i + "-------------" );
+            
         }
     }
 
@@ -289,19 +298,31 @@
      * Test a valid bind followed by another valid bind
      */
     @Test
-    @Ignore
     public void testDoubleSimpleBindValid() throws Exception
     {
-        BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
-        LdapResult ldapResult = response.getLdapResult();
-        assertEquals( ResultCodeEnum.SUCCESS, ldapResult.getResultCode() );
-        assertEquals( 1, response.getMessageId() );
+        BindResponse response1 = connection.bind( "uid=admin,ou=system", "secret" );
+        LdapResult ldapResult1 = response1.getLdapResult();
+        assertEquals( ResultCodeEnum.SUCCESS, ldapResult1.getResultCode() );
+        assertEquals( 1, response1.getMessageId() );
         assertTrue( connection.isAuthenticated() );
         
+        // The messageId must have been incremented
         BindResponse response2 = connection.bind( "uid=admin,ou=system", "secret" );
-        LdapResult ldapResult2 = response.getLdapResult();
+        LdapResult ldapResult2 = response2.getLdapResult();
         assertEquals( ResultCodeEnum.SUCCESS, ldapResult2.getResultCode() );
-        assertEquals( 1, response2.getMessageId() );
+        assertEquals( 2, response2.getMessageId() );
+        assertTrue( connection.isAuthenticated() );
+        
+        // Now, unbind
+        connection.unBind();
+        assertFalse( connection.isAuthenticated() );
+        assertFalse( connection.isConnected() );
+        
+        // And Bind again. The messageId should be 1 
+        BindResponse response3 = connection.bind( "uid=admin,ou=system", "secret" );
+        LdapResult ldapResult3 = response3.getLdapResult();
+        assertEquals( ResultCodeEnum.SUCCESS, ldapResult3.getResultCode() );
+        assertEquals( 1, response3.getMessageId() );
         assertTrue( connection.isAuthenticated() );
     }
 



Mime
View raw message