diff --git a/afterburner/src/test/java/tools/jackson/module/afterburner/deser/filter/TestUnknownPropertyDeserialization.java b/afterburner/src/test/java/tools/jackson/module/afterburner/deser/filter/TestUnknownPropertyDeserialization.java index 6d369e36..94e54537 100644 --- a/afterburner/src/test/java/tools/jackson/module/afterburner/deser/filter/TestUnknownPropertyDeserialization.java +++ b/afterburner/src/test/java/tools/jackson/module/afterburner/deser/filter/TestUnknownPropertyDeserialization.java @@ -135,7 +135,9 @@ static class Bean987 { public void testUnknownHandlingDefault() throws Exception { try { - MAPPER.readValue(new StringReader(JSON_UNKNOWN_FIELD), TestBean.class); + MAPPER.readerFor(TestBean.class) + .with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .readValue(new StringReader(JSON_UNKNOWN_FIELD)); fail("Should not pass"); } catch (UnrecognizedPropertyException jex) { verifyException(jex, "Unrecognized property \"foo\""); @@ -231,14 +233,16 @@ public void testClassWithIgnoreUnknown() throws Exception */ public void testClassWithUnknownAndIgnore() throws Exception { + ObjectReader r = MAPPER.readerFor(ImplicitIgnores.class) + .with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); // should be ok: "a" and "b" ignored, "c" mapped: - ImplicitIgnores result = MAPPER.readValue - ("{\"a\":1,\"b\":2,\"c\":3 }", ImplicitIgnores.class); + ImplicitIgnores result = r.readValue + ("{\"a\":1,\"b\":2,\"c\":3 }"); assertEquals(3, result.c); // but "d" is not defined, so should still error try { - MAPPER.readValue("{\"a\":1,\"b\":2,\"c\":3,\"d\":4 }", ImplicitIgnores.class); + r.readValue("{\"a\":1,\"b\":2,\"c\":3,\"d\":4 }"); fail("Should not pass"); } catch (UnrecognizedPropertyException e) { verifyException(e, "Unrecognized property \"d\""); diff --git a/afterburner/src/test/java/tools/jackson/module/afterburner/deser/merge/PropertyMergeTest.java b/afterburner/src/test/java/tools/jackson/module/afterburner/deser/merge/PropertyMergeTest.java index 01dca917..ca6e14b4 100644 --- a/afterburner/src/test/java/tools/jackson/module/afterburner/deser/merge/PropertyMergeTest.java +++ b/afterburner/src/test/java/tools/jackson/module/afterburner/deser/merge/PropertyMergeTest.java @@ -181,6 +181,7 @@ public void testBeanAsArrayMerging() throws Exception // and finally with extra, failing try { MAPPER.readerForUpdating(input) + .with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .readValue("[9, 8, 14]"); fail("Should not pass"); } catch (MismatchedInputException e) { diff --git a/blackbird/src/test/java/tools/jackson/module/blackbird/deser/filter/TestUnknownPropertyDeserialization.java b/blackbird/src/test/java/tools/jackson/module/blackbird/deser/filter/TestUnknownPropertyDeserialization.java index c94f6fa1..821e7061 100644 --- a/blackbird/src/test/java/tools/jackson/module/blackbird/deser/filter/TestUnknownPropertyDeserialization.java +++ b/blackbird/src/test/java/tools/jackson/module/blackbird/deser/filter/TestUnknownPropertyDeserialization.java @@ -4,8 +4,10 @@ import java.util.*; import com.fasterxml.jackson.annotation.*; + import tools.jackson.core.*; import tools.jackson.core.type.TypeReference; + import tools.jackson.databind.*; import tools.jackson.databind.deser.DeserializationProblemHandler; import tools.jackson.databind.exc.UnrecognizedPropertyException; @@ -135,7 +137,9 @@ static class Bean987 { public void testUnknownHandlingDefault() throws Exception { try { - MAPPER.readValue(new StringReader(JSON_UNKNOWN_FIELD), TestBean.class); + MAPPER.readerFor(TestBean.class) + .with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .readValue(new StringReader(JSON_UNKNOWN_FIELD)); fail("Should not pass"); } catch (UnrecognizedPropertyException e) { verifyException(e, "Unrecognized property \"foo\""); @@ -230,14 +234,17 @@ public void testClassWithIgnoreUnknown() throws Exception */ public void testClassWithUnknownAndIgnore() throws Exception { + ObjectReader r = MAPPER.readerFor(ImplicitIgnores.class) + .with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + // should be ok: "a" and "b" ignored, "c" mapped: - ImplicitIgnores result = MAPPER.readValue - ("{\"a\":1,\"b\":2,\"c\":3 }", ImplicitIgnores.class); + ImplicitIgnores result = r.readValue + ("{\"a\":1,\"b\":2,\"c\":3 }"); assertEquals(3, result.c); // but "d" is not defined, so should still error try { - MAPPER.readValue("{\"a\":1,\"b\":2,\"c\":3,\"d\":4 }", ImplicitIgnores.class); + r.readValue("{\"a\":1,\"b\":2,\"c\":3,\"d\":4 }"); fail("Should not pass"); } catch (UnrecognizedPropertyException e) { verifyException(e, "Unrecognized property \"d\""); diff --git a/blackbird/src/test/java/tools/jackson/module/blackbird/deser/merge/PropertyMergeTest.java b/blackbird/src/test/java/tools/jackson/module/blackbird/deser/merge/PropertyMergeTest.java index 45fee00d..768e80b8 100644 --- a/blackbird/src/test/java/tools/jackson/module/blackbird/deser/merge/PropertyMergeTest.java +++ b/blackbird/src/test/java/tools/jackson/module/blackbird/deser/merge/PropertyMergeTest.java @@ -182,6 +182,7 @@ public void testBeanAsArrayMerging() throws Exception // and finally with extra, failing try { MAPPER.readerForUpdating(input) + .with(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .readValue("[9, 8, 14]"); fail("Should not pass"); } catch (MismatchedInputException e) {