Skip to content

Commit

Permalink
minor test cleanup to ease merging to 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 30, 2019
1 parent b353cad commit 603d70a
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;

import java.io.IOException;

Expand Down Expand Up @@ -38,12 +39,15 @@ private NestedJsonEntity(@JsonProperty("entity") JsonEntity entity) {
/**********************************************************
*/

private final ObjectMapper MAPPER = sharedMapper();

// [databind#2101]: ensure that the property is included in the path
public void testCreatorNullPrimitive() throws IOException {
ObjectMapper objectMapper = new ObjectMapper().enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
final ObjectReader r = MAPPER.readerFor(JsonEntity.class)
.with(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
String json = aposToQuotes("{'x': 2}");
try {
objectMapper.readValue(json, JsonEntity.class);
r.readValue(json);
fail("Should not have succeeded");
} catch (JsonMappingException e) {
verifyException(e, "Cannot map `null` into type int");
Expand All @@ -53,10 +57,11 @@ public void testCreatorNullPrimitive() throws IOException {
}

public void testCreatorNullPrimitiveInNestedObject() throws IOException {
ObjectMapper objectMapper = new ObjectMapper().enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
final ObjectReader r = MAPPER.readerFor(NestedJsonEntity.class)
.with(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
String json = aposToQuotes("{ 'entity': {'x': 2}}");
try {
objectMapper.readValue(json, NestedJsonEntity.class);
r.readValue(json);
fail("Should not have succeeded");
} catch (JsonMappingException e) {
verifyException(e, "Cannot map `null` into type int");
Expand Down

0 comments on commit 603d70a

Please sign in to comment.