sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1652197 - /sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/JsonObjectCreatorTest.java
Date Thu, 15 Jan 2015 17:50:21 GMT
Author: bdelacretaz
Date: Thu Jan 15 17:50:20 2015
New Revision: 1652197

URL: http://svn.apache.org/r1652197
Log:
SLING-4258 - reasonably complete tests

Modified:
    sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/JsonObjectCreatorTest.java

Modified: sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/JsonObjectCreatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/JsonObjectCreatorTest.java?rev=1652197&r1=1652196&r2=1652197&view=diff
==============================================================================
--- sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/JsonObjectCreatorTest.java
(original)
+++ sling/trunk/bundles/commons/json/src/test/java/org/apache/sling/commons/json/sling/JsonObjectCreatorTest.java
Thu Jan 15 17:50:20 2015
@@ -34,6 +34,7 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
+import org.apache.sling.commons.json.JSONArray;
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
 import org.junit.Before;
@@ -99,7 +100,12 @@ public class JsonObjectCreatorTest {
         final JSONObject j = JsonObjectCreator.create(resource, 1);
         
         final String getKey = data instanceof InputStream ? ":"  + key : key;
-        assertEquals(expected == SAME ? data : expected, j.get(getKey));
+        final Object toExpect = expected == SAME ? data : expected;
+        if(toExpect instanceof String) {
+            assertEquals(toExpect, j.get(getKey).toString());
+        } else {
+            assertEquals(toExpect, j.get(getKey));
+        }
     }
     
     @Test
@@ -129,6 +135,19 @@ public class JsonObjectCreatorTest {
     }
     
     @Test
+    public void testArray() throws JSONException {
+        final String [] values = { "C", "D" };
+        final JSONArray a = new JSONArray().put("C").put("D");
+        assertGet(values, a.toString());
+    }
+    
+    @Test
+    public void testEmptyArray() throws JSONException {
+        final Long [] values = {};
+        assertGet(values, "[]");
+    }
+    
+    @Test
     public void testCalendar() throws JSONException {
         final Calendar nowCalendar = Calendar.getInstance();
         final String ECMA_DATE_FORMAT = "EEE MMM dd yyyy HH:mm:ss 'GMT'Z";



Mime
View raw message