directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1175948 - in /directory/apacheds/trunk/server-integ/src: main/java/org/apache/directory/server/integ/ test/java/org/apache/directory/server/operations/add/ test/java/org/apache/directory/server/operations/bind/ test/java/org/apache/directo...
Date Mon, 26 Sep 2011 16:49:29 GMT
Author: elecharny
Date: Mon Sep 26 16:49:28 2011
New Revision: 1175948

URL: http://svn.apache.org/viewvc?rev=1175948&view=rev
Log:
Get rid of LdapSDK to use our LDAP API instead (we should create a new subproject for LdapSDK tests)

Modified:
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java Mon Sep 26 16:49:28 2011
@@ -25,8 +25,6 @@ import javax.naming.Context;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
-import netscape.ldap.LDAPConnection;
-
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.constants.ServerDNConstants;
@@ -84,6 +82,7 @@ public class ServerIntegrationUtils exte
         env.put( Context.SECURITY_PRINCIPAL, principalDn );
         env.put( Context.SECURITY_CREDENTIALS, password );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+        
         return new InitialLdapContext( env, null );
     }
 
@@ -180,7 +179,7 @@ public class ServerIntegrationUtils exte
     }
 
 
-    public static LDAPConnection getWiredConnection( LdapServer ldapServer ) throws Exception
+    public static LdapConnection getWiredConnection( LdapServer ldapServer ) throws Exception
     {
         String testServer = System.getProperty( "ldap.test.server", null );
 
@@ -203,8 +202,9 @@ public class ServerIntegrationUtils exte
         int port = Integer.parseInt( System.getProperty( testServer + ".port", Integer.toString( DEFAULT_PORT ) ) );
         LOG.debug( testServer + ".port = " + port );
 
-        LDAPConnection conn = new LDAPConnection();
-        conn.connect( 3, host, port, admin, password );
+        LdapConnection conn = new LdapNetworkConnection( host, port );
+        conn.bind( admin, password );
+        
         return conn;
     }
 
@@ -218,11 +218,11 @@ public class ServerIntegrationUtils exte
      * @return A LdapConnection instance if we got one
      * @throws Exception If the connection cannot be created
      */
-    public static LDAPConnection getWiredConnection( LdapServer ldapServer, String principalDn, String password )
+    public static LdapConnection getWiredConnection( LdapServer ldapServer, String principalDn, String password )
         throws Exception
     {
-        LDAPConnection connection = new LDAPConnection();
-        connection.connect( 3, "localhost", ldapServer.getPort(), principalDn, password );
+        LdapConnection connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
+        connection.bind( principalDn, password );
         
         return connection;
     }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Mon Sep 26 16:49:28 2011
@@ -51,17 +51,6 @@ import javax.naming.directory.SearchResu
 import javax.naming.ldap.LdapContext;
 import javax.naming.ldap.LdapName;
 
-import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPAttributeSet;
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPConstraints;
-import netscape.ldap.LDAPControl;
-import netscape.ldap.LDAPEntry;
-import netscape.ldap.LDAPException;
-import netscape.ldap.LDAPResponse;
-import netscape.ldap.LDAPResponseListener;
-import netscape.ldap.LDAPSearchConstraints;
-
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -94,7 +83,13 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.exception.LdapNoSuchAttributeException;
 import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
 import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.model.message.AddRequest;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddResponse;
+import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
@@ -701,39 +696,26 @@ public class AddIT extends AbstractLdapT
     @Test
     public void testOnReferralWithManageDsaITControl() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
