directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r290643 - /directory/testsuite/trunk/protocoltests/jndi/ops/add/BasicAddTests.java
Date Wed, 21 Sep 2005 07:23:10 GMT
Author: elecharny
Date: Wed Sep 21 00:23:05 2005
New Revision: 290643

URL: http://svn.apache.org/viewcvs?rev=290643&view=rev
Log:
Added a test to check if non ASCII attributes are correctly handled by ApacheDS. It is, at
least with TwixDecoder.
(Further testing urgently needed :)

Modified:
    directory/testsuite/trunk/protocoltests/jndi/ops/add/BasicAddTests.java

Modified: directory/testsuite/trunk/protocoltests/jndi/ops/add/BasicAddTests.java
URL: http://svn.apache.org/viewcvs/directory/testsuite/trunk/protocoltests/jndi/ops/add/BasicAddTests.java?rev=290643&r1=290642&r2=290643&view=diff
==============================================================================
--- directory/testsuite/trunk/protocoltests/jndi/ops/add/BasicAddTests.java (original)
+++ directory/testsuite/trunk/protocoltests/jndi/ops/add/BasicAddTests.java Wed Sep 21 00:23:05
2005
@@ -17,7 +17,7 @@
     private static String PERSON_CN_VALUE  = "Tori Amos";
     private static String PERSON_CN_ALTERNATE = "Myra Ellen Amos";
     
-    private static String PERSON_RDN = "cn="+PERSON_CN_VALUE; 
+    private static String PERSON_RDN = "cn=" + PERSON_CN_VALUE; 
     
     private Attributes createPersonAttributes(String cn, String sn) {
         Attributes person = new BasicAttributes();
@@ -117,4 +117,57 @@
 
         ctx.close();
     }
+
+    /**
+     * Cheks that an entry with non-ASCII chars can be added
+     * 
+     * @throws NamingException
+     */
+    public void testAddEntryNonASCII() throws NamingException 
+    {
+        // The bytes used are the UTF-8 encoding for Jérôme :
+        // 0x4A = J
+        // 0xC3 0xA9 = é, encoded 
+        // 0x72 = r
+        // 0xC3 0xB4 = ô, encoded
+        // 0x6D = m
+        // 0x65 = e
+        String cn = new String(new byte[]{0x4A, (byte)0xC3, (byte)0xA9, 0x72, (byte)0xC3,
(byte)0xB4, 0x6D, 0x65});
+        String sn = "baumgarten";
+        
+        DirContext ctx = this.createContext();
+        DirContext target = (DirContext) ctx.lookup(getTestContainerRdn());
+
+        // Add a person
+        Attributes attributes = createPersonAttributes(cn, sn);
+        
+        String rdn = "cn=" + cn;
+        
+        DirContext person = target
+                .createSubcontext(rdn, attributes);
+
+        // Check wether person looks fine
+        person = (DirContext) target.lookup(rdn);
+        assertNotNull(person);
+        attributes = person.getAttributes("");
+        
+        // objectclasses
+        Attribute ocls = attributes.get("objectClass");
+        String[] expectedOcls = { "top", "person" };
+        
+        for (int i = 0; i < expectedOcls.length; i++) {
+            String name = expectedOcls[i];
+            assertTrue("object class " + name + " is not present", ocls
+                    .contains(name));
+        }
+        
+        // Other attributes
+        Attribute cnRes = attributes.get("cn");
+        assertTrue(cn.contains(cn));
+        Attribute snRes = attributes.get("sn");
+        assertTrue(sn.contains(sn));
+        
+        ctx.close();
+    }
+    
 }



Mime
View raw message