File tree 4 files changed +50
-18
lines changed
src/test/java/com/fasterxml/jackson/dataformat/xml
4 files changed +50
-18
lines changed Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .dataformat .xml .stream .dos ;
2
2
3
- import com .ctc .wstx .stax .WstxInputFactory ;
4
-
5
3
import com .fasterxml .jackson .core .JsonParser ;
6
4
import com .fasterxml .jackson .core .exc .StreamReadException ;
7
5
@@ -22,17 +20,6 @@ public void testDeepDoc() throws Exception
22
20
}
23
21
}
24
22
25
- public void testDeepDocWithCustomDepthLimit () throws Exception
26
- {
27
- final WstxInputFactory wstxInputFactory = new WstxInputFactory ();
28
- wstxInputFactory .getConfig ().setMaxElementDepth (2000 );
29
- final XmlMapper xmlMapper = new XmlMapper (wstxInputFactory );
30
- final String XML = createDeepNestedDoc (1050 );
31
- try (JsonParser p = xmlMapper .createParser (XML )) {
32
- while (p .nextToken () != null ) { }
33
- }
34
- }
35
-
36
23
private String createDeepNestedDoc (final int depth ) {
37
24
StringBuilder sb = new StringBuilder ();
38
25
sb .append ("<root>" );
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .xml .woodstox ;
2
+
3
+ import com .ctc .wstx .stax .WstxInputFactory ;
4
+
5
+ import com .fasterxml .jackson .core .JsonParser ;
6
+
7
+ import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
8
+ import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
9
+
10
+ public class DeepNestingWoodstoxParserTest extends XmlTestBase
11
+ {
12
+ // Try using Woodstox-specific settings above and beyond
13
+ // what Jackson-core would provide
14
+ public void testDeepDocWithWoodstoxLimits () throws Exception
15
+ {
16
+ final WstxInputFactory wstxInputFactory = new WstxInputFactory ();
17
+ wstxInputFactory .getConfig ().setMaxElementDepth (2000 );
18
+ final XmlMapper xmlMapper = new XmlMapper (wstxInputFactory );
19
+ final String XML = createDeepNestedDoc (1050 );
20
+ try (JsonParser p = xmlMapper .createParser (XML )) {
21
+ while (p .nextToken () != null ) { }
22
+ }
23
+ }
24
+
25
+ private String createDeepNestedDoc (final int depth ) {
26
+ StringBuilder sb = new StringBuilder ();
27
+ sb .append ("<root>" );
28
+ for (int i = 0 ; i < depth ; i ++) {
29
+ sb .append ("<leaf>" );
30
+ }
31
+ sb .append ("abc" );
32
+ for (int i = 0 ; i < depth ; i ++) {
33
+ sb .append ("</leaf>" );
34
+ }
35
+ sb .append ("</root>" );
36
+ return sb .toString ();
37
+ }
38
+ }
Original file line number Diff line number Diff line change 1
- package com .fasterxml .jackson .dataformat .xml .deser ;
1
+ package com .fasterxml .jackson .dataformat .xml .woodstox ;
2
2
3
3
import java .util .List ;
4
4
5
5
import javax .xml .stream .XMLInputFactory ;
6
6
7
- import com .ctc .wstx .stax .WstxInputFactory ;
8
-
9
7
import com .fasterxml .jackson .annotation .JsonIgnoreProperties ;
10
8
11
9
import com .fasterxml .jackson .dataformat .xml .XmlFactory ;
14
12
import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlElementWrapper ;
15
13
import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlProperty ;
16
14
17
- // [dataformat-xml#422]
15
+ // [dataformat-xml#422]: while setting itself is NOT Woodstox-specific,
16
+ // many/most Stax implementations do not offer non-namespace-aware mode
17
+ // so let's separate this into Woodstox-specific section
18
18
public class NonNamespaceAwareDeser422Test extends XmlTestBase
19
19
{
20
20
// [dataformat-xml#422]
@@ -55,7 +55,7 @@ static class RssItem {
55
55
56
56
public void testBigDocIssue422 () throws Exception
57
57
{
58
- final XMLInputFactory xmlInputFactory = new WstxInputFactory ();
58
+ final XMLInputFactory xmlInputFactory = XMLInputFactory . newInstance ();
59
59
xmlInputFactory .setProperty (XMLInputFactory .IS_NAMESPACE_AWARE , false );
60
60
final XmlMapper xmlMapper = XmlMapper .builder (XmlFactory .builder ()
61
61
.xmlInputFactory (xmlInputFactory )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Package that contains <a href="https://github.com/FasterXML/woodstox/">Woodstox</a>
3
+ * - specific tests, distinct from general Stax-backed tests.
4
+ *
5
+ * @since 2.17
6
+ */
7
+ package com .fasterxml .jackson .dataformat .xml .woodstox ;
You can’t perform that action at this time.
0 commit comments