This is an automated email from the ASF dual-hosted git repository. slfan1989 pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push: new 676027176de HADOOP-19423. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-archives. (#7620) 676027176de is described below commit 676027176de7d4a64db436320838ab6dca0eaec7 Author: slfan1989 <55643692+slfan1...@users.noreply.github.com> AuthorDate: Thu Apr 24 06:18:57 2025 +0800 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 <cnaur...@apache.org> Reviewed-by: Chris Nauroth <cnaur...@apache.org> Signed-off-by: Shilun Fan <slfan1...@apache.org> --- .../apache/hadoop/tools/TestHadoopArchives.java | 45 +++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java index 3267a683c27..9adf29d078d 100644 --- a/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java +++ b/hadoop-tools/hadoop-archives/src/test/java/org/apache/hadoop/tools/TestHadoopArchives.java @@ -46,16 +46,17 @@ import org.apache.hadoop.util.JarFinder; import org.apache.hadoop.util.ToolRunner; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; -import org.junit.After; -import org.junit.Assert; -import static org.junit.Assert.*; -import static org.slf4j.LoggerFactory.getLogger; -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.event.Level; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.slf4j.LoggerFactory.getLogger; + /** * test {@link HadoopArchives} */ @@ -104,7 +105,7 @@ private static String createFile(Path root, FileSystem fs, byte[] fileContent, S return sb.toString(); } - @Before + @BeforeEach public void setUp() throws Exception { conf = new Configuration(); conf.set(CapacitySchedulerConfiguration.PREFIX @@ -133,7 +134,7 @@ public void setUp() throws Exception { fileList.add(createFile(inputPath, fs, "c")); } - @After + @AfterEach public void tearDown() throws Exception { if (dfscluster != null) { dfscluster.shutdown(); @@ -155,7 +156,7 @@ public void testRelativePath() throws Exception { // compare results: final List<String> harPaths = lsr(shell, fullHarPathStr); - Assert.assertEquals(originalPaths, harPaths); + assertEquals(originalPaths, harPaths); } @Test @@ -173,7 +174,7 @@ public void testRelativePathWitRepl() throws Exception { // compare results: final List<String> harPaths = lsr(shell, fullHarPathStr); - Assert.assertEquals(originalPaths, harPaths); + assertEquals(originalPaths, harPaths); } @Test @@ -194,10 +195,10 @@ public void testOutputPathValidity() throws Exception { createFile(archivePath, fs, harName); final String[] args = { "-archiveName", harName, "-p", inputPathStr, "*", archivePath.toString() }; - Assert.assertEquals(-1, ToolRunner.run(har, args)); + assertEquals(-1, ToolRunner.run(har, args)); String output = byteStream.toString(); final Path outputPath = new Path(archivePath, harName); - Assert.assertTrue(output.indexOf("Archive path: " + outputPath.toString() + assertTrue(output.indexOf("Archive path: " + outputPath.toString() + " already exists") != -1); byteStream.reset(); @@ -207,9 +208,9 @@ public void testOutputPathValidity() throws Exception { final Path archivePath2 = new Path(archivePath, "sub1"); final String[] args2 = { "-archiveName", harName, "-p", inputPathStr, "*", archivePath2.toString() }; - Assert.assertEquals(-1, ToolRunner.run(har, args2)); + assertEquals(-1, ToolRunner.run(har, args2)); output = byteStream.toString(); - Assert.assertTrue(output.indexOf("Destination " + archivePath2.toString() + assertTrue(output.indexOf("Destination " + archivePath2.toString() + " should be a directory but is a file") != -1); System.setErr(stderr); @@ -239,7 +240,7 @@ public void testPathWithSpaces() throws Exception { // compare results final List<String> harPaths = lsr(shell, fullHarPathStr); - Assert.assertEquals(originalPaths, harPaths); + assertEquals(originalPaths, harPaths); } @Test @@ -258,7 +259,7 @@ public void testSingleFile() throws Exception { // compare results: final List<String> harPaths = lsr(shell, fullHarPathStr); - Assert.assertEquals(originalPaths, harPaths); + assertEquals(originalPaths, harPaths); } @Test @@ -283,7 +284,7 @@ public void testGlobFiles() throws Exception { // compare results: final List<String> harPaths = lsr(shell, fullHarPathStr, fullHarPathStr + "/" + glob); - Assert.assertEquals(originalPaths, harPaths); + assertEquals(originalPaths, harPaths); } 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, System.setErr(out); final String results; try { - Assert.assertEquals(0, shell.run(new String[] { "-lsr", dir })); + assertEquals(0, shell.run(new String[]{"-lsr", dir})); results = bytes.toString(); } finally { IOUtils.closeStream(out); @@ -605,7 +606,7 @@ private static byte[] readAllWithSeek(final int totalLength, private static void expectSeekIOE(FSDataInputStream fsdis, long seekPos, String message) { try { fsdis.seek(seekPos); - assertTrue(message + " (Position = " + fsdis.getPos() + ")", false); + assertTrue(false, message + " (Position = " + fsdis.getPos() + ")"); } catch (IOException ioe) { // okay } @@ -764,7 +765,7 @@ private String makeArchiveWithRepl() throws Exception { while (listFiles.hasNext()) { LocatedFileStatus next = listFiles.next(); if (!next.getPath().toString().endsWith("_SUCCESS")) { - assertEquals(next.getPath().toString(), 2, next.getReplication()); + assertEquals(2, next.getReplication(), next.getPath().toString()); } } return fullHarPathStr; --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org