-        // add success
-        LDAPAttributeSet attrSet = new LDAPAttributeSet();
-        attrSet.add( new LDAPAttribute( "objectClass", "organizationalUnit" ) );
-        attrSet.add( new LDAPAttribute( "ou", "UnderReferral" ) );
-        LDAPEntry entry = new LDAPEntry( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", attrSet );
+        AddRequest addRequest = new AddRequestImpl();
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
+        addRequest.addControl( manageDSAIT );
 
-        try
-        {
-            conn.add( entry, constraints );
-            fail();
-        }
-        catch ( LDAPException le )
-        {
-            assertEquals( ResultCodeEnum.REFERRAL.getValue(), le.getLDAPResultCode() );
-        }
+        // add success
+        Entry entry = new DefaultEntry( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", 
+            "objectClass", "organizationalUnit",
+            "ou", "UnderReferral" );
+        
+        addRequest.setEntry( entry );
 
-        try
-        {
-            conn.read( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
-            fail();
-        }
-        catch ( LDAPException le )
-        {
+        AddResponse addResponse = conn.add( addRequest );
+        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
 
-        }
+        assertNull( conn.lookup( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", new Control[]{ manageDSAIT } ) );
 
-        conn.disconnect();
+        conn.close();
     }
 
 
@@ -796,28 +778,26 @@ public class AddIT extends AbstractLdapT
     {
         LOG.debug( "" );
 
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+
+        AddRequest addRequest = new AddRequestImpl();
 
         // referrals failure
-        LDAPAttributeSet attrSet = new LDAPAttributeSet();
-        attrSet.add( new LDAPAttribute( "objectClass", "organizationalUnit" ) );
-        attrSet.add( new LDAPAttribute( "ou", "UnderReferral" ) );
-        LDAPEntry entry = new LDAPEntry( "ou=UnderReferral,ou=Computers,uid=akarasuluref,ou=users,ou=system", attrSet );
-
-        LDAPResponseListener listener = conn.add( entry, null, constraints );
-        LDAPResponse response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system", response
-            .getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system", response
-            .getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system", response
-            .getReferrals()[2] );
+        Entry entry = new DefaultEntry( 
+            "ou=UnderReferral,ou=Computers,uid=akarasuluref,ou=users,ou=system", 
+            "objectClass", "organizationalUnit",
+            "ou", "UnderReferral" );
+        addRequest.setEntry( entry );
+
+        AddResponse addResponse = conn.add( addRequest );
 
-        conn.disconnect();
+        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
+
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=UnderReferral,ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+
+        conn.close();
     }
 
 
@@ -829,31 +809,30 @@ public class AddIT extends AbstractLdapT
     @Test
     public void testOnReferral() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+
+        AddRequest addRequest = new AddRequestImpl();
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
+        //addRequest.addControl( manageDSAIT );
 
         // referrals failure
+        Entry entry = new DefaultEntry( 
+            "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", 
+            "objectClass", "organizationalUnit",
+            "ou", "UnderReferral" );
+        
+        addRequest.setEntry( entry );
+
+        AddResponse addResponse = conn.add( addRequest );
+
+        assertEquals( ResultCodeEnum.REFERRAL, addResponse.getLdapResult().getResultCode() );
 
-        LDAPAttributeSet attrSet = new LDAPAttributeSet();
-        attrSet.add( new LDAPAttribute( "objectClass", "organizationalUnit" ) );
-        attrSet.add( new LDAPAttribute( "ou", "UnderReferral" ) );
-        LDAPEntry entry = new LDAPEntry( "ou=UnderReferral,uid=akarasuluref,ou=users,ou=system", attrSet );
-
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-        listener = conn.add( entry, null, constraints );
-        response = listener.getResponse();
-
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system", response
-            .getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( addResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=UnderReferral,uid=akarasulu,ou=users,ou=system" ) );
 
-        conn.disconnect();
+        conn.close();
     }
 
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java Mon Sep 26 16:49:28 2011
@@ -20,7 +20,7 @@
 package org.apache.directory.server.operations.bind;
 
 
-import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -39,6 +39,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -96,32 +98,22 @@ public class BindIT extends AbstractLdap
      * 
      * @throws Exception 
      */
-    @Test
+    @Test( expected=LdapAuthenticationException.class )
     public void testBadBindDnNotInContext() throws Exception
     {
-        try
-        {
-            getWiredContext( getLdapServer(), "cn=bogus", "blah" );
-            fail( "should never get here due to a " );
-        }
-        catch ( AuthenticationException e )
-        {
-        }
+        getWiredConnection( getLdapServer(), "cn=bogus", "blah" );
+        fail( "should never get here due to a " );
     }
 
 
     /**
      * Test bind with malformed bind Dn.
      */
-    @Test
+    @Test( expected=LdapInvalidDnException.class )
     public void testBadBindDnMalformed() throws Exception
     {
-        try
-        {
-            getWiredContext( getLdapServer(), "system", "blah" );
-            fail( "should never get here due to a " );
-        }
-        catch ( InvalidNameException e ){}
+        getWiredConnection( getLdapServer(), "system", "blah" );
+        fail( "should never get here due to a " );
     }
 
     /**
@@ -129,17 +121,11 @@ public class BindIT extends AbstractLdap
      * 
      * @throws Exception 
      */
-    @Test
+    @Test( expected=LdapAuthenticationException.class )
     public void testBadBindDnInContext() throws Exception
     {
-        try
-        {
-            getWiredContext( getLdapServer(), "cn=bogus,ou=system", "blah" );
-            fail( "should never get here due to a " );
-        }
-        catch ( AuthenticationException e )
-        {
-        }
+        getWiredConnection( getLdapServer(), "cn=bogus,ou=system", "blah" );
+        fail( "should never get here due to a " );
     }
 
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java Mon Sep 26 16:49:28 2011
@@ -34,21 +34,23 @@ import javax.naming.directory.SearchCont
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 
-import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPConstraints;
-import netscape.ldap.LDAPControl;
-import netscape.ldap.LDAPException;
-import netscape.ldap.LDAPResponse;
-import netscape.ldap.LDAPResponseListener;
-
 import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.ldap.client.api.exception.InvalidConnectionException;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
+import org.apache.directory.shared.ldap.model.message.CompareRequest;
+import org.apache.directory.shared.ldap.model.message.CompareRequestImpl;
+import org.apache.directory.shared.ldap.model.message.CompareResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
+import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -116,26 +118,23 @@ public class CompareIT extends AbstractL
     @Test
     public void testNormalCompareMissingAttribute() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
         // comparison success
-        LDAPAttribute attribute = new LDAPAttribute( "sn", "karasulu" );
-        assertTrue( conn.compare( "uid=akarasulu,ou=users,ou=system", attribute ) );
+        assertTrue( conn.compare( "uid=akarasulu,ou=users,ou=system", "sn", "karasulu" ) );
 
         // non-existing attribute
-        attribute = new LDAPAttribute( "mail", "akarasulu@apache.org" );
-
         try
         {
-            conn.compare( "uid=akarasulu,ou=users,ou=system", attribute );
+            conn.compare( "uid=akarasulu,ou=users,ou=system", "mail", "akarasulu@apache.org" );
             fail( "Should never get here" );
         }
-        catch ( LDAPException e )
+        catch ( LdapOperationException e )
         {
-            assertEquals( ResultCodeEnum.NO_SUCH_ATTRIBUTE.getValue(), e.getLDAPResultCode() );
+            assertEquals( ResultCodeEnum.NO_SUCH_ATTRIBUTE, e.getResultCode() );
         }
 
-        conn.disconnect();
+        conn.close();
     }
 
 
@@ -145,21 +144,24 @@ public class CompareIT extends AbstractL
     @Test
     public void testOnReferralWithManageDsaITControl() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
         // comparison success
-        LDAPAttribute attribute = new LDAPAttribute( "uid", "akarasuluref" );
-        assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
+        assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", "uid", "akarasuluref" ) );
 
         // comparison failure
-        attribute = new LDAPAttribute( "uid", "elecharny" );
-        assertFalse( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        compareRequest.setAttributeId( "uid" );
+        compareRequest.setAssertionValue( "elecharny" );
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
+        compareRequest.addControl( manageDSAIT );
+        
+        CompareResponse compareResponse = conn.compare( compareRequest );
+        assertEquals( ResultCodeEnum.COMPARE_FALSE, compareResponse.getLdapResult().getResultCode() );
 
-        conn.disconnect();
+        conn.close();
     }
 
 
@@ -171,29 +173,34 @@ public class CompareIT extends AbstractL
     @Test
     public void testOnReferral() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
-
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+        
         // comparison success
-        LDAPAttribute attribute = new LDAPAttribute( "uid", "akarasulu" );
-        assertTrue( conn.compare( "uid=akarasulu,ou=users,ou=system", attribute, constraints ) );
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( new Dn( "uid=akarasulu,ou=users,ou=system" ) );
+        compareRequest.setAttributeId( "uid" );
+        compareRequest.setAssertionValue( "akarasulu" );
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( false );
+        compareRequest.addControl( manageDSAIT );
+
+        CompareResponse compareResponse = conn.compare( compareRequest );
+        assertEquals( ResultCodeEnum.COMPARE_TRUE, compareResponse.getLdapResult().getResultCode() );
 
         // referrals failure
-        attribute = new LDAPAttribute( "uid", "akarasulu" );
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-
-        listener = conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        compareRequest = new CompareRequestImpl();
+        compareRequest.setName( new Dn( "uid=akarasuluREF,ou=users,ou=system" ) );
+        compareRequest.setAttributeId( "uid" );
+        compareRequest.setAssertionValue( "akarasulu" );
+
+        compareResponse = conn.compare( compareRequest );
+        assertEquals( ResultCodeEnum.REFERRAL, compareResponse.getLdapResult().getResultCode() );
+
+        assertTrue( compareResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( compareResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( compareResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system" ) );
 
-        conn.disconnect();
+        conn.close();
     }
 
 
@@ -239,25 +246,16 @@ public class CompareIT extends AbstractL
     /**
      * Check that operation are not executed if we are now allowed to bind
      * anonymous
-     * @throws LDAPException
+     * @throws LdapException
      */
-    @Test
-    public void testCompareWithoutAuthentication() throws LDAPException
+    @Test( expected=InvalidConnectionException.class )
+    public void testCompareWithoutAuthentication() throws LdapException
     {
         getLdapServer().getDirectoryService().setAllowAnonymousAccess( false );
-        LDAPConnection conn = new LDAPConnection();
-        conn.connect( "localhost", getLdapServer().getPort() );
-        LDAPAttribute attr = new LDAPAttribute( "uid", "admin" );
+        LdapConnection conn = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
 
-        try
-        {
-            conn.compare( "uid=admin,ou=system", attr );
-            fail( "Compare success without authentication" );
-        }
-        catch ( LDAPException e )
-        {
-            assertEquals( "no permission exception", 50, e.getLDAPResultCode() );
-        }
+        conn.compare( "uid=admin,ou=system", "uid", "admin" );
+        fail( "Compare success without authentication" );
     }
 
 
@@ -269,24 +267,21 @@ public class CompareIT extends AbstractL
     {
         LOG.debug( "" );
 
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
         // referrals failure
-        LDAPAttribute attribute = new LDAPAttribute( "ou", "Computers" );
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-
-        listener = conn.compare( "ou=Computers,uid=akarasuluref,ou=users,ou=system", attribute, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system",
-            response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        CompareRequest compareRequest = new CompareRequestImpl();
+        compareRequest.setName( new Dn( "ou=Computers,uid=akarasuluref,ou=users,ou=system" ) );
+        compareRequest.setAttributeId( "ou" );
+        compareRequest.setAssertionValue( "Computers" );
+
+        CompareResponse compareResponse = conn.compare( compareRequest );
+        assertEquals( ResultCodeEnum.REFERRAL, compareResponse.getLdapResult().getResultCode() );
+
+        assertTrue( compareResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( compareResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( compareResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
 
-        conn.disconnect();
+        conn.close();
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/delete/DeleteIT.java Mon Sep 26 16:49:28 2011
@@ -25,20 +25,13 @@ import static org.apache.directory.serve
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextThrowOnRefferal;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 
 import javax.naming.NameNotFoundException;
 import javax.naming.ReferralException;
 import javax.naming.ldap.LdapContext;
 
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPConstraints;
-import netscape.ldap.LDAPControl;
-import netscape.ldap.LDAPException;
-import netscape.ldap.LDAPResponse;
-import netscape.ldap.LDAPResponseListener;
-import netscape.ldap.LDAPSearchConstraints;
-
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
@@ -47,7 +40,15 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapContextNotEmptyException;
 import org.apache.directory.shared.ldap.model.exception.LdapNoSuchObjectException;
+import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
+import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.DeleteRequest;
+import org.apache.directory.shared.ldap.model.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.model.message.DeleteResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
+import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -171,26 +172,20 @@ public class DeleteIT extends AbstractLd
     @Test
     public void testOnReferralWithManageDsaITControl() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
 
         // delete success
-        conn.delete( "uid=akarasuluref,ou=users,ou=system", constraints );
+        DeleteRequest deleteRequest = new DeleteRequestImpl();
+        deleteRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        deleteRequest.addControl( manageDSAIT );
+        conn.delete( deleteRequest );
 
-        try
-        {
-            conn.read( "uid=akarasuluref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
-            fail( "Should never get here." );
-        }
-        catch ( LDAPException e )
-        {
-            assertEquals( ResultCodeEnum.NO_SUCH_OBJECT.getValue(), e.getLDAPResultCode() );
-        }
+        assertNull( conn.lookup( "uid=akarasuluref,ou=users,ou=system", new Control[]{ manageDSAIT } ) );
 
-        conn.disconnect();
+        conn.close();
     }
 
 
@@ -202,24 +197,20 @@ public class DeleteIT extends AbstractLd
     @Test
     public void testOnReferral() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
-
-        // referrals failure
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-
-        listener = conn.delete( "uid=akarasuluref,ou=users,ou=system", null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+
+        // delete success
+        DeleteRequest deleteRequest = new DeleteRequestImpl();
+        deleteRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        DeleteResponse deleteResponse = conn.delete( deleteRequest );
+
+        assertEquals( ResultCodeEnum.REFERRAL, deleteResponse.getLdapResult().getResultCode() );
+
+        assertTrue( deleteResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( deleteResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( deleteResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system" ) );
 
-        conn.disconnect();
+        conn.close();
     }
 
 
@@ -269,24 +260,20 @@ public class DeleteIT extends AbstractLd
     {
         LOG.debug( "" );
 
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
-
-        // referrals failure
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-
-        listener = conn.delete( "ou=Computers,uid=akarasuluref,ou=users,ou=system", null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system",
-            response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
-        conn.disconnect();
+        // delete success
+        DeleteRequest deleteRequest = new DeleteRequestImpl();
+        deleteRequest.setName( new Dn( "ou=Computers,uid=akarasuluref,ou=users,ou=system" ) );
+        DeleteResponse deleteResponse = conn.delete( deleteRequest );
+
+        assertEquals( ResultCodeEnum.REFERRAL, deleteResponse.getLdapResult().getResultCode() );
+
+        assertTrue( deleteResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( deleteResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system") );
+        assertTrue( deleteResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+
+        conn.close();
     }
 
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/IllegalModificationIT.java Mon Sep 26 16:49:28 2011
@@ -24,11 +24,6 @@ import static org.apache.directory.serve
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredConnection;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPEntry;
-import netscape.ldap.LDAPException;
-import netscape.ldap.LDAPModification;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -36,7 +31,11 @@ import org.apache.directory.server.annot
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.model.entry.DefaultModification;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.Modification;
+import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.message.ModifyRequest;
 import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
 import org.apache.directory.shared.ldap.model.message.ModifyResponse;
@@ -101,28 +100,26 @@ public class IllegalModificationIT exten
     @Test
     public void testIllegalModification2() throws Exception
     {
-        LDAPConnection con = getWiredConnection( getLdapServer() );
+        LdapConnection con = getWiredConnection( getLdapServer() );
 
         // first a valid attribute
-        LDAPAttribute attr = new LDAPAttribute( "description", "The description" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );
+        Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "description", "The description" );
         // then an invalid one without any value
-        attr = new LDAPAttribute( "displayName" );
-        LDAPModification mod2 = new LDAPModification( LDAPModification.ADD, attr );
+        Modification mod2 = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "displayName" );
 
         try
         {
-            con.modify( "cn=Kate Bush,ou=system", new LDAPModification[]
+            con.modify( "cn=Kate Bush,ou=system", new Modification[]
                 { mod, mod2 } );
             fail( "error expected due to empty attribute value" );
         }
-        catch ( LDAPException e )
+        catch ( LdapException e )
         {
             // expected
         }
 
         // Check whether entry is unmodified, i.e. no displayName
-        LDAPEntry entry = con.read( DN );
-        assertEquals( "displayName exists?", null, entry.getAttribute( "displayName" ) );
+        Entry entry = con.lookup( DN );
+        assertEquals( "displayName exists?", null, entry.get( "displayName" ) );
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReferralIT.java Mon Sep 26 16:49:28 2011
@@ -32,21 +32,20 @@ import javax.naming.directory.DirContext
 import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.LdapContext;
 
-import netscape.ldap.LDAPAttribute;
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPConstraints;
-import netscape.ldap.LDAPControl;
-import netscape.ldap.LDAPModification;
-import netscape.ldap.LDAPResponse;
-import netscape.ldap.LDAPResponseListener;
-
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.operations.compare.CompareIT;
+import org.apache.directory.shared.ldap.model.message.ModifyRequest;
+import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.model.message.ModifyResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
+import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -118,20 +117,23 @@ public class ModifyReferralIT extends Ab
     @Test
     public void testOnReferralWithManageDsaITControl() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+        
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
+
         
         // modify success
-        LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
-        conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, constraints );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        modifyRequest.add( "description", "referral to akarasulu" );
+        modifyRequest.addControl( manageDSAIT );
         
-        assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", attribute, constraints ) );
+        conn.modify( modifyRequest );
         
-        conn.disconnect();
+        assertTrue( conn.compare( "uid=akarasuluref,ou=users,ou=system", "description", "referral to akarasulu" ) );
+        
+        conn.close();
     }
     
     
@@ -143,25 +145,23 @@ public class ModifyReferralIT extends Ab
     @Test
     public void testOnReferral() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
         
         // referrals failure
         // modify success
-        LDAPAttribute attribute = new LDAPAttribute( "description", "referral to akarasulu" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
-        LDAPResponseListener listener = conn.modify( "uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
-        LDAPResponse response = listener.getResponse();
-        
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        modifyRequest.add( "description", "referral to akarasulu" );
+        
+        ModifyResponse modifyResponse = conn.modify( modifyRequest );
 
-        conn.disconnect();
+        assertEquals( ResultCodeEnum.REFERRAL, modifyResponse.getLdapResult().getResultCode() );
+
+        assertTrue( modifyResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system" ) );
+
+        conn.close();
     }
     
     
@@ -201,24 +201,21 @@ public class ModifyReferralIT extends Ab
     {
         LOG.debug( "" );
 
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
         // referrals failure
-        LDAPAttribute attribute = new LDAPAttribute( "ou", "Machines" );
-        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attribute );
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
-
-        listener = conn.modify( "ou=Computers,uid=akarasuluref,ou=users,ou=system", mod, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setName( new Dn( "ou=Computers,uid=akarasuluref,ou=users,ou=system" ) );
+        modifyRequest.add( "ou", "Machines" );
+        
+        ModifyResponse modifyResponse = conn.modify( modifyRequest );
+
+        assertEquals( ResultCodeEnum.REFERRAL, modifyResponse.getLdapResult().getResultCode() );
+
+        assertTrue( modifyResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
 
-        conn.disconnect();
+        conn.close();
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java?rev=1175948&r1=1175947&r2=1175948&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modifydn/ModifyDnReferralIT.java Mon Sep 26 16:49:28 2011
@@ -24,26 +24,29 @@ import static org.apache.directory.serve
 import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContextThrowOnRefferal;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import javax.naming.ReferralException;
 import javax.naming.ldap.LdapContext;
 
-import netscape.ldap.LDAPConnection;
-import netscape.ldap.LDAPConstraints;
-import netscape.ldap.LDAPControl;
-import netscape.ldap.LDAPEntry;
-import netscape.ldap.LDAPException;
-import netscape.ldap.LDAPResponse;
-import netscape.ldap.LDAPResponseListener;
-import netscape.ldap.LDAPSearchConstraints;
-
+import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
+import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.model.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
+import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -110,19 +113,24 @@ public class ModifyDnReferralIT extends 
     @Test
     public void testOnReferralWithManageDsaITControl() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+        
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
         
         // ModifyDN success
-        conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
-        LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
+        ModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl();
+        modifyDnRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        modifyDnRequest.setNewRdn( new Rdn( "uid=ref" ) );
+        modifyDnRequest.setDeleteOldRdn( true );
+        modifyDnRequest.addControl( manageDSAIT );
+        
+        conn.modifyDn( modifyDnRequest );
+        Entry entry = conn.lookup( "uid=ref,ou=users,ou=system", new Control[]{ manageDSAIT } );
         assertNotNull( entry );
-        assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );
+        assertEquals( "uid=ref,ou=users,ou=system", entry.getDn().getName() );
         
-        conn.disconnect();
+        conn.close();
     }
     
     
@@ -133,24 +141,29 @@ public class ModifyDnReferralIT extends 
     @Test
     public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPSearchConstraints();
-        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
+
+        ManageDsaIT manageDSAIT = new ManageDsaITImpl();
+        manageDSAIT.setCritical( true );
         
+        ModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl();
+        modifyDnRequest.setName( new Dn( "uid=elecharny,ou=users,ou=system" ) );
+        modifyDnRequest.setNewRdn( new Rdn( "uid=newuser" ) );
+        modifyDnRequest.setNewSuperior( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        modifyDnRequest.setDeleteOldRdn( true );
+        modifyDnRequest.addControl( manageDSAIT );
+
         // ModifyDN success
         try
         {
-            conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser", 
-                "uid=akarasuluref,ou=users,ou=system", true, constraints );
+            conn.modifyDn( modifyDnRequest );
         }
-        catch ( LDAPException le )
+        catch ( LdapOperationException le )
         {
-            assertEquals ( LDAPException.AFFECTS_MULTIPLE_DSAS, le.getLDAPResultCode() );
+            assertEquals ( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS, le.getResultCode() );
         }
         
-        conn.disconnect();
+        conn.close();
     }
     
     
@@ -162,24 +175,23 @@ public class ModifyDnReferralIT extends 
     @Test
     public void testOnReferral() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
         
         // referrals failure
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
+        ModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl();
+        modifyDnRequest.setName( new Dn( "uid=akarasuluref,ou=users,ou=system" ) );
+        modifyDnRequest.setNewRdn( new Rdn( "uid=ref" ) );
+        modifyDnRequest.setDeleteOldRdn( true );
 
-        listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        ModifyDnResponse modifyDnResponse = conn.modifyDn( modifyDnRequest );
 
-        conn.disconnect();
+        assertEquals( ResultCodeEnum.REFERRAL, modifyDnResponse.getLdapResult().getResultCode() );
+
+        assertTrue( modifyDnResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyDnResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyDnResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system" ) );
+
+        conn.close();
     }
     
     
@@ -189,25 +201,21 @@ public class ModifyDnReferralIT extends 
      * non-success result code.
      */
     @Test
-    public void testNewSupierorOnReferral() throws Exception
+    public void testNewSuperiorOnReferral() throws Exception
     {
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        constraints.setReferrals( false );
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
         
         // referrals failure
         try
         {
-            conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref", 
-                "uid=akarasuluref,ou=users,ou=system", true, constraints );
+            conn.moveAndRename( "uid=elecharny,ou=users,ou=system", "uid=ref,uid=akarasuluref,ou=users,ou=system", true );
         }
-        catch ( LDAPException e )
+        catch ( LdapOperationException e )
         {
-            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+            assertEquals( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS, e.getResultCode() );
         }
 
-        conn.disconnect();
+        conn.close();
     }
     
     
@@ -245,23 +253,23 @@ public class ModifyDnReferralIT extends 
     {
         LOG.debug( "" );
 
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
         // referrals failure
-        LDAPResponseListener listener = null;
-        LDAPResponse response = null;
+        ModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl();
+        modifyDnRequest.setName( new Dn( "ou=Computers,uid=akarasuluref,ou=users,ou=system" ) );
+        modifyDnRequest.setNewRdn( new Rdn( "ou=Machines" ) );
+        modifyDnRequest.setDeleteOldRdn( true );
+
+        ModifyDnResponse modifyDnResponse = conn.modifyDn( modifyDnRequest );
+
+        assertEquals( ResultCodeEnum.REFERRAL, modifyDnResponse.getLdapResult().getResultCode() );
 
-        listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints );
-        response = listener.getResponse();
-        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );
-
-        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
-        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
-        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );
+        assertTrue( modifyDnResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyDnResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
+        assertTrue( modifyDnResponse.getLdapResult().getReferral().getLdapUrls().contains( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system" ) );
 
-        conn.disconnect();
+        conn.close();
     }
     
     
@@ -273,22 +281,19 @@ public class ModifyDnReferralIT extends 
     {
         LOG.debug( "" );
 
-        LDAPConnection conn = getWiredConnection( getLdapServer() );
-        LDAPConstraints constraints = new LDAPConstraints();
-        conn.setConstraints( constraints );
+        LdapConnection conn = getWiredConnection( getLdapServer() );
 
         // referrals failure
         try
         {
-            conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines", 
-                "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
+            conn.moveAndRename( "uid=elecharny,ou=users,ou=system", "ou=Machines,ou=Computers,uid=akarasuluref,ou=users,ou=system", true );
             fail( "Should never get here to affectsMultipleDSA error result code" );
         }
-        catch ( LDAPException e )
+        catch ( LdapOperationException e )
         {
-            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
+            assertEquals( ResultCodeEnum.AFFECTS_MULTIPLE_DSAS, e.getResultCode() );
         }
 
-        conn.disconnect();
+        conn.close();
     }
 }



Mime
View raw message