-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e1cd09
commit b358792
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/test/java/com/fasterxml/jackson/failing/DeepNestingWithUntyped2816Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
// [databind#2816] | ||
public class DeepNestingWithUntyped2816Test extends BaseMapTest | ||
{ | ||
// 2000 passes, 3000 fails | ||
private final static int TOO_DEEP_NESTING = 4000; | ||
|
||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
public void testWithArray() 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 | ||
{ | ||
final String doc = "{"+_nestedDoc(TOO_DEEP_NESTING, "\"x\":{", "} ") + "}"; | ||
Object ob = MAPPER.readValue(doc, Object.class); | ||
assertTrue(ob instanceof Map<?,?>); | ||
} | ||
|
||
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) { | ||
sb.append(open); | ||
if ((i & 31) == 0) { | ||
sb.append("\n"); | ||
} | ||
} | ||
for (int i = 0; i < nesting; ++i) { | ||
sb.append(close); | ||
if ((i & 31) == 0) { | ||
sb.append("\n"); | ||
} | ||
} | ||
return sb.toString(); | ||
} | ||
} |