37
37
import org .apache .hadoop .io .erasurecode .CodecUtil ;
38
38
import org .apache .hadoop .io .erasurecode .ErasureCoderOptions ;
39
39
import org .apache .hadoop .io .erasurecode .rawcoder .RawErasureEncoder ;
40
- import org .junit .Assert ;
41
40
import org .slf4j .Logger ;
42
41
import org .slf4j .LoggerFactory ;
43
42
55
54
import java .util .concurrent .TimeoutException ;
56
55
import java .util .concurrent .atomic .AtomicInteger ;
57
56
58
- import static org .junit .Assert .assertEquals ;
57
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
58
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
59
+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
60
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
61
+ import static org .junit .jupiter .api .Assertions .fail ;
59
62
60
63
public class StripedFileTestUtil {
61
64
public static final Logger LOG =
@@ -77,7 +80,7 @@ static byte getByte(long pos) {
77
80
static void verifyLength (FileSystem fs , Path srcPath , int fileLength )
78
81
throws IOException {
79
82
FileStatus status = fs .getFileStatus (srcPath );
80
- assertEquals ("File length should be the same" , fileLength , status . getLen () );
83
+ assertEquals (fileLength , status . getLen (), "File length should be the same" );
81
84
}
82
85
83
86
static void verifyPread (DistributedFileSystem fs , Path srcPath ,
@@ -109,9 +112,8 @@ static void verifyPread(FileSystem fs, Path srcPath, int fileLength,
109
112
offset += target ;
110
113
}
111
114
for (int i = 0 ; i < fileLength - startOffset ; i ++) {
112
- assertEquals ("Byte at " + (startOffset + i ) + " is different, "
113
- + "the startOffset is " + startOffset , expected [startOffset + i ],
114
- result [i ]);
115
+ assertEquals (expected [startOffset + i ], result [i ], "Byte at " + (startOffset + i ) +
116
+ " is different, " + "the startOffset is " + startOffset );
115
117
}
116
118
}
117
119
}
@@ -127,8 +129,8 @@ static void verifyStatefulRead(FileSystem fs, Path srcPath, int fileLength,
127
129
System .arraycopy (buf , 0 , result , readLen , ret );
128
130
readLen += ret ;
129
131
}
130
- assertEquals ("The length of file should be the same to write size" , fileLength , readLen );
131
- Assert . assertArrayEquals (expected , result );
132
+ assertEquals (fileLength , readLen , "The length of file should be the same to write size" );
133
+ assertArrayEquals (expected , result );
132
134
}
133
135
}
134
136
@@ -144,8 +146,8 @@ static void verifyStatefulRead(FileSystem fs, Path srcPath, int fileLength,
144
146
result .put (buf );
145
147
buf .clear ();
146
148
}
147
- assertEquals ("The length of file should be the same to write size" , fileLength , readLen );
148
- Assert . assertArrayEquals (expected , result .array ());
149
+ assertEquals (fileLength , readLen , "The length of file should be the same to write size" );
150
+ assertArrayEquals (expected , result .array ());
149
151
}
150
152
}
151
153
@@ -185,14 +187,14 @@ static void verifySeek(FileSystem fs, Path srcPath, int fileLength,
185
187
if (!(in .getWrappedStream () instanceof WebHdfsInputStream )) {
186
188
try {
187
189
in .seek (-1 );
188
- Assert . fail ("Should be failed if seek to negative offset" );
190
+ fail ("Should be failed if seek to negative offset" );
189
191
} catch (EOFException e ) {
190
192
// expected
191
193
}
192
194
193
195
try {
194
196
in .seek (fileLength + 1 );
195
- Assert . fail ("Should be failed if seek after EOF" );
197
+ fail ("Should be failed if seek after EOF" );
196
198
} catch (EOFException e ) {
197
199
// expected
198
200
}
@@ -206,8 +208,8 @@ static void assertSeekAndRead(FSDataInputStream fsdis, int pos,
206
208
byte [] buf = new byte [writeBytes - pos ];
207
209
IOUtils .readFully (fsdis , buf , 0 , buf .length );
208
210
for (int i = 0 ; i < buf .length ; i ++) {
209
- assertEquals ("Byte at " + i + " should be the same" ,
210
- StripedFileTestUtil . getByte ( pos + i ), buf [ i ] );
211
+ assertEquals (StripedFileTestUtil . getByte ( pos + i ) ,
212
+ buf [ i ], "Byte at " + i + " should be the same" );
211
213
}
212
214
}
213
215
@@ -225,7 +227,7 @@ static DatanodeInfo getDatanodes(StripedDataStreamer streamer) {
225
227
final DatanodeInfo [] datanodes = streamer .getNodes ();
226
228
if (datanodes != null ) {
227
229
assertEquals (1 , datanodes .length );
228
- Assert . assertNotNull (datanodes [0 ]);
230
+ assertNotNull (datanodes [0 ]);
229
231
return datanodes [0 ];
230
232
}
231
233
try {
@@ -377,13 +379,13 @@ static void checkData(DistributedFileSystem dfs, Path srcPath, int length,
377
379
final int parityBlkNum = ecPolicy .getNumParityUnits ();
378
380
int index = 0 ;
379
381
for (LocatedBlock firstBlock : lbs .getLocatedBlocks ()) {
380
- Assert . assertTrue (firstBlock instanceof LocatedStripedBlock );
382
+ assertTrue (firstBlock instanceof LocatedStripedBlock );
381
383
382
384
final long gs = firstBlock .getBlock ().getGenerationStamp ();
383
385
final long oldGS = oldGSList != null ? oldGSList .get (index ++) : -1L ;
384
386
final String s = "gs=" + gs + ", oldGS=" + oldGS ;
385
387
LOG .info (s );
386
- Assert . assertTrue (s , gs >= oldGS );
388
+ assertTrue (gs >= oldGS , s );
387
389
388
390
LocatedBlock [] blocks = StripedBlockUtil .parseStripedBlockGroup (
389
391
(LocatedStripedBlock ) firstBlock , cellSize ,
@@ -456,7 +458,7 @@ static void checkData(DistributedFileSystem dfs, Path srcPath, int length,
456
458
for (int posInBlk = 0 ; posInBlk < actual .length ; posInBlk ++) {
457
459
final long posInFile = StripedBlockUtil .offsetInBlkToOffsetInBG (
458
460
cellSize , dataBlkNum , posInBlk , i ) + groupPosInFile ;
459
- Assert . assertTrue (posInFile < length );
461
+ assertTrue (posInFile < length );
460
462
final byte expected = getByte (posInFile );
461
463
462
464
if (killed ) {
@@ -466,7 +468,7 @@ static void checkData(DistributedFileSystem dfs, Path srcPath, int length,
466
468
String s = "expected=" + expected + " but actual=" + actual [posInBlk ]
467
469
+ ", posInFile=" + posInFile + ", posInBlk=" + posInBlk
468
470
+ ". group=" + group + ", i=" + i ;
469
- Assert . fail (s );
471
+ fail (s );
470
472
}
471
473
}
472
474
}
@@ -507,12 +509,12 @@ static void verifyParityBlocks(Configuration conf, final long size,
507
509
try {
508
510
encoder .encode (dataBytes , expectedParityBytes );
509
511
} catch (IOException e ) {
510
- Assert . fail ("Unexpected IOException: " + e .getMessage ());
512
+ fail ("Unexpected IOException: " + e .getMessage ());
511
513
}
512
514
for (int i = 0 ; i < parityBytes .length ; i ++) {
513
515
if (checkSet .contains (i + dataBytes .length )){
514
- Assert . assertArrayEquals ("i=" + i , expectedParityBytes [i ],
515
- parityBytes [i ]);
516
+ assertArrayEquals (expectedParityBytes [i ],
517
+ parityBytes [i ], "i=" + i );
516
518
}
517
519
}
518
520
}
0 commit comments