Skip to content

Commit 78297f0

Browse files
committed
Add a verification of fix in jackson-core/#1361
1 parent 568066d commit 78297f0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.fasterxml.jackson.databind.node;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import com.fasterxml.jackson.core.JsonPointer;
6+
import com.fasterxml.jackson.databind.*;
7+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
8+
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
import static org.junit.jupiter.api.Assertions.assertFalse;
11+
12+
// For [core#1361] (not databind)
13+
public class JsonPointerCore1361Test extends DatabindTestUtil
14+
{
15+
@Test
16+
public void test1361() throws Exception
17+
{
18+
ObjectMapper om = newJsonMapper();
19+
ObjectNode jo = om.createObjectNode();
20+
ArrayNode nums = om.createArrayNode().add(42).add(-99);
21+
jo.set("num~s",nums);
22+
JsonPointer jp = JsonPointer.compile("/num~s/0");
23+
24+
jo.remove("num~s");
25+
jo.set("nums~",nums);
26+
jp = JsonPointer.compile("/nums~");
27+
28+
jo.remove("num~s");
29+
jo.set("nums~",nums);
30+
jp = JsonPointer.compile("/nums~/0");
31+
32+
JsonNode elem0 = jo.at(jp);
33+
assertFalse(elem0.isMissingNode());
34+
assertEquals(42, elem0.asInt());
35+
}
36+
}

0 commit comments

Comments
 (0)