17
17
*/
18
18
package org .apache .hadoop .io .compress ;
19
19
20
- import static org .junit .Assert .assertArrayEquals ;
21
- import static org .junit .Assert .assertEquals ;
22
- import static org .junit .Assert .assertTrue ;
23
- import static org .junit .Assert .fail ;
20
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
21
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
22
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
23
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
24
+ import static org .junit .jupiter .api .Assertions .fail ;
24
25
25
26
import java .io .ByteArrayInputStream ;
26
27
import java .io .ByteArrayOutputStream ;
37
38
import org .apache .hadoop .io .compress .zlib .ZlibFactory ;
38
39
import org .apache .hadoop .util .NativeCodeLoader ;
39
40
import org .apache .log4j .Logger ;
40
- import org .junit .Assert ;
41
41
42
42
import org .apache .hadoop .thirdparty .com .google .common .base .Joiner ;
43
43
import org .apache .hadoop .thirdparty .com .google .common .collect .ImmutableList ;
44
44
import org .apache .hadoop .thirdparty .com .google .common .collect .ImmutableMap ;
45
45
import org .apache .hadoop .thirdparty .com .google .common .collect .ImmutableSet ;
46
- import static org .junit .Assert .*;
47
46
48
47
public class CompressDecompressTester <T extends Compressor , E extends Decompressor > {
49
48
@@ -274,12 +273,10 @@ public void assertCompression(String name, Compressor compressor,
274
273
int maxCompressedLength = 32 + rawData .length + rawData .length /6 ;
275
274
byte [] compressedResult = new byte [maxCompressedLength ];
276
275
byte [] decompressedBytes = new byte [rawData .length ];
277
- assertTrue (
278
- joiner .join (name , "compressor.needsInput before error !!!" ),
279
- compressor .needsInput ());
280
- assertEquals (
281
- joiner .join (name , "compressor.getBytesWritten before error !!!" ),
282
- 0 , compressor .getBytesWritten ());
276
+ assertTrue (compressor .needsInput (),
277
+ joiner .join (name , "compressor.needsInput before error !!!" ));
278
+ assertEquals (0 , compressor .getBytesWritten (),
279
+ joiner .join (name , "compressor.getBytesWritten before error !!!" ));
283
280
compressor .setInput (rawData , 0 , rawData .length );
284
281
compressor .finish ();
285
282
while (!compressor .finished ()) {
@@ -288,23 +285,20 @@ public void assertCompression(String name, Compressor compressor,
288
285
}
289
286
compressor .reset ();
290
287
291
- assertTrue (
292
- joiner .join (name , "decompressor.needsInput() before error !!!" ),
293
- decompressor .needsInput ());
288
+ assertTrue (decompressor .needsInput (),
289
+ joiner .join (name , "decompressor.needsInput() before error !!!" ));
294
290
decompressor .setInput (compressedResult , 0 , cSize );
295
- assertFalse (
296
- joiner .join (name , "decompressor.needsInput() after error !!!" ),
297
- decompressor .needsInput ());
291
+ assertFalse (decompressor .needsInput (),
292
+ joiner .join (name , "decompressor.needsInput() after error !!!" ));
298
293
while (!decompressor .finished ()) {
299
294
decompressedSize = decompressor .decompress (decompressedBytes , 0 ,
300
295
decompressedBytes .length );
301
296
}
302
297
decompressor .reset ();
303
- assertEquals (joiner .join (name , " byte size not equals error !!!" ),
304
- rawData .length , decompressedSize );
305
- assertArrayEquals (
306
- joiner .join (name , " byte arrays not equals error !!!" ), rawData ,
307
- decompressedBytes );
298
+ assertEquals (rawData .length , decompressedSize ,
299
+ joiner .join (name , " byte size not equals error !!!" ));
300
+ assertArrayEquals (rawData , decompressedBytes ,
301
+ joiner .join (name , " byte arrays not equals error !!!" ));
308
302
}
309
303
}),
310
304
@@ -331,17 +325,16 @@ void assertCompression(String name, Compressor compressor,
331
325
// check compressed output
332
326
buf = bytesOut .toByteArray ();
333
327
int emSize = emptySize .get (compressor .getClass ());
334
- Assert .assertEquals (
335
- joiner .join (name , "empty stream compressed output size != "
336
- + emSize ), emSize , buf .length );
328
+ assertEquals (emSize , buf .length ,
329
+ joiner .join (name , "empty stream compressed output size != " + emSize ));
337
330
// use compressed output as input for decompression
338
331
bytesIn = new ByteArrayInputStream (buf );
339
332
// create decompression stream
340
333
blockDecompressorStream = new BlockDecompressorStream (bytesIn ,
341
334
decompressor , 1024 );
342
335
// no byte is available because stream was closed
343
- assertEquals (joiner . join ( name , " return value is not -1" ), -1 ,
344
- blockDecompressorStream .read ());
336
+ assertEquals (-1 ,
337
+ blockDecompressorStream .read (), joiner . join ( name , " return value is not -1" ) );
345
338
} catch (IOException e ) {
346
339
fail (joiner .join (name , e .getMessage ()));
347
340
} finally {
@@ -407,9 +400,8 @@ public void assertCompression(String name, Compressor compressor,
407
400
decompressor .reset ();
408
401
off = off + step ;
409
402
}
410
- assertArrayEquals (
411
- joiner .join (name , "byte arrays not equals error !!!" ),
412
- originalRawData , decompressOut .toByteArray ());
403
+ assertArrayEquals (originalRawData , decompressOut .toByteArray (),
404
+ joiner .join (name , "byte arrays not equals error !!!" ));
413
405
} catch (Exception ex ) {
414
406
throw new AssertionError (name + ex , ex );
415
407
} finally {
0 commit comments