File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
src/test/java/com/fasterxml/jackson/failing Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import com .fasterxml .jackson .databind .*;
4
+
5
+ // [databind#3234]
6
+ public class CoerceEmptyToInt3234Test extends BaseMapTest
7
+ {
8
+ static class BasicIntWrapper {
9
+ public int value = 13 ;
10
+ }
11
+
12
+ static class BasicLongWrapper {
13
+ public long value = 7L ;
14
+ }
15
+
16
+ private final ObjectMapper MAPPER = newJsonMapper ();
17
+ private final ObjectReader READER_INT_BASIC = MAPPER .readerFor (BasicIntWrapper .class );
18
+ private final ObjectReader READER_LONG_BASIC = MAPPER .readerFor (BasicLongWrapper .class );
19
+
20
+ // // // Ints
21
+
22
+ public void testSimpleIntFromEmpty () throws Exception
23
+ {
24
+ BasicIntWrapper w = READER_INT_BASIC .readValue (a2q ("{'value':''}" ));
25
+ assertEquals (0 , w .value );
26
+ }
27
+
28
+ public void testSimpleIntFromBlank () throws Exception
29
+ {
30
+ BasicIntWrapper w = READER_INT_BASIC .readValue (a2q ("{'value':' '}" ));
31
+ assertEquals (0 , w .value );
32
+ }
33
+
34
+ // // // Long
35
+
36
+ public void testSimpleLongFromEmpty () throws Exception
37
+ {
38
+ BasicLongWrapper w = READER_LONG_BASIC .readValue (a2q ("{'value':''}" ));
39
+ assertEquals (0L , w .value );
40
+ }
41
+
42
+ public void testSimpleLongFromBlank () throws Exception
43
+ {
44
+ BasicLongWrapper w = READER_LONG_BASIC .readValue (a2q ("{'value':' '}" ));
45
+ assertEquals (0L , w .value );
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments