You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2017/03/28 13:03:28 UTC

svn commit: r1789122 - in /sling/trunk/bundles/jcr/contentloader: ./ src/main/java/org/apache/sling/jcr/contentloader/internal/readers/ src/test/java/org/apache/sling/jcr/contentloader/internal/ src/test/java/org/apache/sling/jcr/contentloader/internal...

Author: pauls
Date: Tue Mar 28 13:03:28 2017
New Revision: 1789122

URL: http://svn.apache.org/viewvc?rev=1789122&view=rev
Log:
SLING-6694: Replace commons.json usage in org.apache.sling.jcr.contentloader

Modified:
    sling/trunk/bundles/jcr/contentloader/pom.xml
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
    sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReader.java
    sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java
    sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReaderTest.java
    sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java

Modified: sling/trunk/bundles/jcr/contentloader/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/pom.xml?rev=1789122&r1=1789121&r2=1789122&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/pom.xml (original)
+++ sling/trunk/bundles/jcr/contentloader/pom.xml Tue Mar 28 13:03:28 2017
@@ -42,7 +42,7 @@
     <sling.launchpad.version>7</sling.launchpad.version>
     <pax.vm.options>-Xmx256M -XX:MaxPermSize=256m</pax.vm.options>
     <dump.test.bundles>false</dump.test.bundles>
-
+    <sling.java.version>7</sling.java.version>
     <!-- argLine needs to be here so that jacoco plugin adds its own stuff to it -->
     <argLine>${pax.vm.options}</argLine>
   </properties>
@@ -188,12 +188,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
-      <artifactId>org.apache.sling.commons.json</artifactId>
-      <version>2.0.6</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.commons.mime</artifactId>
       <version>2.1.2</version>
       <scope>provided</scope>
@@ -283,6 +277,18 @@
         <artifactId>org.apache.sling.testing.sling-mock</artifactId>
         <version>1.6.0</version>
         <scope>test</scope>
+        <exclusions>
+        <exclusion>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>org.apache.sling.commons.json</artifactId>
+        </exclusion>
+        </exclusions>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>org.apache.sling.commons.johnzon</artifactId>
+        <version>0.1.0-SNAPSHOT</version>
+        <scope>provided</scope>
     </dependency>
     <dependency>
         <groupId>org.apache.sling</groupId>

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java?rev=1789122&r1=1789121&r2=1789122&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java Tue Mar 28 13:03:28 2017
@@ -22,6 +22,8 @@ import java.io.BufferedInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.StringReader;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -30,14 +32,18 @@ import java.util.regex.Pattern;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonException;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+import javax.json.JsonString;
+import javax.json.JsonValue;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.jcr.contentloader.ContentCreator;
 import org.apache.sling.jcr.contentloader.ContentReader;
 
@@ -152,15 +158,16 @@ public class JsonReader implements Conte
             if (!jsonString.startsWith("{")) {
                 jsonString = "{" + jsonString + "}";
             }
-
-            JSONObject json = new JSONObject(jsonString);
+            Map<String, Object> config = new HashMap<>();
+            config.put("org.apache.johnzon.supports-comments", true);
+            JsonObject json = Json.createReaderFactory(config).createReader(new StringReader(jsonString)).readObject();
             this.createNode(null, json, contentCreator);
-        } catch (JSONException je) {
+        } catch (JsonException je) {
             throw (IOException) new IOException(je.getMessage()).initCause(je);
         }
     }
 
