jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1173652 - /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
Date Wed, 21 Sep 2011 14:04:06 GMT
Author: thomasm
Date: Wed Sep 21 14:04:05 2011
New Revision: 1173652

URL: http://svn.apache.org/viewvc?rev=1173652&view=rev
Log:
Improved test coverage (100%)

Modified:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java?rev=1173652&r1=1173651&r2=1173652&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/json/JsopTest.java
Wed Sep 21 14:04:05 2011
@@ -116,6 +116,15 @@ public class JsopTest extends TestCase {
     }
 
     public void testTokenizer() {
+        assertEquals("test", JsopTokenizer.decode("test"));
+        assertEquals("test", JsopTokenizer.decodeQuoted("\"test\""));
+        assertEquals("hello\n" + "world", JsopTokenizer.decodeQuoted("\"hello\\n" + "world\""));
+        try {
+            JsopTokenizer.decodeQuoted("test");
+            fail();
+        } catch (IllegalArgumentException e) {
+            // ok
+        }
         try {
             JsopTokenizer.decode("test\\");
             fail();
@@ -324,6 +333,14 @@ public class JsopTest extends TestCase {
         assertEquals("\"back\\\\slash\":\"\\\\\",\"back\\\\\\\\slash\":\"\\\\\\\\\"", buff.toString());
     }
 
+    public void testPrettyPrint() {
+        assertEquals("{}", JsopBuilder.prettyPrint("{}"));
+        assertEquals("{\n  \"a\": 1,\n  \"b\": \"Hello\"\n}",
+                JsopBuilder.prettyPrint("{\"a\":1,\"b\":\"Hello\"}"));
+        assertEquals("{\n  \"a\": [1, 2]\n}",
+                JsopBuilder.prettyPrint("{\"a\":[1, 2]}"));
+    }
+
     public static String format(String json) {
         return prettyPrint(new StringBuilder(),
                 new JsopTokenizer(json), "    ");



Mime
View raw message