From becc1631e6dbe41e3a0245d765b01509de2608b5 Mon Sep 17 00:00:00 2001 From: simonh5 Date: Mon, 18 Sep 2023 20:20:13 -0500 Subject: [PATCH] fix: flakiness in JSONMLTest#testToJSONObject_reversibility --- build.gradle | 1 + pom.xml | 7 +++++++ src/test/java/org/json/junit/JSONMLTest.java | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8a3708a..5a5be37 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ dependencies { testImplementation 'junit:junit:4.13.1' testImplementation 'com.jayway.jsonpath:json-path:2.1.0' testImplementation 'org.mockito:mockito-core:4.2.0' + testImplementation 'org.skyscreamer:jsonassert:1.5.1' } subprojects { diff --git a/pom.xml b/pom.xml index 720529c..8bbcc3c 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,13 @@ 4.2.0 test + + + org.skyscreamer + jsonassert + 1.5.1 + test + diff --git a/src/test/java/org/json/junit/JSONMLTest.java b/src/test/java/org/json/junit/JSONMLTest.java index 35c0af2..9b5e5b6 100644 --- a/src/test/java/org/json/junit/JSONMLTest.java +++ b/src/test/java/org/json/junit/JSONMLTest.java @@ -8,6 +8,7 @@ import static org.junit.Assert.*; import org.json.*; import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; /** * Tests for org.json.JSONML.java @@ -763,7 +764,7 @@ public class JSONMLTest { final JSONObject revertedObject = JSONML.toJSONObject(xml, false); final String newJson = revertedObject.toString(); assertTrue("JSON Objects are not similar",originalObject.similar(revertedObject)); - assertEquals("original JSON does not equal the new JSON",originalJson, newJson); + JSONAssert.assertEquals("original JSON does not equal the new JSON", originalJson, newJson, false); } // these tests do not pass for the following reasons: