directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r987611 [8/13] - in /directory/apacheds/trunk: ./ all/ core-annotations/ core-api/ core-api/src/main/java/org/apache/directory/server/core/ core-api/src/main/java/org/apache/directory/server/core/event/ core-api/src/main/java/org/apache/dir...
Date Fri, 20 Aug 2010 19:32:02 GMT
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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -28,9 +28,6 @@ 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.ldap.client.api.message.SearchRequest;
-import org.apache.directory.ldap.client.api.message.SearchResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultDone;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.CoreSession;
@@ -42,6 +39,10 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.message.SearchResultDone;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.After;
 import org.junit.Before;
@@ -55,12 +56,8 @@ import org.junit.runner.RunWith;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer (
-    transports =
-    {
-        @CreateTransport( protocol = "LDAP" ),
-        @CreateTransport( protocol = "LDAPS" )
-    })
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientAbandonRequestTest extends AbstractLdapTestUnit
 {
 
@@ -68,15 +65,13 @@ public class ClientAbandonRequestTest ex
 
     private CoreSession session;
 
+
     @Before
     public void setup() throws Exception
     {
         connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
         DN bindDn = new DN( "uid=admin,ou=system" );
-        connection.setTimeOut( 0L );
         connection.bind( bindDn.getName(), "secret" );
-
-//        session = ldapServer.getDirectoryService().getSession();
     }
 
 
@@ -93,7 +88,7 @@ public class ClientAbandonRequestTest ex
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
@@ -119,16 +114,16 @@ public class ClientAbandonRequestTest ex
             connection.add( entry );
         }
 
-        SearchRequest sr = new SearchRequest();
+        SearchRequest sr = new SearchRequestImpl();
         sr.setFilter( "(cn=*)" );
-        sr.setBaseDn( "ou=system" );
+        sr.setBase( new DN( "ou=system" ) );
         sr.setScope( SearchScope.ONELEVEL );
         sr.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
 
         // Launch the search now
         SearchFuture searchFuture = connection.searchAsync( sr );
 
-        SearchResponse searchResponse = null;
+        Response searchResponse = null;
         int count = 0;
 
         do
@@ -142,13 +137,13 @@ public class ClientAbandonRequestTest ex
                 break;
             }
         }
-        while ( !(searchResponse instanceof SearchResultDone ) );
+        while ( !( searchResponse instanceof SearchResultDone ) );
 
         assertTrue( numEntries > count );
         assertTrue( searchFuture.isCancelled() );
 
         // Now do a simple synchronous search
-        Cursor<SearchResponse> results = connection.search( sr );
+        Cursor<Response> results = connection.search( sr );
 
         int n = -1;
 

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -33,10 +33,6 @@ import java.util.concurrent.TimeoutExcep
 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.ldap.client.api.message.AddRequest;
-import org.apache.directory.ldap.client.api.message.AddResponse;
-import org.apache.directory.ldap.client.api.message.BindResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultEntry;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.CoreSession;
@@ -47,7 +43,12 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.message.AddRequest;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.message.AddResponse;
+import org.apache.directory.shared.ldap.message.BindResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.junit.After;
@@ -55,35 +56,32 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+
 /**
  * Tests the add operation
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" ), 
-        @CreateTransport( protocol = "LDAPS" ) 
-    })
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientAddRequestTest extends AbstractLdapTestUnit
 {
     private LdapAsyncConnection connection;
     private CoreSession session;
-    
+
+
     @Before
     public void setup() throws Exception
     {
         connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        connection.setTimeOut( 0 );
         DN bindDn = new DN( "uid=admin,ou=system" );
         connection.bind( bindDn.getName(), "secret" );
-        
+
         session = ldapServer.getDirectoryService().getSession();
     }
 
-    
+
     /**
      * Close the LdapConnection
      */
@@ -97,49 +95,51 @@ public class ClientAddRequestTest extend
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
     }
-    
-    
+
+
     @Test
     public void testAdd() throws Exception
     {
         DN dn = new DN( "cn=testadd,ou=system" );
-        Entry entry = new DefaultEntry( dn ); 
+        Entry entry = new DefaultEntry( dn );
         entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
         entry.add( SchemaConstants.CN_AT, "testadd_cn" );
         entry.add( SchemaConstants.SN_AT, "testadd_sn" );
-        
+
         assertFalse( session.exists( dn ) );
-        
+
         AddResponse response = connection.add( entry );
         assertNotNull( response );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
-        
+
         assertTrue( session.exists( dn ) );
     }
 
-    
+
     @Test
     public void testAddAsync() throws Exception
     {
         DN dn = new DN( "cn=testAsyncAdd,ou=system" );
-        Entry entry = new DefaultEntry( dn ); 
+        Entry entry = new DefaultEntry( dn );
         entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
         entry.add( SchemaConstants.CN_AT, "testAsyncAdd_cn" );
         entry.add( SchemaConstants.SN_AT, "testAsyncAdd_sn" );
-        
+
         assertFalse( session.exists( dn ) );
+        AddRequest addRequest = new AddRequestImpl();
+        addRequest.setEntry( entry );
 
-        AddFuture addFuture = connection.addAsync( new AddRequest( entry ));
+        AddFuture addFuture = connection.addAsync( addRequest );
 
         try
         {
             AddResponse addResponse = addFuture.get( 1000, TimeUnit.MILLISECONDS );
-            
+
             assertNotNull( addResponse );
             assertEquals( ResultCodeEnum.SUCCESS, addResponse.getLdapResult().getResultCode() );
             assertTrue( connection.isAuthenticated() );
@@ -150,18 +150,11 @@ public class ClientAddRequestTest extend
             fail();
         }
     }
