|
6 | 6 | import com.fasterxml.jackson.databind.*;
|
7 | 7 |
|
8 | 8 | // [databind#2816]
|
9 |
| -public class DeepNestingWithUntyped2816Test extends BaseMapTest |
| 9 | +public class DeepNestingDeser2816Test extends BaseMapTest |
10 | 10 | {
|
11 |
| - // 2000 passes, 3000 fails |
12 |
| - private final static int TOO_DEEP_NESTING = 4000; |
| 11 | + // 2000 passes for all; 3000 fails for untyped, 5000 for tree/object, |
| 12 | + // 8000 for tree/array too |
| 13 | + private final static int TOO_DEEP_NESTING = 8000; |
13 | 14 |
|
14 | 15 | private final ObjectMapper MAPPER = newJsonMapper();
|
15 | 16 |
|
16 |
| - public void testWithArray() throws Exception |
| 17 | + public void testUntypedWithArray() throws Exception |
17 | 18 | {
|
18 | 19 | final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] ");
|
19 | 20 | Object ob = MAPPER.readValue(doc, Object.class);
|
20 | 21 | assertTrue(ob instanceof List<?>);
|
21 | 22 | }
|
22 | 23 |
|
23 |
| - public void testWithObject() throws Exception |
| 24 | + public void testUntypedWithObject() throws Exception |
24 | 25 | {
|
25 | 26 | final String doc = "{"+_nestedDoc(TOO_DEEP_NESTING, "\"x\":{", "} ") + "}";
|
26 | 27 | Object ob = MAPPER.readValue(doc, Object.class);
|
27 | 28 | assertTrue(ob instanceof Map<?,?>);
|
28 | 29 | }
|
29 | 30 |
|
| 31 | + public void testTreeWithArray() throws Exception |
| 32 | + { |
| 33 | + final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] "); |
| 34 | + JsonNode n = MAPPER.readTree(doc); |
| 35 | + assertTrue(n.isArray()); |
| 36 | + } |
| 37 | + |
| 38 | + public void testTreeWithObject() throws Exception |
| 39 | + { |
| 40 | + final String doc = "{"+_nestedDoc(TOO_DEEP_NESTING, "\"x\":{", "} ") + "}"; |
| 41 | + JsonNode n = MAPPER.readTree(doc); |
| 42 | + assertTrue(n.isObject()); |
| 43 | + } |
| 44 | + |
30 | 45 | private String _nestedDoc(int nesting, String open, String close) {
|
31 | 46 | StringBuilder sb = new StringBuilder(nesting * (open.length() + close.length()));
|
32 | 47 | for (int i = 0; i < nesting; ++i) {
|
|
0 commit comments