Skip to content

Commit 6760271

Browse files
slfan1989cnauroth
andauthored
HADOOP-19423. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-archives. (#7620)
* HADOOP-19423. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-archives. Co-authored-by: Chris Nauroth <[email protected]> Reviewed-by: Chris Nauroth <[email protected]> Signed-off-by: Shilun Fan <[email protected]>
1 parent b6682d3 commit 6760271

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java

+23-22
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@
4646
import org.apache.hadoop.util.JarFinder;
4747
import org.apache.hadoop.util.ToolRunner;
4848
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;
5752
import org.slf4j.event.Level;
5853

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+
5960
/**
6061
* test {@link HadoopArchives}
6162
*/
@@ -104,7 +105,7 @@ private static String createFile(Path root, FileSystem fs, byte[] fileContent, S
104105
return sb.toString();
105106
}
106107

107-
@Before
108+
@BeforeEach
108109
public void setUp() throws Exception {
109110
conf = new Configuration();
110111
conf.set(CapacitySchedulerConfiguration.PREFIX
@@ -133,7 +134,7 @@ public void setUp() throws Exception {
133134
fileList.add(createFile(inputPath, fs, "c"));
134135
}
135136

136-
@After
137+
@AfterEach
137138
public void tearDown() throws Exception {
138139
if (dfscluster != null) {
139140
dfscluster.shutdown();
@@ -155,7 +156,7 @@ public void testRelativePath() throws Exception {
155156

156157
// compare results:
157158
final List<String> harPaths = lsr(shell, fullHarPathStr);
158-
Assert.assertEquals(originalPaths, harPaths);
159+
assertEquals(originalPaths, harPaths);
159160
}
160161

161162
@Test
@@ -173,7 +174,7 @@ public void testRelativePathWitRepl() throws Exception {
173174

174175
// compare results:
175176
final List<String> harPaths = lsr(shell, fullHarPathStr);
176-
Assert.assertEquals(originalPaths, harPaths);
177+
assertEquals(originalPaths, harPaths);
177178
}
178179

179180
@Test
@@ -194,10 +195,10 @@ public void testOutputPathValidity() throws Exception {
194195
createFile(archivePath, fs, harName);
195196
final String[] args = { "-archiveName", harName, "-p", inputPathStr, "*",
196197
archivePath.toString() };
197-
Assert.assertEquals(-1, ToolRunner.run(har, args));
198+
assertEquals(-1, ToolRunner.run(har, args));
198199
String output = byteStream.toString();
199200
final Path outputPath = new Path(archivePath, harName);
200-
Assert.assertTrue(output.indexOf("Archive path: " + outputPath.toString()
201+
assertTrue(output.indexOf("Archive path: " + outputPath.toString()
201202
+ " already exists") != -1);
202203

203204
byteStream.reset();
@@ -207,9 +208,9 @@ public void testOutputPathValidity() throws Exception {
207208
final Path archivePath2 = new Path(archivePath, "sub1");
208209
final String[] args2 = { "-archiveName", harName, "-p", inputPathStr, "*",
209210
archivePath2.toString() };
210-
Assert.assertEquals(-1, ToolRunner.run(har, args2));
211+
assertEquals(-1, ToolRunner.run(har, args2));
211212
output = byteStream.toString();
212-
Assert.assertTrue(output.indexOf("Destination " + archivePath2.toString()
213+
assertTrue(output.indexOf("Destination " + archivePath2.toString()
213214
+ " should be a directory but is a file") != -1);
214215

215216
System.setErr(stderr);
@@ -239,7 +240,7 @@ public void testPathWithSpaces() throws Exception {
239240

240241
// compare results
241242
final List<String> harPaths = lsr(shell, fullHarPathStr);
242-
Assert.assertEquals(originalPaths, harPaths);
243+
assertEquals(originalPaths, harPaths);
243244
}
244245

245246
@Test
@@ -258,7 +259,7 @@ public void testSingleFile() throws Exception {
258259

259260
// compare results:
260261
final List<String> harPaths = lsr(shell, fullHarPathStr);
261-
Assert.assertEquals(originalPaths, harPaths);
262+
assertEquals(originalPaths, harPaths);
262263
}
263264

264265
@Test
@@ -283,7 +284,7 @@ public void testGlobFiles() throws Exception {
283284
// compare results:
284285
final List<String> harPaths = lsr(shell, fullHarPathStr,
285286
fullHarPathStr + "/" + glob);
286-
Assert.assertEquals(originalPaths, harPaths);
287+
assertEquals(originalPaths, harPaths);
287288
}
288289

289290
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,
302303
System.setErr(out);
303304
final String results;
304305
try {
305-
Assert.assertEquals(0, shell.run(new String[] { "-lsr", dir }));
306+
assertEquals(0, shell.run(new String[]{"-lsr", dir}));
306307
results = bytes.toString();
307308
} finally {
308309
IOUtils.closeStream(out);
@@ -605,7 +606,7 @@ private static byte[] readAllWithSeek(final int totalLength,
605606
private static void expectSeekIOE(FSDataInputStream fsdis, long seekPos, String message) {
606607
try {
607608
fsdis.seek(seekPos);
608-
assertTrue(message + " (Position = " + fsdis.getPos() + ")", false);
609+
assertTrue(false, message + " (Position = " + fsdis.getPos() + ")");
609610
} catch (IOException ioe) {
610611
// okay
611612
}
@@ -764,7 +765,7 @@ private String makeArchiveWithRepl() throws Exception {
764765
while (listFiles.hasNext()) {
765766
LocatedFileStatus next = listFiles.next();
766767
if (!next.getPath().toString().endsWith("_SUCCESS")) {
767-
assertEquals(next.getPath().toString(), 2, next.getReplication());
768+
assertEquals(2, next.getReplication(), next.getPath().toString());
768769
}
769770
}
770771
return fullHarPathStr;

0 commit comments

Comments
 (0)