directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r980603 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
Date Thu, 29 Jul 2010 23:03:41 GMT
Author: elecharny
Date: Thu Jul 29 23:03:41 2010
New Revision: 980603

URL: http://svn.apache.org/viewvc?rev=980603&view=rev
Log:
Added code and tests for move, rename and move&rename methods. atm, it just throw an UnwillingToPerform
exception when applied on AdminsitrativePoint. 

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/admin/AdministrativePointServiceIT.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java

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=980603&r1=980602&r2=980603&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
Thu Jul 29 23:03:41 2010
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertTru
 
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.message.AddResponse;
+import org.apache.directory.ldap.client.api.message.ModifyDnResponse;
 import org.apache.directory.ldap.client.api.message.SearchResponse;
 import org.apache.directory.ldap.client.api.message.SearchResultEntry;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
@@ -66,6 +67,9 @@ public class AdministrativePointServiceI
     }
 
 
+    // -------------------------------------------------------------------
+    // Test the Add operation
+    // -------------------------------------------------------------------
     /**
      * Test the addition of an autonomous area
      * @throws Exception
@@ -73,9 +77,6 @@ public class AdministrativePointServiceI
     @Test
     public void testAddAutonomousArea() throws Exception
     {
-        // -------------------------------------------------------------------
-        // Inject an AA alone
-        // -------------------------------------------------------------------
         Entry autonomousArea = LdifUtils.createEntry(
             "ou=autonomousArea, ou=system",
             "ObjectClass: top",
@@ -84,7 +85,7 @@ public class AdministrativePointServiceI
             "administrativeRole: autonomousArea"
             );
 
-        // It should fail, as we haven't injected all the roles
+        // It should succeed
         AddResponse response = connection.add( autonomousArea );
 
         assertEquals( ResultCodeEnum.SUCCESS, response.getLdapResult().getResultCode() );
@@ -102,9 +103,6 @@ public class AdministrativePointServiceI
         assertFalse( result.contains( "administrativeRole", "2.5.23.4" ) );
         assertFalse( result.contains( "administrativeRole", "triggerExecutionSpecificArea"
) );
 
-        // -------------------------------------------------------------------
-        // Inject a AA with specific A
-        // -------------------------------------------------------------------
         autonomousArea = LdifUtils.createEntry(
             "ou=autonomousArea2, ou=system",
             "ObjectClass: top",
@@ -234,4 +232,91 @@ public class AdministrativePointServiceI
 
         assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, response.getLdapResult().getResultCode()
);
     }
+
+
+    // -------------------------------------------------------------------
+    // Test the Modify operation
+    // -------------------------------------------------------------------
+    // -------------------------------------------------------------------
+    // Test the Move operation
+    // -------------------------------------------------------------------
+    /**
+     * Test the move of an autonomous area
+     * @throws Exception
+     */
+    @Test
+    public void testMoveAutonomousArea() throws Exception
+    {
+        // Inject an AAA
+        Entry autonomousArea = LdifUtils.createEntry(
+            "ou=autonomousArea, ou=system",
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit",
+            "ou: autonomousArea",
+            "administrativeRole: autonomousArea"
+            );
+
+        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()
);
+    }
+
+
+    // -------------------------------------------------------------------
+    // Test the Move And Rename operation
+    // -------------------------------------------------------------------
+    /**
+     * Test the move and rename of an autonomous area
+     * @throws Exception
+     */
+    @Test
+    public void testMoveAndRenameAutonomousArea() throws Exception
+    {
+        // Inject an AAA
+        Entry autonomousArea = LdifUtils.createEntry(
+            "ou=autonomousArea, ou=system",
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit",
+            "ou: autonomousArea",
+            "administrativeRole: autonomousArea"
+            );
+
+        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()
);
+    }
+
+
+    // -------------------------------------------------------------------
+    // Test the Rename operation
+    // -------------------------------------------------------------------
+    /**
+     * Test the renaming of an autonomous area
+     * @throws Exception
+     */
+    @Test
+    public void testRenameAutonomousArea() throws Exception
+    {
+        // Inject an AAA
+        Entry autonomousArea = LdifUtils.createEntry(
+            "ou=autonomousArea, ou=system",
+            "ObjectClass: top",
+            "ObjectClass: organizationalUnit",
+            "ou: autonomousArea",
+            "administrativeRole: autonomousArea"
+            );
+
+        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()
);
+    }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java?rev=980603&r1=980602&r2=980603&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
Thu Jul 29 23:03:41 2010
@@ -316,7 +316,7 @@ public class AdministrativePointIntercep
                  adminPoint.contains( SchemaConstants.TRIGGER_EXECUTION_INNER_AREA_OID )
) ) )
         {
             // This is inconsistant
-            String message = "Cannot add a specific Administratve Point and the same" +
+            String message = "Cannot add a specific Administrative Point and the same" +
                 " inner Administrative point at the same time : " + adminPoint;
             LOG.error( message );
             throw new LdapUnwillingToPerformException( message );
@@ -494,7 +494,25 @@ public class AdministrativePointIntercep
      */
     public void move( NextInterceptor next, MoveOperationContext moveContext ) throws LdapException
     {
-        next.move( moveContext );
+        Entry entry = moveContext.getOriginalEntry();
+
+        // Check if we are moving an Administrative Point
+        EntryAttribute adminPoint = entry.get( ADMINISTRATIVE_ROLE_AT );
+
+        if ( adminPoint == null )
+        {
+            // Nope, go on.
+            next.move( moveContext );
+
+            LOG.debug( "Exit from Administrative Interceptor" );
+
+            return;
+        }
+
+        // Else throw an UnwillingToPerform exception ATM
+        String message = "Cannot move an Administrative Point in the current version";
+        LOG.error( message );
+        throw new LdapUnwillingToPerformException( message );
     }
 
 
@@ -504,7 +522,25 @@ public class AdministrativePointIntercep
     public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext moveAndRenameContext
)
         throws LdapException
     {
-        next.moveAndRename( moveAndRenameContext );
+        Entry entry = moveAndRenameContext.getOriginalEntry();
+
+        // Check if we are moving and renaming an Administrative Point
+        EntryAttribute adminPoint = entry.get( ADMINISTRATIVE_ROLE_AT );
+
+        if ( adminPoint == null )
+        {
+            // Nope, go on.
+            next.moveAndRename( moveAndRenameContext );
+
+            LOG.debug( "Exit from Administrative Interceptor" );
+
+            return;
+        }
+
+        // Else throw an UnwillingToPerform exception ATM
+        String message = "Cannot move and rename an Administrative Point in the current version";
+        LOG.error( message );
+        throw new LdapUnwillingToPerformException( message );
     }
 
 
@@ -514,6 +550,24 @@ public class AdministrativePointIntercep
     public void rename( NextInterceptor next, RenameOperationContext renameContext )
         throws LdapException
     {
-        next.rename( renameContext );
+        Entry entry = renameContext.getEntry();
+
+        // Check if we are renaming an Administrative Point
+        EntryAttribute adminPoint = entry.get( ADMINISTRATIVE_ROLE_AT );
+
+        if ( adminPoint == null )
+        {
+            // Nope, go on.
+            next.rename( renameContext );
+
+            LOG.debug( "Exit from Administrative Interceptor" );
+
+            return;
+        }
+
+        // Else throw an UnwillingToPerform exception ATM
+        String message = "Cannot rename an Administrative Point in the current version";
+        LOG.error( message );
+        throw new LdapUnwillingToPerformException( message );
     }
 }



Mime
View raw message