incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r600595 - /incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/JsonRenderingTest.java
Date Mon, 03 Dec 2007 16:53:05 GMT
Author: bdelacretaz
Date: Mon Dec  3 08:53:03 2007
New Revision: 600595

URL: http://svn.apache.org/viewvc?rev=600595&view=rev
Log:
SLING-114 - additional JSON escaping tests

Modified:
    incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/JsonRenderingTest.java

Modified: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/JsonRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/JsonRenderingTest.java?rev=600595&r1=600594&r2=600595&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/JsonRenderingTest.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/JsonRenderingTest.java
Mon Dec  3 08:53:03 2007
@@ -23,6 +23,7 @@
 /** Test creating Nodes and rendering them in JSON */
 public class JsonRenderingTest extends MicroslingHttpTestBase {
 
+    private String postUrl; 
     private String testText;
     private String jsonUrl;
     
@@ -34,10 +35,10 @@
         testText = "This is a test " + System.currentTimeMillis();
         
         // create the test node, under a path that's specific to this class to allow collisions
-        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "." + System.currentTimeMillis();
+        postUrl = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "_" + System.currentTimeMillis()
+ "/*";
         final Map<String,String> props = new HashMap<String,String>();
         props.put("text", testText);
-        jsonUrl = testClient.createNode(url, props) + ".json";
+        jsonUrl = testClient.createNode(postUrl, props) + ".json";
     }
     
     /** test our assertJavascript method with static json */ 
@@ -51,7 +52,31 @@
         assertJavascript(testText, json ,"out.println(data.text)");
     }
     
-    public void TODOneedToTestMoreJsonStuff() {
-        // TODO - test recursive JSON retrieval, property filters, etc...
+    public void testEscapedStrings() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("dq", "Some text with \"double quotes\"");
+        props.put("sq", "Some text with 'single quotes'");
+        props.put("cb", "Some text with {curly brackets}");
+        props.put("sb", "Some text with [square brackets]");
+        
+        final String location = testClient.createNode(postUrl, props);
+        final String json = getContent(location + ".json", CONTENT_TYPE_JSON);
+        
+        for(String key : props.keySet()) {
+            assertJavascript(props.get(key),json,"out.println(data." + key + ")");
+        }
+    }
+    
+    public void testAccentedStrings() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("a", "Les amis en \u000C9t\u000C9 au ch\u000Eteau");
+        props.put("b", "The \u000B0 degree sign and \u000F5 ntilde");
+        
+        final String location = testClient.createNode(postUrl, props);
+        final String json = getContent(location + ".json", CONTENT_TYPE_JSON);
+        
+        for(String key : props.keySet()) {
+            assertJavascript(props.get(key),json,"out.println(data." + key + ")");
+        }
     }
  }



Mime
View raw message