6
6
public class JsonPointerWithNodeTest
7
7
extends BaseMapTest
8
8
{
9
+ private final ObjectMapper MAPPER = newJsonMapper ();
10
+
9
11
public void testIt () throws Exception
10
12
{
11
- final JsonNode SAMPLE_ROOT = objectMapper () .readTree (SAMPLE_DOC_JSON_SPEC );
13
+ final JsonNode SAMPLE_ROOT = MAPPER .readTree (SAMPLE_DOC_JSON_SPEC );
12
14
13
15
// first: "empty" pointer points to context node:
14
16
assertSame (SAMPLE_ROOT , SAMPLE_ROOT .at (JsonPointer .compile ("" )));
17
+ // second: "/" is NOT root, but "root property with name of Empty String"
18
+ assertTrue (SAMPLE_ROOT .at (JsonPointer .compile ("/" )).isMissingNode ());
15
19
16
20
// then simple reference
17
21
assertTrue (SAMPLE_ROOT .at (JsonPointer .compile ("/Image" )).isObject ());
@@ -32,18 +36,25 @@ public void testIt() throws Exception
32
36
assertTrue (SAMPLE_ROOT .at ("/Image/1" ).isMissingNode ());
33
37
}
34
38
35
- // To help verify [Core #133]; should be fine with "big numbers" as property keys
39
+ // To help verify [core #133]; should be fine with "big numbers" as property keys
36
40
public void testLongNumbers () throws Exception
37
41
{
38
-
39
42
// First, with small int key
40
- JsonNode root = objectMapper () .readTree ("{\" 123\" : 456}" );
43
+ JsonNode root = MAPPER .readTree ("{\" 123\" : 456}" );
41
44
JsonNode jn2 = root .at ("/123" );
42
45
assertEquals (456 , jn2 .asInt ());
43
46
44
47
// and then with above int-32:
45
- root = objectMapper () .readTree ("{\" 35361706045\" : 1234}" );
48
+ root = MAPPER .readTree ("{\" 35361706045\" : 1234}" );
46
49
jn2 = root .at ("/35361706045" );
47
50
assertEquals (1234 , jn2 .asInt ());
48
51
}
52
+
53
+ // [databind#2934]
54
+ public void testIssue2934 () throws Exception
55
+ {
56
+ JsonNode tree = MAPPER .readTree ("{\" \" : 123}" );
57
+ assertEquals (123 , tree .at ("/" ).intValue ());
58
+ assertSame (tree , tree .at ("" ));
59
+ }
49
60
}
0 commit comments