jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1347687 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
Date Thu, 07 Jun 2012 15:45:15 GMT
Author: reschke
Date: Thu Jun  7 15:45:14 2012
New Revision: 1347687

URL: http://svn.apache.org/viewvc?rev=1347687&view=rev
Log:
JCR-3327: avoid non-ASCII characters in source code

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java?rev=1347687&r1=1347686&r2=1347687&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/commons/json/JsonUtilTest.java
Thu Jun  7 15:45:14 2012
@@ -16,41 +16,43 @@
  */
 package org.apache.jackrabbit.commons.json;
 
-import junit.framework.TestCase;
-
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
+import junit.framework.TestCase;
+
 /**
  * <code>JSONUtilTest</code>...
  */
 public class JsonUtilTest extends TestCase {
 
     public void testGetJsonString() {
-        Map m = new HashMap();
-        m.put("abc", "\"abc\"");
-        m.put("a \"b\" c", "\"a \\\"b\\\" c\"");
-        m.put("a\tb\rc\nd\fe\b", "\"a\\tb\\rc\\nd\\fe\\b\"");
-        m.put("\\abc", "\"\\\\abc\"");
-        m.put("abc", "\"abc\"");
+        char DQ = '"';
+
+        Map<String, String> m = new HashMap<String, String>();
+        m.put("abc", "abc");
+        m.put("a \"b\" c", "a \\\"b\\\" c");
+        m.put("a\tb\rc\nd\fe\b", "a\\tb\\rc\\nd\\fe\\b");
+        m.put("\\abc", "\\\\abc");
+        m.put("abc", "abc");
 
         // non-printable ascii other than those treated (\t,\r,\n)
-        m.put(String.valueOf((char) 7), "\"\\u0007\"");
-        m.put(String.valueOf((char) 30), "\"\\u001e\"");
+        m.put(String.valueOf((char) 7), "\\u0007");
+        m.put(String.valueOf((char) 30), "\\u001e");
 
-        // chinese
-        m.put("\u4e00a\u4e8cb\u4e09c", "\"\u4e00a\u4e8cb\u4e09c\"");
+        /* chinese */
+        m.put("\u4e00a\u4e8cb\u4e09c", "\u4e00a\u4e8cb\u4e09c");
         /* arabic */
-        m.put("\u062c\u062f\u064a\u062f", "\"\u062c\u062f\u064a\u062f\"");
-        /* Ñaçb?c */
-        m.put("\u00d1a\u00e7b\u0416c", "\"\u00d1a\u00e7b\u0416c\"");
-        // âèøü
-        // m.put("âèøü", "\"\u00e2\u00e8\u00f8\u00fc\"");
-
-        for (Iterator it = m.keySet().iterator(); it.hasNext();) {
-            String key = it.next().toString();
-            assertEquals(m.get(key).toString(), JsonUtil.getJsonString(key));
+        m.put("\u062c\u062f\u064a\u062f", "\u062c\u062f\u064a\u062f");
+        /* U+00D1 a U+00E7 b U+0416 c */
+        m.put("\u00d1a\u00e7b\u0416c", "\u00d1a\u00e7b\u0416c");
+        /* U+00E2 a U+00E8 b U+00F8 c U+00FC d */
+        m.put("\u00e2a\u00e8b\u00f8c\u00fcd", "\u00e2a\u00e8b\u00f8c\u00fcd");
+
+        for (Map.Entry<String, String> t : m.entrySet()) {
+            String input = t.getKey();
+            String output = DQ + t.getValue() + DQ;
+            assertEquals(output, JsonUtil.getJsonString(input));
         }
     }
 }
\ No newline at end of file



Mime
View raw message