diff --git a/src/test/java/com/fasterxml/jackson/failing/DeepNestingWithUntyped2816Test.java b/src/test/java/com/fasterxml/jackson/failing/DeepNestingDeser2816Test.java similarity index 59% rename from src/test/java/com/fasterxml/jackson/failing/DeepNestingWithUntyped2816Test.java rename to src/test/java/com/fasterxml/jackson/failing/DeepNestingDeser2816Test.java index 86cf66f25f..b6ab2252ae 100644 --- a/src/test/java/com/fasterxml/jackson/failing/DeepNestingWithUntyped2816Test.java +++ b/src/test/java/com/fasterxml/jackson/failing/DeepNestingDeser2816Test.java @@ -6,27 +6,42 @@ import com.fasterxml.jackson.databind.*; // [databind#2816] -public class DeepNestingWithUntyped2816Test extends BaseMapTest +public class DeepNestingDeser2816Test extends BaseMapTest { - // 2000 passes, 3000 fails - private final static int TOO_DEEP_NESTING = 4000; + // 2000 passes for all; 3000 fails for untyped, 5000 for tree/object, + // 8000 for tree/array too + private final static int TOO_DEEP_NESTING = 8000; private final ObjectMapper MAPPER = newJsonMapper(); - public void testWithArray() throws Exception + public void testUntypedWithArray() throws Exception { final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] "); Object ob = MAPPER.readValue(doc, Object.class); assertTrue(ob instanceof List); } - public void testWithObject() throws Exception + public void testUntypedWithObject() throws Exception { final String doc = "{"+_nestedDoc(TOO_DEEP_NESTING, "\"x\":{", "} ") + "}"; Object ob = MAPPER.readValue(doc, Object.class); assertTrue(ob instanceof Map); } + public void testTreeWithArray() throws Exception + { + final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] "); + JsonNode n = MAPPER.readTree(doc); + assertTrue(n.isArray()); + } + + public void testTreeWithObject() throws Exception + { + final String doc = "{"+_nestedDoc(TOO_DEEP_NESTING, "\"x\":{", "} ") + "}"; + JsonNode n = MAPPER.readTree(doc); + assertTrue(n.isObject()); + } + private String _nestedDoc(int nesting, String open, String close) { StringBuilder sb = new StringBuilder(nesting * (open.length() + close.length())); for (int i = 0; i < nesting; ++i) {