Skip to content

Commit 651511f

Browse files
committed
tests: add new test to verify that an XML having the permitted nesting depth can be converted
1 parent a14cb12 commit 651511f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

+21
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,27 @@ public void testMaxNestingDepthIsRespectedWithValidXML() {
12851285
e.getMessage().startsWith("Maximum nesting depth of " + maxNestingDepth));
12861286
}
12871287
}
1288+
1289+
@Test
1290+
public void testMaxNestingDepthWithValidFittingXML() {
1291+
final String perfectlyFineXML = "<Test>\n" +
1292+
" <employee>\n" +
1293+
" <name>sonoo</name>\n" +
1294+
" <salary>56000</salary>\n" +
1295+
" <married>true</married>\n" +
1296+
" </employee>\n" +
1297+
"</Test>\n";
1298+
1299+
final int maxNestingDepth = 3;
1300+
1301+
try {
1302+
XML.toJSONObject(perfectlyFineXML, XMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
1303+
} catch (JSONException e) {
1304+
e.printStackTrace();
1305+
fail("XML document should be parsed as its maximum depth fits the maxNestingDepth " +
1306+
"parameter of the XMLParserConfiguration used");
1307+
}
1308+
}
12881309
}
12891310

12901311

0 commit comments

Comments
 (0)