-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
eb71d68
commit efe5d07
Showing
2 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/com/fasterxml/jackson/databind/DeserializationContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.fasterxml.jackson.databind; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | ||
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class DeserializationContextTest extends DatabindTestUtil | ||
{ | ||
private final ObjectMapper MAPPER = newJsonMapper(); | ||
|
||
static class Bean4934 { | ||
public String value; | ||
} | ||
|
||
// [databind#4934] | ||
@Test | ||
public void testTreeAsValueFromNulls() throws Exception | ||
{ | ||
final JsonNodeFactory nodeF = MAPPER.getNodeFactory(); | ||
try (JsonParser p = MAPPER.createParser("abc")) { | ||
DeserializationContext ctxt = MAPPER.readerFor(String.class).createDeserializationContext(p); | ||
|
||
assertNull(ctxt.readTreeAsValue(nodeF.nullNode(), Boolean.class)); | ||
assertEquals(Boolean.FALSE, ctxt.readTreeAsValue(nodeF.nullNode(), Boolean.TYPE)); | ||
|
||
// Only fixed in 2.19: | ||
//assertNull(ctxt.readTreeAsValue(nodeF.nullNode(), Bean4934.class)); | ||
|
||
} | ||
} | ||
|
||
// [databind#4934] | ||
@Test | ||
public void testTreeAsValueFromMissing() throws Exception | ||
{ | ||
final JsonNodeFactory nodeF = MAPPER.getNodeFactory(); | ||
try (JsonParser p = MAPPER.createParser("abc")) { | ||
DeserializationContext ctxt = MAPPER.readerFor(String.class).createDeserializationContext(p); | ||
|
||
assertNull(ctxt.readTreeAsValue(nodeF.missingNode(), Boolean.class)); | ||
// Absent becomes `null` for now as well | ||
assertNull(ctxt.readTreeAsValue(nodeF.missingNode(), Boolean.TYPE)); | ||
|
||
// Only fixed in 2.19: | ||
//assertNull(ctxt.readTreeAsValue(nodeF.missingNode(), Bean4934.class)); | ||
} | ||
} | ||
} |