directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r675299 - /directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
Date Wed, 09 Jul 2008 18:45:40 GMT
Author: elecharny
Date: Wed Jul  9 11:45:39 2008
New Revision: 675299

URL: http://svn.apache.org/viewvc?rev=675299&view=rev
Log:
Added a test for DIRSERVER-1096

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=675299&r1=675298&r2=675299&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
Wed Jul  9 11:45:39 2008
@@ -940,6 +940,56 @@
 
 
     /**
+     * Test for DIRSERVER-1096.
+     * Modify the RDN of an entry with an escaped new RDN. 
+     * Ensure that the attribute itself contains the unescaped value.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testModifyRdnWithEscapedPoundNewRdn() throws Exception
+    {
+        // Create a person "cn=Tori Amos", cn value is rdn
+        String cnVal = "Tori Amos";
+        String snVal = "Amos";
+        String oldRdn = "cn=" + cnVal;
+        Attributes attributes = this.getPersonAttributes( snVal, cnVal );
+        ctx.createSubcontext( oldRdn, attributes );
+
+        // modify Rdn from cn=Tori Amos to cn=\#test\+
+        ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
+        String newRdn = "cn=\\23test";
+        ctx.rename( oldRdn, newRdn );
+
+        // Check, whether old Entry does not exists
+        try
+        {
+            ctx.lookup( oldRdn );
+            fail( "Entry must not exist" );
+        }
+        catch ( NameNotFoundException ignored )
+        {
+            // expected behaviour
+        }
+
+        // Check, whether new Entry exists
+        DirContext newCtx = ( DirContext ) ctx.lookup( newRdn );
+        assertNotNull( newCtx );
+
+        // Check that the DN contains the escaped value
+        assertEquals( "cn=\\23test," + ctx.getNameInNamespace(), newCtx.getNameInNamespace()
);
+
+        // Check that cn contains the unescaped value
+        Attribute cn = newCtx.getAttributes( "" ).get( "cn" );
+        assertEquals( "Number of cn occurences", 1, cn.size() );
+        assertTrue( cn.contains( "\\#test" ) );
+
+        // Remove entry (use new rdn)
+        ctx.unbind( newRdn );
+    }
+
+    
+    /**
      * Test for DIRSERVER-1162 and DIRSERVER-1085.
      * 
      * Tries to rename+deleteOldRdn an entry that has the structural object class



Mime
View raw message