@@ -245,7 +245,7 @@ public void testSingleString() throws Exception
245
245
String result = MAPPER .readValue ("\" " +value +"\" " , String .class );
246
246
assertEquals (value , result );
247
247
}
248
-
248
+
249
249
public void testSingleStringWrapped () throws Exception
250
250
{
251
251
final ObjectMapper mapper = new ObjectMapper ();
@@ -256,8 +256,7 @@ public void testSingleStringWrapped() throws Exception
256
256
mapper .readValue ("[\" " +value +"\" ]" , String .class );
257
257
fail ("Exception not thrown when attempting to unwrap a single value 'String' array into a simple String" );
258
258
} catch (MismatchedInputException exp ) {
259
- verifyException (exp , "Cannot deserialize" );
260
- verifyException (exp , "out of START_ARRAY" );
259
+ _verifyNoDeserFromArray (exp );
261
260
}
262
261
263
262
mapper .enable (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS );
@@ -284,8 +283,7 @@ public void testBigDecimal() throws Exception
284
283
mapper .readValue ("[" + value .toString () + "]" , BigDecimal .class );
285
284
fail ("Exception was not thrown when attempting to read a single value array of BigDecimal when UNWRAP_SINGLE_VALUE_ARRAYS feature is disabled" );
286
285
} catch (MismatchedInputException exp ) {
287
- verifyException (exp , "Cannot deserialize" );
288
- verifyException (exp , "out of START_ARRAY" );
286
+ _verifyNoDeserFromArray (exp );
289
287
}
290
288
291
289
mapper .enable (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS );
@@ -313,8 +311,7 @@ public void testBigInteger() throws Exception
313
311
mapper .readValue ("[" + value .toString () + "]" , BigInteger .class );
314
312
fail ("Exception was not thrown when attempting to read a single value array of BigInteger when UNWRAP_SINGLE_VALUE_ARRAYS feature is disabled" );
315
313
} catch (MismatchedInputException exp ) {
316
- verifyException (exp , "Cannot deserialize" );
317
- verifyException (exp , "out of START_ARRAY" );
314
+ _verifyNoDeserFromArray (exp );
318
315
}
319
316
320
317
mapper .enable (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS );
@@ -343,7 +340,7 @@ public void testClassAsArray() throws Exception
343
340
.readValue ("[" + quote (String .class .getName ()) + "]" );
344
341
fail ("Did not throw exception when UNWRAP_SINGLE_VALUE_ARRAYS feature was disabled and attempted to read a Class array containing one element" );
345
342
} catch (MismatchedInputException e ) {
346
- verifyException ( e , "out of START_ARRAY token" );
343
+ _verifyNoDeserFromArray ( e );
347
344
}
348
345
349
346
_verifyMultiValueArrayFail ("[" + quote (Object .class .getName ()) + "," + quote (Object .class .getName ()) +"]" ,
@@ -363,7 +360,7 @@ public void testURIAsArray() throws Exception
363
360
.readValue ("[\" " +value .toString ()+"\" ]" );
364
361
fail ("Did not throw exception for single value array when UNWRAP_SINGLE_VALUE_ARRAYS is disabled" );
365
362
} catch (MismatchedInputException e ) {
366
- verifyException ( e , "out of START_ARRAY token" );
363
+ _verifyNoDeserFromArray ( e );
367
364
}
368
365
369
366
_verifyMultiValueArrayFail ("[\" " +value .toString ()+"\" ,\" " +value .toString ()+"\" ]" , URI .class );
@@ -379,7 +376,7 @@ public void testUUIDAsArray() throws Exception
379
376
.readValue ("[" + quote (uuidStr ) + "]" );
380
377
fail ("Exception was not thrown when UNWRAP_SINGLE_VALUE_ARRAYS is disabled and attempted to read a single value array as a single element" );
381
378
} catch (MismatchedInputException e ) {
382
- verifyException ( e , "out of START_ARRAY token" );
379
+ _verifyNoDeserFromArray ( e );
383
380
}
384
381
assertEquals (uuid ,
385
382
reader .with (DeserializationFeature .UNWRAP_SINGLE_VALUE_ARRAYS )
@@ -393,6 +390,12 @@ public void testUUIDAsArray() throws Exception
393
390
/**********************************************************
394
391
*/
395
392
393
+ private void _verifyNoDeserFromArray (Exception e ) {
394
+ verifyException (e , "Cannot deserialize" );
395
+ verifyException (e , "from Array value" );
396
+ verifyException (e , "JsonToken.START_ARRAY" );
397
+ }
398
+
396
399
private void _verifyMultiValueArrayFail (String input , Class <?> type ) throws IOException {
397
400
try {
398
401
UNWRAPPING_READER .forType (type ).readValue (input );
0 commit comments