-
-
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.
Refactor Woodstox-specific tests into their own Java package (#621)
- Loading branch information
1 parent
6a125c3
commit f5cc10a
Showing
4 changed files
with
50 additions
and
18 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
38 changes: 38 additions & 0 deletions
38
...est/java/com/fasterxml/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,38 @@ | ||
package com.fasterxml.jackson.dataformat.xml.woodstox; | ||
|
||
import com.ctc.wstx.stax.WstxInputFactory; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.fasterxml.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); | ||
final XmlMapper xmlMapper = new XmlMapper(wstxInputFactory); | ||
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/com/fasterxml/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 com.fasterxml.jackson.dataformat.xml.woodstox; |