-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/tools/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package tools.jackson.dataformat.xml.woodstox; | ||
|
||
import com.ctc.wstx.stax.WstxInputFactory; | ||
|
||
import tools.jackson.core.JsonParser; | ||
|
||
import tools.jackson.dataformat.xml.XmlFactory; | ||
import tools.jackson.dataformat.xml.XmlMapper; | ||
import tools.jackson.dataformat.xml.XmlTestBase; | ||
|
||
public class DeepNestingWoodstoxParserTest extends XmlTestBase | ||
{ | ||
// Try using Woodstox-specific settings above and beyond | ||
// what Jackson-core would provide | ||
public void testDeepDocWithWoodstoxLimits() throws Exception | ||
{ | ||
final WstxInputFactory wstxInputFactory = new WstxInputFactory(); | ||
wstxInputFactory.getConfig().setMaxElementDepth(2000); | ||
XmlMapper xmlMapper = new XmlMapper( | ||
XmlFactory.builder() | ||
.xmlInputFactory(wstxInputFactory) | ||
.build()); | ||
final String XML = createDeepNestedDoc(1050); | ||
try (JsonParser p = xmlMapper.createParser(XML)) { | ||
while (p.nextToken() != null) { } | ||
} | ||
} | ||
|
||
private String createDeepNestedDoc(final int depth) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("<root>"); | ||
for (int i = 0; i < depth; i++) { | ||
sb.append("<leaf>"); | ||
} | ||
sb.append("abc"); | ||
for (int i = 0; i < depth; i++) { | ||
sb.append("</leaf>"); | ||
} | ||
sb.append("</root>"); | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/test/java/tools/jackson/dataformat/xml/woodstox/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Package that contains <a href="https://github.com/FasterXML/woodstox/">Woodstox</a> | ||
* - specific tests, distinct from general Stax-backed tests. | ||
* | ||
* @since 2.17 | ||
*/ | ||
package tools.jackson.dataformat.xml.woodstox; |