directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1101261 [1/3] - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/ core-integ/src/test/java/org/apache/directory/server/core/admin/ core-integ/src/test/java/org/apache/directory/server/core/authn/ core-i...
Date Mon, 09 May 2011 22:52:01 GMT
Author: elecharny
Date: Mon May  9 22:52:00 2011
New Revision: 1101261

URL: http://svn.apache.org/viewvc?rev=1101261&view=rev
Log:
o Applied the LdapConnection modifications to the LdapCoreSessionConnection class, and to the tests using the modified methods
o Fixed some tests that were wrong

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AuthorizationServiceAsAdminIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/CompareAuthorizationIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/DeleteAuthorizationIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/MoveRenameAuthorizationIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operational/OperationalAttributeServiceIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/bind/SimpleBindIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/compare/ComparePerfIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/subtree/SubentryServiceIT.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientCompareRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientDeleteRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/ClientSearchRequestTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConsumer.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointAddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyDelIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointModifyIT.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/DelegatedAuthIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.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/modifydn/MoveIT.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java Mon May  9 22:52:00 2011
@@ -20,6 +20,8 @@
 package org.apache.directory.server.core;
 
 
+import static org.apache.directory.shared.ldap.model.message.AbstractResponse.processResponse;
+
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Iterator;
@@ -135,7 +137,7 @@ public class LdapCoreSessionConnection i
         messageId.incrementAndGet();
     }
 
-
+    
     /**
      * {@inheritDoc}
      */
