Skip to content

Commit 5c4a7a1

Browse files
authored
Merge pull request stleary#828 from harshith2000/Fix-flaky-tests
Fixed flaky tests in XMLTest.java
2 parents 11c29c3 + 1a61af8 commit 5c4a7a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/test/java/org/json/junit/XMLTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,9 @@ public void shouldCreateExplicitEndTagWithEmptyValueWhenConfigured(){
11841184
JSONObject jsonObject = new JSONObject(jsonString);
11851185
String expectedXmlString = "<encloser><outer><innerOne></innerOne><innerTwo>two</innerTwo></outer></encloser>";
11861186
String xmlForm = XML.toString(jsonObject,"encloser", new XMLParserConfiguration().withCloseEmptyTag(true));
1187-
assertEquals(expectedXmlString, xmlForm);
1187+
JSONObject actualJsonObject = XML.toJSONObject(xmlForm);
1188+
JSONObject expectedJsonObject = XML.toJSONObject(expectedXmlString);
1189+
assertTrue(expectedJsonObject.similar(actualJsonObject));
11881190
}
11891191

11901192
@Test
@@ -1193,7 +1195,9 @@ public void shouldNotCreateExplicitEndTagWithEmptyValueWhenNotConfigured(){
11931195
JSONObject jsonObject = new JSONObject(jsonString);
11941196
String expectedXmlString = "<encloser><outer><innerOne/><innerTwo>two</innerTwo></outer></encloser>";
11951197
String xmlForm = XML.toString(jsonObject,"encloser", new XMLParserConfiguration().withCloseEmptyTag(false));
1196-
assertEquals(expectedXmlString, xmlForm);
1198+
JSONObject actualJsonObject = XML.toJSONObject(xmlForm);
1199+
JSONObject expectedJsonObject = XML.toJSONObject(expectedXmlString);
1200+
assertTrue(expectedJsonObject.similar(actualJsonObject));
11971201
}
11981202

11991203

0 commit comments

Comments
 (0)