mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 03:24:27 +08:00
fix: limit the nesting depth
This commit is contained in:
@@ -1051,6 +1051,29 @@ public class XMLConfigurationTest {
|
||||
|
||||
Util.compareActualVsExpectedJsonObjects(jsonObject, expetedJsonObject);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxNestingDepthIsSet() {
|
||||
XMLParserConfiguration xmlParserConfiguration = XMLParserConfiguration.ORIGINAL;
|
||||
|
||||
assertEquals(xmlParserConfiguration.getMaxNestingDepth(), XMLParserConfiguration.UNDEFINED_MAXIMUM_NESTING_DEPTH);
|
||||
|
||||
xmlParserConfiguration = xmlParserConfiguration.withMaxNestingDepth(42);
|
||||
|
||||
assertEquals(xmlParserConfiguration.getMaxNestingDepth(), 42);
|
||||
|
||||
xmlParserConfiguration = xmlParserConfiguration.withMaxNestingDepth(0);
|
||||
|
||||
assertEquals(xmlParserConfiguration.getMaxNestingDepth(), 0);
|
||||
|
||||
xmlParserConfiguration = xmlParserConfiguration.withMaxNestingDepth(-31415926);
|
||||
|
||||
assertEquals(xmlParserConfiguration.getMaxNestingDepth(), XMLParserConfiguration.UNDEFINED_MAXIMUM_NESTING_DEPTH);
|
||||
|
||||
xmlParserConfiguration = xmlParserConfiguration.withMaxNestingDepth(Integer.MIN_VALUE);
|
||||
|
||||
assertEquals(xmlParserConfiguration.getMaxNestingDepth(), XMLParserConfiguration.UNDEFINED_MAXIMUM_NESTING_DEPTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method, given an input string and expected result,
|
||||
|
Reference in New Issue
Block a user