Commit 651511f 1 parent a14cb12 commit 651511f Copy full SHA for 651511f
File tree 1 file changed +21
-0
lines changed
src/test/java/org/json/junit
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1285,6 +1285,27 @@ public void testMaxNestingDepthIsRespectedWithValidXML() {
1285
1285
e .getMessage ().startsWith ("Maximum nesting depth of " + maxNestingDepth ));
1286
1286
}
1287
1287
}
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
+ }
1288
1309
}
1289
1310
1290
1311
You can’t perform that action at this time.
0 commit comments