Jelajahi Sumber

HADOOP-19432. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-dynamometer-workload. (#7587)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Co-authored-by: Hualong Zhang <hualong.z@hotmail.com>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Hualong Zhang <hualong.z@hotmail.com>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 1 bulan lalu
induk
melakukan
4389380ad2

+ 9 - 9
hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/test/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/TestWorkloadGenerator.java

@@ -40,16 +40,16 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.authorize.AuthorizationException;
 import org.apache.hadoop.security.authorize.ImpersonationProvider;
 import org.jline.utils.Log;
-import org.junit.After;
-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.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_IMPERSONATION_PROVIDER_CLASS;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /** Tests for {@link WorkloadDriver} and related classes. */
@@ -61,7 +61,7 @@ public class TestWorkloadGenerator {
   private MiniDFSCluster miniCluster;
   private FileSystem dfs;
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
     conf = new Configuration();
     conf.setClass(HADOOP_SECURITY_IMPERSONATION_PROVIDER_CLASS,
@@ -74,7 +74,7 @@ public class TestWorkloadGenerator {
     dfs.setOwner(new Path("/tmp"), "hdfs", "hdfs");
   }
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
     if (miniCluster != null) {
       miniCluster.shutdown();
@@ -135,7 +135,7 @@ public class TestWorkloadGenerator {
     Job workloadJob = WorkloadDriver.getJobForSubmission(conf,
         dfs.getUri().toString(), workloadStartTime, AuditReplayMapper.class);
     boolean success = workloadJob.waitForCompletion(true);
-    assertTrue("workload job should succeed", success);
+    assertTrue(success, "workload job should succeed");
     Counters counters = workloadJob.getCounters();
     assertEquals(6,
         counters.findCounter(AuditReplayMapper.REPLAYCOUNTERS.TOTALCOMMANDS)

+ 4 - 4
hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/test/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/audit/TestAuditLogDirectParser.java

@@ -20,10 +20,10 @@ package org.apache.hadoop.tools.dynamometer.workloadgenerator.audit;
 import java.util.function.Function;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.Text;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 /** Tests for {@link AuditLogDirectParser}. */
 public class TestAuditLogDirectParser {
@@ -32,7 +32,7 @@ public class TestAuditLogDirectParser {
   private AuditLogDirectParser parser;
   private Long sequence = 1L;
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
     parser = new AuditLogDirectParser();
     Configuration conf = new Configuration();