@@ -209,7 +211,7 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public AddResponse add( Entry entry ) throws LdapException
+    public void add( Entry entry ) throws LdapException
     {
         if ( entry == null )
         {
@@ -220,8 +222,11 @@ public class LdapCoreSessionConnection i
 
         AddRequest addRequest = new AddRequestImpl();
         addRequest.setEntry( entry );
+        addRequest.setEntryDn( entry.getDn() );
 
-        return add( addRequest );
+        AddResponse addResponse = add( addRequest );
+        
+        processResponse( addResponse );
     }
 
 
@@ -258,35 +263,39 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public CompareResponse compare( Dn dn, String attributeName, byte[] value ) throws LdapException
+    public boolean compare( Dn dn, String attributeName, byte[] value ) throws LdapException
     {
         CompareRequest compareRequest = new CompareRequestImpl();
         compareRequest.setName( dn );
         compareRequest.setAttributeId( attributeName );
         compareRequest.setAssertionValue( value );
 
-        return compare( compareRequest );
+        CompareResponse compareResponse = compare( compareRequest );
+
+        return processResponse( compareResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public CompareResponse compare( Dn dn, String attributeName, String value ) throws LdapException
+    public boolean compare( Dn dn, String attributeName, String value ) throws LdapException
     {
         CompareRequest compareRequest = new CompareRequestImpl();
         compareRequest.setName( dn );
         compareRequest.setAttributeId( attributeName );
         compareRequest.setAssertionValue( value );
 
-        return compare( compareRequest );
+        CompareResponse compareResponse = compare( compareRequest );
+
+        return processResponse( compareResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public CompareResponse compare( String dn, String attributeName, byte[] value ) throws LdapException
+    public boolean compare( String dn, String attributeName, byte[] value ) throws LdapException
     {
         return compare( new Dn( schemaManager, dn ), attributeName, value );
     }
@@ -295,7 +304,7 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public CompareResponse compare( String dn, String attributeName, String value ) throws LdapException
+    public boolean compare( String dn, String attributeName, String value ) throws LdapException
     {
         return compare( new Dn( schemaManager, dn ), attributeName, value );
     }
@@ -304,7 +313,7 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public CompareResponse compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
+    public boolean compare( Dn dn, String attributeName, Value<?> value ) throws LdapException
     {
         CompareRequest compareRequest = new CompareRequestImpl();
         compareRequest.setName( dn );
@@ -319,14 +328,16 @@ public class LdapCoreSessionConnection i
             compareRequest.setAssertionValue( value.getBytes() );
         }
 
-        return compare( compareRequest );
+        CompareResponse compareResponse = compare( compareRequest );
+
+        return processResponse( compareResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public CompareResponse compare( String dn, String attributeName, Value<?> value ) throws LdapException
+    public boolean compare( String dn, String attributeName, Value<?> value ) throws LdapException
     {
         return compare( new Dn( schemaManager, dn ), attributeName, value );
     }
@@ -370,21 +381,23 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public DeleteResponse delete( Dn dn ) throws LdapException
+    public void delete( Dn dn ) throws LdapException
     {
         DeleteRequest deleteRequest = new DeleteRequestImpl();
         deleteRequest.setName( dn );
 
-        return delete( deleteRequest );
+        DeleteResponse deleteResponse = delete( deleteRequest );
+
+        processResponse( deleteResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public DeleteResponse delete( String dn ) throws LdapException
+    public void delete( String dn ) throws LdapException
     {
-        return delete( new Dn( schemaManager, dn ) );
+        delete( new Dn( schemaManager, dn ) );
     }
 
 
@@ -572,7 +585,7 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public ModifyResponse modify( Dn dn, Modification... modifications ) throws LdapException
+    public void modify( Dn dn, Modification... modifications ) throws LdapException
     {
         if ( dn == null )
         {
@@ -589,49 +602,35 @@ public class LdapCoreSessionConnection i
 
         int newId = messageId.incrementAndGet();
 
-        ModifyResponse resp = new ModifyResponseImpl( newId );
-        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setMessageId( newId );
 
-        ModifyRequest iModReq = new ModifyRequestImpl();
-        iModReq.setMessageId( newId );
+        modifyRequest.setName( dn );
 
-        try
+        for ( Modification modification : modifications )
         {
-            iModReq.setName( dn );
-
-            for ( Modification modification : modifications )
-            {
-                iModReq.addModification( modification );
-            }
-
-            session.modify( iModReq );
+            modifyRequest.addModification( modification );
         }
-        catch ( LdapException e )
-        {
-            LOG.warn( e.getMessage(), e );
 
-            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
-            resp.getLdapResult().setDiagnosticMessage( e.getMessage() );
-        }
+        ModifyResponse modifyResponse = modify( modifyRequest );
 
-        addResponseControls( iModReq, resp );
-        return resp;
+        processResponse( modifyResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyResponse modify( String dn, Modification... modifications ) throws LdapException
+    public void modify( String dn, Modification... modifications ) throws LdapException
     {
-        return modify( new Dn( schemaManager, dn ), modifications );
+        modify( new Dn( schemaManager, dn ), modifications );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyResponse modify( Entry entry, ModificationOperation modOp ) throws LdapException
+    public void modify( Entry entry, ModificationOperation modOp ) throws LdapException
     {
         if ( entry == null )
         {
@@ -640,34 +639,22 @@ public class LdapCoreSessionConnection i
         }
 
         int newId = messageId.incrementAndGet();
-        ModifyResponse resp = new ModifyResponseImpl( newId );
-        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+        ModifyRequest modifyRequest = new ModifyRequestImpl();
+        modifyRequest.setMessageId( newId );
 
-        ModifyRequest iModReq = new ModifyRequestImpl();
-        iModReq.setMessageId( newId );
+        modifyRequest.setName( entry.getDn() );
 
-        try
+        Iterator<Attribute> itr = entry.iterator();
+        
+        while ( itr.hasNext() )
         {
-            iModReq.setName( entry.getDn() );
-
-            Iterator<Attribute> itr = entry.iterator();
-            while ( itr.hasNext() )
-            {
-                iModReq.addModification( new DefaultModification( modOp, itr.next() ) );
-            }
-
-            session.modify( iModReq );
+            modifyRequest.addModification( new DefaultModification( modOp, itr.next() ) );
         }
-        catch ( LdapException e )
-        {
-            LOG.warn( e.getMessage(), e );
 
-            resp.getLdapResult().setResultCode( ResultCodeEnum.getResultCode( e ) );
-            resp.getLdapResult().setDiagnosticMessage( e.getMessage() );
-        }
+        
+        ModifyResponse modifyResponse = modify( modifyRequest );
 
-        addResponseControls( iModReq, resp );
-        return resp;
+        processResponse( modifyResponse );
     }
 
 
@@ -702,6 +689,7 @@ public class LdapCoreSessionConnection i
         }
 
         addResponseControls( modRequest, resp );
+        
         return resp;
     }
 
@@ -787,7 +775,7 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
+    public void move( Dn entryDn, Dn newSuperiorDn ) throws LdapException
     {
         if ( entryDn == null )
         {
@@ -807,14 +795,15 @@ public class LdapCoreSessionConnection i
         iModDnReq.setName( entryDn );
         iModDnReq.setNewSuperior( newSuperiorDn );
 
-        return modifyDn( iModDnReq );
+        ModifyDnResponse modifyDnResponse = modifyDn( iModDnReq );
+        processResponse( modifyDnResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse move( String entryDn, String newSuperiorDn ) throws LdapException
+    public void move( String entryDn, String newSuperiorDn ) throws LdapException
     {
         if ( entryDn == null )
         {
@@ -830,14 +819,14 @@ public class LdapCoreSessionConnection i
             throw new IllegalArgumentException( msg );
         }
 
-        return move( new Dn( schemaManager, entryDn ), new Dn( schemaManager, newSuperiorDn ) );
+        move( new Dn( schemaManager, entryDn ), new Dn( schemaManager, newSuperiorDn ) );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
+    public void rename( Dn entryDn, Rdn newRdn, boolean deleteOldRdn ) throws LdapException
     {
         if ( entryDn == null )
         {
@@ -853,37 +842,39 @@ public class LdapCoreSessionConnection i
             throw new IllegalArgumentException( msg );
         }
 
-        ModifyDnRequest iModDnReq = new ModifyDnRequestImpl();
-        iModDnReq.setName( entryDn );
-        iModDnReq.setNewRdn( newRdn );
-        iModDnReq.setDeleteOldRdn( deleteOldRdn );
+        ModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl();
+        modifyDnRequest.setName( entryDn );
+        modifyDnRequest.setNewRdn( newRdn );
+        modifyDnRequest.setDeleteOldRdn( deleteOldRdn );
+
+        ModifyDnResponse modifyDnResponse = modifyDn( modifyDnRequest );
+        processResponse( modifyDnResponse );
 
-        return modifyDn( iModDnReq );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse rename( Dn entryDn, Rdn newRdn ) throws LdapException
+    public void rename( Dn entryDn, Rdn newRdn ) throws LdapException
     {
-        return rename( entryDn, newRdn, false );
+        rename( entryDn, newRdn, false );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
+    public void rename( String entryDn, String newRdn, boolean deleteOldRdn ) throws LdapException
     {
-        return rename( new Dn( schemaManager, entryDn ), new Rdn( newRdn ), deleteOldRdn );
+        rename( new Dn( schemaManager, entryDn ), new Rdn( newRdn ), deleteOldRdn );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse rename( String entryDn, String newRdn ) throws LdapException
+    public void rename( String entryDn, String newRdn ) throws LdapException
     {
         if ( entryDn == null )
         {
@@ -899,7 +890,7 @@ public class LdapCoreSessionConnection i
             throw new IllegalArgumentException( msg );
         }
 
-        return rename( new Dn( schemaManager, entryDn ), new Rdn( newRdn ) );
+        rename( new Dn( schemaManager, entryDn ), new Rdn( newRdn ) );
     }
 
 
@@ -908,9 +899,9 @@ public class LdapCoreSessionConnection i
      *
      * @see #moveAndRename(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Dn, boolean)
      */
-    public ModifyDnResponse moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
+    public void moveAndRename( Dn entryDn, Dn newDn ) throws LdapException
     {
-        return moveAndRename( entryDn, newDn, true );
+        moveAndRename( entryDn, newDn, true );
     }
 
 
@@ -919,9 +910,9 @@ public class LdapCoreSessionConnection i
      *
      * @see #moveAndRename(org.apache.directory.shared.ldap.model.name.Dn, org.apache.directory.shared.ldap.model.name.Dn, boolean)
      */
-    public ModifyDnResponse moveAndRename( String entryDn, String newDn ) throws LdapException
+    public void moveAndRename( String entryDn, String newDn ) throws LdapException
     {
-        return moveAndRename( new Dn( schemaManager, entryDn ), new Dn( schemaManager, newDn ), true );
+        moveAndRename( new Dn( schemaManager, entryDn ), new Dn( schemaManager, newDn ), true );
     }
 
 
@@ -932,7 +923,7 @@ public class LdapCoreSessionConnection i
      * @param newDn The new Entry Dn
      * @param deleteOldRdn Tells if the old Rdn must be removed
      */
-    public ModifyDnResponse moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
+    public void moveAndRename( Dn entryDn, Dn newDn, boolean deleteOldRdn ) throws LdapException
     {
         // Check the parameters first
         if ( entryDn == null )
@@ -958,14 +949,15 @@ public class LdapCoreSessionConnection i
         ModifyDnResponse resp = new ModifyDnResponseImpl();
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
 
-        ModifyDnRequest iModDnReq = new ModifyDnRequestImpl();
+        ModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl();
 
-        iModDnReq.setName( entryDn );
-        iModDnReq.setNewRdn( newDn.getRdn() );
-        iModDnReq.setNewSuperior( newDn.getParent() );
-        iModDnReq.setDeleteOldRdn( deleteOldRdn );
+        modifyDnRequest.setName( entryDn );
+        modifyDnRequest.setNewRdn( newDn.getRdn() );
+        modifyDnRequest.setNewSuperior( newDn.getParent() );
+        modifyDnRequest.setDeleteOldRdn( deleteOldRdn );
 
-        return modifyDn( iModDnReq );
+        ModifyDnResponse modifyDnResponse = modifyDn( modifyDnRequest );
+        processResponse( modifyDnResponse );
     }
 
 
@@ -976,9 +968,9 @@ public class LdapCoreSessionConnection i
      * @param newDn The new Entry Dn
      * @param deleteOldRdn Tells if the old Rdn must be removed
      */
-    public ModifyDnResponse moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
+    public void moveAndRename( String entryDn, String newDn, boolean deleteOldRdn ) throws LdapException
     {
-        return moveAndRename( new Dn( schemaManager, entryDn ), new Dn( schemaManager, newDn ), deleteOldRdn );
+        moveAndRename( new Dn( schemaManager, entryDn ), new Dn( schemaManager, newDn ), deleteOldRdn );
     }
 
 
@@ -1149,13 +1141,15 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public BindResponse bind() throws LdapException, IOException
+    public void bind() throws LdapException, IOException
     {
-        BindRequest bindReq = new BindRequestImpl();
-        bindReq.setName( Dn.EMPTY_DN );
-        bindReq.setCredentials( ( byte[] ) null );
+        BindRequest bindRequest = new BindRequestImpl();
+        bindRequest.setName( Dn.EMPTY_DN );
+        bindRequest.setCredentials( ( byte[] ) null );
+
+        BindResponse bindResponse = bind( bindRequest );
 
-        return bind( bindReq );
+        processResponse( bindResponse );
     }
 
 
@@ -1209,48 +1203,52 @@ public class LdapCoreSessionConnection i
     /**
      * {@inheritDoc}
      */
-    public BindResponse bind( Dn name ) throws LdapException, IOException
+    public void bind( Dn name ) throws LdapException, IOException
     {
         byte[] credBytes = StringConstants.EMPTY_BYTES;
 
-        BindRequest bindReq = new BindRequestImpl();
-        bindReq.setName( name );
-        bindReq.setCredentials( credBytes );
+        BindRequest bindRequest = new BindRequestImpl();
+        bindRequest.setName( name );
+        bindRequest.setCredentials( credBytes );
 
-        return bind( bindReq );
+        BindResponse bindResponse = bind( bindRequest );
+
+        processResponse( bindResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public BindResponse bind( Dn name, String credentials ) throws LdapException, IOException
+    public void bind( Dn name, String credentials ) throws LdapException, IOException
     {
         byte[] credBytes = ( credentials == null ? StringConstants.EMPTY_BYTES : Strings.getBytesUtf8(credentials) );
 
-        BindRequest bindReq = new BindRequestImpl();
-        bindReq.setName( name );
-        bindReq.setCredentials( credBytes );
+        BindRequest bindRequest = new BindRequestImpl();
+        bindRequest.setName( name );
+        bindRequest.setCredentials( credBytes );
+
+        BindResponse bindResponse = bind( bindRequest );
 
-        return bind( bindReq );
+        processResponse( bindResponse );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public BindResponse bind( String name ) throws LdapException, IOException
+    public void bind( String name ) throws LdapException, IOException
     {
-        return bind( new Dn( schemaManager, name ), null );
+        bind( new Dn( schemaManager, name ), null );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public BindResponse bind( String name, String credentials ) throws LdapException, IOException
+    public void bind( String name, String credentials ) throws LdapException, IOException
     {
-        return bind( new Dn( schemaManager, name ), credentials );
+        bind( new Dn( schemaManager, name ), credentials );
     }
 
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java Mon May  9 22:52:00 2011
@@ -20,10 +20,10 @@
 package org.apache.directory.server.core.admin;
 
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.CreateDS;
@@ -36,10 +36,9 @@ import org.apache.directory.shared.ldap.
 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.message.AddResponse;
-import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
-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.exception.LdapAttributeInUseException;
+import org.apache.directory.shared.ldap.model.exception.LdapNoSuchAttributeException;
+import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -103,9 +102,9 @@ public class AdministrativePointServiceI
             "administrativeRole: autonomousArea" );
 
         // It should succeed
-        AddResponse response = connection.add( autonomousArea );
+        connection.add( autonomousArea );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        assertTrue( connection.exists( "ou=autonomousArea, ou=system" ) );
 
         // Check that the entry is containing all the roles
         Entry entry = getAdminRole( "ou=autonomousArea, ou=system" );
@@ -128,9 +127,15 @@ public class AdministrativePointServiceI
             "administrativeRole: TRIGGEREXECUTIONSPECIFICAREA" );
 
         // It should fail, as an autonomous area is already defining the specific areas
-        response = connection.add( autonomousArea );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.add( autonomousArea );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -149,9 +154,9 @@ public class AdministrativePointServiceI
             "administrativeRole: accessControlSpecificArea",
             "administrativeRole: TRIGGEREXECUTIONSPECIFICAREA" );
 
-        AddResponse response = connection.add( autonomousArea );
+        connection.add( autonomousArea );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        assertTrue( connection.exists( "ou=autonomousArea, ou=system" ) );
 
         // Check that the entry is containing all the roles
         Entry entry = getAdminRole( "ou=autonomousArea, ou=system" );
@@ -179,9 +184,9 @@ public class AdministrativePointServiceI
             "administrativeRole: accessControlINNERArea",
             "administrativeRole: TRIGGEREXECUTIONINNERAREA" );
 
-        AddResponse response = connection.add( autonomousArea );
+        connection.add( autonomousArea );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
+        assertTrue( connection.exists( "ou=autonomousArea, ou=system" ) );
 
         // Check that the entry is containing all the roles
         Entry entry = getAdminRole( "ou=autonomousArea, ou=system" );
@@ -207,9 +212,15 @@ public class AdministrativePointServiceI
             "administrativeRole: accessControlBadArea",
             "administrativeRole: TRIGGEREXECUTIONINNERAREA" );
 
-        AddResponse response = connection.add( autonomousArea );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.add( autonomousArea );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -228,9 +239,15 @@ public class AdministrativePointServiceI
             "administrativeRole: accessControlSpecificArea",
             "administrativeRole: accessControlInnerArea" );
 
-        AddResponse response = connection.add( autonomousArea );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.add( autonomousArea );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
     
     
@@ -250,9 +267,15 @@ public class AdministrativePointServiceI
             "administrativeRole: 2.5.23.1" );
 
         // It should not succeed
-        AddResponse response = connection.add( autonomousArea );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.add( autonomousArea );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -279,9 +302,8 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "accessControlSpecificArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
+        connection.modify( "ou=caArea, ou=system", modification );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         Entry entry = getAdminRole( "ou=caArea, ou=system" );
 
         assertTrue( entry.contains( "administrativeRole", "accessControlSpecificArea" ) );
@@ -309,9 +331,8 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "accessControlInnerArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
+        connection.modify( "ou=caArea, ou=system", modification );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         Entry entry = getAdminRole( "ou=caArea, ou=system" );
 
         assertTrue( entry.contains( "administrativeRole", "collectiveAttributeSpecificArea" ) );
@@ -339,9 +360,16 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "collectiveAttributeInnerArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        
+        try
+        {
+            connection.modify( "ou=caArea, ou=system", modification );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -365,9 +393,16 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "collectiveAttributeSpecificArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
-
-        assertEquals( ResultCodeEnum.ATTRIBUTE_OR_VALUE_EXISTS, response.getLdapResult().getResultCode() );
+        
+        try
+        {
+            connection.modify( "ou=caArea, ou=system", modification );
+            fail();
+        }
+        catch ( LdapAttributeInUseException lnsae )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -392,9 +427,8 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
+        connection.modify( "ou=caArea, ou=system", modification );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         Entry entry = getAdminRole( "ou=caArea, ou=system" );
 
         assertFalse( entry.containsAttribute( "administrativeRole" ) );
@@ -423,9 +457,8 @@ public class AdministrativePointServiceI
         Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "collectiveAttributeSpecificArea",
                 "accessControlSpecificArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
+        connection.modify( "ou=caArea, ou=system", modification );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         Entry entry = getAdminRole( "ou=caArea, ou=system" );
 
         assertFalse( entry.containsAttribute( "administrativeRole" ) );
@@ -453,9 +486,8 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "accessControlSpecificArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
+        connection.modify( "ou=caArea, ou=system", modification );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         Entry entry = getAdminRole( "ou=caArea, ou=system" );
 
         assertTrue( entry.containsAttribute( "administrativeRole" ) );
@@ -485,9 +517,16 @@ public class AdministrativePointServiceI
         // Add another specific area
         Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "triggerExecutionSpecificArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
-
-        assertEquals( ResultCodeEnum.NO_SUCH_ATTRIBUTE, response.getLdapResult().getResultCode() );
+        
+        try
+        {
+            connection.modify( "ou=caArea, ou=system", modification );
+            fail();
+        }
+        catch ( LdapNoSuchAttributeException lnsae )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -515,10 +554,8 @@ public class AdministrativePointServiceI
         Modification modification2 = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "triggerExecutionSpecificArea" ) );
 
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification1, modification2,
-            modification1 );
+        connection.modify( "ou=caArea, ou=system", modification1, modification2, modification1 );
 
-        assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
         Entry entry = getAdminRole( "ou=caArea, ou=system" );
 
         assertTrue( entry.containsAttribute( "administrativeRole" ) );
@@ -548,10 +585,16 @@ public class AdministrativePointServiceI
         // Try to modify it to an InnerArea
         Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
             new DefaultAttribute( "administrativeRole", "collectiveAttributeSpecificArea" ) );
-        ModifyResponse response = connection.modify( "ou=caArea, ou=system", modification );
-
-        // Should fail
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        
+        try
+        {
+            connection.modify( "ou=caArea, ou=system", modification );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -576,9 +619,15 @@ public class AdministrativePointServiceI
         connection.add( autonomousArea );
 
         // It should fail, as we haven't injected all the roles
-        ModifyDnResponse response = connection.move( "ou=autonomousArea, ou=system", "uid=admin, ou=system" );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.move( "ou=autonomousArea, ou=system", "uid=admin, ou=system" );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -603,10 +652,15 @@ public class AdministrativePointServiceI
         connection.add( autonomousArea );
 
         // It should fail, as we haven't injected all the roles
-        ModifyDnResponse response = connection.moveAndRename( "ou=autonomousArea, ou=system",
-            "ou=new autonomousArea, uid=admin, ou=system" );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.moveAndRename( "ou=autonomousArea, ou=system", "ou=new autonomousArea, uid=admin, ou=system" );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 
 
@@ -631,8 +685,14 @@ public class AdministrativePointServiceI
         connection.add( autonomousArea );
 
         // It should fail, as we haven't injected all the roles
-        ModifyDnResponse response = connection.rename( "ou=autonomousArea, ou=system", "ou=new autonomousArea" );
-
-        assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode() );
+        try
+        {
+            connection.rename( "ou=autonomousArea, ou=system", "ou=new autonomousArea" );
+            fail();
+        }
+        catch ( LdapUnwillingToPerformException lutpe )
+        {
+            assertTrue( true );
+        }
     }
 }

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/SimpleAuthenticationIT.java Mon May  9 22:52:00 2011
@@ -23,9 +23,9 @@ package org.apache.directory.server.core
 import static org.apache.directory.server.core.integ.IntegrationUtils.apply;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getConnectionAs;
 import static org.apache.directory.server.core.integ.IntegrationUtils.getUserAddLdif;
-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 org.apache.commons.lang.ArrayUtils;
 import org.apache.directory.ldap.client.api.LdapConnection;
@@ -33,12 +33,11 @@ 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.server.core.integ.IntegrationUtils;
-import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
-import org.apache.directory.shared.ldap.model.message.BindResponse;
+import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationException;
 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.ResultCodeEnum;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
 import org.junit.After;
@@ -210,8 +209,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // close and try again now with new password (should succeed)
         connection.bind( userDn, "newpwd" );
@@ -261,8 +267,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // try again now with new password (should be successful)
         connection.bind( userDn, "secret" );
@@ -303,8 +316,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // try again now with new password (should be successful)
         connection.bind( userDn, "secret" );
@@ -343,8 +363,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // try again now with new password (should be successful)
         connection.bind( userDn, "test123" );
@@ -383,8 +410,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // try again now with new password (should be successful)
         connection.bind( userDn, "secret" );
@@ -424,8 +458,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // try again now with new password (should be successful)
         connection.bind( userDn, "secret" );
@@ -464,8 +505,15 @@ public class SimpleAuthenticationIT exte
         // close and try with old password (should fail)
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
 
         // try again now with new password (should be successful)
         connection.bind( userDn, "secret" );
@@ -503,7 +551,14 @@ public class SimpleAuthenticationIT exte
         connection.modify( modReq );
         connection.close();
 
-        BindResponse bindResp = connection.bind( userDn, "test" );
-        assertEquals( ResultCodeEnum.INVALID_CREDENTIALS, bindResp.getLdapResult().getResultCode() );
+        try
+        {
+            connection.bind( userDn, "test" );
+            fail();
+        }
+        catch ( LdapAuthenticationException lae )
+        {
+            assertTrue( true );
+        }
     }
 }

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AddAuthorizationIT.java Mon May  9 22:52:00 2011
@@ -34,8 +34,6 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.message.AddResponse;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
@@ -86,27 +84,20 @@ public class AddAuthorizationIT extends 
     {
         LdapConnection connection = null;
 
-        try
-        {
-            Dn userName = new Dn( "uid=" + uid + ",ou=users,ou=system" );
-            connection = getConnectionAs( userName, password );
-
-            Entry entry = new DefaultEntry( new Dn( "ou=system" ).add( entryRdn ) );
-            entry.add( "ou", "testou" );
-            entry.add( "ObjectClass", "top", "organizationalUnit" );
-
-            AddResponse resp = connection.add( entry );
-
-            if ( resp.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
-            {
-                return false;
-            }
+        Dn userName = new Dn( "uid=" + uid + ",ou=users,ou=system" );
+        connection = getConnectionAs( userName, password );
 
-            connection.delete( entry.getDn() );
+        String entryDn = entryRdn + ",ou=system";
+        Entry entry = new DefaultEntry( entryDn );
+        entry.add( "ou", "testou" );
+        entry.add( "ObjectClass", "top", "organizationalUnit" );
 
+        try
+        {
+            connection.add( entry );
             return true;
         }
-        catch ( LdapException e )
+        catch ( LdapException le )
         {
             return false;
         }
@@ -163,7 +154,7 @@ public class AddAuthorizationIT extends 
         addUserToGroup( "billyd", "Administrators" );
 
         // try an add operation which should succeed with ACI and group membership change
-        assertTrue( checkCanAddEntryAs( "billyd", "billyd", "ou=testou" ) );
+        assertTrue( checkCanAddEntryAs( "billyd", "billyd", "ou=testou1" ) );
 
         // Now, make sure the ACI is persisted if we stop and restart the server
         // Stop the server now, we will restart it immediately 
@@ -177,7 +168,7 @@ public class AddAuthorizationIT extends 
         assertTrue( getService().isStarted() );
 
         // try an add operation which should succeed with ACI and group membership change
-        assertTrue( checkCanAddEntryAs( "billyd", "billyd", "ou=testou" ) );
+        assertTrue( checkCanAddEntryAs( "billyd", "billyd", "ou=testou2" ) );
     }
 
 
@@ -198,21 +189,21 @@ public class AddAuthorizationIT extends 
         // now add a subentry that enables user billyd to add an entry below ou=system
         createAccessControlSubentry( "billydAdd",
             "{ " +
-                "  identificationTag \"addAci\", " +
-                "  precedence 14, " +
-                "  authenticationLevel none, " +
-                "  itemOrUserFirst userFirst: " +
-                "  { " +
-                "    userClasses { name { \"uid=billyd,ou=users,ou=system\" } }, " +
-                "    userPermissions " +
-                "    { " +
-                "      { " +
-                "        protectedItems {entry, allUserAttributeTypesAndValues}, " +
-                "        grantsAndDenials { grantAdd, grantBrowse } " +
-                "      } " +
-                "    } " +
-                "  } " +
-                "}" );
+            "  identificationTag \"addAci\", " +
+            "  precedence 14, " +
+            "  authenticationLevel none, " +
+            "  itemOrUserFirst userFirst: " +
+            "  { " +
+            "    userClasses { name { \"uid=billyd,ou=users,ou=system\" } }, " +
+            "    userPermissions " +
+            "    { " +
+            "      { " +
+            "        protectedItems {entry, allUserAttributeTypesAndValues}, " +
+            "        grantsAndDenials { grantAdd, grantBrowse } " +
+            "      } " +
+            "    } " +
+            "  } " +
+            "}" );
 
         // should work now that billyd is authorized by name
         assertTrue( checkCanAddEntryAs( "billyd", "billyd", "ou=testou" ) );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AuthorizationServiceAsAdminIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AuthorizationServiceAsAdminIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AuthorizationServiceAsAdminIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AuthorizationServiceAsAdminIT.java Mon May  9 22:52:00 2011
@@ -36,12 +36,10 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.cursor.Cursor;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.message.DeleteResponse;
-import org.apache.directory.shared.ldap.model.message.ModifyDnResponse;
+import org.apache.directory.shared.ldap.model.exception.LdapNoPermissionException;
 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.Response;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.model.message.SearchResultEntry;
 import org.apache.directory.shared.ldap.model.message.SearchScope;
 import org.apache.directory.shared.ldap.model.name.Dn;
@@ -83,11 +81,10 @@ public class AuthorizationServiceAsAdmin
      *
      * @throws Exception if there are problems
      */
-    @Test
+    @Test( expected=LdapNoPermissionException.class )
     public void testNoDeleteOnAdminByAdmin() throws Exception
     {
-        DeleteResponse delResp = getAdminConnection().delete( "uid=admin,ou=system" );
-        assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, delResp.getLdapResult().getResultCode() );
+        getAdminConnection().delete( "uid=admin,ou=system" );
     }
 
 
@@ -96,11 +93,10 @@ public class AuthorizationServiceAsAdmin
      *
      * @throws Exception if there are problems
      */
-    @Test
+    @Test( expected=LdapNoPermissionException.class )
     public void testNoRdnChangesOnAdminByAdmin() throws Exception
     {
-        ModifyDnResponse resp = getAdminConnection().rename( new Dn( "uid=admin,ou=system" ), new Rdn( "uid=alex" ) );
-        assertEquals( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS, resp.getLdapResult().getResultCode() );
+        getAdminConnection().rename( new Dn( "uid=admin,ou=system" ), new Rdn( "uid=alex" ) );
     }
 
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java Mon May  9 22:52:00 2011
@@ -20,12 +20,16 @@
 package org.apache.directory.server.core.authz;
 
 
+import static org.junit.Assert.assertTrue;
+
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+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.ModifyRequest;
 import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
@@ -136,6 +140,7 @@ public class AutzIntegUtils
             "userPassword", password );
 
         connection.add( entry );
+        assertTrue( connection.exists(  entry.getDn() ) );
 
         return entry.getDn();
     }
@@ -260,9 +265,11 @@ public class AutzIntegUtils
             "subtreeSpecification", subtree,
             "prescriptiveACI", aciItem );
 
-        AddResponse addResp = connection.add( subEntry );
+        AddRequest addRequest = new AddRequestImpl();
+        addRequest.setEntry( subEntry );
+        AddResponse addResponse = connection.add( addRequest );
 
-        return addResp.getLdapResult().getResultCode();
+        return addResponse.getLdapResult().getResultCode();
     }
 
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/CompareAuthorizationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/CompareAuthorizationIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/CompareAuthorizationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/CompareAuthorizationIT.java Mon May  9 22:52:00 2011
@@ -25,7 +25,6 @@ import static org.apache.directory.serve
 import static org.apache.directory.server.core.authz.AutzIntegUtils.createUser;
 import static org.apache.directory.server.core.authz.AutzIntegUtils.getAdminConnection;
 import static org.apache.directory.server.core.authz.AutzIntegUtils.getConnectionAs;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
@@ -36,8 +35,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-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.exception.LdapNoPermissionException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
@@ -93,7 +91,6 @@ public class CompareAuthorizationIT exte
     {
 
         Dn entryDn = new Dn( service.getSchemaManager(), entryRdn + ",ou=system" );
-        boolean result = true;
 
         // create the entry with the telephoneNumber attribute to compare
         Entry testEntry = new DefaultEntry( 
@@ -112,16 +109,20 @@ public class CompareAuthorizationIT exte
         Dn userName = new Dn( "uid=" + uid + ",ou=users,ou=system" );
         // compare the telephone numbers
         LdapConnection userConnection = getConnectionAs( userName, password );
-        CompareResponse resp = userConnection.compare( entryDn, "telephoneNumber", number );
-
-        // don't set based on compare result success/failure but based on whether the op was permitted or not
-        if ( resp.getLdapResult().getResultCode() == ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS )
+        boolean result = true;
+        
+        try
+        {  
+            // don't set based on compare result success/failure but based on whether the op was permitted or not
+            result = userConnection.compare( entryDn, "telephoneNumber", number );
+        }
+        catch ( LdapNoPermissionException lnpe )
         {
             result = false;
         }
 
         // let's clean up
-        adminConnection.delete( entryRdn );
+        adminConnection.delete( entryDn );
 
         return result;
     }
@@ -277,8 +278,6 @@ public class CompareAuthorizationIT exte
 
         adminCtx.add( user );
 
-        CompareResponse resp = adminCtx.compare( userDn, "userPassword", "bobspassword" );
-        assertEquals( ResultCodeEnum.COMPARE_TRUE, resp.getLdapResult().getResultCode() );
+        assertTrue( adminCtx.compare( userDn, "userPassword", "bobspassword" ) );
     }
-
 }

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/DeleteAuthorizationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/DeleteAuthorizationIT.java?rev=1101261&r1=1101260&r2=1101261&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/DeleteAuthorizationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authz/DeleteAuthorizationIT.java Mon May  9 22:52:00 2011
@@ -36,8 +36,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-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.exception.LdapNoPermissionException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.After;
 import org.junit.Before;
@@ -107,17 +106,18 @@ public class DeleteAuthorizationIT exten
 
         // delete the newly created context as the user
         LdapConnection userConnection = getConnectionAs( userName, password );
-        DeleteResponse resp = userConnection.delete(entryDn);
-
-        if ( resp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+        
+        try
         {
-            return true;
+            userConnection.delete( entryDn );
         }
-        else
+        catch ( LdapNoPermissionException lnpe )
         {
             adminConnection.delete(entryDn);
             return false;
         }
+
+        return true;
     }
 
 



Mime
View raw message