You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/10/10 22:53:11 UTC

svn commit: r312737 - /directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java

Author: elecharny
Date: Mon Oct 10 13:53:06 2005
New Revision: 312737

URL: http://svn.apache.org/viewcvs?rev=312737&view=rev
Log:
Fixed the umlaut test : String should not contains non ASCII characters if they are
saved using ISO-8858-1 local (typically under windows computers here in Europe),
or if using Eclipse, files encoding *must* be set to UTF-8 encoding.

However, using a byte[] seems to be a bulletproof solution here ;)

Modified:
    directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java

Modified: directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java
URL: http://svn.apache.org/viewcvs/directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java?rev=312737&r1=312736&r2=312737&view=diff
==============================================================================
--- directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java (original)
+++ directory/testsuite/trunk/ldaptests/src/main/java/org/apache/ldap/testsuite/ldaptests/jndi/ops/add/SpecialCharacterAddTests.java Mon Oct 10 13:53:06 2005
@@ -16,6 +16,8 @@
  */
 package org.apache.ldap.testsuite.ldaptests.jndi.ops.add;
 
+import java.io.UnsupportedEncodingException;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -51,14 +53,15 @@
         super.tearDown();
     }
 
-    public void testAddEntryWithGermanUmlauts() throws NamingException
+    public void testAddEntryWithGermanUmlauts() throws NamingException, UnsupportedEncodingException
     {
 
-        // Create a person with german "umlaut"
-        String cnValue = "Stefan Zörner";
-        String snValue = "Zörner";
+        // Create a person with german "umlaut". The UTF-8 bytes code for
+        // a german o umlaut is C3 B6. Its equivalence in ISO-8859-1 is F6.
+        String cnValue = new String(new byte[]{'S', 't', 'e', 'f', 'a', 'n', ' ', 'Z', (byte)0xC3, (byte)0xB6, 'r', 'n', 'e', 'r'}, "UTF-8");
+        String snValue = new String(new byte[]{'Z', (byte)0xC3, (byte)0xB6, 'r', 'n', 'e', 'r'}, "UTF-8");
         String rdn = "cn=" + cnValue;
-        String allUmlauts = "äöüÄÖÜß";
+        String allUmlauts = new String(new byte[]{(byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xB6, (byte)0xC3, (byte)0xB6,}, "UTF-8");
         Attributes attributes = AttributesFactory.createPersonAttributes(cnValue, snValue);
         attributes.put("description", allUmlauts);