Skip to content

Commit b571885

Browse files
committed
Test improvement wrt #2113
1 parent d1a213e commit b571885

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberLeniencyTest.java

+8-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public class JDKNumberLeniencyTest extends BaseMapTest
88
final ObjectMapper VANILLA_MAPPER = sharedMapper();
99

1010
final ObjectMapper STRICT_MAPPER = jsonMapperBuilder()
11-
.defaultLeniency(false)
11+
.disable(MapperFeature.ALLOW_COERCION_OF_SCALARS)
12+
// .defaultLeniency(false)
1213
.build();
1314

1415
public void testBooleanLeniencyInts() throws Exception
@@ -19,23 +20,19 @@ public void testBooleanLeniencyInts() throws Exception
1920
VANILLA_MAPPER.readValue("{\"b\" : 3}", BooleanWrapper.class).b);
2021

2122
// But not with strict handling, first by global settings
22-
/*
23-
_verifyCoercionFailure(STRICT_MAPPER, "0", Boolean.class);
24-
25-
_verifyCoercionFailure(STRICT_MAPPER, "{\"b\" : 1}", BooleanWrapper.class);
26-
*/
23+
_verifyBooleanCoercionFailure(STRICT_MAPPER, "0", Boolean.class);
24+
_verifyBooleanCoercionFailure(STRICT_MAPPER, "{\"b\" : 1}", BooleanWrapper.class);
2725
}
2826

29-
protected void _verifyCoercionFailure(ObjectMapper mapper, String json, Class<?> type)
27+
protected void _verifyBooleanCoercionFailure(ObjectMapper mapper, String json, Class<?> type)
3028
throws Exception
3129
{
3230
try {
33-
VANILLA_MAPPER.readValue("1", Boolean.class);
31+
mapper.readValue(json, type);
3432
fail("Should not allow read in strict mode");
3533
} catch (MismatchedInputException e) {
36-
verifyException(e, "foo");
34+
verifyException(e, "Cannot coerce");
35+
verifyException(e, "for type `java.lang.Boolean`");
3736
}
3837
}
39-
40-
// protected ObjectMapper _
4138
}

0 commit comments

Comments
 (0)