Skip to content

Commit 9659d43

Browse files
committed
test refactoring
1 parent 9080182 commit 9659d43

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.fasterxml.jackson.databind.node;
2+
3+
import java.io.ByteArrayInputStream;
4+
import java.io.StringReader;
5+
6+
import com.fasterxml.jackson.databind.*;
7+
8+
/**
9+
* Tests to verify handling of empty content with "readTree()"
10+
*/
11+
public class EmptyContentAsTreeTest extends BaseMapTest
12+
{
13+
private final ObjectMapper MAPPER = objectMapper();
14+
15+
// [databind#1406]: when passing `JsonParser`, indicate lack of content
16+
// by returning `null`
17+
18+
public void testNullFromEOFWithParser() throws Exception
19+
{
20+
assertNull(MAPPER.readTree(new StringReader("")));
21+
assertNull(MAPPER.readTree(new ByteArrayInputStream(new byte[0])));
22+
}
23+
24+
// [databind#1406]
25+
public void testNullFromEOFWithParserViaReader() throws Exception
26+
{
27+
assertNull(MAPPER.readTree(new StringReader("")));
28+
assertNull(MAPPER.readTree(new ByteArrayInputStream(new byte[0])));
29+
assertNull(MAPPER.readerFor(JsonNode.class)
30+
.readTree(new StringReader("")));
31+
assertNull(MAPPER.readerFor(JsonNode.class)
32+
.readTree(new ByteArrayInputStream(new byte[0])));
33+
}
34+
35+
// [databind#2211]: when passing content sources OTHER than `JsonParser`,
36+
// return "missing node" instead of alternate (return `null`, throw exception).
37+
public void testMissingNodeForEOFOther() throws Exception
38+
{
39+
40+
}
41+
42+
public void testMissingNodeForEOFOtherViaReader() throws Exception
43+
{
44+
45+
}
46+
}

0 commit comments

Comments
 (0)