From 1a61af8255e559f7b3766e5a858d7286800e4746 Mon Sep 17 00:00:00 2001 From: Saiharshith Karuneegar Ramesh Date: Mon, 13 Nov 2023 13:25:30 -0600 Subject: [PATCH 1/2] Fixed flaky tests in XMLTest.java --- src/test/java/org/json/junit/XMLTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/json/junit/XMLTest.java b/src/test/java/org/json/junit/XMLTest.java index d8aedb3..823a065 100644 --- a/src/test/java/org/json/junit/XMLTest.java +++ b/src/test/java/org/json/junit/XMLTest.java @@ -1184,7 +1184,9 @@ public class XMLTest { JSONObject jsonObject = new JSONObject(jsonString); String expectedXmlString = "two"; String xmlForm = XML.toString(jsonObject,"encloser", new XMLParserConfiguration().withCloseEmptyTag(true)); - assertEquals(expectedXmlString, xmlForm); + JSONObject actualJsonObject = XML.toJSONObject(xmlForm); + JSONObject expectedJsonObject = XML.toJSONObject(expectedXmlString); + assertTrue(expectedJsonObject.similar(actualJsonObject)); } @Test @@ -1193,7 +1195,9 @@ public class XMLTest { JSONObject jsonObject = new JSONObject(jsonString); String expectedXmlString = "two"; String xmlForm = XML.toString(jsonObject,"encloser", new XMLParserConfiguration().withCloseEmptyTag(false)); - assertEquals(expectedXmlString, xmlForm); + JSONObject actualJsonObject = XML.toJSONObject(xmlForm); + JSONObject expectedJsonObject = XML.toJSONObject(expectedXmlString); + assertTrue(expectedJsonObject.similar(actualJsonObject)); } From b5f9febfe90d9667f47b22d72c4ff7693735b2dc Mon Sep 17 00:00:00 2001 From: HappyHacker123 Date: Fri, 17 Nov 2023 21:31:06 +0800 Subject: [PATCH 2/2] Upgrade json-path's version to 2.4 to avoid dependency conflict. --- build.gradle | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index fbc2ff1..30a8578 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ repositories { dependencies { testImplementation 'junit:junit:4.13.2' - testImplementation 'com.jayway.jsonpath:json-path:2.1.0' + testImplementation 'com.jayway.jsonpath:json-path:2.4.0' testImplementation 'org.mockito:mockito-core:4.2.0' } diff --git a/pom.xml b/pom.xml index ba0efd1..927a989 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ com.jayway.jsonpath json-path - 2.1.0 + 2.4.0 test