-    
-    
+
+
     @ApplyLdifs(
-        {
-            "dn: cn=kayyagari,ou=system",
-            "objectClass: person",
-            "objectClass: top",
-            "cn: kayyagari",
-            "description: dbugger",
-            "sn: dbugger",
-            "userPassword: secret"
-        })
+        { "dn: cn=kayyagari,ou=system", "objectClass: person", "objectClass: top", "cn: kayyagari",
+            "description: dbugger", "sn: dbugger", "userPassword: secret" })
     @Test
     /**
      * tests adding entryUUID, entryCSN, creatorsName and createTimestamp attributes
@@ -174,7 +167,7 @@ public class ClientAddRequestTest extend
         String csn = new CsnFactory( 0 ).newInstance().toString();
         String creator = dn.getName();
         String createdTime = DateUtils.getGeneralizedTime();
-        
+
         Entry entry = new DefaultEntry( dn );
         entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
         entry.add( SchemaConstants.CN_AT, "x" );
@@ -183,26 +176,26 @@ public class ClientAddRequestTest extend
         entry.add( SchemaConstants.ENTRY_CSN_AT, csn );
         entry.add( SchemaConstants.CREATORS_NAME_AT, creator );
         entry.add( SchemaConstants.CREATE_TIMESTAMP_AT, createdTime );
-        
+
         connection.add( entry );
-        
+
         Entry loadedEntry = ( ( SearchResultEntry ) connection.lookup( dn.getName(), "+" ) ).getEntry();
-        
+
         // successful for admin
         assertEquals( uuid, loadedEntry.get( SchemaConstants.ENTRY_UUID_AT ).getString() );
         assertEquals( csn, loadedEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
         assertEquals( creator, loadedEntry.get( SchemaConstants.CREATORS_NAME_AT ).getString() );
         assertEquals( createdTime, loadedEntry.get( SchemaConstants.CREATE_TIMESTAMP_AT ).getString() );
-        
+
         connection.delete( dn );
         connection.unBind();
-        
+
         // connect as non admin user and try to add entry with uuid and csn
         BindResponse bindResp = connection.bind( "cn=kayyagari,ou=system", "secret" );
         assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
-        
+
         AddResponse resp = connection.add( entry );
         assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, resp.getLdapResult().getResultCode() );
     }
-    
+
 }

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -31,14 +31,15 @@ import java.util.concurrent.TimeoutExcep
 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.ldap.client.api.message.CompareRequest;
-import org.apache.directory.ldap.client.api.message.CompareResponse;
 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.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.message.CompareRequest;
+import org.apache.directory.shared.ldap.message.CompareRequestImpl;
+import org.apache.directory.shared.ldap.message.CompareResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.After;
@@ -46,35 +47,33 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+
 /**
  * Tests the compare operation
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" ), 
-        @CreateTransport( protocol = "LDAPS" ) 
-    })
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientCompareRequestTest extends AbstractLdapTestUnit
 {
     private LdapAsyncConnection 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();
     }
 
-    
+
     /**
      * Close the LdapConnection
      */
@@ -88,48 +87,48 @@ public class ClientCompareRequestTest ex
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
     }
-    
-    
+
+
     @Test
     public void testCompare() throws Exception
     {
         DN dn = new DN( "uid=admin,ou=system" );
-        
+
         CompareResponse response = connection.compare( dn, SchemaConstants.UID_AT, "admin" );
         assertNotNull( response );
         assertTrue( response.isTrue() );
-        
+
         response = connection.compare( dn.getName(), SchemaConstants.USER_PASSWORD_AT, "secret".getBytes() );
         assertNotNull( response );
         assertTrue( response.isTrue() );
     }
 
-    
+
     @Test
     public void testCompareAsync() throws Exception
     {
         DN dn = new DN( "uid=admin,ou=system" );
 
-        CompareRequest compareRequest = new CompareRequest();
-        compareRequest.setEntryDn( dn );
-        compareRequest.setAttrName( SchemaConstants.UID_AT );
-        compareRequest.setValue( "admin" );
-        
-        connection.compare( compareRequest);
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( dn );
+        compareRequest.setAttributeId( SchemaConstants.UID_AT );
+        compareRequest.setAssertionValue( "admin" );
+
+        connection.compare( compareRequest );
 
         assertTrue( session.exists( dn ) );
 
         CompareFuture compareFuture = connection.compareAsync( compareRequest );
-        
+
         try
         {
             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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.client.api.operations;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -36,8 +37,6 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.DeleteFuture;
 import org.apache.directory.ldap.client.api.listener.DeleteListener;
-import org.apache.directory.ldap.client.api.message.DeleteRequest;
-import org.apache.directory.ldap.client.api.message.DeleteResponse;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.CoreSession;
@@ -45,6 +44,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.DeleteRequest;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.message.DeleteResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.After;
@@ -53,59 +55,42 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+
 /**
  * Test case for client delete operation.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" ), 
-        @CreateTransport( protocol = "LDAPS" ) 
-    })
-@ApplyLdifs( {
-    "dn: cn=parent,ou=system",
-    "objectClass: person",
-    "cn: parent_cn",
-    "sn: parent_sn", 
-    
-    "",
-    
-    "dn: cn=child1,cn=parent,ou=system",
-    "objectClass: person",
-    "cn: child1_cn",
-    "sn: child1_sn", 
-    
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
+@ApplyLdifs(
+    { "dn: cn=parent,ou=system", "objectClass: person", "cn: parent_cn", "sn: parent_sn",
+
     "",
-    
-    "dn: cn=child2,cn=parent,ou=system",
-    "objectClass: person",
-    "cn: child2_cn",
-    "sn: child2_sn", 
-    
+
+    "dn: cn=child1,cn=parent,ou=system", "objectClass: person", "cn: child1_cn", "sn: child1_sn",
+
     "",
-    
-    "dn: cn=grand_child11,cn=child1,cn=parent,ou=system",
-    "objectClass: person",
-    "cn: grand_child11_cn",
-    "sn: grand_child11_sn", 
-    
+
+    "dn: cn=child2,cn=parent,ou=system", "objectClass: person", "cn: child2_cn", "sn: child2_sn",
+
     "",
-    
-    "dn: cn=grand_child12,cn=child1,cn=parent,ou=system",
-    "objectClass: person",
-    "cn: grand_child12_cn",
-    "sn: grand_child12_sn"
-})
+
+    "dn: cn=grand_child11,cn=child1,cn=parent,ou=system", "objectClass: person", "cn: grand_child11_cn",
+        "sn: grand_child11_sn",
+
+        "",
+
+        "dn: cn=grand_child12,cn=child1,cn=parent,ou=system", "objectClass: person", "cn: grand_child12_cn",
+        "sn: grand_child12_sn" })
 public class ClientDeleteRequestTest extends AbstractLdapTestUnit
 {
     private LdapNetworkConnection connection;
-    
+
     private CoreSession session;
-    
-    
+
+
     @Before
     public void setup() throws Exception
     {
@@ -113,11 +98,11 @@ public class ClientDeleteRequestTest ext
 
         DN bindDn = new DN( "uid=admin,ou=system" );
         connection.bind( bindDn.getName(), "secret" );
-        
+
         session = ldapServer.getDirectoryService().getAdminSession();
     }
 
-    
+
     /**
      * Close the LdapConnection
      */
@@ -131,61 +116,61 @@ public class ClientDeleteRequestTest ext
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
     }
-    
-    
+
+
     @Test
     public void testDeleteLeafNode() throws Exception
     {
         DN dn = new DN( "cn=grand_child12,cn=child1,cn=parent,ou=system" );
-        
+
         assertTrue( session.exists( dn ) );
-        
+
         DeleteResponse response = connection.delete( dn.getName() );
         assertNotNull( response );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
-        
+
         assertFalse( session.exists( dn ) );
     }
-    
-    
+
+
     @Test
     public void testDeleteNonLeafFailure() throws Exception
     {
         DN dn = new DN( "cn=child1,cn=parent,ou=system" ); // has children
         assertTrue( session.exists( dn ) );
- 
+
         DeleteResponse response = connection.delete( dn.getName() );
         assertNotNull( response );
         assertEquals( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF, response.getLdapResult().getResultCode() );
-        
+
         assertTrue( session.exists( dn ) );
     }
-    
+
 
     @Test
     @Ignore
     public void testDeleteWithCascadeControl() throws Exception
     {
         DN dn = new DN( "cn=parent,ou=system" );
-        
+
         assertTrue( session.exists( dn ) );
-        
+
         if ( connection.isControlSupported( "1.2.840.113556.1.4.805" ) )
         {
             DeleteResponse response = connection.deleteTree( dn );
             assertNotNull( response );
             assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
-            
+
             assertFalse( session.exists( dn ) );
         }
     }
-    
-    
+
+
     /**
      * this method uses reflection to test deleteChildren method without using the
      * convenient method delete( dn, true ), cause the convenient method checks 
@@ -202,20 +187,21 @@ public class ClientDeleteRequestTest ext
     public void testDeleteWithoutCascadeControl() throws Exception
     {
         DN dn = new DN( "cn=parent,ou=system" );
-        
+
         assertTrue( session.exists( dn ) );
 
-        Method deleteChildrenMethod = connection.getClass().getDeclaredMethod( "deleteRecursive", DN.class, Map.class, DeleteListener.class );
+        Method deleteChildrenMethod = connection.getClass().getDeclaredMethod( "deleteRecursive", DN.class, Map.class,
+            DeleteListener.class );
         deleteChildrenMethod.setAccessible( true );
-        
+
         DeleteResponse response = ( DeleteResponse ) deleteChildrenMethod.invoke( connection, dn, null, null );
         assertNotNull( response );
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
-        
+
         assertFalse( session.exists( dn ) );
     }
 
-    
+
     /**
      * @see #testDeleteWithoutCascadeControl()
      */
@@ -224,14 +210,15 @@ public class ClientDeleteRequestTest ext
     public void testDeleteAsyncWithoutCascadeControl() throws Exception
     {
         DN dn = new DN( "cn=parent,ou=system" );
-        
+
         assertTrue( session.exists( dn ) );
 
-        Method deleteChildrenMethod = connection.getClass().getDeclaredMethod( "deleteRecursive", DN.class, Map.class, DeleteListener.class );
+        Method deleteChildrenMethod = connection.getClass().getDeclaredMethod( "deleteRecursive", DN.class, Map.class,
+            DeleteListener.class );
         deleteChildrenMethod.setAccessible( true );
-    
+
         final AtomicInteger count = new AtomicInteger();
-        
+
         DeleteListener listener = new DeleteListener()
         {
             public void entryDeleted( LdapAsyncConnection connection, DeleteResponse response ) throws LdapException
@@ -241,7 +228,7 @@ public class ClientDeleteRequestTest ext
                 count.incrementAndGet();
             }
         };
-        
+
         try
         {
             connection.deleteTree( dn );
@@ -253,20 +240,23 @@ public class ClientDeleteRequestTest ext
         }
     }
 
-    
+
     @Test
     public void testDeleteAsync() throws Exception
     {
         DN dn = new DN( "cn=grand_child12,cn=child1,cn=parent,ou=system" );
-        
+
         assertTrue( session.exists( dn ) );
-        
-        DeleteFuture deleteFuture = connection.deleteAsync( new DeleteRequest( dn ));
-        
+
+        DeleteRequest deleteRequest = new DeleteRequestImpl();
+        deleteRequest.setName( dn );
+
+        DeleteFuture deleteFuture = connection.deleteAsync( deleteRequest );
+
         try
         {
             DeleteResponse deleteResponse = deleteFuture.get( 1000, TimeUnit.MILLISECONDS );
-            
+
             assertNotNull( deleteResponse );
             assertEquals( ResultCodeEnum.SUCCESS, deleteResponse.getLdapResult().getResultCode() );
             assertTrue( connection.isAuthenticated() );

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -33,14 +33,15 @@ 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.ldap.client.api.message.ExtendedRequest;
-import org.apache.directory.ldap.client.api.message.ExtendedResponse;
 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.ldap.message.ExtendedRequest;
+import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
+import org.apache.directory.shared.ldap.message.ExtendedResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.After;
@@ -48,85 +49,81 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+
 /**
  * Tests the extended operation
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer (
-   transports =
-   {
-       @CreateTransport( protocol = "LDAP" ),
-       @CreateTransport( protocol = "LDAPS" )
-   },
-   extendedOpHandlers =
-   {
-       StartTlsHandler.class
-   })
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") }, extendedOpHandlers =
+    { StartTlsHandler.class })
 public class ClientExtendedRequestTest extends AbstractLdapTestUnit
 {
-   private LdapAsyncConnection connection;
-   private CoreSession session;
+    private LdapAsyncConnection 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();
-   }
-
-
-   /**
-    * Close the LdapConnection
-    */
-   @After
-   public void shutdown()
-   {
-       try
-       {
-           if ( connection != null )
-           {
-               connection.close();
-           }
-       }
-       catch( Exception ioe )
-       {
-           fail();
-       }
-   }
-
-
-   @Test
-   public void testExtended() throws Exception
-   {
-       ExtendedResponse response = connection.extended( StartTlsRequest.OID );
-       assertNotNull( response );
-       assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
-   }
-
-
-   @Test
-   public void testExtendedAsync() throws Exception
-   {
-       ExtendedRequest extendedRequest = new ExtendedRequest( StartTlsRequest.OID );
-
-       ExtendedFuture extendedFuture = connection.extendedAsync( extendedRequest );
-
-       try
-       {
-           ExtendedResponse extendedResponse = extendedFuture.get( 1000, TimeUnit.MILLISECONDS );
-
-           assertNotNull( extendedResponse );
-           assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
-           assertTrue( connection.isAuthenticated() );
-       }
-       catch ( TimeoutException toe )
-       {
-           fail();
-       }
-   }
+    @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();
+    }
+
+
+    /**
+     * Close the LdapConnection
+     */
+    @After
+    public void shutdown()
+    {
+        try
+        {
+            if ( connection != null )
+            {
+                connection.close();
+            }
+        }
+        catch ( Exception ioe )
+        {
+            fail();
+        }
+    }
+
+
+    @Test
+    public void testExtended() throws Exception
+    {
+        ExtendedResponse response = connection.extended( StartTlsRequest.OID );
+        assertNotNull( response );
+        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+    }
+
+
+    @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 );
+
+            assertNotNull( extendedResponse );
+            assertEquals( ResultCodeEnum.SUCCESS, extendedResponse.getLdapResult().getResultCode() );
+            assertTrue( connection.isAuthenticated() );
+        }
+        catch ( TimeoutException toe )
+        {
+            fail();
+        }
+    }
 }
