@@ -8,7 +8,8 @@ public class JDKNumberLeniencyTest extends BaseMapTest
8
8
final ObjectMapper VANILLA_MAPPER = sharedMapper ();
9
9
10
10
final ObjectMapper STRICT_MAPPER = jsonMapperBuilder ()
11
- .defaultLeniency (false )
11
+ .disable (MapperFeature .ALLOW_COERCION_OF_SCALARS )
12
+ // .defaultLeniency(false)
12
13
.build ();
13
14
14
15
public void testBooleanLeniencyInts () throws Exception
@@ -19,23 +20,19 @@ public void testBooleanLeniencyInts() throws Exception
19
20
VANILLA_MAPPER .readValue ("{\" b\" : 3}" , BooleanWrapper .class ).b );
20
21
21
22
// 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 );
27
25
}
28
26
29
- protected void _verifyCoercionFailure (ObjectMapper mapper , String json , Class <?> type )
27
+ protected void _verifyBooleanCoercionFailure (ObjectMapper mapper , String json , Class <?> type )
30
28
throws Exception
31
29
{
32
30
try {
33
- VANILLA_MAPPER .readValue ("1" , Boolean . class );
31
+ mapper .readValue (json , type );
34
32
fail ("Should not allow read in strict mode" );
35
33
} catch (MismatchedInputException e ) {
36
- verifyException (e , "foo" );
34
+ verifyException (e , "Cannot coerce" );
35
+ verifyException (e , "for type `java.lang.Boolean`" );
37
36
}
38
37
}
39
-
40
- // protected ObjectMapper _
41
38
}
0 commit comments