1010
1111/**
1212 * Unit test(s) for verifying handling of new (in 2.15) StreamReadConstraints
13- * wrt maximum nesting depth.
13+ * wrt maximum nesting depth, for all streaming (InputStream,
14+ * Reader; regular/throttled) inputs and {@link DataInput}.
15+ *
1416 */
1517class DeeplyNestedContentReadTest
16- extends com .fasterxml .jackson .core .JUnit5TestBase
18+ extends com .fasterxml .jackson .core .JUnit5TestBase
1719{
1820 private final JsonFactory JSON_F = newStreamFactory ();
1921
@@ -32,6 +34,15 @@ void deepNestingStreaming() throws Exception
3234 }
3335 }
3436
37+ @ Test
38+ void deepNestingDataInput () throws Exception
39+ {
40+ final String DOC = createDeepNestedDoc (TESTED_NESTING );
41+ try (JsonParser p = createParser (JSON_F , MODE_DATA_INPUT , DOC )) {
42+ _testDeepNesting (p );
43+ }
44+ }
45+
3546 private void _testDeepNesting (JsonParser p ) throws Exception
3647 {
3748 try {
@@ -44,7 +55,7 @@ private void _testDeepNesting(JsonParser p) throws Exception
4455 }
4556
4657 @ Test
47- void legacyConstraintSettingTest () throws Exception
58+ void legacyConstraintSettingStreaming () throws Exception
4859 {
4960 final int LOWER_MAX = 40 ;
5061
@@ -59,6 +70,20 @@ void legacyConstraintSettingTest() throws Exception
5970 }
6071 }
6172
73+ @ Test
74+ void legacyConstraintSettingDataInput () throws Exception
75+ {
76+ final int LOWER_MAX = 40 ;
77+
78+ final String DOC = createDeepNestedDoc (LOWER_MAX + 10 );
79+ JsonFactory f = new JsonFactory ();
80+ f .setStreamReadConstraints (StreamReadConstraints .builder ()
81+ .maxNestingDepth (LOWER_MAX ).build ());
82+ try (JsonParser p = createParser (f , MODE_DATA_INPUT , DOC )) {
83+ _testLegacyConstraintSettingTest (p , LOWER_MAX );
84+ }
85+ }
86+
6287 private void _testLegacyConstraintSettingTest (JsonParser p , int maxNesting ) throws Exception
6388 {
6489 try {
0 commit comments