\ 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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -20,6 +20,7 @@
 
 package org.apache.directory.shared.client.api.operations;
 
+
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -31,8 +32,6 @@ import java.util.concurrent.TimeoutExcep
 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.ldap.client.api.message.ModifyDnRequest;
-import org.apache.directory.ldap.client.api.message.ModifyDnResponse;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.CoreSession;
@@ -40,6 +39,9 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
 import org.junit.After;
@@ -47,32 +49,26 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+
 /**
  * Testcase for modifyDn operation.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@ApplyLdifs( {
-    "dn: cn=modDn,ou=system",
-    "objectClass: person",
-    "cn: modDn",
-    "sn: snModDn" 
-})
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" ), 
-        @CreateTransport( protocol = "LDAPS" ) 
-    })
+@ApplyLdifs(
+    { "dn: cn=modDn,ou=system", "objectClass: person", "cn: modDn", "sn: snModDn" })
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientModifyDnRequestTest extends AbstractLdapTestUnit
 {
     private LdapAsyncConnection connection;
-    
+
     private CoreSession session;
-    
+
     private String dn = "cn=modDn,ou=system";
 
+
     @Before
     public void setup() throws Exception
     {
@@ -80,11 +76,11 @@ public class ClientModifyDnRequestTest e
 
         DN bindDn = new DN( "uid=admin,ou=system" );
         connection.bind( bindDn.getName(), "secret" );
-        
+
         session = ldapServer.getDirectoryService().getAdminSession();
     }
 
-    
+
     /**
      * Close the LdapConnection
      */
@@ -98,13 +94,13 @@ public class ClientModifyDnRequestTest e
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
     }
-    
-    
+
+
     @Test
     public void testRename() throws Exception
     {
@@ -113,55 +109,55 @@ public class ClientModifyDnRequestTest e
         assertFalse( session.exists( new DN( dn ) ) );
         assertTrue( session.exists( new DN( "cn=modifyDnWithString,ou=system" ) ) );
     }
-    
-    
+
+
     @Test
     public void testRenameWithoutDeleteOldRdn() throws Exception
     {
         ModifyDnResponse resp = connection.rename( dn, "cn=modifyDnWithString", false );
         assertNotNull( resp );
-        
+
         DN oldDn = new DN( dn );
         assertFalse( session.exists( oldDn ) );
-        
+
         Entry entry = session.lookup( new DN( "cn=modifyDnWithString,ou=system" ) );
         assertNotNull( entry );
-        
+
         RDN oldRdn = oldDn.getRdn();
         assertTrue( entry.contains( oldRdn.getUpType(), oldRdn.getNormValue() ) );
     }
-    
-    
+
+
     @Test
     public void testMove() throws Exception
     {
         ModifyDnResponse resp = connection.move( dn, "ou=users,ou=system" );
         assertNotNull( resp );
-        
+
         DN oldDn = new DN( dn );
         assertFalse( session.exists( oldDn ) );
-        
+
         assertTrue( session.exists( new DN( "cn=modDn,ou=users,ou=system" ) ) );
     }
