Skip to content

Commit

Permalink
Add a verification of fix in jackson-core/#1361
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 25, 2024
1 parent 568066d commit 78297f0
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.fasterxml.jackson.databind.node;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.core.JsonPointer;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

// For [core#1361] (not databind)
public class JsonPointerCore1361Test extends DatabindTestUtil
{
@Test
public void test1361() throws Exception
{
ObjectMapper om = newJsonMapper();
ObjectNode jo = om.createObjectNode();
ArrayNode nums = om.createArrayNode().add(42).add(-99);
jo.set("num~s",nums);
JsonPointer jp = JsonPointer.compile("/num~s/0");

jo.remove("num~s");
jo.set("nums~",nums);
jp = JsonPointer.compile("/nums~");

jo.remove("num~s");
jo.set("nums~",nums);
jp = JsonPointer.compile("/nums~/0");

JsonNode elem0 = jo.at(jp);
assertFalse(elem0.isMissingNode());
assertEquals(42, elem0.asInt());
}
}

0 comments on commit 78297f0

Please sign in to comment.