3
3
import java .io .*;
4
4
import java .util .*;
5
5
6
- import static org .junit .Assert .* ;
6
+ import org .junit .jupiter . api . Test ;
7
7
8
8
import com .fasterxml .jackson .core .*;
9
9
import com .fasterxml .jackson .core .type .TypeReference ;
12
12
import com .fasterxml .jackson .databind .jsontype .TypeSerializer ;
13
13
import com .fasterxml .jackson .databind .module .SimpleModule ;
14
14
15
+ import static org .junit .jupiter .api .Assertions .*;
16
+
17
+ import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .a2q ;
18
+ import static com .fasterxml .jackson .databind .testutil .DatabindTestUtil .q ;
19
+
20
+
15
21
/**
16
22
* This unit test suite tries to verify that the "Native" java type
17
23
* mapper can properly re-construct Java array objects from Json arrays.
18
24
*/
19
25
public class ArrayDeserializationTest
20
- extends BaseMapTest
21
26
{
22
27
public final static class Bean1
23
28
{
@@ -142,6 +147,7 @@ static class HiddenBinaryBean890 {
142
147
143
148
private final ObjectMapper MAPPER = new ObjectMapper ();
144
149
150
+ @ Test
145
151
public void testUntypedArray () throws Exception
146
152
{
147
153
@@ -160,6 +166,7 @@ public void testUntypedArray() throws Exception
160
166
assertEquals (Double .valueOf (2.0 ), result [4 ]);
161
167
}
162
168
169
+ @ Test
163
170
public void testIntegerArray () throws Exception
164
171
{
165
172
final int LEN = 90000 ;
@@ -186,6 +193,7 @@ public void testIntegerArray() throws Exception
186
193
}
187
194
188
195
// [JACKSON-620]: allow "" to mean 'null' for Arrays, List and Maps
196
+ @ Test
189
197
public void testFromEmptyString () throws Exception
190
198
{
191
199
ObjectReader r = MAPPER .reader ()
@@ -196,6 +204,7 @@ public void testFromEmptyString() throws Exception
196
204
}
197
205
198
206
// [JACKSON-620]: allow "" to mean 'null' for Arrays, List and Maps
207
+ @ Test
199
208
public void testFromEmptyString2 () throws Exception
200
209
{
201
210
ObjectReader r = MAPPER .readerFor (Product .class )
@@ -212,6 +221,7 @@ public void testFromEmptyString2() throws Exception
212
221
/**********************************************************
213
222
*/
214
223
224
+ @ Test
215
225
public void testUntypedArrayOfArrays () throws Exception
216
226
{
217
227
// to get "untyped" default map-to-map, pass Object[].class
@@ -244,6 +254,7 @@ public void testUntypedArrayOfArrays() throws Exception
244
254
/**********************************************************
245
255
*/
246
256
257
+ @ Test
247
258
public void testStringArray () throws Exception
248
259
{
249
260
final String [] STRS = new String [] {
@@ -273,6 +284,7 @@ public void testStringArray() throws Exception
273
284
assertNull (result [0 ]);
274
285
}
275
286
287
+ @ Test
276
288
public void testCharArray () throws Exception
277
289
{
278
290
final String TEST_STR = "Let's just test it? Ok!" ;
@@ -290,6 +302,7 @@ public void testCharArray() throws Exception
290
302
/**********************************************************
291
303
*/
292
304
305
+ @ Test
293
306
public void testBooleanArray () throws Exception
294
307
{
295
308
boolean [] result = MAPPER .readValue ("[ true, false, false ]" , boolean [].class );
@@ -300,6 +313,7 @@ public void testBooleanArray() throws Exception
300
313
assertFalse (result [2 ]);
301
314
}
302
315
316
+ @ Test
303
317
public void testByteArrayAsNumbers () throws Exception
304
318
{
305
319
final int LEN = 37000 ;
@@ -325,6 +339,7 @@ public void testByteArrayAsNumbers() throws Exception
325
339
assertEquals (0 , result [LEN ]);
326
340
}
327
341
342
+ @ Test
328
343
public void testByteArrayAsBase64 () throws Exception
329
344
{
330
345
/* Hmmh... let's use JsonGenerator here, to hopefully ensure we
@@ -354,6 +369,7 @@ public void testByteArrayAsBase64() throws Exception
354
369
* And then bit more challenging case; let's try decoding
355
370
* multiple byte arrays from an array...
356
371
*/
372
+ @ Test
357
373
public void testByteArraysAsBase64 () throws Exception
358
374
{
359
375
JsonFactory jf = new JsonFactory ();
@@ -384,11 +400,12 @@ public void testByteArraysAsBase64() throws Exception
384
400
assertEquals (entryCount , result .length );
385
401
for (int i = 0 ; i < entryCount ; ++i ) {
386
402
byte [] b = result [i ];
387
- assertArrayEquals ("Comparing entry #" +i +"/" +entryCount , entries [ i ], b );
403
+ assertArrayEquals (entries [ i ], b , "Comparing entry #" +i +"/" +entryCount );
388
404
}
389
405
}
390
406
391
407
// [JACKSON-763]
408
+ @ Test
392
409
public void testByteArraysWith763 () throws Exception
393
410
{
394
411
String [] input = new String [] { "YQ==" , "Yg==" , "Yw==" };
@@ -398,6 +415,7 @@ public void testByteArraysWith763() throws Exception
398
415
assertEquals ("c" , new String (data [2 ], "US-ASCII" ));
399
416
}
400
417
418
+ @ Test
401
419
public void testShortArray () throws Exception
402
420
{
403
421
final int LEN = 31001 ; // fits in signed 16-bit
@@ -421,6 +439,7 @@ public void testShortArray() throws Exception
421
439
}
422
440
}
423
441
442
+ @ Test
424
443
public void testIntArray () throws Exception
425
444
{
426
445
final int LEN = 70000 ;
@@ -446,6 +465,7 @@ public void testIntArray() throws Exception
446
465
}
447
466
}
448
467
468
+ @ Test
449
469
public void testLongArray () throws Exception
450
470
{
451
471
final int LEN = 12300 ;
@@ -469,6 +489,7 @@ public void testLongArray() throws Exception
469
489
}
470
490
}
471
491
492
+ @ Test
472
493
public void testDoubleArray () throws Exception
473
494
{
474
495
final int LEN = 7000 ;
@@ -496,6 +517,7 @@ public void testDoubleArray() throws Exception
496
517
}
497
518
}
498
519
520
+ @ Test
499
521
public void testFloatArray () throws Exception
500
522
{
501
523
final int LEN = 7000 ;
@@ -526,6 +548,7 @@ public void testFloatArray() throws Exception
526
548
/**********************************************************
527
549
*/
528
550
551
+ @ Test
529
552
public void testBeanArray ()
530
553
throws Exception
531
554
{
@@ -558,6 +581,7 @@ public void testBeanArray()
558
581
*/
559
582
560
583
// for [databind#890]
584
+ @ Test
561
585
public void testByteArrayTypeOverride890 () throws Exception
562
586
{
563
587
HiddenBinaryBean890 result = MAPPER .readValue (
@@ -573,6 +597,7 @@ public void testByteArrayTypeOverride890() throws Exception
573
597
/**********************************************************
574
598
*/
575
599
600
+ @ Test
576
601
public void testCustomDeserializers () throws Exception
577
602
{
578
603
ObjectMapper mapper = new ObjectMapper ();
0 commit comments