-    
-    
+
+
     @Test
     public void testModifyDnAsync() throws Exception
     {
         DN oldDn = new DN( dn );
         DN newDn = new DN( "cn=modifyDnWithString,ou=system" );
 
-        ModifyDnRequest modDnReq = new ModifyDnRequest();
-        modDnReq.setEntryDn( oldDn );
+        ModifyDnRequest modDnReq = new ModifyDnRequestImpl();
+        modDnReq.setName( oldDn );
         modDnReq.setNewRdn( new RDN( "cn=modifyDnWithString" ) );
         modDnReq.setDeleteOldRdn( true );
 
         ModifyDnFuture modifyDnFuture = connection.modifyDnAsync( modDnReq );
-        
+
         try
         {
             ModifyDnResponse response = modifyDnFuture.get( 1000, TimeUnit.MILLISECONDS );
-            
+
             assertNotNull( response );
 
             assertTrue( connection.isAuthenticated() );

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -33,9 +33,6 @@ import java.util.concurrent.TimeoutExcep
 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.ldap.client.api.message.ModifyRequest;
-import org.apache.directory.ldap.client.api.message.ModifyResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultEntry;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.CoreSession;
@@ -47,7 +44,11 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyResponse;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.junit.After;
@@ -62,23 +63,19 @@ import org.junit.runner.RunWith;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer (
-    transports =
-    {
-        @CreateTransport( protocol = "LDAP" ),
-        @CreateTransport( protocol = "LDAPS" )
-    })
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
 public class ClientModifyRequestTest extends AbstractLdapTestUnit
 {
     private LdapAsyncConnection connection;
 
     private CoreSession session;
 
+
     @Before
     public void setup() throws Exception
     {
         connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-        connection.setTimeOut( 0 );
 
         DN bindDn = new DN( "uid=admin,ou=system" );
         connection.bind( bindDn.getName(), "secret" );
@@ -100,7 +97,7 @@ public class ClientModifyRequestTest ext
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
@@ -113,7 +110,8 @@ public class ClientModifyRequestTest ext
         DN dn = new DN( "uid=admin,ou=system" );
 
         String expected = String.valueOf( System.currentTimeMillis() );
-        ModifyRequest modRequest = new ModifyRequest( dn );
+        ModifyRequest modRequest = new ModifyRequestImpl();
+        modRequest.setName( dn );
         modRequest.replace( SchemaConstants.SN_AT, expected );
 
         connection.modify( modRequest );
@@ -169,7 +167,8 @@ public class ClientModifyRequestTest ext
         assertEquals( "test", gn );
 
         // Now, replace the givenName
-        ModifyRequest modifyRequest = new ModifyRequest( dn );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( dn );
         modifyRequest.replace( "givenName" );
         connection.modify( modifyRequest );
 
@@ -185,12 +184,13 @@ public class ClientModifyRequestTest ext
         DN dn = new DN( "uid=admin,ou=system" );
 
         String expected = String.valueOf( System.currentTimeMillis() );
-        ModifyRequest modRequest = new ModifyRequest( dn );
-        modRequest.replace( SchemaConstants.SN_AT, expected );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( dn );
+        modifyRequest.replace( SchemaConstants.SN_AT, expected );
 
         assertTrue( session.exists( dn ) );
 
-        ModifyFuture modifyFuture = connection.modifyAsync( modRequest );
+        ModifyFuture modifyFuture = connection.modifyAsync( modifyRequest );
 
         try
         {
@@ -222,16 +222,18 @@ public class ClientModifyRequestTest ext
     {
         DN dn = new DN( "uid=admin,ou=system" );
 
-        ModifyRequest modReq = new ModifyRequest( dn );
-        modReq.replace( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( dn );
+        modifyRequest.replace( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
 
-        ModifyResponse modResp = connection.modify( modReq );
+        ModifyResponse modResp = connection.modify( modifyRequest );
         assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, modResp.getLdapResult().getResultCode() );
 
-        modReq = new ModifyRequest( dn );
-        modReq.replace( SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString() );
+        modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( dn );
+        modifyRequest.replace( SchemaConstants.ENTRY_CSN_AT, new CsnFactory( 0 ).newInstance().toString() );
 
-        modResp = connection.modify( modReq );
+        modResp = connection.modify( modifyRequest );
         assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, modResp.getLdapResult().getResultCode() );
     }
 
@@ -247,11 +249,12 @@ public class ClientModifyRequestTest ext
         String modifierName = "uid=x,ou=system";
         String modifiedTime = DateUtils.getGeneralizedTime();
 
-        ModifyRequest modReq = new ModifyRequest( dn );
-        modReq.replace( SchemaConstants.MODIFIERS_NAME_AT, modifierName );
-        modReq.replace( SchemaConstants.MODIFY_TIMESTAMP_AT, modifiedTime );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( dn );
+        modifyRequest.replace( SchemaConstants.MODIFIERS_NAME_AT, modifierName );
+        modifyRequest.replace( SchemaConstants.MODIFY_TIMESTAMP_AT, modifiedTime );
 
-        ModifyResponse modResp = connection.modify( modReq );
+        ModifyResponse modResp = connection.modify( modifyRequest );
         assertEquals( ResultCodeEnum.SUCCESS, modResp.getLdapResult().getResultCode() );
 
         Entry loadedEntry = ( ( SearchResultEntry ) connection.lookup( dn.getName(), "+" ) ).getEntry();

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.client.api.operations.bind;
 
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
@@ -32,9 +33,6 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.BindFuture;
-import org.apache.directory.ldap.client.api.message.BindRequest;
-import org.apache.directory.ldap.client.api.message.BindResponse;
-import org.apache.directory.ldap.client.api.message.LdapResult;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -44,42 +42,37 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.interceptor.NextInterceptor;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.BindRequest;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.message.BindResponse;
+import org.apache.directory.shared.ldap.message.LdapResult;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+
 /**
  * Test the Simple BindRequest operation
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-@RunWith ( FrameworkRunner.class ) 
-@CreateLdapServer ( 
-    transports = 
-    {
-        @CreateTransport( protocol = "LDAP" ),
-        @CreateTransport( protocol = "LDAPS" ) 
-    })
-@ApplyLdifs( {
-    // Entry # 1
-    "dn: uid=superuser,ou=system",
-    "objectClass: person",
-    "objectClass: organizationalPerson",
-    "objectClass: inetOrgPerson",
-    "objectClass: top",
-    "cn: superuser",
-    "sn: administrator",
-    "displayName: Directory Superuser",
-    "uid: superuser",
-    "userPassword: test"
-})
+@RunWith(FrameworkRunner.class)
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
+@ApplyLdifs(
+    {
+        // Entry # 1
+        "dn: uid=superuser,ou=system", "objectClass: person", "objectClass: organizationalPerson",
+        "objectClass: inetOrgPerson", "objectClass: top", "cn: superuser", "sn: administrator",
+        "displayName: Directory Superuser", "uid: superuser", "userPassword: test" })
 public class SimpleBindRequestTest extends AbstractLdapTestUnit
 {
     private LdapAsyncConnection connection;
 
-    
+
     /**
      * Create the LdapConnection
      */
@@ -89,7 +82,7 @@ public class SimpleBindRequestTest exten
         connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
     }
 
-    
+
     /**
      * Close the LdapConnection
      */
@@ -103,13 +96,13 @@ public class SimpleBindRequestTest exten
                 connection.close();
             }
         }
-        catch( Exception ioe )
+        catch ( Exception ioe )
         {
             fail();
         }
     }
 
-    
+
     /**
      * Test a successful synchronous bind request. the server allows it.
      */
@@ -117,7 +110,7 @@ public class SimpleBindRequestTest exten
     public void testSyncBindRequest() throws Exception
     {
         BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret" );
-        
+
         assertNotNull( bindResponse );
         assertNotNull( bindResponse.getLdapResult() );
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
@@ -125,7 +118,7 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isAuthenticated() );
     }
 
-    
+
     /**
      * Test a successful asynchronous bind request, 10 times.
      */
@@ -135,18 +128,18 @@ public class SimpleBindRequestTest exten
         int i = 0;
         int nbLoop = 10;
 
-        for ( ; i < nbLoop; i++)
+        for ( ; i < nbLoop; i++ )
         {
-            BindRequest bindRequest = new BindRequest();
-            bindRequest.setName( "uid=admin,ou=system" );
+            BindRequest bindRequest = new BindRequestImpl();
+            bindRequest.setName( new DN( "uid=admin,ou=system" ) );
             bindRequest.setCredentials( "secret" );
-            
+
             BindFuture bindFuture = connection.bindAsync( bindRequest );
-            
+
             try
             {
                 BindResponse bindResponse = bindFuture.get( 1000, TimeUnit.MILLISECONDS );
-                
+
                 assertNotNull( bindResponse );
                 assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
                 assertTrue( connection.isAuthenticated() );
@@ -157,50 +150,50 @@ public class SimpleBindRequestTest exten
             }
         }
     }
