diff --git a/bundles/core/pom.xml b/bundles/core/pom.xml
index 35f0caa794..7b61436de5 100644
--- a/bundles/core/pom.xml
+++ b/bundles/core/pom.xml
@@ -534,6 +534,12 @@
4.7.2
compile
+
+ org.skyscreamer
+ jsonassert
+ 1.5.1
+ test
+
diff --git a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/Utils.java b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/Utils.java
index f71bc1a073..002607d41e 100644
--- a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/Utils.java
+++ b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/Utils.java
@@ -33,6 +33,8 @@
import org.apache.sling.api.resource.Resource;
import org.apache.sling.caconfig.ConfigurationBuilder;
import org.mockito.Mockito;
+import org.skyscreamer.jsonassert.JSONAssert;
+import org.skyscreamer.jsonassert.JSONCompareMode;
import com.adobe.cq.wcm.core.components.internal.DataLayerConfig;
import com.adobe.cq.wcm.core.components.internal.jackson.DefaultMethodSkippingModuleProvider;
@@ -68,11 +70,22 @@ public static void testJSONExport(Object model, String expectedJsonResource) {
} catch (IOException e) {
fail(String.format("Unable to generate JSON export for model %s: %s", model.getClass().getName(), e.getMessage()));
}
- JsonReader outputReader = Json.createReader(IOUtils.toInputStream(writer.toString(), StandardCharsets.UTF_8));
+ String actualJString = writer.toString();
InputStream is = Utils.class.getResourceAsStream(expectedJsonResource);
if (is != null) {
- JsonReader expectedReader = Json.createReader(is);
- assertEquals(expectedReader.read(), outputReader.read());
+ String expectedJString = "";
+ try {
+ expectedJString = IOUtils.toString(is, StandardCharsets.UTF_8);
+ }
+ catch(IOException e) {
+ fail("Error reading expected JSON resource: " + e.getMessage());
+ }
+ try {
+ JSONAssert.assertEquals(expectedJString, actualJString, JSONCompareMode.NON_EXTENSIBLE);
+ }
+ catch (org.json.JSONException e) {
+ fail(e.getMessage() + ": expected: " + expectedJString + " but was: " + actualJString);
+ }
} else {
fail("Unable to find test file " + expectedJsonResource + ".");
}