From b5718850982f710f64591f2d398126b9f2e1702c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 9 Sep 2019 22:46:35 -0700 Subject: [PATCH] Test improvement wrt #2113 --- .../deser/jdk/JDKNumberLeniencyTest.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberLeniencyTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberLeniencyTest.java index 4a963aba46..b7269cbf73 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberLeniencyTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberLeniencyTest.java @@ -8,7 +8,8 @@ public class JDKNumberLeniencyTest extends BaseMapTest final ObjectMapper VANILLA_MAPPER = sharedMapper(); final ObjectMapper STRICT_MAPPER = jsonMapperBuilder() - .defaultLeniency(false) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) +// .defaultLeniency(false) .build(); public void testBooleanLeniencyInts() throws Exception @@ -19,23 +20,19 @@ public void testBooleanLeniencyInts() throws Exception VANILLA_MAPPER.readValue("{\"b\" : 3}", BooleanWrapper.class).b); // But not with strict handling, first by global settings - /* - _verifyCoercionFailure(STRICT_MAPPER, "0", Boolean.class); - - _verifyCoercionFailure(STRICT_MAPPER, "{\"b\" : 1}", BooleanWrapper.class); - */ + _verifyBooleanCoercionFailure(STRICT_MAPPER, "0", Boolean.class); + _verifyBooleanCoercionFailure(STRICT_MAPPER, "{\"b\" : 1}", BooleanWrapper.class); } - protected void _verifyCoercionFailure(ObjectMapper mapper, String json, Class type) + protected void _verifyBooleanCoercionFailure(ObjectMapper mapper, String json, Class type) throws Exception { try { - VANILLA_MAPPER.readValue("1", Boolean.class); + mapper.readValue(json, type); fail("Should not allow read in strict mode"); } catch (MismatchedInputException e) { - verifyException(e, "foo"); + verifyException(e, "Cannot coerce"); + verifyException(e, "for type `java.lang.Boolean`"); } } - - // protected ObjectMapper _ }