Skip to content

Commit 1a994c8

Browse files
committed
add passing tests for #2932
1 parent c7f27e8 commit 1a994c8

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/test/java/com/fasterxml/jackson/databind/node/JsonPointerWithNodeTest.java

+16-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
public class JsonPointerWithNodeTest
77
extends BaseMapTest
88
{
9+
private final ObjectMapper MAPPER = newJsonMapper();
10+
911
public void testIt() throws Exception
1012
{
11-
final JsonNode SAMPLE_ROOT = objectMapper().readTree(SAMPLE_DOC_JSON_SPEC);
13+
final JsonNode SAMPLE_ROOT = MAPPER.readTree(SAMPLE_DOC_JSON_SPEC);
1214

1315
// first: "empty" pointer points to context node:
1416
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());
1519

1620
// then simple reference
1721
assertTrue(SAMPLE_ROOT.at(JsonPointer.compile("/Image")).isObject());
@@ -32,18 +36,25 @@ public void testIt() throws Exception
3236
assertTrue(SAMPLE_ROOT.at("/Image/1").isMissingNode());
3337
}
3438

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
3640
public void testLongNumbers() throws Exception
3741
{
38-
3942
// First, with small int key
40-
JsonNode root = objectMapper().readTree("{\"123\" : 456}");
43+
JsonNode root = MAPPER.readTree("{\"123\" : 456}");
4144
JsonNode jn2 = root.at("/123");
4245
assertEquals(456, jn2.asInt());
4346

4447
// and then with above int-32:
45-
root = objectMapper().readTree("{\"35361706045\" : 1234}");
48+
root = MAPPER.readTree("{\"35361706045\" : 1234}");
4649
jn2 = root.at("/35361706045");
4750
assertEquals(1234, jn2.asInt());
4851
}
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+
}
4960
}

0 commit comments

Comments
 (0)