-    
-    
+
+
     /**
      * Test an Anonymous BindRequest
      */
     @Test
     public void testSimpleBindAnonymous() throws Exception
     {
-        for ( int i = 0; i < 5; i++)
+        for ( int i = 0; i < 5; i++ )
         {
             //System.out.println( "------------------Create connection" + i + "-------------" );
             LdapConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
             //System.out.println( "------------------Bind" + i + "-------------" );
-            
+
             // Try with no parameters
             BindResponse bindResponse = connection.bind();
-            
+
             assertNotNull( bindResponse );
             assertNotNull( bindResponse.getLdapResult() );
             assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
             assertEquals( 1, bindResponse.getMessageId() );
             assertTrue( connection.isAuthenticated() );
-    
+
             //System.out.println( "----------------Unbind" + i + "-------------" );
             connection.unBind();
             assertFalse( connection.isConnected() );
-    
+
             // Try with empty strings
             connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
             bindResponse = connection.bind( "", "" );
-            
+
             assertNotNull( bindResponse );
             assertNotNull( bindResponse.getLdapResult() );
             assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
             assertEquals( 1, bindResponse.getMessageId() );
             assertTrue( connection.isAuthenticated() );
-    
+
             connection.unBind();
             assertFalse( connection.isConnected() );
-    
+
             // Try with null parameters
             connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-            bindResponse = connection.bind( (String)null, (String)null );
-            
+            bindResponse = connection.bind( ( String ) null, ( String ) null );
+
             assertNotNull( bindResponse );
             assertNotNull( bindResponse.getLdapResult() );
             assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
@@ -212,23 +205,22 @@ public class SimpleBindRequestTest exten
             assertFalse( connection.isConnected() );
 
             connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
-            
-            
+
             //System.out.println( "----------------Unbind done" + i + "-------------" );
             assertFalse( connection.isConnected() );
             //System.out.println( "----------------Unconnected" + i + "-------------" );
-            
+
         }
     }
 
-    
+
     /**
      * A bind with no name and a password is invalid
      */
     @Test
     public void testSimpleBindNoNamePassword() throws Exception
     {
-        BindResponse response = connection.bind((String)null, "abc" );
+        BindResponse response = connection.bind( ( String ) null, "abc" );
         LdapResult ldapResult = response.getLdapResult();
         assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, ldapResult.getResultCode() );
         assertEquals( 1, response.getMessageId() );
@@ -236,14 +228,14 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isConnected() );
     }
 
-    
+
     /**
      * Test an unauthenticated bind (name, no password)
      */
     @Test
     public void testSimpleBindUnauthenticated() throws Exception
     {
-        BindResponse response = connection.bind( "uid=admin,ou=system", (String)null );
+        BindResponse response = connection.bind( "uid=admin,ou=system", ( String ) null );
         LdapResult ldapResult = response.getLdapResult();
         assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, ldapResult.getResultCode() );
         assertEquals( 1, response.getMessageId() );
@@ -251,7 +243,7 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isConnected() );
     }
 
-    
+
     /**
      * Test a valid bind
      */
@@ -265,7 +257,7 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isAuthenticated() );
     }
 
-    
+
     /**
      * Test a bind with a valid user but a wrong password
      */
@@ -280,7 +272,7 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isConnected() );
     }
 
-    
+
     /**
      * Test a bind with an invalid user
      */
@@ -295,7 +287,7 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isConnected() );
     }
 
-    
+
     /**
      * Test a valid bind followed by another valid bind
      */
@@ -307,19 +299,19 @@ public class SimpleBindRequestTest exten
         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 = response2.getLdapResult();
         assertEquals( ResultCodeEnum.SUCCESS, ldapResult2.getResultCode() );
         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();
@@ -328,7 +320,7 @@ public class SimpleBindRequestTest exten
         assertTrue( connection.isAuthenticated() );
     }
 
-    
+
     /**
      * Test that we can't send another request until the BindResponse arrives
      */
@@ -340,7 +332,7 @@ public class SimpleBindRequestTest exten
             // Inject the interceptor that waits 1 second when binding 
             // in order to be able to send a request before we get the response
             service.getInterceptorChain().addFirst( new BaseInterceptor()
-                {
+            {
                 /**
                  * Wait 1 second before going any further
                  */
@@ -355,32 +347,32 @@ public class SimpleBindRequestTest exten
                     {
                         // Ok, get out
                     }
-                    
+
                     next.bind( bindContext );
                 }
             } );
-            
+
             // Send another BindRequest
-            BindRequest bindRequest = new BindRequest();
-            bindRequest.setName( "uid=admin,ou=system" );
+            BindRequest bindRequest = new BindRequestImpl();
+            bindRequest.setName( new DN( "uid=admin,ou=system" ) );
             bindRequest.setCredentials( "secret" );
-            
+
             BindFuture bindFuture = connection.bindAsync( bindRequest );
-            
+
             // Wait a bit to be sure the server is processing the bind request
             Thread.sleep( 200 );
-            
+
             // It will take 1 seconds to bind, let's send another bind request : it should fail
             BindResponse response = connection.bind( "uid=admin,ou=system", "secret" );
-            
+
             assertFalse( connection.isAuthenticated() );
             assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
-            
+
             // Now get back the BindResponse
             try
             {
                 BindResponse bindResponse = bindFuture.get( 2000, TimeUnit.MILLISECONDS );
-                
+
                 assertNotNull( bindResponse );
                 assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
                 assertTrue( connection.isAuthenticated() );
@@ -395,8 +387,8 @@ public class SimpleBindRequestTest exten
             service.getInterceptorChain().remove( this.getClass().getName() + "$1" );
         }
     }
-    
-    
+
+
     /**
      * Bind with a new user when the connection is establish with an anonymous authent.
      */
@@ -405,33 +397,33 @@ public class SimpleBindRequestTest exten
     {
         // Bind anonymous
         BindResponse bindResponse = connection.bind();
-        
+
         assertNotNull( bindResponse );
         assertNotNull( bindResponse.getLdapResult() );
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
         assertEquals( 1, bindResponse.getMessageId() );
         assertTrue( connection.isAuthenticated() );
-        
+
         // Now bind with some credentials
         bindResponse = connection.bind( "uid=admin, ou=system", "secret" );
-        
+
         assertNotNull( bindResponse );
         assertNotNull( bindResponse.getLdapResult() );
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
         assertEquals( 2, bindResponse.getMessageId() );
         assertTrue( connection.isAuthenticated() );
-        
+
         //And back to anonymous
         bindResponse = connection.bind();
-        
+
         assertNotNull( bindResponse );
         assertNotNull( bindResponse.getLdapResult() );
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
         assertEquals( 3, bindResponse.getMessageId() );
         assertTrue( connection.isAuthenticated() );
     }
-    
-    
+
+
     /**
      * Bind with a new user when the connection is establish with an anonymous authent.
      */