-    protected boolean handleSecurity(String n, Object o, ContentCreator contentCreator) throws JSONException, RepositoryException{
+    protected boolean handleSecurity(String n, Object o, ContentCreator contentCreator) throws RepositoryException{
         if (SECURITY_PRINCIPLES.equals(n)) {
             this.createPrincipals(o, contentCreator);
         } else if (SECURITY_ACL.equals(n)) {
@@ -171,17 +178,16 @@ public class JsonReader implements Conte
         return true;
     }
 
-    protected void writeChildren(JSONObject obj, ContentCreator contentCreator) throws JSONException, RepositoryException{
+    protected void writeChildren(JsonObject obj, ContentCreator contentCreator) throws RepositoryException{
         // add properties and nodes
-        JSONArray names = obj.names();
-        for (int i = 0; names != null && i < names.length(); i++) {
-            final String n = names.getString(i);
+        for (Map.Entry<String, JsonValue> entry : obj.entrySet()) {
+            final String n = entry.getKey();
             // skip well known objects
             if (!ignoredNames.contains(n)) {
-                Object o = obj.get(n);
+                Object o = entry.getValue();
                 if (!handleSecurity(n, o, contentCreator)) {
-                    if (o instanceof JSONObject) {
-                        this.createNode(n, (JSONObject) o, contentCreator);
+                    if (o instanceof JsonObject) {
+                        this.createNode(n, (JsonObject) o, contentCreator);
                     } else {
                         this.createProperty(n, o, contentCreator);
                     }
@@ -190,20 +196,15 @@ public class JsonReader implements Conte
         }
     }
 
-    protected void createNode(String name, JSONObject obj, ContentCreator contentCreator)
-    throws JSONException, RepositoryException {
-        Object primaryTypeObj = obj.opt("jcr:primaryType");
-        String primaryType = null;
-        if (primaryTypeObj != null) {
-            primaryType = String.valueOf(primaryTypeObj);
-        }
+    protected void createNode(String name, JsonObject obj, ContentCreator contentCreator) throws RepositoryException {
+        String primaryType = obj.getString("jcr:primaryType", null);
 
         String[] mixinTypes = null;
-        Object mixinsObject = obj.opt("jcr:mixinTypes");
-        if (mixinsObject instanceof JSONArray) {
-            JSONArray mixins = (JSONArray) mixinsObject;
-            mixinTypes = new String[mixins.length()];
-            for (int i = 0; i < mixins.length(); i++) {
+        Object mixinsObject = obj.get("jcr:mixinTypes");
+        if (mixinsObject instanceof JsonArray) {
+            JsonArray mixins = (JsonArray) mixinsObject;
+            mixinTypes = new String[mixins.size()];
+            for (int i = 0; i < mixinTypes.length; i++) {
                 mixinTypes[i] = mixins.getString(i);
             }
         }
@@ -213,30 +214,55 @@ public class JsonReader implements Conte
         contentCreator.finishNode();
     }
 
-    protected void createProperty(String name, Object value, ContentCreator contentCreator)
-    throws JSONException, RepositoryException {
+    protected void createProperty(String name, Object value, ContentCreator contentCreator) throws RepositoryException {
         // assume simple value
-        if (value instanceof JSONArray) {
+        if (value instanceof JsonArray) {
             // multivalue
-            final JSONArray array = (JSONArray) value;
-            if (array.length() > 0) {
-                final String values[] = new String[array.length()];
-                for (int i = 0; i < array.length(); i++) {
-                    values[i] = array.get(i).toString();
+            final JsonArray array = (JsonArray) value;
+            if (array.size() > 0) {
+                final String values[] = new String[array.size()];
+                for (int i = 0; i < values.length; i++) {
+                    values[i] =  unbox(array.get(i)).toString();
                 }
-                final int propertyType = getType(name, array.get(0));
+                final int propertyType = getType(name, unbox(array.get(0)));
                 contentCreator.createProperty(getName(name), propertyType, values);
             } else {
                 contentCreator.createProperty(getName(name), PropertyType.STRING, new String[0]);
             }
 
-        } else {
+        } else if (value instanceof JsonValue) {
             // single value
+            value = unbox(value);
             final int propertyType = getType(name, value);
             contentCreator.createProperty(getName(name), propertyType, value.toString());
         }
     }
 
+    private Object unbox(Object o) {
+        if (o instanceof JsonValue) {
+            switch (((JsonValue)o).getValueType()) {
+                case FALSE:
+                    return false;
+                case TRUE:
+                    return true;
+                case NULL:
+                    return null;
+                case NUMBER:
+                    if (((JsonNumber) o).isIntegral()) {
+                        return Long.valueOf(((JsonNumber) o).longValue());
+                    }
+                    else
+                    {
+                        return Double.valueOf(((JsonNumber)o).doubleValue());
+                    }
+                case STRING:
+                    return ((JsonString) o).getString();
+                default:
+                    return o;
+            }
+        }
+        return o;
+    }
     private int getType(String name, Object object) {
         if (object instanceof Double || object instanceof Float) {
             return PropertyType.DOUBLE;
@@ -311,20 +337,19 @@ public class JsonReader implements Conte
      *  }
      *  </code>
      */
-    protected void createPrincipals(Object obj, ContentCreator contentCreator)
-    throws JSONException, RepositoryException {
-    	if (obj instanceof JSONObject) {
+    protected void createPrincipals(Object obj, ContentCreator contentCreator) throws RepositoryException {
+    	if (obj instanceof JsonObject) {
     		//single principal
-    		createPrincipal((JSONObject)obj, contentCreator);
-    	} else if (obj instanceof JSONArray) {
+    		createPrincipal((JsonObject)obj, contentCreator);
+    	} else if (obj instanceof JsonArray) {
     		//array of principals
-    		JSONArray jsonArray = (JSONArray)obj;
-    		for (int i=0; i < jsonArray.length(); i++) {
+    		JsonArray jsonArray = (JsonArray)obj;
+    		for (int i=0; i < jsonArray.size(); i++) {
     			Object object = jsonArray.get(i);
-    			if (object instanceof JSONObject) {
-    	    		createPrincipal((JSONObject)object, contentCreator);
+    			if (object instanceof JsonObject) {
+    	    		createPrincipal((JsonObject)object, contentCreator);
     			} else {
-    				throw new JSONException("Unexpected data type in principals array: " + object.getClass().getName());
+    				throw new JsonException("Unexpected data type in principals array: " + object.getClass().getName());
     			}
     		}
     	}
@@ -333,29 +358,27 @@ public class JsonReader implements Conte
     /**
      * Create or update a user or group
      */
-    private void createPrincipal(JSONObject json, ContentCreator contentCreator)
-    throws JSONException, RepositoryException {
+    private void createPrincipal(JsonObject json, ContentCreator contentCreator) throws RepositoryException {
     	//create a principal
     	String name = json.getString("name");
-    	boolean isGroup = json.optBoolean("isgroup", false);
+    	boolean isGroup = json.getBoolean("isgroup", false);
 
     	//collect the extra property names to assign to the new principal
     	Map<String, Object> extraProps = new LinkedHashMap<String, Object>();
-		JSONArray names = json.names();
-		for(int p=0; p < names.length(); p++) {
-			String propName = names.getString(p);
+		for(Map.Entry<String, JsonValue> entry : json.entrySet()) {
+			String propName = entry.getKey();
 			if (!ignoredPrincipalPropertyNames.contains(propName)) {
-    			Object value = json.get(propName);
+    			Object value = unbox(entry.getValue());
     			extraProps.put(propName, value);
 			}
 		}
 
     	if (isGroup) {
     		String [] members = null;
-    		JSONArray membersJSONArray = json.optJSONArray("members");
+    		JsonArray membersJSONArray = (JsonArray) json.get("members");
     		if (membersJSONArray != null) {
-    			members = new String[membersJSONArray.length()];
-    			for (int i=0; i < membersJSONArray.length(); i++) {
+    			members = new String[membersJSONArray.size()];
+    			for (int i=0; i < members.length; i++) {
     				members[i] = membersJSONArray.getString(i);
     			}
     		}
@@ -393,20 +416,19 @@ public class JsonReader implements Conte
      *  }
      *  </code>
      */
-    private void createAcl(Object obj, ContentCreator contentCreator)
-    throws JSONException, RepositoryException {
-    	if (obj instanceof JSONObject) {
+    private void createAcl(Object obj, ContentCreator contentCreator) throws RepositoryException {
+    	if (obj instanceof JsonObject) {
     		//single ace
-    		createAce((JSONObject)obj, contentCreator);
-    	} else if (obj instanceof JSONArray) {
+    		createAce((JsonObject)obj, contentCreator);
+    	} else if (obj instanceof JsonArray) {
     		//array of aces
-    		JSONArray jsonArray = (JSONArray)obj;
-    		for (int i=0; i < jsonArray.length(); i++) {
+    		JsonArray jsonArray = (JsonArray)obj;
+    		for (int i=0; i < jsonArray.size(); i++) {
     			Object object = jsonArray.get(i);
-    			if (object instanceof JSONObject) {
-    	    		createAce((JSONObject)object, contentCreator);
+    			if (object instanceof JsonObject) {
+    	    		createAce((JsonObject)object, contentCreator);
     			} else {
-    				throw new JSONException("Unexpected data type in acl array: " + object.getClass().getName());
+    				throw new JsonException("Unexpected data type in acl array: " + object.getClass().getName());
     			}
     		}
     	}
@@ -415,29 +437,28 @@ public class JsonReader implements Conte
     /**
      * Create or update an access control entry
      */
-    private void createAce(JSONObject ace, ContentCreator contentCreator)
-    throws JSONException, RepositoryException {
+    private void createAce(JsonObject ace, ContentCreator contentCreator) throws RepositoryException {
 		String principalID = ace.getString("principal");
 
 		String [] grantedPrivileges = null;
-		JSONArray granted = ace.optJSONArray("granted");
+		JsonArray granted = (JsonArray) ace.get("granted");
 		if (granted != null) {
-			grantedPrivileges = new String[granted.length()];
-			for (int a=0; a < granted.length(); a++) {
+			grantedPrivileges = new String[granted.size()];
+			for (int a=0; a < grantedPrivileges.length; a++) {
 				grantedPrivileges[a] = granted.getString(a);
 			}
 		}
 
 		String [] deniedPrivileges = null;
-		JSONArray denied = ace.optJSONArray("denied");
+		JsonArray denied = (JsonArray) ace.get("denied");
 		if (denied != null) {
-			deniedPrivileges = new String[denied.length()];
-			for (int a=0; a < denied.length(); a++) {
+			deniedPrivileges = new String[denied.size()];
+			for (int a=0; a < deniedPrivileges.length; a++) {
 				deniedPrivileges[a] = denied.getString(a);
 			}
 		}
 
-		String order = ace.optString("order", null);
+		String order = ace.getString("order", null);
 
 		//do the work.
 		contentCreator.createAce(principalID, grantedPrivileges, deniedPrivileges, order);

Modified: sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReader.java?rev=1789122&r1=1789121&r2=1789122&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReader.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReader.java Tue Mar 28 13:03:28 2017
@@ -23,13 +23,18 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONException;
-import org.apache.sling.commons.json.JSONObject;
 import org.apache.sling.jcr.contentloader.ContentCreator;
 import org.apache.sling.jcr.contentloader.ContentReader;
 
+import java.util.Map;
+
 import javax.jcr.RepositoryException;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonException;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.JsonValue;
 
 /**
  * Specific <code>JsonReader</code>, <code>OrderedJsonReader</code> parse json document exactly the same,
@@ -50,38 +55,45 @@ public class OrderedJsonReader extends J
     private static final String PN_ORDEREDCHILDNAME = "SLING:name";
 
     @Override
-    protected void writeChildren(JSONObject obj, ContentCreator contentCreator) throws JSONException, RepositoryException {
-        if (! obj.has(PN_ORDEREDCHILDREN)) {
+    protected void writeChildren(JsonObject obj, ContentCreator contentCreator) throws RepositoryException {
+        if (! obj.containsKey(PN_ORDEREDCHILDREN)) {
             super.writeChildren(obj, contentCreator);
         } else {
-            JSONArray names = obj.names();
-            for (int i = 0; names != null && i < names.length(); i++) {
-                final String n = names.getString(i);
+            for (Map.Entry<String, JsonValue> entry : obj.entrySet()) {
+                final String n = entry.getKey();
                 // skip well known objects
                 if (!ignoredNames.contains(n)) {
-                    Object o = obj.get(n);
+                    Object o = entry.getValue();
                     if (!handleSecurity(n, o, contentCreator)) {
                         if (n.equals(PN_ORDEREDCHILDREN)) {
-                            if (o instanceof JSONArray) {
-                                JSONArray children = (JSONArray) o;
-                                for (int childIndex = 0; childIndex < children.length(); childIndex++) {
+                            if (o instanceof JsonArray) {
+                                JsonArray children = (JsonArray) o;
+                                for (int childIndex = 0; childIndex < children.size(); childIndex++) {
                                     Object oc = children.get(childIndex);
-                                    if (oc instanceof JSONObject) {
-                                        JSONObject child = (JSONObject) oc;
-                                        String childName = child.optString(PN_ORDEREDCHILDNAME);
+                                    if (oc instanceof JsonObject) {
+                                        JsonObject child = (JsonObject) oc;
+                                        String childName = child.getString(PN_ORDEREDCHILDNAME, null);
                                         if (StringUtils.isNotBlank(childName)) {
-                                            child.remove(PN_ORDEREDCHILDNAME);
+                                            JsonObjectBuilder builder = Json.createObjectBuilder();
+                                            for (Map.Entry<String, JsonValue> e : child.entrySet())
+                                            {
+                                                if (!PN_ORDEREDCHILDNAME.equals(e.getKey()))
+                                                {
+                                                    builder.add(e.getKey(), e.getValue());
+                                                }
+                                            }
+                                            child = builder.build();
                                             this.createNode(childName, child, contentCreator);
                                         } else {
-                                            throw new JSONException(PN_ORDEREDCHILDREN + " children must have a name whose key is " + PN_ORDEREDCHILDNAME);
+                                            throw new JsonException(PN_ORDEREDCHILDREN + " children must have a name whose key is " + PN_ORDEREDCHILDNAME);
                                         }
                                     } else {
-                                        throw new JSONException(PN_ORDEREDCHILDREN + " array must only have JSONObject items");
+                                        throw new JsonException(PN_ORDEREDCHILDREN + " array must only have JSONObject items");
                                     }
 
                                 }
                             } else {
-                                throw new JSONException(PN_ORDEREDCHILDREN + " value must be a JSON array");
+                                throw new JsonException(PN_ORDEREDCHILDREN + " value must be a JSON array");
                             }
                         }
                     } else {

Modified: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java?rev=1789122&r1=1789121&r2=1789122&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/JsonReaderTest.java Tue Mar 28 13:03:28 2017
@@ -19,14 +19,17 @@ package org.apache.sling.jcr.contentload
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.StringWriter;
 import java.util.Arrays;
 import java.util.LinkedHashMap;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonWriter;
 
-import org.apache.sling.commons.json.JSONArray;
-import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.jcr.contentloader.ContentCreator;
 import org.apache.sling.jcr.contentloader.internal.readers.JsonReader;
 import org.jmock.Expectations;
@@ -208,7 +211,7 @@ public class JsonReaderTest {
 
     @org.junit.Test public void testChild() throws Exception {
         String json = "{ " +
-                      " c1 : {}" +
+                      " \"c1\" : {}" +
                       "}";
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); inSequence(mySequence);
@@ -221,7 +224,7 @@ public class JsonReaderTest {
 
     @org.junit.Test public void testChildWithMixin() throws Exception {
         String json = "{ " +
-        " c1 : {" +
+        " \"c1\" : {" +
               "\"jcr:mixinTypes\" : [\"xyz:TestType\"]" +
               "}" +
         "}";
@@ -236,8 +239,8 @@ public class JsonReaderTest {
 
     @org.junit.Test public void testTwoChildren() throws Exception {
         String json = "{ " +
-        " c1 : {}," +
-        " c2 : {}" +
+        " \"c1\" : {}," +
+        " \"c2\" : {}" +
         "}";
         this.mockery.checking(new Expectations() {{
             allowing(creator).createNode(null, null, null); inSequence(mySequence);
@@ -252,8 +255,8 @@ public class JsonReaderTest {
 
     @org.junit.Test public void testChildWithProperty() throws Exception {
         String json = "{ " +
-        " c1 : {" +
-        "      c1p1 : \"v1\"" +
+        " \"c1\" : {" +
+        "      \"c1p1\" : \"v1\"" +
               "}" +
         "}";
         this.mockery.checking(new Expectations() {{
@@ -350,7 +353,17 @@ public class JsonReaderTest {
         this.jsonReader.parse(ins, this.creator);
     }
 
-    protected JSONArray toJsonArray(String[] array) throws JSONException {
-        return new JSONArray(Arrays.asList(array));
+    protected String toJsonArray(String[] array) {
+        JsonArrayBuilder builder = Json.createArrayBuilder();
+        for (String value : array)
+        {
+            builder.add(value);
+        }
+        StringWriter stringWriter = new StringWriter();
+        try (JsonWriter writer = Json.createWriter(stringWriter))
+        {
+            writer.writeArray(builder.build());
+        }
+        return stringWriter.toString();
     }
 }

Modified: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReaderTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReaderTest.java?rev=1789122&r1=1789121&r2=1789122&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReaderTest.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/internal/readers/OrderedJsonReaderTest.java Tue Mar 28 13:03:28 2017
@@ -38,9 +38,9 @@ public class OrderedJsonReaderTest exten
 
     @org.junit.Test public void testTwoOrderedChildren() throws Exception {
         String json = "{ " +
-                " 'SLING:ordered' : [" +
-                        "{ 'SLING:name': c1}," +
-                        "{ 'SLING:name': c2}" +
+                " \"SLING:ordered\" : [" +
+                        "{ \"SLING:name\": \"c1\"}," +
+                        "{ \"SLING:name\": \"c2\"}" +
                     "]" +
                 "}";
         this.mockery.checking(new Expectations() {{

Modified: sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java?rev=1789122&r1=1789121&r2=1789122&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java (original)
+++ sling/trunk/bundles/jcr/contentloader/src/test/java/org/apache/sling/jcr/contentloader/it/PaxExamUtilities.java Tue Mar 28 13:03:28 2017
@@ -49,6 +49,7 @@ public final class PaxExamUtilities {
                     provision(bundle(thisProjectsBundle.toURI().toString())),
                     wrappedBundle(mavenBundle("org.apache.sling", "org.apache.sling.commons.testing").versionAsInProject()),
                     wrappedBundle(mavenBundle("org.ops4j.pax.tinybundles", "tinybundles").versionAsInProject()),
+                    mavenBundle("org.apache.sling", "org.apache.sling.commons.johnzon").versionAsInProject(),
                     mavenBundle("biz.aQute.bnd", "bndlib").versionAsInProject()
             ).getOptions();
         } finally {