@@ -111,21 +111,28 @@ public void testBooleanPrimitive() throws Exception
111
111
// first, simple case:
112
112
BooleanBean result = MAPPER .readValue (new StringReader ("{\" v\" :true}" ), BooleanBean .class );
113
113
assertTrue (result ._v );
114
- // then [JACKSON-79]:
115
114
result = MAPPER .readValue (new StringReader ("{\" v\" :null}" ), BooleanBean .class );
116
115
assertNotNull (result );
117
116
assertFalse (result ._v );
117
+ // [databind#1480]
118
+ result = MAPPER .readValue (new StringReader ("{\" v\" :1}" ), BooleanBean .class );
119
+ assertNotNull (result );
120
+ assertTrue (result ._v );
118
121
119
122
// should work with arrays too..
120
123
boolean [] array = MAPPER .readValue (new StringReader ("[ null ]" ), boolean [].class );
121
124
assertNotNull (array );
122
125
assertEquals (1 , array .length );
123
126
assertFalse (array [0 ]);
127
+
128
+ }
124
129
125
- // [Issue#381]
130
+ public void testBooleanPrimitiveArrayUnwrap () throws Exception
131
+ {
132
+ // [databind#381]
126
133
final ObjectMapper mapper = new ObjectMapper ();
127
134
mapper .enable (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS );
128
- result = mapper .readValue (new StringReader ("{\" v\" :[true]}" ), BooleanBean .class );
135
+ BooleanBean result = mapper .readValue (new StringReader ("{\" v\" :[true]}" ), BooleanBean .class );
129
136
assertTrue (result ._v );
130
137
131
138
try {
@@ -143,7 +150,7 @@ public void testBooleanPrimitive() throws Exception
143
150
assertNotNull (result );
144
151
assertFalse (result ._v );
145
152
146
- array = mapper .readValue (new StringReader ("[ [ null ] ]" ), boolean [].class );
153
+ boolean [] array = mapper .readValue (new StringReader ("[ [ null ] ]" ), boolean [].class );
147
154
assertNotNull (array );
148
155
assertEquals (1 , array .length );
149
156
assertFalse (array [0 ]);
@@ -161,9 +168,9 @@ public void testBooleanWrapper() throws Exception
161
168
assertEquals (Boolean .FALSE , result );
162
169
163
170
// should accept ints too, (0 == false, otherwise true)
164
- result = MAPPER .readValue (new StringReader ( "0" ) , Boolean .class );
171
+ result = MAPPER .readValue ("0" , Boolean .class );
165
172
assertEquals (Boolean .FALSE , result );
166
- result = MAPPER .readValue (new StringReader ( "1" ) , Boolean .class );
173
+ result = MAPPER .readValue ("1" , Boolean .class );
167
174
assertEquals (Boolean .TRUE , result );
168
175
}
169
176
0 commit comments