@@ -440,16 +432,16 @@ public class SimpleBindRequestTest exten
     {
         // Bind with some credentials
         BindResponse bindResponse = connection.bind( "uid=admin, ou=system", "secret" );
-        
+
         assertNotNull( bindResponse );
         assertNotNull( bindResponse.getLdapResult() );
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );
         assertEquals( 1, bindResponse.getMessageId() );
         assertTrue( connection.isAuthenticated() );
-        
+
         // Bind with another user
-        bindResponse = connection.bind( "uid=superuser,ou=system", "test");
-        
+        bindResponse = connection.bind( "uid=superuser,ou=system", "test" );
+
         assertNotNull( bindResponse );
         assertNotNull( bindResponse.getLdapResult() );
         assertEquals( ResultCodeEnum.SUCCESS, bindResponse.getLdapResult().getResultCode() );

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -31,10 +31,6 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.SearchCursor;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
-import org.apache.directory.ldap.client.api.message.SearchRequest;
-import org.apache.directory.ldap.client.api.message.SearchResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultDone;
-import org.apache.directory.ldap.client.api.message.SearchResultEntry;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -45,7 +41,12 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.Response;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.message.SearchResultDone;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.After;
 import org.junit.Before;
@@ -59,39 +60,26 @@ import org.junit.runner.RunWith;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer(
-    transports = 
-        {
-          @CreateTransport(protocol = "LDAP"), 
-          @CreateTransport(protocol = "LDAPS") 
-        })
-@ApplyLdifs({
-    "dn: cn=user1,ou=users,ou=system",
-    "objectClass: person",
-    "objectClass: top",
-    "sn: user1 sn",
-    "cn: user1",
-
-    // alias to the above entry
-    "dn: cn=user1-alias,ou=users,ou=system",
-    "objectClass: alias",
-    "objectClass: top",
-    "objectClass: extensibleObject",
-    "aliasedObjectName: cn=user1,ou=users,ou=system",
-    "cn: user1-alias",
-
-    // Another user
-    "dn: cn=elecharny,ou=users,ou=system",
-    "objectClass: person",
-    "objectClass: top",
-    "sn:: RW1tYW51ZWwgTMOpY2hhcm55",
-    "cn: elecharny"
-    
-})
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
+@ApplyLdifs(
+    { "dn: cn=user1,ou=users,ou=system", "objectClass: person", "objectClass: top", "sn: user1 sn",
+        "cn: user1",
+
+        // alias to the above entry
+        "dn: cn=user1-alias,ou=users,ou=system", "objectClass: alias", "objectClass: top",
+        "objectClass: extensibleObject", "aliasedObjectName: cn=user1,ou=users,ou=system", "cn: user1-alias",
+
+        // Another user
+        "dn: cn=elecharny,ou=users,ou=system", "objectClass: person", "objectClass: top",
+        "sn:: RW1tYW51ZWwgTMOpY2hhcm55", "cn: elecharny"
+
+    })
 public class ClientSearchRequestTest extends AbstractLdapTestUnit
 {
     private LdapAsyncConnection connection;
 
+
     @Before
     public void setup() throws Exception
     {
@@ -124,7 +112,8 @@ public class ClientSearchRequestTest ext
     @Test
     public void testSearch() throws Exception
     {
-        SearchCursor cursor = ( SearchCursor ) connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL, "*", "+" );
+        SearchCursor cursor = ( SearchCursor ) connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL,
+            "*", "+" );
         int count = 0;
         while ( cursor.next() )
         {
@@ -133,43 +122,43 @@ public class ClientSearchRequestTest ext
         }
 
         SearchResultDone done = cursor.getSearchDone();
-        
+
         assertNotNull( done );
         assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
         assertEquals( 5, count );
     }
-    
+
 
     @Test
     public void testSearchEquality() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)", SearchScope.ONELEVEL, "*",
-            "+" );
+        Cursor<Response> cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)",
+            SearchScope.ONELEVEL, "*", "+" );
         int count = 0;
         while ( cursor.next() )
         {
             Entry entry = ( ( SearchResultEntry ) cursor.get() ).getEntry();
-            assertNotNull(  entry );
+            assertNotNull( entry );
             count++;
         }
-        
+
         assertEquals( 4, count );
     }
-    
-    
+
+
     @Test
     public void testAsyncSearch() throws Exception
     {
         SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL, "*",
             "+" );
         int count = 0;
-        SearchResponse searchResponse = null;
-        
+        Response searchResponse = null;
+
         do
         {
-            searchResponse = ( SearchResponse ) searchFuture.get( 1000, TimeUnit.MILLISECONDS );
+            searchResponse = ( Response ) searchFuture.get( 1000, TimeUnit.MILLISECONDS );
             assertNotNull( searchResponse );
-            if( !( searchResponse instanceof SearchResultDone ) )
+            if ( !( searchResponse instanceof SearchResultDone ) )
             {
                 count++;
             }
@@ -179,7 +168,7 @@ public class ClientSearchRequestTest ext
         assertEquals( 5, count );
     }
 
