From ee80779918084c5456eadc3a1f049c95e8074a43 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Wed, 9 Apr 2025 09:33:45 +0800 Subject: [PATCH] HADOOP-19433. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-extras. --- .../hadoop/mapred/tools/TestGetGroups.java | 55 ------------------- .../org/apache/hadoop/tools/TestDistCh.java | 21 +++---- 2 files changed, 11 insertions(+), 65 deletions(-) delete mode 100644 hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/mapred/tools/TestGetGroups.java diff --git a/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/mapred/tools/TestGetGroups.java b/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/mapred/tools/TestGetGroups.java deleted file mode 100644 index ed7b8aa8632a6..0000000000000 --- a/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/mapred/tools/TestGetGroups.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.mapred.tools; - -import java.io.IOException; -import java.io.PrintStream; - -import org.apache.hadoop.mapred.MiniMRCluster; -import org.apache.hadoop.mapred.tools.GetGroups; -import org.apache.hadoop.tools.GetGroupsTestBase; -import org.apache.hadoop.util.Tool; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; - -/** - * Tests for the MR implementation of {@link GetGroups} - */ -@Ignore -public class TestGetGroups extends GetGroupsTestBase { - - private MiniMRCluster cluster; - - @Before - public void setUpJobTracker() throws IOException, InterruptedException { - cluster = new MiniMRCluster(0, "file:///", 1); - conf = cluster.createJobConf(); - } - - @After - public void tearDownJobTracker() throws IOException { - cluster.shutdown(); - } - - @Override - protected Tool getTool(PrintStream o) { - return new GetGroups(conf, o); - } - -} diff --git a/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java b/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java index 3e52b3cb6d1e2..7efaaf1a25d12 100644 --- a/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java +++ b/hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java @@ -38,11 +38,12 @@ import org.apache.hadoop.mapred.MiniMRClientClusterFactory; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.event.Level; import static org.slf4j.LoggerFactory.getLogger; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestDistCh { { @@ -77,20 +78,20 @@ static class FileTree { Path createSmallFile(Path dir) throws IOException { final Path f = new Path(dir, "f" + ++fcount); - Assert.assertTrue(!fs.exists(f)); + assertTrue(!fs.exists(f)); final DataOutputStream out = fs.create(f); try { out.writeBytes("createSmallFile: f=" + f); } finally { out.close(); } - Assert.assertTrue(fs.exists(f)); + assertTrue(fs.exists(f)); return f; } Path mkdir(Path dir) throws IOException { - Assert.assertTrue(fs.mkdirs(dir)); - Assert.assertTrue(fs.getFileStatus(dir).isDirectory()); + assertTrue(fs.mkdirs(dir)); + assertTrue(fs.getFileStatus(dir).isDirectory()); return dir; } @@ -193,13 +194,13 @@ public void testDistCh() throws Exception { } static void checkFileStatus(ChPermissionStatus expected, FileStatus actual) { - Assert.assertEquals(expected.getUserName(), actual.getOwner()); - Assert.assertEquals(expected.getGroupName(), actual.getGroup()); + assertEquals(expected.getUserName(), actual.getOwner()); + assertEquals(expected.getGroupName(), actual.getGroup()); FsPermission perm = expected.getPermission(); if (actual.isFile() && expected.defaultPerm) { perm = perm.applyUMask(UMASK); } - Assert.assertEquals(perm, actual.getPermission()); + assertEquals(perm, actual.getPermission()); } private static String runLsr(final FsShell shell, String root, int returnvalue @@ -213,7 +214,7 @@ private static String runLsr(final FsShell shell, String root, int returnvalue System.setErr(out); final String results; try { - Assert.assertEquals(returnvalue, shell.run(new String[]{"-lsr", root})); + assertEquals(returnvalue, shell.run(new String[]{"-lsr", root})); results = bytes.toString(); } finally { IOUtils.closeStream(out);