Browse Source

HADOOP-19433. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-extras. (#7586)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 1 week ago
parent
commit
f34c4be413

+ 0 - 55
hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/mapred/tools/TestGetGroups.java

@@ -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);
-  }
-
-}

+ 11 - 10
hadoop-tools/hadoop-extras/src/test/java/org/apache/hadoop/tools/TestDistCh.java

@@ -38,11 +38,12 @@ import org.apache.hadoop.io.IOUtils;
 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 @@ public class TestDistCh {
 
     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 class TestDistCh {
   }
 
   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 @@ public class TestDistCh {
     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);