diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java index 1f6c9a8e0..4b3593f5d 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java @@ -1,7 +1,5 @@ package com.fasterxml.jackson.dataformat.xml.stream.dos; -import com.ctc.wstx.stax.WstxInputFactory; - import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.exc.StreamReadException; @@ -22,17 +20,6 @@ public void testDeepDoc() throws Exception } } - public void testDeepDocWithCustomDepthLimit() 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(""); diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java new file mode 100644 index 000000000..f7ca7edfa --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java @@ -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(""); + for (int i = 0; i < depth; i++) { + sb.append(""); + } + sb.append("abc"); + for (int i = 0; i < depth; i++) { + sb.append(""); + } + sb.append(""); + return sb.toString(); + } +} diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NonNamespaceAwareDeser422Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java similarity index 96% rename from src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NonNamespaceAwareDeser422Test.java rename to src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java index 6c9038e08..2ec01868b 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NonNamespaceAwareDeser422Test.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java @@ -1,11 +1,9 @@ -package com.fasterxml.jackson.dataformat.xml.deser; +package com.fasterxml.jackson.dataformat.xml.woodstox; import java.util.List; import javax.xml.stream.XMLInputFactory; -import com.ctc.wstx.stax.WstxInputFactory; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.dataformat.xml.XmlFactory; @@ -14,7 +12,9 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -// [dataformat-xml#422] +// [dataformat-xml#422]: while setting itself is NOT Woodstox-specific, +// many/most Stax implementations do not offer non-namespace-aware mode +// so let's separate this into Woodstox-specific section public class NonNamespaceAwareDeser422Test extends XmlTestBase { // [dataformat-xml#422] @@ -55,7 +55,7 @@ static class RssItem { public void testBigDocIssue422() throws Exception { - final XMLInputFactory xmlInputFactory = new WstxInputFactory(); + final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false); final XmlMapper xmlMapper = XmlMapper.builder(XmlFactory.builder() .xmlInputFactory(xmlInputFactory) diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/package-info.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/package-info.java new file mode 100644 index 000000000..84e1d7a60 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/package-info.java @@ -0,0 +1,7 @@ +/** + * Package that contains Woodstox + * - specific tests, distinct from general Stax-backed tests. + * + * @since 2.17 + */ +package com.fasterxml.jackson.dataformat.xml.woodstox;