File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/test/java/org/json/junit Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments