directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r584630 - /directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
Date Sun, 14 Oct 2007 22:37:54 GMT
Author: seelmann
Date: Sun Oct 14 15:37:51 2007
New Revision: 584630

URL: http://svn.apache.org/viewvc?rev=584630&view=rev
Log:
Added commented test for DIRSERVER-1086

Modified:
    directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java

Modified: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java?rev=584630&r1=584629&r2=584630&view=diff
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
(original)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
Sun Oct 14 15:37:51 2007
@@ -26,11 +26,15 @@
 
 import java.util.Hashtable;
 
+import javax.naming.NameClassPair;
 import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
@@ -72,6 +76,23 @@
 
         return attributes;
     }
+    
+    
+    /**
+     * Create attributes for a organizational unit entry.
+     */
+    protected Attributes getOrganizationalUnitAttributes( String ou )
+    {
+        Attributes attributes = new AttributesImpl();
+        Attribute attribute = new AttributeImpl( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "organizationalUnit" );
+        attributes.put( attribute );
+        attributes.put( "ou", ou );
+        attributes.put( "description", ou + " is an organizational unit." );
+        
+        return attributes;
+    }
 
 
     /**
@@ -349,4 +370,72 @@
         // Remove entry (use new rdn)
         ctx.unbind( newRdn );
     }
+    
+    
+    /**
+     * Test for DIRSERVER-1086.
+     * Modify Rdn of an entry that has a child entry, delete its old rdn value.
+     * 
+     * @throws NamingException
+     */
+    /*
+    @Test public void testModifyRdnAndDeleteOldWithChild() throws NamingException
+    {
+        // Create an organizational unit, ou value is rdn
+        String oldOu = "Writers";
+        String oldRdn = "ou=" + oldOu;
+        Attributes attributes = this.getOrganizationalUnitAttributes( oldOu );
+        DirContext createdCtx = ctx.createSubcontext( oldRdn, attributes );
+        
+        // Create a child
+        String childCn = "Tori Amos";
+        String childRdn = "cn=" + childCn;
+        Attributes childAttributes = this.getPersonAttributes( "Amos", childCn );
+        createdCtx.createSubcontext( childRdn, childAttributes );
+
+        // modify Rdn
+        String newOu = "Singers";
+        String newRdn = "ou=" + newOu;
+        ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
+        ctx.rename( oldRdn, newRdn );
+
+        // Check, whether old Entry does not exists
+        try
+        {
+            ctx.lookup( oldRdn );
+            Assert.fail( "Entry must not exist" );
+        }
+        catch ( NameNotFoundException ignored )
+        {
+            // expected behaviour
+            assertTrue( true );
+        }
+
+        // Check, whether new Entry exists
+        DirContext org = ( DirContext ) ctx.lookup( newRdn );
+        assertNotNull( org );
+
+        // Check values of ou
+        Attribute ou = org.getAttributes( "" ).get( "ou" );
+        assertTrue( ou.contains( newOu ) );
+        assertTrue( !ou.contains( oldOu ) ); // old value is gone
+        assertEquals( 1, ou.size() );
+
+        // Perform a search under renamed ou and check whether exactly one child entry exist
+        SearchControls searchControls = new SearchControls();
+        searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        searchControls.setReturningAttributes( new String[]{"objectClass"} );
+        NamingEnumeration<SearchResult> results = org.search( "", "(objectClass=*)",
searchControls );
+        assertTrue( results.hasMore() );
+        results.next();
+        assertTrue( !results.hasMore() );
+        
+        // Check whether Tori exists
+        DirContext tori = ( DirContext ) org.lookup( childRdn );
+        assertNotNull( tori );
+        
+        // Remove entry (use new rdn)
+        ctx.unbind( newRdn );
+    }
+    */
 }



Mime
View raw message