-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab9413a
commit 9874b0e
Showing
4 changed files
with
85 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/java/com/fasterxml/jackson/databind/deser/jdk/JDKNumberLeniencyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.fasterxml.jackson.databind.deser.jdk; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.exc.MismatchedInputException; | ||
|
||
public class JDKNumberLeniencyTest extends BaseMapTest | ||
{ | ||
final ObjectMapper VANILLA_MAPPER = sharedMapper(); | ||
|
||
final ObjectMapper STRICT_MAPPER = jsonMapperBuilder() | ||
.defaultLeniency(false) | ||
.build(); | ||
|
||
public void testBooleanLeniencyInts() throws Exception | ||
{ | ||
// First: read from integers fine by default | ||
assertEquals(Boolean.TRUE, VANILLA_MAPPER.readValue("1", Boolean.class)); | ||
assertEquals(Boolean.TRUE, | ||
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); | ||
*/ | ||
} | ||
|
||
protected void _verifyCoercionFailure(ObjectMapper mapper, String json, Class<?> type) | ||
throws Exception | ||
{ | ||
try { | ||
VANILLA_MAPPER.readValue("1", Boolean.class); | ||
fail("Should not allow read in strict mode"); | ||
} catch (MismatchedInputException e) { | ||
verifyException(e, "foo"); | ||
} | ||
} | ||
|
||
// protected ObjectMapper _ | ||
} |