Skip to content

Commit

Permalink
tests: add new test to verify that an XML having the permitted nestin…
Browse files Browse the repository at this point in the history
…g depth can be converted
  • Loading branch information
cleydyr committed Feb 1, 2023
1 parent a14cb12 commit 651511f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/org/json/junit/XMLTest.java
Expand Up @@ -1285,6 +1285,27 @@ public void testMaxNestingDepthIsRespectedWithValidXML() {
e.getMessage().startsWith("Maximum nesting depth of " + maxNestingDepth));
}
}

@Test
public void testMaxNestingDepthWithValidFittingXML() {
final String perfectlyFineXML = "<Test>\n" +
" <employee>\n" +
" <name>sonoo</name>\n" +
" <salary>56000</salary>\n" +
" <married>true</married>\n" +
" </employee>\n" +
"</Test>\n";

final int maxNestingDepth = 3;

try {
XML.toJSONObject(perfectlyFineXML, XMLParserConfiguration.ORIGINAL.withMaxNestingDepth(maxNestingDepth));
} catch (JSONException e) {
e.printStackTrace();
fail("XML document should be parsed as its maximum depth fits the maxNestingDepth " +
"parameter of the XMLParserConfiguration used");
}
}
}


Expand Down

0 comments on commit 651511f

Please sign in to comment.