Skip to content

Commit

Permalink
Add a failing test for #3214
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 1, 2021
1 parent 9019677 commit ef38891
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.node.TextNode;

public class NullJsonNodeViaCreator3214Test extends BaseMapTest
{
static class Pojo3214
{
JsonNode fromCtor = TextNode.valueOf("x");
JsonNode fromSetter = TextNode.valueOf("x");

@JsonCreator
public Pojo3214(@JsonProperty("node") JsonNode n) {
this.fromCtor = n;
}

public void setNodeFromSetter(JsonNode nodeFromSetter) {
this.fromSetter = nodeFromSetter;
}
}

private final ObjectMapper MAPPER = newJsonMapper();

// [databind#3214]
public void testNullFromMissingNodeParameter() throws Exception
{
Pojo3214 p = MAPPER.readValue("{}", Pojo3214.class);
if (p.fromCtor != null) {
fail("Expected null to be passed, got instance of "+p.fromCtor.getClass());
}
}
}

0 comments on commit ef38891

Please sign in to comment.