46
46
import org .apache .hadoop .util .JarFinder ;
47
47
import org .apache .hadoop .util .ToolRunner ;
48
48
import org .apache .hadoop .yarn .server .resourcemanager .scheduler .capacity .CapacitySchedulerConfiguration ;
49
- import org .junit .After ;
50
- import org .junit .Assert ;
51
- import static org .junit .Assert .*;
52
- import static org .slf4j .LoggerFactory .getLogger ;
53
- import static org .assertj .core .api .Assertions .assertThat ;
54
-
55
- import org .junit .Before ;
56
- import org .junit .Test ;
49
+ import org .junit .jupiter .api .AfterEach ;
50
+ import org .junit .jupiter .api .BeforeEach ;
51
+ import org .junit .jupiter .api .Test ;
57
52
import org .slf4j .event .Level ;
58
53
54
+ import static org .assertj .core .api .Assertions .assertThat ;
55
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
56
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
57
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
58
+ import static org .slf4j .LoggerFactory .getLogger ;
59
+
59
60
/**
60
61
* test {@link HadoopArchives}
61
62
*/
@@ -104,7 +105,7 @@ private static String createFile(Path root, FileSystem fs, byte[] fileContent, S
104
105
return sb .toString ();
105
106
}
106
107
107
- @ Before
108
+ @ BeforeEach
108
109
public void setUp () throws Exception {
109
110
conf = new Configuration ();
110
111
conf .set (CapacitySchedulerConfiguration .PREFIX
@@ -133,7 +134,7 @@ public void setUp() throws Exception {
133
134
fileList .add (createFile (inputPath , fs , "c" ));
134
135
}
135
136
136
- @ After
137
+ @ AfterEach
137
138
public void tearDown () throws Exception {
138
139
if (dfscluster != null ) {
139
140
dfscluster .shutdown ();
@@ -155,7 +156,7 @@ public void testRelativePath() throws Exception {
155
156
156
157
// compare results:
157
158
final List <String > harPaths = lsr (shell , fullHarPathStr );
158
- Assert . assertEquals (originalPaths , harPaths );
159
+ assertEquals (originalPaths , harPaths );
159
160
}
160
161
161
162
@ Test
@@ -173,7 +174,7 @@ public void testRelativePathWitRepl() throws Exception {
173
174
174
175
// compare results:
175
176
final List <String > harPaths = lsr (shell , fullHarPathStr );
176
- Assert . assertEquals (originalPaths , harPaths );
177
+ assertEquals (originalPaths , harPaths );
177
178
}
178
179
179
180
@ Test
@@ -194,10 +195,10 @@ public void testOutputPathValidity() throws Exception {
194
195
createFile (archivePath , fs , harName );
195
196
final String [] args = { "-archiveName" , harName , "-p" , inputPathStr , "*" ,
196
197
archivePath .toString () };
197
- Assert . assertEquals (-1 , ToolRunner .run (har , args ));
198
+ assertEquals (-1 , ToolRunner .run (har , args ));
198
199
String output = byteStream .toString ();
199
200
final Path outputPath = new Path (archivePath , harName );
200
- Assert . assertTrue (output .indexOf ("Archive path: " + outputPath .toString ()
201
+ assertTrue (output .indexOf ("Archive path: " + outputPath .toString ()
201
202
+ " already exists" ) != -1 );
202
203
203
204
byteStream .reset ();
@@ -207,9 +208,9 @@ public void testOutputPathValidity() throws Exception {
207
208
final Path archivePath2 = new Path (archivePath , "sub1" );
208
209
final String [] args2 = { "-archiveName" , harName , "-p" , inputPathStr , "*" ,
209
210
archivePath2 .toString () };
210
- Assert . assertEquals (-1 , ToolRunner .run (har , args2 ));
211
+ assertEquals (-1 , ToolRunner .run (har , args2 ));
211
212
output = byteStream .toString ();
212
- Assert . assertTrue (output .indexOf ("Destination " + archivePath2 .toString ()
213
+ assertTrue (output .indexOf ("Destination " + archivePath2 .toString ()
213
214
+ " should be a directory but is a file" ) != -1 );
214
215
215
216
System .setErr (stderr );
@@ -239,7 +240,7 @@ public void testPathWithSpaces() throws Exception {
239
240
240
241
// compare results
241
242
final List <String > harPaths = lsr (shell , fullHarPathStr );
242
- Assert . assertEquals (originalPaths , harPaths );
243
+ assertEquals (originalPaths , harPaths );
243
244
}
244
245
245
246
@ Test
@@ -258,7 +259,7 @@ public void testSingleFile() throws Exception {
258
259
259
260
// compare results:
260
261
final List <String > harPaths = lsr (shell , fullHarPathStr );
261
- Assert . assertEquals (originalPaths , harPaths );
262
+ assertEquals (originalPaths , harPaths );
262
263
}
263
264
264
265
@ Test
@@ -283,7 +284,7 @@ public void testGlobFiles() throws Exception {
283
284
// compare results:
284
285
final List <String > harPaths = lsr (shell , fullHarPathStr ,
285
286
fullHarPathStr + "/" + glob );
286
- Assert . assertEquals (originalPaths , harPaths );
287
+ assertEquals (originalPaths , harPaths );
287
288
}
288
289
289
290
private static List <String > lsr (final FsShell shell , String rootDir ) throws Exception {
@@ -302,7 +303,7 @@ private static List<String> lsr(final FsShell shell, String rootDir,
302
303
System .setErr (out );
303
304
final String results ;
304
305
try {
305
- Assert . assertEquals (0 , shell .run (new String [] { "-lsr" , dir }));
306
+ assertEquals (0 , shell .run (new String []{ "-lsr" , dir }));
306
307
results = bytes .toString ();
307
308
} finally {
308
309
IOUtils .closeStream (out );
@@ -605,7 +606,7 @@ private static byte[] readAllWithSeek(final int totalLength,
605
606
private static void expectSeekIOE (FSDataInputStream fsdis , long seekPos , String message ) {
606
607
try {
607
608
fsdis .seek (seekPos );
608
- assertTrue (message + " (Position = " + fsdis .getPos () + ")" , false );
609
+ assertTrue (false , message + " (Position = " + fsdis .getPos () + ")" );
609
610
} catch (IOException ioe ) {
610
611
// okay
611
612
}
@@ -764,7 +765,7 @@ private String makeArchiveWithRepl() throws Exception {
764
765
while (listFiles .hasNext ()) {
765
766
LocatedFileStatus next = listFiles .next ();
766
767
if (!next .getPath ().toString ().endsWith ("_SUCCESS" )) {
767
- assertEquals (next .getPath (). toString (), 2 , next .getReplication ());
768
+ assertEquals (2 , next .getReplication (), next .getPath (). toString ());
768
769
}
769
770
}
770
771
return fullHarPathStr ;
0 commit comments