directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1752828 - /directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MoveIT.java
Date Fri, 15 Jul 2016 12:19:40 GMT
Author: elecharny
Date: Fri Jul 15 12:19:40 2016
New Revision: 1752828

URL: http://svn.apache.org/viewvc?rev=1752828&view=rev
Log:
Added a test for a move to a non existent parent

Modified:
    directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MoveIT.java

Modified: directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MoveIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MoveIT.java?rev=1752828&r1=1752827&r2=1752828&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MoveIT.java
(original)
+++ directory/apacheds/branches/apacheds-value/core-integ/src/test/java/org/apache/directory/server/core/operations/move/MoveIT.java
Fri Jul 15 12:19:40 2016
@@ -21,6 +21,8 @@ package org.apache.directory.server.core
 
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.exception.LdapOperationErrorException;
+import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.ContextEntry;
@@ -33,8 +35,10 @@ import org.apache.directory.server.core.
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 
 /**
@@ -110,10 +114,6 @@ public class MoveIT extends AbstractLdap
     {
         LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
 
-        String oldDn = "cn=test,ou=system";
-        String newDn = "cn=test,ou=users,ou=system";
-        String newSuperior = "ou=users,ou=system";
-
         Entry test1 = new DefaultEntry( getService().getSchemaManager(), "cn=test1,ou=system",
             "ObjectClass: top", 
             "ObjectClass: person",
@@ -159,4 +159,46 @@ public class MoveIT extends AbstractLdap
         
         connection.close();
     }
+    
+    
+    /**
+     * Test a move operation to a non existing parent:
+     * cn=test,ou=system will be moved to cn=test,ou=users,ou=system
+     */
+    @Test
+    public void testMoveNonExistingParent() throws Exception
+    {
+        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
+
+        String oldDn = "cn=test,ou=system";
+        String newDn = "cn=test,ou=nonExisting,ou=system";
+        String newSuperior = "ou=nonExisting,ou=system";
+
+        Dn dn = new Dn( oldDn );
+        Entry entry = new DefaultEntry( getService().getSchemaManager(), dn,
+            "ObjectClass: top", 
+            "ObjectClass: person",
+            "sn: TEST",
+            "cn: test" );
+
+        connection.add( entry );
+
+        assertNull( connection.lookup( newDn ) );
+        assertNotNull( connection.lookup( oldDn ) );
+
+        try
+        {
+            connection.move( oldDn, newSuperior );
+            fail();
+        }
+        catch ( LdapOperationErrorException loee )
+        {
+            assertEquals( ResultCodeEnum.OPERATIONS_ERROR, loee.getResultCode() );
+        }
+
+        assertNull( connection.lookup( newDn ) );
+        assertNotNull( connection.lookup( oldDn ) );
+        
+        connection.close();
+    }
 }



Mime
View raw message