Skip to content

Commit

Permalink
Bit more testing wrt #2816
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 13, 2020
1 parent b358792 commit 0a8157c
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0a8157c

Please sign in to comment.