-    
+
     /**
      * Test a search with a Substring filter
      * @throws Exception
@@ -187,16 +176,16 @@ public class ClientSearchRequestTest ext
     @Test
     public void testSearchPersonSubstring() throws Exception
     {
-        SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*ers*)", SearchScope.SUBTREE, "*",
-            "+" );
+        SearchFuture searchFuture = connection.searchAsync( "ou=system", "(objectclass=*ers*)", SearchScope.SUBTREE,
+            "*", "+" );
         int count = 0;
-        SearchResponse searchResponse = null;
-        
+        Response searchResponse = null;
+
         do
         {
-            searchResponse = ( SearchResponse ) searchFuture.get( 100000, TimeUnit.MILLISECONDS );
+            searchResponse = ( Response ) searchFuture.get( 100000, TimeUnit.MILLISECONDS );
             assertNotNull( searchResponse );
-            
+
             if ( !( searchResponse instanceof SearchResultDone ) )
             {
                 count++;
@@ -207,41 +196,41 @@ public class ClientSearchRequestTest ext
         assertEquals( 3, count );
     }
 
-    
+
     @Test
     public void testSearchWithDerefAlias() throws Exception
     {
-        SearchRequest searchRequest = new SearchRequest();
-        searchRequest.setBaseDn( "ou=users,ou=system" );
+        SearchRequest searchRequest = new SearchRequestImpl();
+        searchRequest.setBase( new DN( "ou=users,ou=system" ) );
         searchRequest.setFilter( "(objectClass=*)" );
         searchRequest.setScope( SearchScope.ONELEVEL );
         searchRequest.addAttributes( "*" );
-        
+
         int count = 0;
-        Cursor<SearchResponse> cursor = connection.search( searchRequest );
-        
-        while( cursor.next() )
+        Cursor<Response> cursor = connection.search( searchRequest );
+
+        while ( cursor.next() )
         {
             count++;
         }
-        
+
         // due to dereferencing of aliases we get only one entry
         assertEquals( 2, count );
 
         count = 0;
         searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
         cursor = connection.search( searchRequest );
-        
-        while( cursor.next() )
+
+        while ( cursor.next() )
         {
             count++;
         }
-        
+
         assertEquals( 3, count );
     }
-    
 
-    @Test(expected=LdapException.class)
+
+    @Test(expected = LdapException.class)
     public void testSearchUTF8() throws Exception
     {
         connection.search( "ou=system", "(sn=Emmanuel LŽcharny)", SearchScope.ONELEVEL, "*", "+" );

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=987611&r1=987610&r2=987611&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 Fri Aug 20 19:31:58 2010
@@ -28,8 +28,6 @@ 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.message.SearchResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultEntry;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
@@ -38,6 +36,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -51,31 +51,19 @@ import org.junit.runner.RunWith;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(FrameworkRunner.class)
-@CreateLdapServer(
-    transports = 
-        {
-          @CreateTransport(protocol = "LDAP"), 
-          @CreateTransport(protocol = "LDAPS") 
-        })
-@ApplyLdifs({
-    "dn: cn=user1,ou=users,ou=system",
-    "objectClass: person",
-    "objectClass: top",
-    "sn: user1 sn",
-    "cn: user1",
-    
-    // alias to the above entry
-    "dn: cn=user1-alias,ou=users,ou=system",
-    "objectClass: alias",
-    "objectClass: top",
-    "objectClass: extensibleObject",
-    "aliasedObjectName: cn=user1,ou=users,ou=system",
-    "cn: user1-alias"
-})
+@CreateLdapServer(transports =
+    { @CreateTransport(protocol = "LDAP"), @CreateTransport(protocol = "LDAPS") })
+@ApplyLdifs(
+    { "dn: cn=user1,ou=users,ou=system", "objectClass: person", "objectClass: top", "sn: user1 sn", "cn: user1",
+
+        // alias to the above entry
+        "dn: cn=user1-alias,ou=users,ou=system", "objectClass: alias", "objectClass: top",
+        "objectClass: extensibleObject", "aliasedObjectName: cn=user1,ou=users,ou=system", "cn: user1-alias" })
 public class SearchRequestReturningAttributesTest extends AbstractLdapTestUnit
 {
     private static LdapConnection connection;
 
+
     @Before
     public void setup() throws Exception
     {
@@ -113,11 +101,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchAll() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, "*",
-            "+" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "*", "+" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -128,9 +116,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 7, entry.size() );
         assertTrue( entry.containsAttribute( "objectClass" ) );
         assertTrue( entry.containsAttribute( "cn" ) );
@@ -150,10 +138,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchAllUsers() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, "*" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "*" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -164,9 +153,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 3, entry.size() );
         assertTrue( entry.containsAttribute( "objectClass" ) );
         assertTrue( entry.containsAttribute( "cn" ) );
@@ -182,10 +171,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchAllOperationals() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, "+" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "+" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -196,9 +186,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 4, entry.size() );
         assertTrue( entry.containsAttribute( "creatorsName" ) );
         assertTrue( entry.containsAttribute( "createTimestamp" ) );
@@ -215,11 +205,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchAllUsersAndSomeOperationals() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, "*",
-            "entryCSN", "entryUUID" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "*", "entryCSN", "entryUUID" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -230,9 +220,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 5, entry.size() );
         assertTrue( entry.containsAttribute( "objectClass" ) );
         assertTrue( entry.containsAttribute( "cn" ) );
@@ -250,11 +240,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchAllOperationalAndSomeUsers() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, "+",
-            "cn", "sn" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "+", "cn", "sn" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -265,9 +255,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 6, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
@@ -286,11 +276,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchSomeOpsAndUsers() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "cn", "entryUUID", "sn", "entryCSN" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "cn", "entryUUID", "sn", "entryCSN" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -301,9 +291,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 4, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
@@ -320,11 +310,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchWithDuplicatedAttrs() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "cn", "entryUUID", "cn", "sn", "entryCSN", "entryUUID" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "cn", "entryUUID", "cn", "sn", "entryCSN", "entryUUID" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -335,9 +325,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 4, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
@@ -354,11 +344,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchWithOIDAndtext() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "cn", "1.3.6.1.1.16.4", "surName", "entryCSN", "entryUUID" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "cn", "1.3.6.1.1.16.4", "surName", "entryCSN", "entryUUID" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -369,9 +359,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 4, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "sn" ) );
@@ -388,11 +378,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchWithMissingAttributes() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "cn", "1.3.6.1.1.16.4", "gn", "entryCSN", "entryUUID" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "cn", "1.3.6.1.1.16.4", "gn", "entryCSN", "entryUUID" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -403,9 +393,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 3, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
         assertTrue( entry.containsAttribute( "entryUUID" ) );
@@ -421,11 +411,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchNoAttributes() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "1.1" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "1.1" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -436,9 +426,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 0, entry.size() );
     }
 
@@ -451,11 +441,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchNoAttributesAndAttributes() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "1.1", "cn" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "1.1", "cn" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -466,9 +456,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
+
         assertEquals( 1, entry.size() );
         assertTrue( entry.containsAttribute( "cn" ) );
     }
@@ -482,11 +472,11 @@ public class SearchRequestReturningAttri
     @Test
     public void testSearchNoAttributesAllAttributes() throws Exception
     {
-        Cursor<SearchResponse> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)", SearchScope.OBJECT, 
-            "1.1", "*", "+" );
+        Cursor<Response> cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
+            SearchScope.OBJECT, "1.1", "*", "+" );
         int count = 0;
-        SearchResponse response = null;
-        
+        Response response = null;
+
         while ( cursor.next() )
         {
             response = cursor.get();
@@ -497,10 +487,9 @@ public class SearchRequestReturningAttri
         assertEquals( 1, count );
         assertNotNull( response );
         assertTrue( response instanceof SearchResultEntry );
-        SearchResultEntry resultEntry = (SearchResultEntry)response;
+        SearchResultEntry resultEntry = ( SearchResultEntry ) response;
         Entry entry = resultEntry.getEntry();
-        
-        
+
         assertEquals( 7, entry.size() );
         assertTrue( entry.containsAttribute( "objectClass" ) );
         assertTrue( entry.containsAttribute( "cn" ) );



Mime
View raw message