Sfoglia il codice sorgente

MAPREDUCE-7414. [JDK17] Upgrade Junit 4 to 5 in hadoop-mapreduce-client-hs. (#7354)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 4 mesi fa
parent
commit
acb7a80060
29 ha cambiato i file con 853 aggiunte e 804 eliminazioni
  1. 22 17
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestCompletedTask.java
  2. 71 65
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryFileManager.java
  3. 9 6
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryFileManagerInitWithNonRunningDFS.java
  4. 43 44
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryServerFileSystemStateStoreService.java
  5. 42 42
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryServerLeveldbStateStoreService.java
  6. 25 27
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJHSDelegationTokenSecretManager.java
  7. 8 8
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistory.java
  8. 42 25
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryEntities.java
  9. 36 38
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryEvents.java
  10. 138 141
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryParsing.java
  11. 19 12
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java
  12. 16 14
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobIdHistoryFileInfoMap.java
  13. 11 8
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobListCache.java
  14. 12 10
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestUnnecessaryBlockingOnHistoryFileInfo.java
  15. 51 38
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/server/TestHSAdminServer.java
  16. 14 13
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestBlocks.java
  17. 9 9
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHSWebApp.java
  18. 16 16
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsJobBlock.java
  19. 12 12
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java
  20. 5 5
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesAcls.java
  21. 42 43
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesAttempts.java
  22. 17 17
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobConf.java
  23. 52 52
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobs.java
  24. 44 44
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobsQuery.java
  25. 6 6
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesLogs.java
  26. 8 8
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesLogsExtend.java
  27. 45 46
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesTasks.java
  28. 25 25
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/VerifyJobsUtils.java
  29. 13 13
      hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java

+ 22 - 17
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestCompletedTask.java

@@ -30,14 +30,18 @@ import org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskInfo;
 import org.apache.hadoop.mapreduce.v2.api.records.Phase;
 import org.apache.hadoop.mapreduce.v2.api.records.Phase;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskId;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskId;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskReport;
 import org.apache.hadoop.mapreduce.v2.api.records.TaskReport;
-import org.apache.hadoop.mapreduce.v2.hs.CompletedTask;
-import org.junit.Test;
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
-public class TestCompletedTask{
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
-  @Test (timeout=5000)
+public class TestCompletedTask {
+
+  @Test
+  @Timeout(value = 5)
   public void testTaskStartTimes() {
   public void testTaskStartTimes() {
     
     
     TaskId taskId = mock(TaskId.class); 
     TaskId taskId = mock(TaskId.class); 
@@ -48,13 +52,13 @@ public class TestCompletedTask{
     TaskAttemptID id = new TaskAttemptID("0", 0, TaskType.MAP, 0, 0);
     TaskAttemptID id = new TaskAttemptID("0", 0, TaskType.MAP, 0, 0);
     TaskAttemptInfo info = mock(TaskAttemptInfo.class);
     TaskAttemptInfo info = mock(TaskAttemptInfo.class);
     when(info.getAttemptId()).thenReturn(id);
     when(info.getAttemptId()).thenReturn(id);
-    when(info.getStartTime()).thenReturn(10l);
+    when(info.getStartTime()).thenReturn(10L);
     taskAttempts.put(id, info);
     taskAttempts.put(id, info);
     
     
     id = new TaskAttemptID("1", 0, TaskType.MAP, 1, 1);
     id = new TaskAttemptID("1", 0, TaskType.MAP, 1, 1);
     info = mock(TaskAttemptInfo.class);
     info = mock(TaskAttemptInfo.class);
     when(info.getAttemptId()).thenReturn(id);
     when(info.getAttemptId()).thenReturn(id);
-    when(info.getStartTime()).thenReturn(20l);
+    when(info.getStartTime()).thenReturn(20L);
     taskAttempts.put(id, info);
     taskAttempts.put(id, info);
     
     
     
     
@@ -69,7 +73,8 @@ public class TestCompletedTask{
   /**
   /**
    * test some methods of CompletedTaskAttempt
    * test some methods of CompletedTaskAttempt
    */
    */
-  @Test (timeout=5000)
+  @Test
+  @Timeout(value = 5)
   public void testCompletedTaskAttempt(){
   public void testCompletedTaskAttempt(){
     
     
     TaskAttemptInfo attemptInfo= mock(TaskAttemptInfo.class);
     TaskAttemptInfo attemptInfo= mock(TaskAttemptInfo.class);
@@ -82,14 +87,14 @@ public class TestCompletedTask{
     TaskID taskId =new TaskID(jobId,TaskType.REDUCE, 0);
     TaskID taskId =new TaskID(jobId,TaskType.REDUCE, 0);
     TaskAttemptID taskAttemptId= new TaskAttemptID(taskId, 0);
     TaskAttemptID taskAttemptId= new TaskAttemptID(taskId, 0);
     when(attemptInfo.getAttemptId()).thenReturn(taskAttemptId);
     when(attemptInfo.getAttemptId()).thenReturn(taskAttemptId);
-    
-    
+
+
     CompletedTaskAttempt taskAttemt= new CompletedTaskAttempt(null,attemptInfo);
     CompletedTaskAttempt taskAttemt= new CompletedTaskAttempt(null,attemptInfo);
-    assertEquals( "Rackname",   taskAttemt.getNodeRackName());
-    assertEquals( Phase.CLEANUP,   taskAttemt.getPhase());
-    assertTrue(  taskAttemt.isFinished());
-    assertEquals( 11L,   taskAttemt.getShuffleFinishTime());
-    assertEquals( 12L,   taskAttemt.getSortFinishTime());
-    assertEquals( 10,   taskAttemt.getShufflePort());
+    assertEquals("Rackname", taskAttemt.getNodeRackName());
+    assertEquals(Phase.CLEANUP, taskAttemt.getPhase());
+    assertTrue(taskAttemt.isFinished());
+    assertEquals(11L, taskAttemt.getShuffleFinishTime());
+    assertEquals(12L, taskAttemt.getSortFinishTime());
+    assertEquals(10, taskAttemt.getShufflePort());
   }
   }
 }
 }

+ 71 - 65
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryFileManager.java

@@ -27,7 +27,6 @@ import java.util.List;
 
 
 import org.apache.hadoop.mapreduce.v2.app.job.Job;
 import org.apache.hadoop.mapreduce.v2.app.job.Job;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JobHistoryUtils;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JobHistoryUtils;
-import org.junit.Assert;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
@@ -47,27 +46,30 @@ import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.util.Clock;
 import org.apache.hadoop.yarn.util.Clock;
 import org.apache.hadoop.yarn.util.ControlledClock;
 import org.apache.hadoop.yarn.util.ControlledClock;
 import org.apache.hadoop.yarn.util.SystemClock;
 import org.apache.hadoop.yarn.util.SystemClock;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
-
-import static org.mockito.Mockito.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 public class TestHistoryFileManager {
 public class TestHistoryFileManager {
   private static MiniDFSCluster dfsCluster = null;
   private static MiniDFSCluster dfsCluster = null;
   private static MiniDFSCluster dfsCluster2 = null;
   private static MiniDFSCluster dfsCluster2 = null;
   private static String coreSitePath;
   private static String coreSitePath;
 
 
-  @Rule
-  public TestName name = new TestName();
-
-  @BeforeClass
+  @BeforeAll
   public static void setUpClass() throws Exception {
   public static void setUpClass() throws Exception {
     coreSitePath = "." + File.separator + "target" + File.separator +
     coreSitePath = "." + File.separator + "target" + File.separator +
-            "test-classes" + File.separator + "core-site.xml";
+        "test-classes" + File.separator + "core-site.xml";
     Configuration conf = new HdfsConfiguration();
     Configuration conf = new HdfsConfiguration();
     Configuration conf2 = new HdfsConfiguration();
     Configuration conf2 = new HdfsConfiguration();
     dfsCluster = new MiniDFSCluster.Builder(conf).build();
     dfsCluster = new MiniDFSCluster.Builder(conf).build();
@@ -77,13 +79,13 @@ public class TestHistoryFileManager {
     dfsCluster2 = new MiniDFSCluster.Builder(conf2).build();
     dfsCluster2 = new MiniDFSCluster.Builder(conf2).build();
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanUpClass() throws Exception {
   public static void cleanUpClass() throws Exception {
     dfsCluster.shutdown();
     dfsCluster.shutdown();
     dfsCluster2.shutdown();
     dfsCluster2.shutdown();
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanTest() throws Exception {
   public void cleanTest() throws Exception {
     new File(coreSitePath).delete();
     new File(coreSitePath).delete();
     dfsCluster.getFileSystem().setSafeMode(
     dfsCluster.getFileSystem().setSafeMode(
@@ -92,46 +94,48 @@ public class TestHistoryFileManager {
         SafeModeAction.LEAVE);
         SafeModeAction.LEAVE);
   }
   }
 
 
-  private String getDoneDirNameForTest() {
-    return "/" + name.getMethodName();
+  private String getDoneDirNameForTest(String name) {
+    return "/" + name;
   }
   }
 
 
-  private String getIntermediateDoneDirNameForTest() {
-    return "/intermediate_" + name.getMethodName();
+  private String getIntermediateDoneDirNameForTest(String name) {
+    return "/intermediate_" + name;
   }
   }
 
 
-  private void testTryCreateHistoryDirs(Configuration conf, boolean expected)
+  private void testTryCreateHistoryDirs(Configuration conf, boolean expected, String methodName)
       throws Exception {
       throws Exception {
-    conf.set(JHAdminConfig.MR_HISTORY_DONE_DIR, getDoneDirNameForTest());
-    conf.set(JHAdminConfig.MR_HISTORY_INTERMEDIATE_DONE_DIR, getIntermediateDoneDirNameForTest());
+    conf.set(JHAdminConfig.MR_HISTORY_DONE_DIR, getDoneDirNameForTest(methodName));
+    conf.set(JHAdminConfig.MR_HISTORY_INTERMEDIATE_DONE_DIR,
+        getIntermediateDoneDirNameForTest(methodName));
     HistoryFileManager hfm = new HistoryFileManager();
     HistoryFileManager hfm = new HistoryFileManager();
     hfm.conf = conf;
     hfm.conf = conf;
-    Assert.assertEquals(expected, hfm.tryCreatingHistoryDirs(false));
+    assertEquals(expected, hfm.tryCreatingHistoryDirs(false));
   }
   }
 
 
   @Test
   @Test
-  public void testCreateDirsWithoutFileSystem() throws Exception {
+  public void testCreateDirsWithoutFileSystem(TestInfo testInfo) throws Exception {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "hdfs://localhost:1");
     conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "hdfs://localhost:1");
-    testTryCreateHistoryDirs(conf, false);
+    testTryCreateHistoryDirs(conf, false, testInfo.getDisplayName());
   }
   }
 
 
   @Test
   @Test
-  public void testCreateDirsWithFileSystem() throws Exception {
+  public void testCreateDirsWithFileSystem(TestInfo testInfo) throws Exception {
     dfsCluster.getFileSystem().setSafeMode(
     dfsCluster.getFileSystem().setSafeMode(
         SafeModeAction.LEAVE);
         SafeModeAction.LEAVE);
-    Assert.assertFalse(dfsCluster.getFileSystem().isInSafeMode());
-    testTryCreateHistoryDirs(dfsCluster.getConfiguration(0), true);
+    assertFalse(dfsCluster.getFileSystem().isInSafeMode());
+    testTryCreateHistoryDirs(dfsCluster.getConfiguration(0), true,
+        testInfo.getDisplayName());
   }
   }
 
 
   @Test
   @Test
-  public void testCreateDirsWithAdditionalFileSystem() throws Exception {
+  public void testCreateDirsWithAdditionalFileSystem(TestInfo testInfo) throws Exception {
     dfsCluster.getFileSystem().setSafeMode(
     dfsCluster.getFileSystem().setSafeMode(
         SafeModeAction.LEAVE);
         SafeModeAction.LEAVE);
     dfsCluster2.getFileSystem().setSafeMode(
     dfsCluster2.getFileSystem().setSafeMode(
         SafeModeAction.LEAVE);
         SafeModeAction.LEAVE);
-    Assert.assertFalse(dfsCluster.getFileSystem().isInSafeMode());
-    Assert.assertFalse(dfsCluster2.getFileSystem().isInSafeMode());
+    assertFalse(dfsCluster.getFileSystem().isInSafeMode());
+    assertFalse(dfsCluster2.getFileSystem().isInSafeMode());
 
 
     // Set default configuration to the first cluster
     // Set default configuration to the first cluster
     Configuration conf = new Configuration(false);
     Configuration conf = new Configuration(false);
@@ -141,25 +145,28 @@ public class TestHistoryFileManager {
     conf.writeXml(os);
     conf.writeXml(os);
     os.close();
     os.close();
 
 
-    testTryCreateHistoryDirs(dfsCluster2.getConfiguration(0), true);
+    testTryCreateHistoryDirs(dfsCluster2.getConfiguration(0), true,
+        testInfo.getDisplayName());
 
 
     // Directories should be created only in the default file system (dfsCluster)
     // Directories should be created only in the default file system (dfsCluster)
-    Assert.assertTrue(dfsCluster.getFileSystem()
-            .exists(new Path(getDoneDirNameForTest())));
-    Assert.assertTrue(dfsCluster.getFileSystem()
-            .exists(new Path(getIntermediateDoneDirNameForTest())));
-    Assert.assertFalse(dfsCluster2.getFileSystem()
-            .exists(new Path(getDoneDirNameForTest())));
-    Assert.assertFalse(dfsCluster2.getFileSystem()
-            .exists(new Path(getIntermediateDoneDirNameForTest())));
+    String displayName = testInfo.getDisplayName();
+    assertTrue(dfsCluster.getFileSystem().
+        exists(new Path(getDoneDirNameForTest(displayName))));
+    assertTrue(dfsCluster.getFileSystem().
+        exists(new Path(getIntermediateDoneDirNameForTest(displayName))));
+    assertFalse(dfsCluster2.getFileSystem().
+        exists(new Path(getDoneDirNameForTest(displayName))));
+    assertFalse(dfsCluster2.getFileSystem().
+        exists(new Path(getIntermediateDoneDirNameForTest(displayName))));
   }
   }
 
 
   @Test
   @Test
-  public void testCreateDirsWithFileSystemInSafeMode() throws Exception {
+  public void testCreateDirsWithFileSystemInSafeMode(TestInfo testInfo) throws Exception {
     dfsCluster.getFileSystem().setSafeMode(
     dfsCluster.getFileSystem().setSafeMode(
         SafeModeAction.ENTER);
         SafeModeAction.ENTER);
-    Assert.assertTrue(dfsCluster.getFileSystem().isInSafeMode());
-    testTryCreateHistoryDirs(dfsCluster.getConfiguration(0), false);
+    assertTrue(dfsCluster.getFileSystem().isInSafeMode());
+    testTryCreateHistoryDirs(dfsCluster.getConfiguration(0), false,
+        testInfo.getDisplayName());
   }
   }
 
 
   private void testCreateHistoryDirs(Configuration conf, Clock clock)
   private void testCreateHistoryDirs(Configuration conf, Clock clock)
@@ -176,7 +183,7 @@ public class TestHistoryFileManager {
       throws Exception {
       throws Exception {
     dfsCluster.getFileSystem().setSafeMode(
     dfsCluster.getFileSystem().setSafeMode(
         SafeModeAction.ENTER);
         SafeModeAction.ENTER);
-    Assert.assertTrue(dfsCluster.getFileSystem().isInSafeMode());
+    assertTrue(dfsCluster.getFileSystem().isInSafeMode());
     new Thread() {
     new Thread() {
       @Override
       @Override
       public void run() {
       public void run() {
@@ -184,9 +191,9 @@ public class TestHistoryFileManager {
           Thread.sleep(500);
           Thread.sleep(500);
           dfsCluster.getFileSystem().setSafeMode(
           dfsCluster.getFileSystem().setSafeMode(
               SafeModeAction.LEAVE);
               SafeModeAction.LEAVE);
-          Assert.assertTrue(dfsCluster.getFileSystem().isInSafeMode());
+          assertTrue(dfsCluster.getFileSystem().isInSafeMode());
         } catch (Exception ex) {
         } catch (Exception ex) {
-          Assert.fail(ex.toString());
+          fail(ex.toString());
         }
         }
       }
       }
     }.start();
     }.start();
@@ -194,12 +201,12 @@ public class TestHistoryFileManager {
         SystemClock.getInstance());
         SystemClock.getInstance());
   }
   }
 
 
-  @Test(expected = YarnRuntimeException.class)
+  @Test
   public void testCreateDirsWithFileSystemNotBecomingAvailBeforeTimeout()
   public void testCreateDirsWithFileSystemNotBecomingAvailBeforeTimeout()
       throws Exception {
       throws Exception {
     dfsCluster.getFileSystem().setSafeMode(
     dfsCluster.getFileSystem().setSafeMode(
         SafeModeAction.ENTER);
         SafeModeAction.ENTER);
-    Assert.assertTrue(dfsCluster.getFileSystem().isInSafeMode());
+    assertTrue(dfsCluster.getFileSystem().isInSafeMode());
     final ControlledClock clock = new ControlledClock();
     final ControlledClock clock = new ControlledClock();
     clock.setTime(1);
     clock.setTime(1);
     new Thread() {
     new Thread() {
@@ -209,11 +216,13 @@ public class TestHistoryFileManager {
           Thread.sleep(500);
           Thread.sleep(500);
           clock.setTime(3000);
           clock.setTime(3000);
         } catch (Exception ex) {
         } catch (Exception ex) {
-          Assert.fail(ex.toString());
+          fail(ex.toString());
         }
         }
       }
       }
     }.start();
     }.start();
-    testCreateHistoryDirs(dfsCluster.getConfiguration(0), clock);
+    assertThrows(YarnRuntimeException.class, () -> {
+      testCreateHistoryDirs(dfsCluster.getConfiguration(0), clock);
+    });
   }
   }
 
 
   @Test
   @Test
@@ -228,7 +237,7 @@ public class TestHistoryFileManager {
 
 
     //primarily, succcess is that an exception was not thrown.  Also nice to
     //primarily, succcess is that an exception was not thrown.  Also nice to
     //check this
     //check this
-    Assert.assertNotNull(lfs);
+    assertNotNull(lfs);
 
 
   }
   }
 
 
@@ -248,7 +257,7 @@ public class TestHistoryFileManager {
     HistoryFileInfo info = hmTest.getHistoryFileInfo(null, null,
     HistoryFileInfo info = hmTest.getHistoryFileInfo(null, null,
         summaryFile, jobIndexInfo, false);
         summaryFile, jobIndexInfo, false);
     info.moveToDone();
     info.moveToDone();
-    Assert.assertFalse(info.didMoveFail());
+    assertFalse(info.didMoveFail());
   }
   }
 
 
   @Test
   @Test
@@ -274,8 +283,8 @@ public class TestHistoryFileManager {
         jobIndexInfo, false);
         jobIndexInfo, false);
 
 
     Job job = info.loadJob();
     Job job = info.loadJob();
-    Assert.assertTrue("Should return an instance of UnparsedJob to indicate" +
-        " the job history file is not parsed", job instanceof UnparsedJob);
+    assertTrue(job instanceof UnparsedJob, "Should return an instance of UnparsedJob to indicate" +
+        " the job history file is not parsed");
   }
   }
 
 
   @Test
   @Test
@@ -307,9 +316,8 @@ public class TestHistoryFileManager {
         null, jobIndexInfo, false);
         null, jobIndexInfo, false);
 
 
     Job job = info.loadJob();
     Job job = info.loadJob();
-    Assert.assertTrue("Should return an instance of CompletedJob as " +
-        "a result of parsing the job history file of the job",
-        job instanceof CompletedJob);
+    assertTrue(job instanceof CompletedJob, "Should return an instance of CompletedJob as " +
+        "a result of parsing the job history file of the job");
   }
   }
 
 
   @Test
   @Test
@@ -336,10 +344,8 @@ public class TestHistoryFileManager {
         null, jobIndexInfo, false);
         null, jobIndexInfo, false);
 
 
     Job job = info.loadJob();
     Job job = info.loadJob();
-    Assert.assertTrue("Should return an instance of CompletedJob as " +
-            "a result of parsing the job history file of the job",
-        job instanceof CompletedJob);
-
+    assertTrue(job instanceof CompletedJob, "Should return an instance of CompletedJob as " +
+        "a result of parsing the job history file of the job");
   }
   }
 
 
   /**
   /**
@@ -386,10 +392,10 @@ public class TestHistoryFileManager {
         jobIndexInfo, false);
         jobIndexInfo, false);
     info.moveToDone();
     info.moveToDone();
 
 
-    Assert.assertFalse(info.isMovePending());
-    Assert.assertEquals(doneHistoryFilePath.toString(),
+    assertFalse(info.isMovePending());
+    assertEquals(doneHistoryFilePath.toString(),
         info.getHistoryFile().toUri().getPath());
         info.getHistoryFile().toUri().getPath());
-    Assert.assertEquals(doneConfFilePath.toString(),
+    assertEquals(doneConfFilePath.toString(),
         info.getConfFile().toUri().getPath());
         info.getConfFile().toUri().getPath());
   }
   }
 
 

+ 9 - 6
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryFileManagerInitWithNonRunningDFS.java

@@ -24,8 +24,11 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 
 
 /**
 /**
@@ -58,16 +61,16 @@ public class TestHistoryFileManagerInitWithNonRunningDFS {
       // set up a cluster with its name node in safe mode
       // set up a cluster with its name node in safe mode
       dfsCluster.getFileSystem().setSafeMode(
       dfsCluster.getFileSystem().setSafeMode(
           SafeModeAction.ENTER);
           SafeModeAction.ENTER);
-      Assert.assertTrue(dfsCluster.getFileSystem().isInSafeMode());
+      assertTrue(dfsCluster.getFileSystem().isInSafeMode());
 
 
       HistoryFileManager hfm = new HistoryFileManager();
       HistoryFileManager hfm = new HistoryFileManager();
       hfm.serviceInit(conf);
       hfm.serviceInit(conf);
-      Assert.fail("History File Manager did not retry to connect to name node");
+      fail("History File Manager did not retry to connect to name node");
     } catch (YarnRuntimeException yex) {
     } catch (YarnRuntimeException yex) {
       String expectedExceptionMsg = "Timed out '" + maxJhsWaitTime +
       String expectedExceptionMsg = "Timed out '" + maxJhsWaitTime +
           "ms' waiting for FileSystem to become available";
           "ms' waiting for FileSystem to become available";
-      Assert.assertEquals("Unexpected reconnect timeout exception message",
-          expectedExceptionMsg, yex.getMessage());
+      assertEquals(expectedExceptionMsg, yex.getMessage(),
+          "Unexpected reconnect timeout exception message");
     } finally {
     } finally {
       dfsCluster.shutdown(true);
       dfsCluster.shutdown(true);
     }
     }

+ 43 - 44
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryServerFileSystemStateStoreService.java

@@ -17,10 +17,10 @@
  */
  */
 package org.apache.hadoop.mapreduce.v2.hs;
 package org.apache.hadoop.mapreduce.v2.hs;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.argThat;
 import static org.mockito.Mockito.argThat;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.isA;
 import static org.mockito.Mockito.isA;
@@ -39,9 +39,9 @@ import org.apache.hadoop.mapreduce.v2.api.MRDelegationTokenIdentifier;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryServerStateStoreService.HistoryServerState;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryServerStateStoreService.HistoryServerState;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
-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.mockito.ArgumentMatcher;
 import org.mockito.ArgumentMatcher;
 
 
 public class TestHistoryServerFileSystemStateStoreService {
 public class TestHistoryServerFileSystemStateStoreService {
@@ -53,7 +53,7 @@ public class TestHistoryServerFileSystemStateStoreService {
 
 
   private Configuration conf;
   private Configuration conf;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     FileUtil.fullyDelete(testDir);
     FileUtil.fullyDelete(testDir);
     testDir.mkdirs();
     testDir.mkdirs();
@@ -66,7 +66,7 @@ public class TestHistoryServerFileSystemStateStoreService {
         testDir.getAbsoluteFile().toURI().toString());
         testDir.getAbsoluteFile().toURI().toString());
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanup() {
   public void cleanup() {
     FileUtil.fullyDelete(testDir);
     FileUtil.fullyDelete(testDir);
   }
   }
@@ -75,8 +75,8 @@ public class TestHistoryServerFileSystemStateStoreService {
       throws IOException {
       throws IOException {
     HistoryServerStateStoreService store =
     HistoryServerStateStoreService store =
         HistoryServerStateStoreServiceFactory.getStore(conf);
         HistoryServerStateStoreServiceFactory.getStore(conf);
-    assertTrue("Factory did not create a filesystem store",
-        store instanceof HistoryServerFileSystemStateStoreService);
+    assertTrue(store instanceof HistoryServerFileSystemStateStoreService,
+        "Factory did not create a filesystem store");
     store.init(conf);
     store.init(conf);
     store.start();
     store.start();
     return store;
     return store;
@@ -87,8 +87,8 @@ public class TestHistoryServerFileSystemStateStoreService {
     HistoryServerStateStoreService store = createAndStartStore();
     HistoryServerStateStoreService store = createAndStartStore();
 
 
     HistoryServerState state = store.loadState();
     HistoryServerState state = store.loadState();
-    assertTrue("token state not empty", state.tokenState.isEmpty());
-    assertTrue("key state not empty", state.tokenMasterKeyState.isEmpty());
+    assertTrue(state.tokenState.isEmpty(), "token state not empty");
+    assertTrue(state.tokenMasterKeyState.isEmpty(), "key state not empty");
 
 
     final DelegationKey key1 = new DelegationKey(1, 2, "keyData1".getBytes());
     final DelegationKey key1 = new DelegationKey(1, 2, "keyData1".getBytes());
     final MRDelegationTokenIdentifier token1 =
     final MRDelegationTokenIdentifier token1 =
@@ -121,17 +121,16 @@ public class TestHistoryServerFileSystemStateStoreService {
 
 
     store = createAndStartStore();
     store = createAndStartStore();
     state = store.loadState();
     state = store.loadState();
-    assertEquals("incorrect loaded token count", 2, state.tokenState.size());
-    assertTrue("missing token 1", state.tokenState.containsKey(token1));
-    assertEquals("incorrect token 1 date", tokenDate1,
-        state.tokenState.get(token1));
-    assertTrue("missing token 2", state.tokenState.containsKey(token2));
-    assertEquals("incorrect token 2 date", tokenDate2,
-        state.tokenState.get(token2));
-    assertEquals("incorrect master key count", 1,
-        state.tokenMasterKeyState.size());
-    assertTrue("missing master key 1",
-        state.tokenMasterKeyState.contains(key1));
+    assertEquals(2, state.tokenState.size(), "incorrect loaded token count");
+    assertTrue(state.tokenState.containsKey(token1), "missing token 1");
+    assertEquals(tokenDate1,
+        state.tokenState.get(token1), "incorrect token 1 date");
+    assertTrue(state.tokenState.containsKey(token2), "missing token 2");
+    assertEquals(tokenDate2,
+        state.tokenState.get(token2), "incorrect token 2 date");
+    assertEquals(1,
+        state.tokenMasterKeyState.size(), "incorrect master key count");
+    assertTrue(state.tokenMasterKeyState.contains(key1), "missing master key 1");
 
 
     final DelegationKey key2 = new DelegationKey(3, 4, "keyData2".getBytes());
     final DelegationKey key2 = new DelegationKey(3, 4, "keyData2".getBytes());
     final DelegationKey key3 = new DelegationKey(5, 6, "keyData3".getBytes());
     final DelegationKey key3 = new DelegationKey(5, 6, "keyData3".getBytes());
@@ -152,22 +151,22 @@ public class TestHistoryServerFileSystemStateStoreService {
 
 
     store = createAndStartStore();
     store = createAndStartStore();
     state = store.loadState();
     state = store.loadState();
-    assertEquals("incorrect loaded token count", 2, state.tokenState.size());
-    assertFalse("token 1 not removed", state.tokenState.containsKey(token1));
-    assertTrue("missing token 2", state.tokenState.containsKey(token2));
-    assertEquals("incorrect token 2 date", newTokenDate2,
-        state.tokenState.get(token2));
-    assertTrue("missing token 3", state.tokenState.containsKey(token3));
-    assertEquals("incorrect token 3 date", tokenDate3,
-        state.tokenState.get(token3));
-    assertEquals("incorrect master key count", 2,
-        state.tokenMasterKeyState.size());
-    assertFalse("master key 1 not removed",
-        state.tokenMasterKeyState.contains(key1));
-    assertTrue("missing master key 2",
-        state.tokenMasterKeyState.contains(key2));
-    assertTrue("missing master key 3",
-        state.tokenMasterKeyState.contains(key3));
+    assertEquals(2, state.tokenState.size(), "incorrect loaded token count");
+    assertFalse(state.tokenState.containsKey(token1), "token 1 not removed");
+    assertTrue(state.tokenState.containsKey(token2), "missing token 2");
+    assertEquals(newTokenDate2,
+        state.tokenState.get(token2), "incorrect token 2 date");
+    assertTrue(state.tokenState.containsKey(token3), "missing token 3");
+    assertEquals(tokenDate3,
+        state.tokenState.get(token3), "incorrect token 3 date");
+    assertEquals(2,
+        state.tokenMasterKeyState.size(), "incorrect master key count");
+    assertFalse(state.tokenMasterKeyState.contains(key1),
+        "master key 1 not removed");
+    assertTrue(state.tokenMasterKeyState.contains(key2),
+        "missing master key 2");
+    assertTrue(state.tokenMasterKeyState.contains(key3),
+        "missing master key 3");
   }
   }
 
 
   @Test
   @Test
@@ -229,10 +228,10 @@ public class TestHistoryServerFileSystemStateStoreService {
     // original token file is missing
     // original token file is missing
     store = createAndStartStore();
     store = createAndStartStore();
     HistoryServerState state = store.loadState();
     HistoryServerState state = store.loadState();
-    assertEquals("incorrect loaded token count", 1, state.tokenState.size());
-    assertTrue("missing token 1", state.tokenState.containsKey(token1));
-    assertEquals("incorrect token 1 date", newTokenDate1,
-        state.tokenState.get(token1));
+    assertEquals(1, state.tokenState.size(), "incorrect loaded token count");
+    assertTrue(state.tokenState.containsKey(token1), "missing token 1");
+    assertEquals(newTokenDate1,
+        state.tokenState.get(token1), "incorrect token 1 date");
     store.close();
     store.close();
   }
   }
 }
 }

+ 42 - 42
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestHistoryServerLeveldbStateStoreService.java

@@ -18,10 +18,10 @@
 
 
 package org.apache.hadoop.mapreduce.v2.hs;
 package org.apache.hadoop.mapreduce.v2.hs;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -35,9 +35,9 @@ import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
 import org.apache.hadoop.service.ServiceStateException;
 import org.apache.hadoop.service.ServiceStateException;
 import org.apache.hadoop.yarn.server.records.Version;
 import org.apache.hadoop.yarn.server.records.Version;
-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;
 
 
 public class TestHistoryServerLeveldbStateStoreService {
 public class TestHistoryServerLeveldbStateStoreService {
 
 
@@ -48,7 +48,7 @@ public class TestHistoryServerLeveldbStateStoreService {
 
 
   private Configuration conf;
   private Configuration conf;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     FileUtil.fullyDelete(testDir);
     FileUtil.fullyDelete(testDir);
     testDir.mkdirs();
     testDir.mkdirs();
@@ -61,7 +61,7 @@ public class TestHistoryServerLeveldbStateStoreService {
         testDir.getAbsoluteFile().toString());
         testDir.getAbsoluteFile().toString());
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanup() {
   public void cleanup() {
     FileUtil.fullyDelete(testDir);
     FileUtil.fullyDelete(testDir);
   }
   }
@@ -70,8 +70,8 @@ public class TestHistoryServerLeveldbStateStoreService {
       throws IOException {
       throws IOException {
     HistoryServerStateStoreService store =
     HistoryServerStateStoreService store =
         HistoryServerStateStoreServiceFactory.getStore(conf);
         HistoryServerStateStoreServiceFactory.getStore(conf);
-    assertTrue("Factory did not create a leveldb store",
-        store instanceof HistoryServerLeveldbStateStoreService);
+    assertTrue(store instanceof HistoryServerLeveldbStateStoreService,
+        "Factory did not create a leveldb store");
     store.init(conf);
     store.init(conf);
     store.start();
     store.start();
     return store;
     return store;
@@ -114,8 +114,8 @@ public class TestHistoryServerLeveldbStateStoreService {
       store.start();
       store.start();
       fail("Incompatible version, should have thrown before here.");
       fail("Incompatible version, should have thrown before here.");
     } catch (ServiceStateException e) {
     } catch (ServiceStateException e) {
-      assertTrue("Exception message mismatch",
-        e.getMessage().contains("Incompatible version for state:"));
+      assertTrue(e.getMessage().contains("Incompatible version for state:"),
+          "Exception message mismatch");
     }
     }
     store.close();
     store.close();
   }
   }
@@ -126,8 +126,8 @@ public class TestHistoryServerLeveldbStateStoreService {
 
 
     // verify initially the store is empty
     // verify initially the store is empty
     HistoryServerState state = store.loadState();
     HistoryServerState state = store.loadState();
-    assertTrue("token state not empty", state.tokenState.isEmpty());
-    assertTrue("key state not empty", state.tokenMasterKeyState.isEmpty());
+    assertTrue(state.tokenState.isEmpty(), "token state not empty");
+    assertTrue(state.tokenMasterKeyState.isEmpty(), "key state not empty");
 
 
     // store a key and some tokens
     // store a key and some tokens
     final DelegationKey key1 = new DelegationKey(1, 2, "keyData1".getBytes());
     final DelegationKey key1 = new DelegationKey(1, 2, "keyData1".getBytes());
@@ -150,17 +150,17 @@ public class TestHistoryServerLeveldbStateStoreService {
     // verify the key and tokens can be recovered
     // verify the key and tokens can be recovered
     store = createAndStartStore();
     store = createAndStartStore();
     state = store.loadState();
     state = store.loadState();
-    assertEquals("incorrect loaded token count", 2, state.tokenState.size());
-    assertTrue("missing token 1", state.tokenState.containsKey(token1));
-    assertEquals("incorrect token 1 date", tokenDate1,
-        state.tokenState.get(token1));
-    assertTrue("missing token 2", state.tokenState.containsKey(token2));
-    assertEquals("incorrect token 2 date", tokenDate2,
-        state.tokenState.get(token2));
-    assertEquals("incorrect master key count", 1,
-        state.tokenMasterKeyState.size());
-    assertTrue("missing master key 1",
-        state.tokenMasterKeyState.contains(key1));
+    assertEquals(2, state.tokenState.size(), "incorrect loaded token count");
+    assertTrue(state.tokenState.containsKey(token1), "missing token 1");
+    assertEquals(tokenDate1,
+        state.tokenState.get(token1), "incorrect token 1 date");
+    assertTrue(state.tokenState.containsKey(token2), "missing token 2");
+    assertEquals(tokenDate2,
+        state.tokenState.get(token2), "incorrect token 2 date");
+    assertEquals(1,
+        state.tokenMasterKeyState.size(), "incorrect master key count");
+    assertTrue(state.tokenMasterKeyState.contains(key1),
+        "missing master key 1");
 
 
     // store some more keys and tokens, remove the previous key and one
     // store some more keys and tokens, remove the previous key and one
     // of the tokens, and renew a previous token
     // of the tokens, and renew a previous token
@@ -186,22 +186,22 @@ public class TestHistoryServerLeveldbStateStoreService {
     // expiration date
     // expiration date
     store = createAndStartStore();
     store = createAndStartStore();
     state = store.loadState();
     state = store.loadState();
-    assertEquals("incorrect loaded token count", 2, state.tokenState.size());
-    assertFalse("token 1 not removed", state.tokenState.containsKey(token1));
-    assertTrue("missing token 2", state.tokenState.containsKey(token2));
-    assertEquals("incorrect token 2 date", newTokenDate2,
-        state.tokenState.get(token2));
-    assertTrue("missing token 3", state.tokenState.containsKey(token3));
-    assertEquals("incorrect token 3 date", tokenDate3,
-        state.tokenState.get(token3));
-    assertEquals("incorrect master key count", 2,
-        state.tokenMasterKeyState.size());
-    assertFalse("master key 1 not removed",
-        state.tokenMasterKeyState.contains(key1));
-    assertTrue("missing master key 2",
-        state.tokenMasterKeyState.contains(key2));
-    assertTrue("missing master key 3",
-        state.tokenMasterKeyState.contains(key3));
+    assertEquals(2, state.tokenState.size(), "incorrect loaded token count");
+    assertFalse(state.tokenState.containsKey(token1), "token 1 not removed");
+    assertTrue(state.tokenState.containsKey(token2), "missing token 2");
+    assertEquals(newTokenDate2,
+        state.tokenState.get(token2), "incorrect token 2 date");
+    assertTrue(state.tokenState.containsKey(token3), "missing token 3");
+    assertEquals(tokenDate3,
+        state.tokenState.get(token3), "incorrect token 3 date");
+    assertEquals(2,
+        state.tokenMasterKeyState.size(), "incorrect master key count");
+    assertFalse(state.tokenMasterKeyState.contains(key1),
+        "master key 1 not removed");
+    assertTrue(state.tokenMasterKeyState.contains(key2),
+        "missing master key 2");
+    assertTrue(state.tokenMasterKeyState.contains(key3),
+        "missing master key 3");
     store.close();
     store.close();
   }
   }
 }
 }

+ 25 - 27
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJHSDelegationTokenSecretManager.java

@@ -18,9 +18,9 @@
 package org.apache.hadoop.mapreduce.v2.hs;
 package org.apache.hadoop.mapreduce.v2.hs;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-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;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -36,8 +36,7 @@ import org.apache.hadoop.security.authentication.util.KerberosName;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestJHSDelegationTokenSecretManager {
 public class TestJHSDelegationTokenSecretManager {
 
 
@@ -80,14 +79,14 @@ public class TestJHSDelegationTokenSecretManager {
     mgr.recover(store.loadState());
     mgr.recover(store.loadState());
     List<DelegationKey> recoveredKeys = Arrays.asList(mgr.getAllKeys());
     List<DelegationKey> recoveredKeys = Arrays.asList(mgr.getAllKeys());
     for (DelegationKey key : keys) {
     for (DelegationKey key : keys) {
-      assertTrue("key missing after recovery", recoveredKeys.contains(key));
+      assertTrue(recoveredKeys.contains(key), "key missing after recovery");
     }
     }
-    assertTrue("token1 missing", mgr.getAllTokens().containsKey(tokenId1));
-    assertEquals("token1 renew date", tokenRenewDate1,
-        mgr.getAllTokens().get(tokenId1).getRenewDate());
-    assertTrue("token2 missing", mgr.getAllTokens().containsKey(tokenId2));
-    assertEquals("token2 renew date", tokenRenewDate2,
-        mgr.getAllTokens().get(tokenId2).getRenewDate());
+    assertTrue(mgr.getAllTokens().containsKey(tokenId1), "token1 missing");
+    assertEquals(tokenRenewDate1,
+        mgr.getAllTokens().get(tokenId1).getRenewDate(), "token1 renew date");
+    assertTrue(mgr.getAllTokens().containsKey(tokenId2), "token2 missing");
+    assertEquals(tokenRenewDate2,
+        mgr.getAllTokens().get(tokenId2).getRenewDate(), "token2 renew date");
 
 
     mgr.startThreads();
     mgr.startThreads();
     mgr.verifyToken(tokenId1, token1.getPassword());
     mgr.verifyToken(tokenId1, token1.getPassword());
@@ -97,8 +96,8 @@ public class TestJHSDelegationTokenSecretManager {
         new Text("tokenUser"));
         new Text("tokenUser"));
     Token<MRDelegationTokenIdentifier> token3 =
     Token<MRDelegationTokenIdentifier> token3 =
         new Token<MRDelegationTokenIdentifier>(tokenId3, mgr);
         new Token<MRDelegationTokenIdentifier>(tokenId3, mgr);
-    assertEquals("sequence number restore", tokenId2.getSequenceNumber() + 1,
-        tokenId3.getSequenceNumber());
+    assertEquals(tokenId2.getSequenceNumber() + 1,
+        tokenId3.getSequenceNumber(), "sequence number restore");
     mgr.cancelToken(token1, "tokenOwner");
     mgr.cancelToken(token1, "tokenOwner");
 
 
     // Testing with full principal name
     // Testing with full principal name
@@ -128,15 +127,15 @@ public class TestJHSDelegationTokenSecretManager {
     stopAndCleanSecretManager(mgr);
     stopAndCleanSecretManager(mgr);
 
 
     mgr.recover(store.loadState());
     mgr.recover(store.loadState());
-    assertFalse("token1 should be missing",
-        mgr.getAllTokens().containsKey(tokenId1));
-    assertTrue("token2 missing", mgr.getAllTokens().containsKey(tokenId2));
-    assertEquals("token2 renew date incorrect", tokenRenewDate2,
-        mgr.getAllTokens().get(tokenId2).getRenewDate());
-    assertTrue("token3 missing from manager",
-        mgr.getAllTokens().containsKey(tokenId3));
-    assertEquals("token3 renew date", tokenRenewDate3,
-        mgr.getAllTokens().get(tokenId3).getRenewDate());
+    assertFalse(mgr.getAllTokens().containsKey(tokenId1),
+        "token1 should be missing");
+    assertTrue(mgr.getAllTokens().containsKey(tokenId2), "token2 missing");
+    assertEquals(tokenRenewDate2,
+        mgr.getAllTokens().get(tokenId2).getRenewDate(), "token2 renew date incorrect");
+    assertTrue(mgr.getAllTokens().containsKey(tokenId3),
+        "token3 missing from manager");
+    assertEquals(tokenRenewDate3,
+        mgr.getAllTokens().get(tokenId3).getRenewDate(), "token3 renew date");
 
 
     mgr.startThreads();
     mgr.startThreads();
     mgr.verifyToken(tokenId2, token2.getPassword());
     mgr.verifyToken(tokenId2, token2.getPassword());
@@ -153,10 +152,9 @@ public class TestJHSDelegationTokenSecretManager {
     stopAndCleanSecretManager(mgr);
     stopAndCleanSecretManager(mgr);
 
 
     // Store should contain token but manager should not
     // Store should contain token but manager should not
-    Assert.assertTrue("Store does not contain token3",
-        tokenState.containsKey(tokenId3));
-    Assert.assertFalse("Store does not contain token3",
-        mgr.getAllTokens().containsKey(tokenId3));
+    assertTrue(tokenState.containsKey(tokenId3), "Store does not contain token3");
+    assertFalse(mgr.getAllTokens().containsKey(tokenId3),
+        "Store does not contain token3");
     // Recover to load the token into the manager; renew date is set to 0
     // Recover to load the token into the manager; renew date is set to 0
     mgr.recover(store.loadState());
     mgr.recover(store.loadState());
     GenericTestUtils.waitFor(new Supplier<Boolean>() {
     GenericTestUtils.waitFor(new Supplier<Boolean>() {

+ 8 - 8
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistory.java

@@ -37,16 +37,16 @@ import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobsInfo;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JobHistoryUtils;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JobHistoryUtils;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
-import static junit.framework.TestCase.assertEquals;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doNothing;
@@ -520,7 +520,7 @@ public class TestJobHistory {
     assertTrue(th instanceof UnsupportedOperationException);
     assertTrue(th instanceof UnsupportedOperationException);
   }
   }
   
   
-  @After
+  @AfterEach
   public void cleanUp() {
   public void cleanUp() {
     if (jobHistory != null) {
     if (jobHistory != null) {
       jobHistory.stop();
       jobHistory.stop();

+ 42 - 25
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryEntities.java

@@ -43,19 +43,19 @@ import org.apache.hadoop.mapreduce.v2.app.job.Task;
 import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
 import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.apache.hadoop.mapred.TaskCompletionEvent;
 import org.apache.hadoop.mapred.TaskCompletionEvent;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 
-@RunWith(value = Parameterized.class)
 public class TestJobHistoryEntities {
 public class TestJobHistoryEntities {
 
 
   private final String historyFileName =
   private final String historyFileName =
@@ -78,11 +78,10 @@ public class TestJobHistoryEntities {
         .getFile());
         .getFile());
   private CompletedJob completedJob;
   private CompletedJob completedJob;
 
 
-  public TestJobHistoryEntities(boolean loadTasks) throws Exception {
-    this.loadTasks = loadTasks;
+  public void initTestJobHistoryEntities(boolean paramLoadTasks) throws Exception {
+    this.loadTasks = paramLoadTasks;
   }
   }
 
 
-  @Parameters
   public static Collection<Object[]> data() {
   public static Collection<Object[]> data() {
     List<Object[]> list = new ArrayList<Object[]>(2);
     List<Object[]> list = new ArrayList<Object[]>(2);
     list.add(new Object[] { true });
     list.add(new Object[] { true });
@@ -91,8 +90,11 @@ public class TestJobHistoryEntities {
   }
   }
 
 
   /* Verify some expected values based on the history file */
   /* Verify some expected values based on the history file */
-  @Test (timeout=100000)
-  public void testCompletedJob() throws Exception {
+  @MethodSource("data")
+  @ParameterizedTest
+  @Timeout(value = 100)
+  public void testCompletedJob(boolean paramLoadTasks) throws Exception {
+    initTestJobHistoryEntities(paramLoadTasks);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getHistoryFile()).thenReturn(fullHistoryPath);
     when(info.getHistoryFile()).thenReturn(fullHistoryPath);
@@ -117,9 +119,12 @@ public class TestJobHistoryEntities {
     assertEquals(JobState.SUCCEEDED, jobReport.getJobState());
     assertEquals(JobState.SUCCEEDED, jobReport.getJobState());
     assertEquals(fullHistoryPath.toString(), jobReport.getHistoryFile());
     assertEquals(fullHistoryPath.toString(), jobReport.getHistoryFile());
   }
   }
-  
-  @Test (timeout=100000)
-  public void testCopmletedJobReportWithZeroTasks() throws Exception {
+
+  @MethodSource("data")
+  @ParameterizedTest
+  @Timeout(value = 100)
+  public void testCopmletedJobReportWithZeroTasks(boolean paramLoadTasks) throws Exception {
+    initTestJobHistoryEntities(paramLoadTasks);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getHistoryFile()).thenReturn(fullHistoryPathZeroReduces);
     when(info.getHistoryFile()).thenReturn(fullHistoryPathZeroReduces);
@@ -136,8 +141,11 @@ public class TestJobHistoryEntities {
         jobReport.getHistoryFile());
         jobReport.getHistoryFile());
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testCompletedTask() throws Exception {
+  @MethodSource("data")
+  @ParameterizedTest
+  @Timeout(value = 10)
+  public void testCompletedTask(boolean paramLoadTasks) throws Exception {
+    initTestJobHistoryEntities(paramLoadTasks);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getConfFile()).thenReturn(fullConfPath);
     completedJob =
     completedJob =
@@ -165,8 +173,11 @@ public class TestJobHistoryEntities {
     assertEquals(rt1Id, rt1Report.getTaskId());
     assertEquals(rt1Id, rt1Report.getTaskId());
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testCompletedTaskAttempt() throws Exception {
+  @MethodSource("data")
+  @ParameterizedTest
+  @Timeout(value = 10)
+  public void testCompletedTaskAttempt(boolean paramLoadTasks) throws Exception {
+    initTestJobHistoryEntities(paramLoadTasks);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getConfFile()).thenReturn(fullConfPath);
     completedJob =
     completedJob =
@@ -204,8 +215,11 @@ public class TestJobHistoryEntities {
    * Simple test of some methods of CompletedJob
    * Simple test of some methods of CompletedJob
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout=30000)
-  public void testGetTaskAttemptCompletionEvent() throws Exception{
+  @MethodSource("data")
+  @ParameterizedTest
+  @Timeout(value = 30)
+  public void testGetTaskAttemptCompletionEvent(boolean paramLoadTasks) throws Exception {
+    initTestJobHistoryEntities(paramLoadTasks);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     HistoryFileInfo info = mock(HistoryFileInfo.class);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getConfFile()).thenReturn(fullConfPath);
     completedJob =
     completedJob =
@@ -241,8 +255,11 @@ public class TestJobHistoryEntities {
 
 
   }
   }
 
 
-  @Test (timeout=30000)
-  public void testCompletedJobWithDiagnostics() throws Exception {
+  @MethodSource("data")
+  @ParameterizedTest
+  @Timeout(value = 30)
+  public void testCompletedJobWithDiagnostics(boolean paramLoadTasks) throws Exception {
+    initTestJobHistoryEntities(paramLoadTasks);
     final String jobError = "Job Diagnostics";
     final String jobError = "Job Diagnostics";
     JobInfo jobInfo = spy(new JobInfo());
     JobInfo jobInfo = spy(new JobInfo());
     when(jobInfo.getErrorInfo()).thenReturn(jobError);
     when(jobInfo.getErrorInfo()).thenReturn(jobError);

+ 36 - 38
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryEvents.java

@@ -20,7 +20,6 @@ package org.apache.hadoop.mapreduce.v2.hs;
 
 
 import java.util.Map;
 import java.util.Map;
 
 
-import org.junit.Assert;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.TypeConverter;
 import org.apache.hadoop.mapreduce.TypeConverter;
@@ -41,11 +40,15 @@ import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
 import org.apache.hadoop.service.Service;
 import org.apache.hadoop.service.Service;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.event.EventHandler;
 import org.apache.hadoop.yarn.event.EventHandler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestJobHistoryEvents {
 public class TestJobHistoryEvents {
   private static final Logger LOG =
   private static final Logger LOG =
@@ -71,39 +74,37 @@ public class TestJobHistoryEvents {
     // test start and stop states
     // test start and stop states
     ((JobHistory)context).init(conf);
     ((JobHistory)context).init(conf);
     ((JobHistory)context).start();
     ((JobHistory)context).start();
-    Assert.assertTrue( context.getStartTime()>0);
-    Assert.assertEquals(((JobHistory)context).getServiceState(),Service.STATE.STARTED);
+    assertTrue(context.getStartTime() > 0);
+    assertEquals(((JobHistory) context).getServiceState(), Service.STATE.STARTED);
 
 
     // get job before stopping JobHistory
     // get job before stopping JobHistory
     Job parsedJob = context.getJob(jobId);
     Job parsedJob = context.getJob(jobId);
 
 
     // stop JobHistory
     // stop JobHistory
     ((JobHistory)context).stop();
     ((JobHistory)context).stop();
-    Assert.assertEquals(((JobHistory)context).getServiceState(),Service.STATE.STOPPED);
+    assertEquals(((JobHistory) context).getServiceState(), Service.STATE.STOPPED);
 
 
 
 
-    Assert.assertEquals("CompletedMaps not correct", 2,
-        parsedJob.getCompletedMaps());
-    Assert.assertEquals(System.getProperty("user.name"), parsedJob.getUserName());
+    assertEquals(2, parsedJob.getCompletedMaps(),
+        "CompletedMaps not correct");
+    assertEquals(System.getProperty("user.name"), parsedJob.getUserName());
     
     
     Map<TaskId, Task> tasks = parsedJob.getTasks();
     Map<TaskId, Task> tasks = parsedJob.getTasks();
-    Assert.assertEquals("No of tasks not correct", 3, tasks.size());
+    assertEquals(3, tasks.size(), "No of tasks not correct");
     for (Task task : tasks.values()) {
     for (Task task : tasks.values()) {
       verifyTask(task);
       verifyTask(task);
     }
     }
     
     
     Map<TaskId, Task> maps = parsedJob.getTasks(TaskType.MAP);
     Map<TaskId, Task> maps = parsedJob.getTasks(TaskType.MAP);
-    Assert.assertEquals("No of maps not correct", 2, maps.size());
+    assertEquals(2, maps.size(), "No of maps not correct");
     
     
     Map<TaskId, Task> reduces = parsedJob.getTasks(TaskType.REDUCE);
     Map<TaskId, Task> reduces = parsedJob.getTasks(TaskType.REDUCE);
-    Assert.assertEquals("No of reduces not correct", 1, reduces.size());
-    
-    
-    Assert.assertEquals("CompletedReduce not correct", 1,
-        parsedJob.getCompletedReduces());
-    
-    Assert.assertEquals("Job state not currect", JobState.SUCCEEDED,
-        parsedJob.getState());
+    assertEquals(1, reduces.size(), "No of reduces not correct");
+
+
+    assertEquals(1, parsedJob.getCompletedReduces(), "CompletedReduce not correct");
+
+    assertEquals(JobState.SUCCEEDED, parsedJob.getState(), "Job state not correct");
   }
   }
 
 
   /**
   /**
@@ -131,18 +132,16 @@ public class TestJobHistoryEvents {
     HistoryContext context = new JobHistory();
     HistoryContext context = new JobHistory();
     ((JobHistory) context).init(conf);
     ((JobHistory) context).init(conf);
     Job parsedJob = context.getJob(jobId);
     Job parsedJob = context.getJob(jobId);
-    Assert.assertEquals("CompletedMaps not correct", 1, parsedJob
-        .getCompletedMaps());
+    assertEquals(1, parsedJob.getCompletedMaps(), "CompletedMaps not correct");
 
 
     Map<TaskId, Task> tasks = parsedJob.getTasks();
     Map<TaskId, Task> tasks = parsedJob.getTasks();
-    Assert.assertEquals("No of tasks not correct", 1, tasks.size());
+    assertEquals(1, tasks.size(), "No of tasks not correct");
     verifyTask(tasks.values().iterator().next());
     verifyTask(tasks.values().iterator().next());
 
 
     Map<TaskId, Task> maps = parsedJob.getTasks(TaskType.MAP);
     Map<TaskId, Task> maps = parsedJob.getTasks(TaskType.MAP);
-    Assert.assertEquals("No of maps not correct", 1, maps.size());
+    assertEquals(1, maps.size(), "No of maps not correct");
 
 
-    Assert.assertEquals("Job state not currect", JobState.SUCCEEDED,
-        parsedJob.getState());
+    assertEquals(JobState.SUCCEEDED, parsedJob.getState(), "Job state not correct");
   }
   }
 
 
   @Test
   @Test
@@ -155,7 +154,7 @@ public class TestJobHistoryEvents {
     // Verifying that it is the last to be added is same as verifying that it is
     // Verifying that it is the last to be added is same as verifying that it is
     // the first to be stopped. CompositeService related tests already validate
     // the first to be stopped. CompositeService related tests already validate
     // this.
     // this.
-    Assert.assertEquals("JobHistoryEventHandler",
+    assertEquals("JobHistoryEventHandler",
         services[services.length - 1].getName());
         services[services.length - 1].getName());
   }
   }
   
   
@@ -180,7 +179,7 @@ public class TestJobHistoryEvents {
     // test start and stop states
     // test start and stop states
     ((JobHistory)context).init(conf);
     ((JobHistory)context).init(conf);
     ((JobHistory)context).start();
     ((JobHistory)context).start();
-    Assert.assertTrue( context.getStartTime()>0);
+    assertTrue(context.getStartTime() > 0);
     assertThat(((JobHistory)context).getServiceState())
     assertThat(((JobHistory)context).getServiceState())
         .isEqualTo(Service.STATE.STARTED);
         .isEqualTo(Service.STATE.STARTED);
 
 
@@ -192,29 +191,28 @@ public class TestJobHistoryEvents {
     assertThat(((JobHistory)context).getServiceState())
     assertThat(((JobHistory)context).getServiceState())
         .isEqualTo(Service.STATE.STOPPED);
         .isEqualTo(Service.STATE.STOPPED);
 
 
-    Assert.assertEquals("QueueName not correct", "assignedQueue",
-        parsedJob.getQueueName());
+    assertEquals("assignedQueue", parsedJob.getQueueName(),
+        "QueueName not correct");
   }
   }
 
 
   private void verifyTask(Task task) {
   private void verifyTask(Task task) {
-    Assert.assertEquals("Task state not currect", TaskState.SUCCEEDED,
-        task.getState());
+    assertEquals(TaskState.SUCCEEDED, task.getState(), "Task state not correct");
     Map<TaskAttemptId, TaskAttempt> attempts = task.getAttempts();
     Map<TaskAttemptId, TaskAttempt> attempts = task.getAttempts();
-    Assert.assertEquals("No of attempts not correct", 1, attempts.size());
+    assertEquals(1, attempts.size(), "No of attempts not correct");
     for (TaskAttempt attempt : attempts.values()) {
     for (TaskAttempt attempt : attempts.values()) {
       verifyAttempt(attempt);
       verifyAttempt(attempt);
     }
     }
   }
   }
 
 
   private void verifyAttempt(TaskAttempt attempt) {
   private void verifyAttempt(TaskAttempt attempt) {
-    Assert.assertEquals("TaskAttempt state not currect", 
-        TaskAttemptState.SUCCEEDED, attempt.getState());
-    Assert.assertNotNull(attempt.getAssignedContainerID());
-  //Verify the wrong ctor is not being used. Remove after mrv1 is removed.
+    assertEquals(TaskAttemptState.SUCCEEDED, attempt.getState(),
+        "TaskAttempt state not correct");
+    assertNotNull(attempt.getAssignedContainerID());
+    // Verify the wrong ctor is not being used. Remove after mrv1 is removed.
     ContainerId fakeCid = MRApp.newContainerId(-1, -1, -1, -1);
     ContainerId fakeCid = MRApp.newContainerId(-1, -1, -1, -1);
-    Assert.assertFalse(attempt.getAssignedContainerID().equals(fakeCid));
-    //Verify complete contianerManagerAddress
-    Assert.assertEquals(MRApp.NM_HOST + ":" + MRApp.NM_PORT,
+    assertNotEquals(attempt.getAssignedContainerID(), fakeCid);
+    //Verify complete containerManagerAddress
+    assertEquals(MRApp.NM_HOST + ":" + MRApp.NM_PORT,
         attempt.getAssignedContainerMgrAddress());
         attempt.getAssignedContainerMgrAddress());
   }
   }
 
 

+ 138 - 141
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryParsing.java

@@ -18,13 +18,15 @@
 
 
 package org.apache.hadoop.mapreduce.v2.hs;
 package org.apache.hadoop.mapreduce.v2.hs;
 
 
-import static org.apache.hadoop.fs.CommonConfigurationKeysPublic
-    .NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY;
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.
+    NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.IOException;
@@ -38,7 +40,6 @@ import java.util.StringTokenizer;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 
 
 import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptFailEvent;
 import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptFailEvent;
-import org.junit.Assert;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataInputStream;
@@ -92,7 +93,8 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.service.Service;
 import org.apache.hadoop.service.Service;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.util.RackResolver;
 import org.apache.hadoop.yarn.util.RackResolver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
@@ -122,14 +124,16 @@ public class TestJobHistoryParsing {
     }
     }
   }
   }
 
 
-  @Test(timeout = 50000)
+  @Test
+  @Timeout(value = 50)
   public void testJobInfo() throws Exception {
   public void testJobInfo() throws Exception {
     JobInfo info = new JobInfo();
     JobInfo info = new JobInfo();
-    Assert.assertEquals("NORMAL", info.getPriority());
+    assertEquals("NORMAL", info.getPriority());
     info.printAll();
     info.printAll();
   }
   }
 
 
-  @Test(timeout = 300000)
+  @Test
+  @Timeout(value = 300)
   public void testHistoryParsing() throws Exception {
   public void testHistoryParsing() throws Exception {
     LOG.info("STARTING testHistoryParsing()");
     LOG.info("STARTING testHistoryParsing()");
     try {
     try {
@@ -139,7 +143,8 @@ public class TestJobHistoryParsing {
     }
     }
   }
   }
 
 
-  @Test(timeout = 50000)
+  @Test
+  @Timeout(value = 50)
   public void testHistoryParsingWithParseErrors() throws Exception {
   public void testHistoryParsingWithParseErrors() throws Exception {
     LOG.info("STARTING testHistoryParsingWithParseErrors()");
     LOG.info("STARTING testHistoryParsingWithParseErrors()");
     try {
     try {
@@ -194,9 +199,9 @@ public class TestJobHistoryParsing {
           .getIntermediateSummaryFileName(jobId);
           .getIntermediateSummaryFileName(jobId);
       Path summaryFile = new Path(jobhistoryDir, summaryFileName);
       Path summaryFile = new Path(jobhistoryDir, summaryFileName);
       String jobSummaryString = getJobSummary(fc, summaryFile);
       String jobSummaryString = getJobSummary(fc, summaryFile);
-      Assert.assertNotNull(jobSummaryString);
-      Assert.assertTrue(jobSummaryString.contains("resourcesPerMap=100"));
-      Assert.assertTrue(jobSummaryString.contains("resourcesPerReduce=100"));
+      assertNotNull(jobSummaryString);
+      assertTrue(jobSummaryString.contains("resourcesPerMap=100"));
+      assertTrue(jobSummaryString.contains("resourcesPerReduce=100"));
 
 
       Map<String, String> jobSummaryElements = new HashMap<String, String>();
       Map<String, String> jobSummaryElements = new HashMap<String, String>();
       StringTokenizer strToken = new StringTokenizer(jobSummaryString, ",");
       StringTokenizer strToken = new StringTokenizer(jobSummaryString, ",");
@@ -205,34 +210,27 @@ public class TestJobHistoryParsing {
         jobSummaryElements.put(keypair.split("=")[0], keypair.split("=")[1]);
         jobSummaryElements.put(keypair.split("=")[0], keypair.split("=")[1]);
       }
       }
 
 
-      Assert.assertEquals("JobId does not match", jobId.toString(),
-          jobSummaryElements.get("jobId"));
-      Assert.assertEquals("JobName does not match", "test",
-          jobSummaryElements.get("jobName"));
-      Assert.assertTrue("submitTime should not be 0",
-          Long.parseLong(jobSummaryElements.get("submitTime")) != 0);
-      Assert.assertTrue("launchTime should not be 0",
-          Long.parseLong(jobSummaryElements.get("launchTime")) != 0);
-      Assert
-          .assertTrue(
-              "firstMapTaskLaunchTime should not be 0",
-              Long.parseLong(jobSummaryElements.get("firstMapTaskLaunchTime")) != 0);
-      Assert
-          .assertTrue("firstReduceTaskLaunchTime should not be 0",
-              Long.parseLong(jobSummaryElements
-                  .get("firstReduceTaskLaunchTime")) != 0);
-      Assert.assertTrue("finishTime should not be 0",
-          Long.parseLong(jobSummaryElements.get("finishTime")) != 0);
-      Assert.assertEquals("Mismatch in num map slots", numSuccessfulMaps,
-          Integer.parseInt(jobSummaryElements.get("numMaps")));
-      Assert.assertEquals("Mismatch in num reduce slots", numReduces,
-          Integer.parseInt(jobSummaryElements.get("numReduces")));
-      Assert.assertEquals("User does not match",
-          System.getProperty("user.name"), jobSummaryElements.get("user"));
-      Assert.assertEquals("Queue does not match", "default",
-          jobSummaryElements.get("queue"));
-      Assert.assertEquals("Status does not match", "SUCCEEDED",
-          jobSummaryElements.get("status"));
+      assertEquals(jobId.toString(), jobSummaryElements.get("jobId"),
+          "JobId does not match");
+      assertEquals("test", jobSummaryElements.get("jobName"), "JobName does not match");
+      assertTrue(Long.parseLong(jobSummaryElements.get("submitTime")) != 0,
+          "submitTime should not be 0");
+      assertTrue(Long.parseLong(jobSummaryElements.get("launchTime")) != 0,
+          "launchTime should not be 0");
+      assertTrue(Long.parseLong(jobSummaryElements.get("firstMapTaskLaunchTime")) != 0,
+          "firstMapTaskLaunchTime should not be 0");
+      assertTrue(Long.parseLong(jobSummaryElements.get("firstReduceTaskLaunchTime")) != 0,
+          "firstReduceTaskLaunchTime should not be 0");
+      assertTrue(Long.parseLong(jobSummaryElements.get("finishTime")) != 0,
+          "finishTime should not be 0");
+      assertEquals(numSuccessfulMaps, Integer.parseInt(jobSummaryElements.get("numMaps")),
+          "Mismatch in num map slots");
+      assertEquals(numReduces, Integer.parseInt(jobSummaryElements.get("numReduces")),
+          "Mismatch in num reduce slots");
+      assertEquals(System.getProperty("user.name"), jobSummaryElements.get("user"),
+          "User does not match");
+      assertEquals("default", jobSummaryElements.get("queue"), "Queue does not match");
+      assertEquals("SUCCEEDED", jobSummaryElements.get("status"), "Status does not match");
     }
     }
 
 
     JobHistory jobHistory = new JobHistory();
     JobHistory jobHistory = new JobHistory();
@@ -283,72 +281,69 @@ public class TestJobHistoryParsing {
 
 
       if (numFinishedMaps != numMaps) {
       if (numFinishedMaps != numMaps) {
         Exception parseException = parser.getParseException();
         Exception parseException = parser.getParseException();
-        Assert.assertNotNull("Didn't get expected parse exception",
-            parseException);
+        assertNotNull(parseException, "Didn't get expected parse exception");
       }
       }
     }
     }
 
 
-    Assert.assertEquals("Incorrect username ", System.getProperty("user.name"),
-        jobInfo.getUsername());
-    Assert.assertEquals("Incorrect jobName ", "test", jobInfo.getJobname());
-    Assert.assertEquals("Incorrect queuename ", "default",
-        jobInfo.getJobQueueName());
-    Assert
-        .assertEquals("incorrect conf path", "test", jobInfo.getJobConfPath());
-    Assert.assertEquals("incorrect finishedMap ", numSuccessfulMaps,
-        numFinishedMaps);
-    Assert.assertEquals("incorrect finishedReduces ", numReduces,
-        jobInfo.getSucceededReduces());
-    Assert.assertEquals("incorrect uberized ", job.isUber(),
-        jobInfo.getUberized());
+    assertEquals(System.getProperty("user.name"),
+        jobInfo.getUsername(), "Incorrect username ");
+    assertEquals("test", jobInfo.getJobname(), "Incorrect jobName");
+    assertEquals("default", jobInfo.getJobQueueName(),
+        "Incorrect queuename");
+    assertEquals("test", jobInfo.getJobConfPath(), "incorrect conf path");
+    assertEquals(numSuccessfulMaps,
+        numFinishedMaps, "incorrect finishedMap ");
+    assertEquals(numReduces,
+        jobInfo.getSucceededReduces(), "incorrect finishedReduces ");
+    assertEquals(job.isUber(),
+        jobInfo.getUberized(), "incorrect uberized ");
     Map<TaskID, TaskInfo> allTasks = jobInfo.getAllTasks();
     Map<TaskID, TaskInfo> allTasks = jobInfo.getAllTasks();
     int totalTasks = allTasks.size();
     int totalTasks = allTasks.size();
-    Assert.assertEquals("total number of tasks is incorrect  ",
-        (numMaps + numReduces), totalTasks);
+    assertEquals((numMaps + numReduces), totalTasks,
+        "total number of tasks is incorrect");
 
 
     // Verify aminfo
     // Verify aminfo
-    Assert.assertEquals(1, jobInfo.getAMInfos().size());
-    Assert.assertEquals(MRApp.NM_HOST, jobInfo.getAMInfos().get(0)
+    assertEquals(1, jobInfo.getAMInfos().size());
+    assertEquals(MRApp.NM_HOST, jobInfo.getAMInfos().get(0)
         .getNodeManagerHost());
         .getNodeManagerHost());
     AMInfo amInfo = jobInfo.getAMInfos().get(0);
     AMInfo amInfo = jobInfo.getAMInfos().get(0);
-    Assert.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
-    Assert.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
-    Assert.assertEquals(1, amInfo.getAppAttemptId().getAttemptId());
-    Assert.assertEquals(amInfo.getAppAttemptId(), amInfo.getContainerId()
+    assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
+    assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
+    assertEquals(1, amInfo.getAppAttemptId().getAttemptId());
+    assertEquals(amInfo.getAppAttemptId(), amInfo.getContainerId()
         .getApplicationAttemptId());
         .getApplicationAttemptId());
-    Assert.assertTrue(amInfo.getStartTime() <= System.currentTimeMillis()
+    assertTrue(amInfo.getStartTime() <= System.currentTimeMillis()
         && amInfo.getStartTime() >= amStartTimeEst);
         && amInfo.getStartTime() >= amStartTimeEst);
 
 
     ContainerId fakeCid = MRApp.newContainerId(-1, -1, -1, -1);
     ContainerId fakeCid = MRApp.newContainerId(-1, -1, -1, -1);
     // Assert at taskAttempt level
     // Assert at taskAttempt level
     for (TaskInfo taskInfo : allTasks.values()) {
     for (TaskInfo taskInfo : allTasks.values()) {
       int taskAttemptCount = taskInfo.getAllTaskAttempts().size();
       int taskAttemptCount = taskInfo.getAllTaskAttempts().size();
-      Assert
-          .assertEquals("total number of task attempts ", 1, taskAttemptCount);
+      assertEquals(1, taskAttemptCount, "total number of task attempts");
       TaskAttemptInfo taInfo = taskInfo.getAllTaskAttempts().values()
       TaskAttemptInfo taInfo = taskInfo.getAllTaskAttempts().values()
           .iterator().next();
           .iterator().next();
-      Assert.assertNotNull(taInfo.getContainerId());
+      assertNotNull(taInfo.getContainerId());
       // Verify the wrong ctor is not being used. Remove after mrv1 is removed.
       // Verify the wrong ctor is not being used. Remove after mrv1 is removed.
-      Assert.assertFalse(taInfo.getContainerId().equals(fakeCid));
+      assertNotEquals(taInfo.getContainerId(), fakeCid);
     }
     }
 
 
     // Deep compare Job and JobInfo
     // Deep compare Job and JobInfo
     for (Task task : job.getTasks().values()) {
     for (Task task : job.getTasks().values()) {
       TaskInfo taskInfo = allTasks.get(TypeConverter.fromYarn(task.getID()));
       TaskInfo taskInfo = allTasks.get(TypeConverter.fromYarn(task.getID()));
-      Assert.assertNotNull("TaskInfo not found", taskInfo);
+      assertNotNull(taskInfo, "TaskInfo not found");
       for (TaskAttempt taskAttempt : task.getAttempts().values()) {
       for (TaskAttempt taskAttempt : task.getAttempts().values()) {
         TaskAttemptInfo taskAttemptInfo = taskInfo.getAllTaskAttempts().get(
         TaskAttemptInfo taskAttemptInfo = taskInfo.getAllTaskAttempts().get(
             TypeConverter.fromYarn((taskAttempt.getID())));
             TypeConverter.fromYarn((taskAttempt.getID())));
-        Assert.assertNotNull("TaskAttemptInfo not found", taskAttemptInfo);
-        Assert.assertEquals("Incorrect shuffle port for task attempt",
-            taskAttempt.getShufflePort(), taskAttemptInfo.getShufflePort());
+        assertNotNull(taskAttemptInfo, "TaskAttemptInfo not found");
+        assertEquals(taskAttempt.getShufflePort(), taskAttemptInfo.getShufflePort(),
+            "Incorrect shuffle port for task attempt");
         if (numMaps == numSuccessfulMaps) {
         if (numMaps == numSuccessfulMaps) {
-          Assert.assertEquals(MRApp.NM_HOST, taskAttemptInfo.getHostname());
-          Assert.assertEquals(MRApp.NM_PORT, taskAttemptInfo.getPort());
+          assertEquals(MRApp.NM_HOST, taskAttemptInfo.getHostname());
+          assertEquals(MRApp.NM_PORT, taskAttemptInfo.getPort());
 
 
           // Verify rack-name
           // Verify rack-name
-          Assert.assertEquals("rack-name is incorrect",
-              taskAttemptInfo.getRackname(), RACK_NAME);
+          assertEquals(taskAttemptInfo.getRackname(), RACK_NAME,
+              "rack-name is incorrect");
         }
         }
       }
       }
     }
     }
@@ -371,8 +366,8 @@ public class TestJobHistoryParsing {
             + " "
             + " "
             + taskInfo.getTaskType()
             + taskInfo.getTaskType()
             + " task list for " + taskInfo.getTaskId().getJobID();
             + " task list for " + taskInfo.getTaskId().getJobID();
-        Assert.assertTrue(outContent.toString().indexOf(test) > 0);
-        Assert.assertTrue(outContent.toString().indexOf(
+        assertTrue(outContent.toString().indexOf(test) > 0);
+        assertTrue(outContent.toString().indexOf(
             taskInfo.getTaskId().toString()) > 0);
             taskInfo.getTaskId().toString()) > 0);
       }
       }
     } finally {
     } finally {
@@ -399,7 +394,8 @@ public class TestJobHistoryParsing {
     return numFinishedMaps;
     return numFinishedMaps;
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testHistoryParsingForFailedAttempts() throws Exception {
   public void testHistoryParsingForFailedAttempts() throws Exception {
     LOG.info("STARTING testHistoryParsingForFailedAttempts");
     LOG.info("STARTING testHistoryParsingForFailedAttempts");
     try {
     try {
@@ -440,8 +436,8 @@ public class TestJobHistoryParsing {
         jobInfo = parser.parse();
         jobInfo = parser.parse();
       }
       }
       Exception parseException = parser.getParseException();
       Exception parseException = parser.getParseException();
-      Assert.assertNull("Caught an expected exception " + parseException,
-          parseException);
+      assertNull(parseException,
+          "Caught an expected exception " + parseException);
       int noOffailedAttempts = 0;
       int noOffailedAttempts = 0;
       Map<TaskID, TaskInfo> allTasks = jobInfo.getAllTasks();
       Map<TaskID, TaskInfo> allTasks = jobInfo.getAllTasks();
       for (Task task : job.getTasks().values()) {
       for (Task task : job.getTasks().values()) {
@@ -457,14 +453,14 @@ public class TestJobHistoryParsing {
           }
           }
         }
         }
       }
       }
-      Assert.assertEquals("No of Failed tasks doesn't match.", 2,
-          noOffailedAttempts);
+      assertEquals(2, noOffailedAttempts, "No of Failed tasks doesn't match.");
     } finally {
     } finally {
       LOG.info("FINISHED testHistoryParsingForFailedAttempts");
       LOG.info("FINISHED testHistoryParsingForFailedAttempts");
     }
     }
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testHistoryParsingForKilledAndFailedAttempts() throws Exception {
   public void testHistoryParsingForKilledAndFailedAttempts() throws Exception {
     MRApp app = null;
     MRApp app = null;
     JobHistory jobHistory = null;
     JobHistory jobHistory = null;
@@ -516,13 +512,13 @@ public class TestJobHistoryParsing {
         jobInfo = parser.parse();
         jobInfo = parser.parse();
       }
       }
       Exception parseException = parser.getParseException();
       Exception parseException = parser.getParseException();
-      Assert.assertNull("Caught an expected exception " + parseException,
-          parseException);
+      assertNull(parseException,
+          "Caught an expected exception " + parseException);
 
 
-      assertEquals("FailedMaps", 1, jobInfo.getFailedMaps());
-      assertEquals("KilledMaps", 1, jobInfo.getKilledMaps());
-      assertEquals("FailedReduces", 1, jobInfo.getFailedReduces());
-      assertEquals("KilledReduces", 1, jobInfo.getKilledReduces());
+      assertEquals(1, jobInfo.getFailedMaps(), "FailedMaps");
+      assertEquals(1, jobInfo.getKilledMaps(), "KilledMaps");
+      assertEquals(1, jobInfo.getFailedReduces(), "FailedReduces");
+      assertEquals(1, jobInfo.getKilledReduces(), "KilledReduces");
     } finally {
     } finally {
       LOG.info("FINISHED testHistoryParsingForKilledAndFailedAttempts");
       LOG.info("FINISHED testHistoryParsingForKilledAndFailedAttempts");
       if (app != null) {
       if (app != null) {
@@ -534,7 +530,8 @@ public class TestJobHistoryParsing {
     }
     }
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testCountersForFailedTask() throws Exception {
   public void testCountersForFailedTask() throws Exception {
     LOG.info("STARTING testCountersForFailedTask");
     LOG.info("STARTING testCountersForFailedTask");
     try {
     try {
@@ -576,19 +573,18 @@ public class TestJobHistoryParsing {
         jobInfo = parser.parse();
         jobInfo = parser.parse();
       }
       }
       Exception parseException = parser.getParseException();
       Exception parseException = parser.getParseException();
-      Assert.assertNull("Caught an expected exception " + parseException,
-          parseException);
+      assertNull(parseException, "Caught an expected exception " + parseException);
       for (Map.Entry<TaskID, TaskInfo> entry : jobInfo.getAllTasks().entrySet()) {
       for (Map.Entry<TaskID, TaskInfo> entry : jobInfo.getAllTasks().entrySet()) {
         TaskId yarnTaskID = TypeConverter.toYarn(entry.getKey());
         TaskId yarnTaskID = TypeConverter.toYarn(entry.getKey());
         CompletedTask ct = new CompletedTask(yarnTaskID, entry.getValue());
         CompletedTask ct = new CompletedTask(yarnTaskID, entry.getValue());
-        Assert.assertNotNull("completed task report has null counters", ct
-            .getReport().getCounters());
+        assertNotNull(ct.getReport().getCounters(),
+            "completed task report has null counters");
       }
       }
       final List<String> originalDiagnostics = job.getDiagnostics();
       final List<String> originalDiagnostics = job.getDiagnostics();
       final String historyError = jobInfo.getErrorInfo();
       final String historyError = jobInfo.getErrorInfo();
-      assertTrue("No original diagnostics for a failed job",
-          originalDiagnostics != null && !originalDiagnostics.isEmpty());
-      assertNotNull("No history error info for a failed job ", historyError);
+      assertTrue(originalDiagnostics != null && !originalDiagnostics.isEmpty(),
+          "No original diagnostics for a failed job");
+      assertNotNull(historyError, "No history error info for a failed job");
       for (String diagString : originalDiagnostics) {
       for (String diagString : originalDiagnostics) {
         assertTrue(historyError.contains(diagString));
         assertTrue(historyError.contains(diagString));
       }
       }
@@ -597,7 +593,8 @@ public class TestJobHistoryParsing {
     }
     }
   }
   }
 
 
-  @Test(timeout = 60000)
+  @Test
+  @Timeout(value = 60)
   public void testDiagnosticsForKilledJob() throws Exception {
   public void testDiagnosticsForKilledJob() throws Exception {
     LOG.info("STARTING testDiagnosticsForKilledJob");
     LOG.info("STARTING testDiagnosticsForKilledJob");
     try {
     try {
@@ -639,24 +636,24 @@ public class TestJobHistoryParsing {
         jobInfo = parser.parse();
         jobInfo = parser.parse();
       }
       }
       Exception parseException = parser.getParseException();
       Exception parseException = parser.getParseException();
-      assertNull("Caught an expected exception " + parseException,
-          parseException);
+      assertNull(parseException, "Caught an expected exception " + parseException);
       final List<String> originalDiagnostics = job.getDiagnostics();
       final List<String> originalDiagnostics = job.getDiagnostics();
       final String historyError = jobInfo.getErrorInfo();
       final String historyError = jobInfo.getErrorInfo();
-      assertTrue("No original diagnostics for a failed job",
-          originalDiagnostics != null && !originalDiagnostics.isEmpty());
-      assertNotNull("No history error info for a failed job ", historyError);
+      assertTrue(originalDiagnostics != null && !originalDiagnostics.isEmpty(),
+          "No original diagnostics for a failed job");
+      assertNotNull(historyError, "No history error info for a failed job ");
       for (String diagString : originalDiagnostics) {
       for (String diagString : originalDiagnostics) {
         assertTrue(historyError.contains(diagString));
         assertTrue(historyError.contains(diagString));
       }
       }
-      assertTrue("No killed message in diagnostics",
-        historyError.contains(JobImpl.JOB_KILLED_DIAG));
+      assertTrue(historyError.contains(JobImpl.JOB_KILLED_DIAG),
+          "No killed message in diagnostics");
     } finally {
     } finally {
       LOG.info("FINISHED testDiagnosticsForKilledJob");
       LOG.info("FINISHED testDiagnosticsForKilledJob");
     }
     }
   }
   }
 
 
-  @Test(timeout = 50000)
+  @Test
+  @Timeout(value = 50)
   public void testScanningOldDirs() throws Exception {
   public void testScanningOldDirs() throws Exception {
     LOG.info("STARTING testScanningOldDirs");
     LOG.info("STARTING testScanningOldDirs");
     try {
     try {
@@ -679,24 +676,24 @@ public class TestJobHistoryParsing {
       HistoryFileManagerForTest hfm = new HistoryFileManagerForTest();
       HistoryFileManagerForTest hfm = new HistoryFileManagerForTest();
       hfm.init(conf);
       hfm.init(conf);
       HistoryFileInfo fileInfo = hfm.getFileInfo(jobId);
       HistoryFileInfo fileInfo = hfm.getFileInfo(jobId);
-      Assert.assertNotNull("Unable to locate job history", fileInfo);
+      assertNotNull(fileInfo, "Unable to locate job history");
 
 
       // force the manager to "forget" the job
       // force the manager to "forget" the job
       hfm.deleteJobFromJobListCache(fileInfo);
       hfm.deleteJobFromJobListCache(fileInfo);
       final int msecPerSleep = 10;
       final int msecPerSleep = 10;
       int msecToSleep = 10 * 1000;
       int msecToSleep = 10 * 1000;
       while (fileInfo.isMovePending() && msecToSleep > 0) {
       while (fileInfo.isMovePending() && msecToSleep > 0) {
-        Assert.assertTrue(!fileInfo.didMoveFail());
+        assertFalse(fileInfo.didMoveFail());
         msecToSleep -= msecPerSleep;
         msecToSleep -= msecPerSleep;
         Thread.sleep(msecPerSleep);
         Thread.sleep(msecPerSleep);
       }
       }
-      Assert.assertTrue("Timeout waiting for history move", msecToSleep > 0);
+      assertTrue(msecToSleep > 0, "Timeout waiting for history move");
 
 
       fileInfo = hfm.getFileInfo(jobId);
       fileInfo = hfm.getFileInfo(jobId);
       hfm.stop();
       hfm.stop();
-      Assert.assertNotNull("Unable to locate old job history", fileInfo);
-      Assert.assertTrue("HistoryFileManager not shutdown properly",
-          hfm.moveToDoneExecutor.isTerminated());
+      assertNotNull(fileInfo, "Unable to locate old job history");
+      assertTrue(hfm.moveToDoneExecutor.isTerminated(),
+          "HistoryFileManager not shutdown properly");
     } finally {
     } finally {
       LOG.info("FINISHED testScanningOldDirs");
       LOG.info("FINISHED testScanningOldDirs");
     }
     }
@@ -813,7 +810,8 @@ public class TestJobHistoryParsing {
    * Test clean old history files. Files should be deleted after 1 week by
    * Test clean old history files. Files should be deleted after 1 week by
    * default.
    * default.
    */
    */
-  @Test(timeout = 15000)
+  @Test
+  @Timeout(value = 15)
   public void testDeleteFileInfo() throws Exception {
   public void testDeleteFileInfo() throws Exception {
     LOG.info("STARTING testDeleteFileInfo");
     LOG.info("STARTING testDeleteFileInfo");
     try {
     try {
@@ -845,20 +843,19 @@ public class TestJobHistoryParsing {
         Thread.sleep(300);
         Thread.sleep(300);
       }
       }
 
 
-      Assert.assertNotNull(hfm.jobListCache.values());
+      assertNotNull(hfm.jobListCache.values());
 
 
       // try to remove fileInfo
       // try to remove fileInfo
       hfm.clean();
       hfm.clean();
       // check that fileInfo does not deleted
       // check that fileInfo does not deleted
-      Assert.assertFalse(fileInfo.isDeleted());
+      assertFalse(fileInfo.isDeleted());
       // correct live time
       // correct live time
       hfm.setMaxHistoryAge(-1);
       hfm.setMaxHistoryAge(-1);
       hfm.clean();
       hfm.clean();
       hfm.stop();
       hfm.stop();
-      Assert.assertTrue("Thread pool shutdown",
-          hfm.moveToDoneExecutor.isTerminated());
+      assertTrue(hfm.moveToDoneExecutor.isTerminated(), "Thread pool shutdown");
       // should be deleted !
       // should be deleted !
-      Assert.assertTrue("file should be deleted ", fileInfo.isDeleted());
+      assertTrue(fileInfo.isDeleted(), "file should be deleted ");
 
 
     } finally {
     } finally {
       LOG.info("FINISHED testDeleteFileInfo");
       LOG.info("FINISHED testDeleteFileInfo");
@@ -868,7 +865,8 @@ public class TestJobHistoryParsing {
   /**
   /**
    * Simple test some methods of JobHistory
    * Simple test some methods of JobHistory
    */
    */
-  @Test(timeout = 20000)
+  @Test
+  @Timeout(value = 20)
   public void testJobHistoryMethods() throws Exception {
   public void testJobHistoryMethods() throws Exception {
     LOG.info("STARTING testJobHistoryMethods");
     LOG.info("STARTING testJobHistoryMethods");
     try {
     try {
@@ -892,27 +890,25 @@ public class TestJobHistoryParsing {
       JobHistory jobHistory = new JobHistory();
       JobHistory jobHistory = new JobHistory();
       jobHistory.init(configuration);
       jobHistory.init(configuration);
       // Method getAllJobs
       // Method getAllJobs
-      Assert.assertEquals(1, jobHistory.getAllJobs().size());
+      assertEquals(1, jobHistory.getAllJobs().size());
       // and with ApplicationId
       // and with ApplicationId
-      Assert.assertEquals(1, jobHistory.getAllJobs(app.getAppID()).size());
+      assertEquals(1, jobHistory.getAllJobs(app.getAppID()).size());
 
 
       JobsInfo jobsinfo = jobHistory.getPartialJobs(0L, 10L, null, "default",
       JobsInfo jobsinfo = jobHistory.getPartialJobs(0L, 10L, null, "default",
           0L, System.currentTimeMillis() + 1, 0L,
           0L, System.currentTimeMillis() + 1, 0L,
           System.currentTimeMillis() + 1, JobState.SUCCEEDED);
           System.currentTimeMillis() + 1, JobState.SUCCEEDED);
 
 
-      Assert.assertEquals(1, jobsinfo.getJobs().size());
-      Assert.assertNotNull(jobHistory.getApplicationAttemptId());
+      assertEquals(1, jobsinfo.getJobs().size());
+      assertNotNull(jobHistory.getApplicationAttemptId());
       // test Application Id
       // test Application Id
-      Assert.assertEquals("application_0_0000", jobHistory.getApplicationID()
-          .toString());
-      Assert
-          .assertEquals("Job History Server", jobHistory.getApplicationName());
+      assertEquals("application_0_0000", jobHistory.getApplicationID().toString());
+      assertEquals("Job History Server", jobHistory.getApplicationName());
       // method does not work
       // method does not work
-      Assert.assertNull(jobHistory.getEventHandler());
+      assertNull(jobHistory.getEventHandler());
       // method does not work
       // method does not work
-      Assert.assertNull(jobHistory.getClock());
+      assertNull(jobHistory.getClock());
       // method does not work
       // method does not work
-      Assert.assertNull(jobHistory.getClusterInfo());
+      assertNull(jobHistory.getClusterInfo());
 
 
     } finally {
     } finally {
       LOG.info("FINISHED testJobHistoryMethods");
       LOG.info("FINISHED testJobHistoryMethods");
@@ -922,7 +918,8 @@ public class TestJobHistoryParsing {
   /**
   /**
    * Simple test PartialJob
    * Simple test PartialJob
    */
    */
-  @Test(timeout = 3000)
+  @Test
+  @Timeout(value = 3)
   public void testPartialJob() throws Exception {
   public void testPartialJob() throws Exception {
     JobId jobId = new JobIdPBImpl();
     JobId jobId = new JobIdPBImpl();
     jobId.setId(0);
     jobId.setId(0);
@@ -930,7 +927,7 @@ public class TestJobHistoryParsing {
         "jobName", jobId, 3, 2, "JobStatus");
         "jobName", jobId, 3, 2, "JobStatus");
     PartialJob test = new PartialJob(jii, jobId);
     PartialJob test = new PartialJob(jii, jobId);
     
     
-    Assert.assertEquals(1.0f, test.getProgress(), 0.001f);
+    assertEquals(1.0f, test.getProgress(), 0.001f);
     assertNull(test.getAllCounters());
     assertNull(test.getAllCounters());
     assertNull(test.getTasks());
     assertNull(test.getTasks());
     assertNull(test.getTasks(TaskType.MAP));
     assertNull(test.getTasks(TaskType.MAP));
@@ -983,8 +980,8 @@ public class TestJobHistoryParsing {
           }
           }
         });
         });
     JobInfo info = parser.parse(reader);
     JobInfo info = parser.parse(reader);
-    assertTrue("Task 0 not implicated",
-        info.getErrorInfo().contains(tids[0].toString()));
+    assertTrue(info.getErrorInfo().contains(tids[0].toString()),
+        "Task 0 not implicated");
   }
   }
 
 
   @Test
   @Test
@@ -997,9 +994,9 @@ public class TestJobHistoryParsing {
     try {
     try {
       JobHistoryParser parser = new JobHistoryParser(fsdis);
       JobHistoryParser parser = new JobHistoryParser(fsdis);
       JobInfo info = parser.parse();
       JobInfo info = parser.parse();
-      assertEquals("History parsed jobId incorrectly",
-          info.getJobId(), JobID.forName("job_1393307629410_0001") );
-      assertEquals("Default diagnostics incorrect ", "", info.getErrorInfo());
+      assertEquals(info.getJobId(), JobID.forName("job_1393307629410_0001"),
+          "History parsed jobId incorrectly");
+      assertEquals("", info.getErrorInfo(), "Default diagnostics incorrect");
     } finally {
     } finally {
       fsdis.close();
       fsdis.close();
     }
     }

+ 19 - 12
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobHistoryServer.java

@@ -56,13 +56,17 @@ import org.apache.hadoop.util.ExitUtil;
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.util.RackResolver;
 import org.apache.hadoop.yarn.util.RackResolver;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /*
 /*
-test JobHistoryServer protocols....
+ * test JobHistoryServer protocols....
  */
  */
 public class TestJobHistoryServer {
 public class TestJobHistoryServer {
   private static RecordFactory recordFactory = RecordFactoryProvider
   private static RecordFactory recordFactory = RecordFactoryProvider
@@ -71,7 +75,8 @@ public class TestJobHistoryServer {
   JobHistoryServer historyServer=null;
   JobHistoryServer historyServer=null;
 
 
   // simple test init/start/stop   JobHistoryServer. Status should change.
   // simple test init/start/stop   JobHistoryServer. Status should change.
-  @Test (timeout= 50000 )
+  @Test
+  @Timeout(value = 50)
   public void testStartStopServer() throws Exception {
   public void testStartStopServer() throws Exception {
     historyServer = new JobHistoryServer();
     historyServer = new JobHistoryServer();
     Configuration config = new Configuration();
     Configuration config = new Configuration();
@@ -90,7 +95,8 @@ public class TestJobHistoryServer {
   }
   }
 
 
   //Test reports of  JobHistoryServer. History server should get log files from  MRApp and read them
   //Test reports of  JobHistoryServer. History server should get log files from  MRApp and read them
-  @Test (timeout= 50000 )
+  @Test
+  @Timeout(value = 50)
   public void testReports() throws Exception {
   public void testReports() throws Exception {
     Configuration config = new Configuration();
     Configuration config = new Configuration();
     config
     config
@@ -117,7 +123,7 @@ public class TestJobHistoryServer {
         jobHistory = (JobHistory) service;
         jobHistory = (JobHistory) service;
       }
       }
     };
     };
-    
+
     Map<JobId, Job> jobs= jobHistory.getAllJobs();
     Map<JobId, Job> jobs= jobHistory.getAllJobs();
     
     
     assertEquals(1, jobs.size());
     assertEquals(1, jobs.size());
@@ -159,10 +165,10 @@ public class TestJobHistoryServer {
     assertEquals(1.0f, reportResponse.getTaskReport().getProgress(), 0.01);
     assertEquals(1.0f, reportResponse.getTaskReport().getProgress(), 0.01);
     // report has corrected taskId
     // report has corrected taskId
     assertEquals(taskId.toString(), reportResponse.getTaskReport().getTaskId()
     assertEquals(taskId.toString(), reportResponse.getTaskReport().getTaskId()
-            .toString());
+         .toString());
     // Task state should be SUCCEEDED
     // Task state should be SUCCEEDED
     assertEquals(TaskState.SUCCEEDED, reportResponse.getTaskReport()
     assertEquals(TaskState.SUCCEEDED, reportResponse.getTaskReport()
-            .getTaskState());
+         .getTaskState());
 
 
     // For invalid jobid, throw IOException
     // For invalid jobid, throw IOException
     GetTaskReportsRequest gtreportsRequest =
     GetTaskReportsRequest gtreportsRequest =
@@ -198,20 +204,21 @@ public class TestJobHistoryServer {
   }
   }
 
 
   // test launch method
   // test launch method
-  @Test (timeout =60000)
+  @Test
+  @Timeout(value = 60)
   public void testLaunch() throws Exception {
   public void testLaunch() throws Exception {
 
 
     ExitUtil.disableSystemExit();
     ExitUtil.disableSystemExit();
     try {
     try {
       historyServer = JobHistoryServer.launchJobHistoryServer(new String[0]);
       historyServer = JobHistoryServer.launchJobHistoryServer(new String[0]);
     } catch (ExitUtil.ExitException e) {
     } catch (ExitUtil.ExitException e) {
-      assertEquals(0,e.status);
+      assertEquals(0, e.status);
       ExitUtil.resetFirstExitException();
       ExitUtil.resetFirstExitException();
       fail();
       fail();
     }
     }
   }
   }
   
   
-  @After
+  @AfterEach
   public void stop(){
   public void stop(){
     if(historyServer != null) {
     if(historyServer != null) {
       historyServer.stop();
       historyServer.stop();

+ 16 - 14
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobIdHistoryFileInfoMap.java

@@ -24,11 +24,12 @@ import org.apache.hadoop.mapreduce.v2.api.records.JobId;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.JobIdHistoryFileInfoMap;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.JobIdHistoryFileInfoMap;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestJobIdHistoryFileInfoMap {
 public class TestJobIdHistoryFileInfoMap {
 
 
@@ -47,7 +48,8 @@ public class TestJobIdHistoryFileInfoMap {
    * Trivial test case that verifies basic functionality of {@link
    * Trivial test case that verifies basic functionality of {@link
    * JobIdHistoryFileInfoMap}
    * JobIdHistoryFileInfoMap}
    */
    */
-  @Test(timeout = 2000)
+  @Test
+  @Timeout(value = 2)
   public void testWithSingleElement() throws InterruptedException {
   public void testWithSingleElement() throws InterruptedException {
     JobIdHistoryFileInfoMap mapWithSize = new JobIdHistoryFileInfoMap();
     JobIdHistoryFileInfoMap mapWithSize = new JobIdHistoryFileInfoMap();
 
 
@@ -56,23 +58,23 @@ public class TestJobIdHistoryFileInfoMap {
     Mockito.when(fileInfo1.getJobId()).thenReturn(jobId);
     Mockito.when(fileInfo1.getJobId()).thenReturn(jobId);
 
 
     // add it twice
     // add it twice
-    assertEquals("Incorrect return on putIfAbsent()",
-        null, mapWithSize.putIfAbsent(jobId, fileInfo1));
-    assertEquals("Incorrect return on putIfAbsent()",
-        fileInfo1, mapWithSize.putIfAbsent(jobId, fileInfo1));
+    assertEquals(null, mapWithSize.putIfAbsent(jobId, fileInfo1),
+        "Incorrect return on putIfAbsent()");
+    assertEquals(fileInfo1, mapWithSize.putIfAbsent(jobId, fileInfo1),
+        "Incorrect return on putIfAbsent()");
 
 
     // check get()
     // check get()
-    assertEquals("Incorrect get()", fileInfo1, mapWithSize.get(jobId));
-    assertTrue("Incorrect size()", checkSize(mapWithSize, 1));
+    assertEquals(fileInfo1, mapWithSize.get(jobId), "Incorrect get()");
+    assertTrue(checkSize(mapWithSize, 1), "Incorrect size()");
 
 
     // check navigableKeySet()
     // check navigableKeySet()
     NavigableSet<JobId> set = mapWithSize.navigableKeySet();
     NavigableSet<JobId> set = mapWithSize.navigableKeySet();
-    assertEquals("Incorrect navigableKeySet()", 1, set.size());
-    assertTrue("Incorrect navigableKeySet()", set.contains(jobId));
+    assertEquals(1, set.size(), "Incorrect navigableKeySet()");
+    assertTrue(set.contains(jobId), "Incorrect navigableKeySet()");
 
 
     // check values()
     // check values()
     Collection<HistoryFileInfo> values = mapWithSize.values();
     Collection<HistoryFileInfo> values = mapWithSize.values();
-    assertEquals("Incorrect values()", 1, values.size());
-    assertTrue("Incorrect values()", values.contains(fileInfo1));
+    assertEquals(1, values.size(), "Incorrect values()");
+    assertTrue(values.contains(fileInfo1), "Incorrect values()");
   }
   }
 }
 }

+ 11 - 8
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestJobListCache.java

@@ -24,14 +24,18 @@ import org.apache.hadoop.mapreduce.v2.api.records.JobId;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.JobListCache;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.JobListCache;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestJobListCache {
 public class TestJobListCache {
 
 
-  @Test (timeout = 5000)
+  @Test
+  @Timeout(value = 5)
   public void testAddExisting() {
   public void testAddExisting() {
     JobListCache cache = new JobListCache(2, 1000);
     JobListCache cache = new JobListCache(2, 1000);
 
 
@@ -41,11 +45,11 @@ public class TestJobListCache {
 
 
     cache.addIfAbsent(fileInfo);
     cache.addIfAbsent(fileInfo);
     cache.addIfAbsent(fileInfo);
     cache.addIfAbsent(fileInfo);
-    assertEquals("Incorrect number of cache entries", 1,
-        cache.values().size());
+    assertEquals(1, cache.values().size(), "Incorrect number of cache entries");
   }
   }
 
 
-  @Test (timeout = 5000)
+  @Test
+  @Timeout(value = 5)
   public void testEviction() throws InterruptedException {
   public void testEviction() throws InterruptedException {
     int maxSize = 2;
     int maxSize = 2;
     JobListCache cache = new JobListCache(maxSize, 1000);
     JobListCache cache = new JobListCache(maxSize, 1000);
@@ -72,8 +76,7 @@ public class TestJobListCache {
       if (values.size() > maxSize) {
       if (values.size() > maxSize) {
         Thread.sleep(100);
         Thread.sleep(100);
       } else {
       } else {
-        assertFalse("fileInfo1 should have been evicted",
-          values.contains(fileInfo1));
+        assertFalse(values.contains(fileInfo1), "fileInfo1 should have been evicted");
         return;
         return;
       }
       }
     }
     }

+ 12 - 10
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/TestUnnecessaryBlockingOnHistoryFileInfo.java

@@ -28,10 +28,11 @@ import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JobIndexInfo;
 import org.apache.hadoop.mapreduce.v2.jobhistory.JobIndexInfo;
 import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl;
 
 
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -61,7 +62,7 @@ public class TestUnnecessaryBlockingOnHistoryFileInfo {
    */
    */
   private final static File USER_DIR = new File(INTERMEDIATE_DIR, "test");
   private final static File USER_DIR = new File(INTERMEDIATE_DIR, "test");
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setUp() throws IOException {
   public static void setUp() throws IOException {
     if(USER_DIR.exists()) {
     if(USER_DIR.exists()) {
       FileUtils.cleanDirectory(USER_DIR);
       FileUtils.cleanDirectory(USER_DIR);
@@ -69,7 +70,7 @@ public class TestUnnecessaryBlockingOnHistoryFileInfo {
     USER_DIR.mkdirs();
     USER_DIR.mkdirs();
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanUp() throws IOException {
   public static void cleanUp() throws IOException {
     FileUtils.deleteDirectory(INTERMEDIATE_DIR);
     FileUtils.deleteDirectory(INTERMEDIATE_DIR);
   }
   }
@@ -83,7 +84,8 @@ public class TestUnnecessaryBlockingOnHistoryFileInfo {
    * blocked by the other while the other thread is holding the lock on its
    * blocked by the other while the other thread is holding the lock on its
    * associated job files and hanging up parsing the files.
    * associated job files and hanging up parsing the files.
    */
    */
-  @Test(timeout = 600000)
+  @Test
+  @Timeout(value = 600)
   public void testTwoThreadsQueryingDifferentJobOfSameUser()
   public void testTwoThreadsQueryingDifferentJobOfSameUser()
       throws InterruptedException, IOException {
       throws InterruptedException, IOException {
     final Configuration config = new Configuration();
     final Configuration config = new Configuration();
@@ -158,9 +160,9 @@ public class TestUnnecessaryBlockingOnHistoryFileInfo {
        * is hanging up parsing the job history files, so it was able to proceed
        * is hanging up parsing the job history files, so it was able to proceed
        * with parsing job history files of job2.
        * with parsing job history files of job2.
        */
        */
-      Assert.assertTrue("Thread 2 is blocked while it is trying to " +
-          "load job2 by Thread 1 which is loading job1.",
-          webRequest2.getState() != Thread.State.BLOCKED);
+      Assertions.assertTrue(webRequest2.getState() != Thread.State.BLOCKED,
+          "Thread 2 is blocked while it is trying to " +
+          "load job2 by Thread 1 which is loading job1.");
     } finally {
     } finally {
       if(webRequest1 != null) {
       if(webRequest1 != null) {
         webRequest1.interrupt();
         webRequest1.interrupt();

+ 51 - 38
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/server/TestHSAdminServer.java

@@ -18,7 +18,11 @@
 
 
 package org.apache.hadoop.mapreduce.v2.hs.server;
 package org.apache.hadoop.mapreduce.v2.hs.server;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedAction;
@@ -42,12 +46,10 @@ import org.apache.hadoop.security.GroupMappingServiceProvider;
 import org.apache.hadoop.security.Groups;
 import org.apache.hadoop.security.Groups;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.authorize.ProxyUsers;
 import org.apache.hadoop.security.authorize.ProxyUsers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.reset;
@@ -60,7 +62,6 @@ import org.apache.hadoop.security.authorize.AuthorizationException;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
 import org.mockito.internal.util.collections.Sets;
 import org.mockito.internal.util.collections.Sets;
 
 
-@RunWith(Parameterized.class)
 public class TestHSAdminServer {
 public class TestHSAdminServer {
   private boolean securityEnabled = true;
   private boolean securityEnabled = true;
   private HSAdminServer hsAdminServer = null;
   private HSAdminServer hsAdminServer = null;
@@ -105,16 +106,15 @@ public class TestHSAdminServer {
     }
     }
   }
   }
 
 
-  @Parameters
   public static Collection<Object[]> testParameters() {
   public static Collection<Object[]> testParameters() {
-    return Arrays.asList(new Object[][] { { false }, { true } });
+    return Arrays.asList(new Object[][]{{false}, {true}});
   }
   }
 
 
-  public TestHSAdminServer(boolean enableSecurity) {
+  public void initTestHSAdminServer(boolean enableSecurity) {
     securityEnabled = enableSecurity;
     securityEnabled = enableSecurity;
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void init() throws HadoopIllegalArgumentException, IOException {
   public void init() throws HadoopIllegalArgumentException, IOException {
     conf = new JobConf();
     conf = new JobConf();
     conf.set(JHAdminConfig.JHS_ADMIN_ADDRESS, "0.0.0.0:0");
     conf.set(JHAdminConfig.JHS_ADMIN_ADDRESS, "0.0.0.0:0");
@@ -142,8 +142,10 @@ public class TestHSAdminServer {
     hsAdminClient = new HSAdmin(conf);
     hsAdminClient = new HSAdmin(conf);
   }
   }
 
 
-  @Test
-  public void testGetGroups() throws Exception {
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testGetGroups(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     // Get the current user
     // Get the current user
     String user = UserGroupInformation.getCurrentUser().getUserName();
     String user = UserGroupInformation.getCurrentUser().getUserName();
     String[] args = new String[2];
     String[] args = new String[2];
@@ -151,12 +153,13 @@ public class TestHSAdminServer {
     args[1] = user;
     args[1] = user;
     // Run the getGroups command
     // Run the getGroups command
     int exitCode = hsAdminClient.run(args);
     int exitCode = hsAdminClient.run(args);
-    assertEquals("Exit code should be 0 but was: " + exitCode, 0, exitCode);
+    assertEquals(0, exitCode, "Exit code should be 0 but was: " + exitCode);
   }
   }
 
 
-  @Test
-  public void testRefreshUserToGroupsMappings() throws Exception {
-
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testRefreshUserToGroupsMappings(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     String[] args = new String[] { "-refreshUserToGroupsMappings" };
     String[] args = new String[] { "-refreshUserToGroupsMappings" };
     Groups groups = Groups.getUserToGroupsMappingService(conf);
     Groups groups = Groups.getUserToGroupsMappingService(conf);
     String user = UserGroupInformation.getCurrentUser().getUserName();
     String user = UserGroupInformation.getCurrentUser().getUserName();
@@ -173,7 +176,7 @@ public class TestHSAdminServer {
     g2.toArray(str_groups);
     g2.toArray(str_groups);
     System.out.println(Arrays.toString(str_groups));
     System.out.println(Arrays.toString(str_groups));
     for (int i = 0; i < g2.size(); i++) {
     for (int i = 0; i < g2.size(); i++) {
-      assertEquals("Should be same group ", g1.get(i), g2.get(i));
+      assertEquals(g1.get(i), g2.get(i), "Should be same group ");
     }
     }
     // run the command,which clears the cache
     // run the command,which clears the cache
     hsAdminClient.run(args);
     hsAdminClient.run(args);
@@ -184,15 +187,15 @@ public class TestHSAdminServer {
     g3.toArray(str_groups);
     g3.toArray(str_groups);
     System.out.println(Arrays.toString(str_groups));
     System.out.println(Arrays.toString(str_groups));
     for (int i = 0; i < g3.size(); i++) {
     for (int i = 0; i < g3.size(); i++) {
-      assertFalse(
-          "Should be different group: " + g1.get(i) + " and " + g3.get(i), g1
-              .get(i).equals(g3.get(i)));
+      assertFalse(g1.get(i).equals(g3.get(i)),
+          "Should be different group: " + g1.get(i) + " and " + g3.get(i));
     }
     }
   }
   }
 
 
-  @Test
-  public void testRefreshSuperUserGroups() throws Exception {
-
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testRefreshSuperUserGroups(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     UserGroupInformation ugi = mock(UserGroupInformation.class);
     UserGroupInformation ugi = mock(UserGroupInformation.class);
     UserGroupInformation superUser = mock(UserGroupInformation.class);
     UserGroupInformation superUser = mock(UserGroupInformation.class);
 
 
@@ -249,12 +252,14 @@ public class TestHSAdminServer {
       th = e;
       th = e;
     }
     }
     // No exception thrown since regularUser can be impersonated.
     // No exception thrown since regularUser can be impersonated.
-    assertNull("Unexpected exception thrown: " + th, th);
+    assertNull(th, "Unexpected exception thrown: " + th);
 
 
   }
   }
 
 
-  @Test
-  public void testRefreshAdminAcls() throws Exception {
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testRefreshAdminAcls(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     // Setting current user to admin acl
     // Setting current user to admin acl
     conf.set(JHAdminConfig.JHS_ADMIN_ACL, UserGroupInformation.getCurrentUser()
     conf.set(JHAdminConfig.JHS_ADMIN_ACL, UserGroupInformation.getCurrentUser()
         .getUserName());
         .getUserName());
@@ -283,24 +288,30 @@ public class TestHSAdminServer {
     assertTrue(th instanceof RemoteException);
     assertTrue(th instanceof RemoteException);
   }
   }
 
 
-  @Test
-  public void testRefreshLoadedJobCache() throws Exception {
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testRefreshLoadedJobCache(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     String[] args = new String[1];
     String[] args = new String[1];
     args[0] = "-refreshLoadedJobCache";
     args[0] = "-refreshLoadedJobCache";
     hsAdminClient.run(args);
     hsAdminClient.run(args);
     verify(jobHistoryService).refreshLoadedJobCache();
     verify(jobHistoryService).refreshLoadedJobCache();
   }
   }
-  
-  @Test
-  public void testRefreshLogRetentionSettings() throws Exception {
+
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testRefreshLogRetentionSettings(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     String[] args = new String[1];
     String[] args = new String[1];
     args[0] = "-refreshLogRetentionSettings";
     args[0] = "-refreshLogRetentionSettings";
     hsAdminClient.run(args);
     hsAdminClient.run(args);
     verify(alds).refreshLogRetentionSettings();
     verify(alds).refreshLogRetentionSettings();
   }
   }
 
 
-  @Test
-  public void testRefreshJobRetentionSettings() throws Exception {
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testRefreshJobRetentionSettings(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     String[] args = new String[1];
     String[] args = new String[1];
     args[0] = "-refreshJobRetentionSettings";
     args[0] = "-refreshJobRetentionSettings";
     hsAdminClient.run(args);
     hsAdminClient.run(args);
@@ -308,8 +319,10 @@ public class TestHSAdminServer {
   }
   }
 
 
   @SuppressWarnings("unchecked")
   @SuppressWarnings("unchecked")
-  @Test
-  public void testUGIForLogAndJobRefresh() throws Exception {
+  @ParameterizedTest
+  @MethodSource("testParameters")
+  public void testUGIForLogAndJobRefresh(boolean pEnableSecurity) throws Exception {
+    initTestHSAdminServer(pEnableSecurity);
     UserGroupInformation ugi =
     UserGroupInformation ugi =
         UserGroupInformation.createUserForTesting("test", new String[] {"grp"});
         UserGroupInformation.createUserForTesting("test", new String[] {"grp"});
     UserGroupInformation loginUGI = spy(hsAdminServer.getLoginUGI());
     UserGroupInformation loginUGI = spy(hsAdminServer.getLoginUGI());
@@ -357,7 +370,7 @@ public class TestHSAdminServer {
     verify(jobHistoryService).refreshJobRetentionSettings();
     verify(jobHistoryService).refreshJobRetentionSettings();
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanUp() {
   public void cleanUp() {
     if (hsAdminServer != null)
     if (hsAdminServer != null)
       hsAdminServer.stop();
       hsAdminServer.stop();

+ 14 - 13
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestBlocks.java

@@ -68,12 +68,14 @@ import org.apache.hadoop.yarn.webapp.log.AggregatedLogsPage;
 import org.apache.hadoop.yarn.webapp.view.BlockForTest;
 import org.apache.hadoop.yarn.webapp.view.BlockForTest;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 /**
 /**
  * Test some HtmlBlock classes
  * Test some HtmlBlock classes
@@ -87,16 +89,15 @@ public class TestBlocks {
     Task task = getTask(0);
     Task task = getTask(0);
     String taskId = task.getID().toString();
     String taskId = task.getID().toString();
 
 
-    Assert.assertEquals("pull links doesn't work correctly",
-        "Task failed <a href=\"/jobhistory/task/" + taskId + "\">" +
-        taskId + "</a>"
-        , HsJobBlock.addTaskLinks("Task failed " + taskId));
+    assertEquals("Task failed <a href=\"/jobhistory/task/" + taskId + "\">" + taskId + "</a>",
+        HsJobBlock.addTaskLinks("Task failed " + taskId),
+        "pull links doesn't work correctly");
 
 
-    Assert.assertEquals("pull links doesn't work correctly",
-        "Task failed <a href=\"/jobhistory/task/" + taskId + "\">" +
-        taskId + "</a>\n Job failed as tasks failed. failedMaps:1 failedReduces:0"
-        , HsJobBlock.addTaskLinks("Task failed " + taskId + "\n " +
-        "Job failed as tasks failed. failedMaps:1 failedReduces:0"));
+    assertEquals("Task failed <a href=\"/jobhistory/task/" + taskId + "\">" +
+        taskId + "</a>\n Job failed as tasks failed. failedMaps:1 failedReduces:0",
+        HsJobBlock.addTaskLinks("Task failed " + taskId + "\n " +
+        "Job failed as tasks failed. failedMaps:1 failedReduces:0"),
+        "pull links doesn't work correctly");
   }
   }
 
 
   /**
   /**

+ 9 - 9
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHSWebApp.java

@@ -27,7 +27,8 @@ import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_ID;
 import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_LOG_TYPE;
 import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_LOG_TYPE;
 import static org.apache.hadoop.yarn.webapp.YarnWebParams.ENTITY_STRING;
 import static org.apache.hadoop.yarn.webapp.YarnWebParams.ENTITY_STRING;
 import static org.apache.hadoop.yarn.webapp.YarnWebParams.NM_NODENAME;
 import static org.apache.hadoop.yarn.webapp.YarnWebParams.NM_NODENAME;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verify;
 
 
 import java.io.IOException;
 import java.io.IOException;
@@ -47,8 +48,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.webapp.View;
 import org.apache.hadoop.yarn.webapp.View;
 import org.apache.hadoop.yarn.webapp.log.AggregatedLogsPage;
 import org.apache.hadoop.yarn.webapp.log.AggregatedLogsPage;
 import org.apache.hadoop.yarn.webapp.test.WebAppTests;
 import org.apache.hadoop.yarn.webapp.test.WebAppTests;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import com.google.inject.AbstractModule;
 import com.google.inject.AbstractModule;
 import com.google.inject.Injector;
 import com.google.inject.Injector;
@@ -91,7 +91,7 @@ public class TestHSWebApp {
     View viewInstance = testPage.getInstance(HsTasksPage.class);
     View viewInstance = testPage.getInstance(HsTasksPage.class);
     Map<String, String> moreParams = viewInstance.context().requestContext().moreParams();
     Map<String, String> moreParams = viewInstance.context().requestContext().moreParams();
     String appTableColumnsMeta = moreParams.get("ui.dataTables.selector.init");
     String appTableColumnsMeta = moreParams.get("ui.dataTables.selector.init");
-    Assert.assertTrue(appTableColumnsMeta.indexOf("natural") != -1);
+    assertTrue(appTableColumnsMeta.indexOf("natural") != -1);
   }
   }
 
 
   @Test
   @Test
@@ -112,14 +112,14 @@ public class TestHSWebApp {
     View viewInstance = testPage.getInstance(HsTaskPage.class);
     View viewInstance = testPage.getInstance(HsTaskPage.class);
     Map<String, String> moreParams = viewInstance.context().requestContext().moreParams();
     Map<String, String> moreParams = viewInstance.context().requestContext().moreParams();
     String appTableColumnsMeta = moreParams.get("ui.dataTables.attempts.init");
     String appTableColumnsMeta = moreParams.get("ui.dataTables.attempts.init");
-    Assert.assertTrue(appTableColumnsMeta.indexOf("natural") != -1);
+    assertTrue(appTableColumnsMeta.indexOf("natural") != -1);
   }
   }
 
 
   @Test public void testAttemptsWithJobView() {
   @Test public void testAttemptsWithJobView() {
     LOG.info("HsAttemptsPage with data");
     LOG.info("HsAttemptsPage with data");
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
     JobId id = ctx.getAllJobs().keySet().iterator().next();
     JobId id = ctx.getAllJobs().keySet().iterator().next();
-    Map<String, String> params = new HashMap<String,String>();
+    Map<String, String> params = new HashMap<>();
     params.put(JOB_ID, id.toString());
     params.put(JOB_ID, id.toString());
     params.put(TASK_TYPE, "m");
     params.put(TASK_TYPE, "m");
     params.put(ATTEMPT_STATE, "SUCCESSFUL");
     params.put(ATTEMPT_STATE, "SUCCESSFUL");
@@ -185,7 +185,7 @@ public class TestHSWebApp {
   public void testLogsView2() throws IOException {
   public void testLogsView2() throws IOException {
     LOG.info("HsLogsPage with data");
     LOG.info("HsLogsPage with data");
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
-    Map<String, String> params = new HashMap<String, String>();
+    Map<String, String> params = new HashMap<>();
 
 
     params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1)
     params.put(CONTAINER_ID, MRApp.newContainerId(1, 1, 333, 1)
         .toString());
         .toString());
@@ -207,7 +207,7 @@ public class TestHSWebApp {
   public void testLogsViewSingle() throws IOException {
   public void testLogsViewSingle() throws IOException {
     LOG.info("HsLogsPage with params for single log and data limits");
     LOG.info("HsLogsPage with params for single log and data limits");
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
-    Map<String, String> params = new HashMap<String, String>();
+    Map<String, String> params = new HashMap<>();
 
 
     final Configuration conf = new YarnConfiguration();
     final Configuration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
@@ -242,7 +242,7 @@ public class TestHSWebApp {
   public void testLogsViewBadStartEnd() throws IOException {
   public void testLogsViewBadStartEnd() throws IOException {
     LOG.info("HsLogsPage with bad start/end params");
     LOG.info("HsLogsPage with bad start/end params");
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
     MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
-    Map<String, String> params = new HashMap<String, String>();
+    Map<String, String> params = new HashMap<>();
 
 
     params.put("start", "foo");
     params.put("start", "foo");
     params.put("end", "bar");
     params.put("end", "bar");

+ 16 - 16
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsJobBlock.java

@@ -21,9 +21,10 @@ package org.apache.hadoop.mapreduce.v2.hs.webapp;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.Counters;
 import org.apache.hadoop.mapreduce.Counters;
-import org.apache.hadoop.mapreduce.v2.api.records.*;
+import org.apache.hadoop.mapreduce.v2.api.records.JobId;
+import org.apache.hadoop.mapreduce.v2.api.records.JobReport;
+import org.apache.hadoop.mapreduce.v2.api.records.JobState;
 import org.apache.hadoop.mapreduce.v2.api.records.impl.pb.JobIdPBImpl;
 import org.apache.hadoop.mapreduce.v2.api.records.impl.pb.JobIdPBImpl;
-import org.apache.hadoop.mapreduce.v2.app.job.Task;
 import org.apache.hadoop.mapreduce.v2.app.webapp.AMParams;
 import org.apache.hadoop.mapreduce.v2.app.webapp.AMParams;
 import org.apache.hadoop.mapreduce.v2.hs.CompletedJob;
 import org.apache.hadoop.mapreduce.v2.hs.CompletedJob;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager;
 import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager;
@@ -39,8 +40,7 @@ import org.apache.hadoop.yarn.webapp.view.BlockForTest;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest;
 
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStream;
@@ -49,6 +49,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
@@ -87,9 +88,8 @@ public class TestHsJobBlock {
 
 
     block.getWriter().flush();
     block.getWriter().flush();
     String out = outputStream.toString();
     String out = outputStream.toString();
-    Assert.assertTrue("Should display warning message for jobs that have too " +
-        "many tasks", out.contains("Any job larger than " + maxAllowedTaskNum +
-            " will not be loaded"));
+    assertTrue(out.contains("Any job larger than " + maxAllowedTaskNum + " will not be loaded"),
+        "Should display warning message for jobs that have too many tasks");
   }
   }
 
 
   @Test
   @Test
@@ -98,7 +98,7 @@ public class TestHsJobBlock {
     Configuration config = new Configuration();
     Configuration config = new Configuration();
     config.setInt(JHAdminConfig.MR_HS_LOADED_JOBS_TASKS_MAX, -1);
     config.setInt(JHAdminConfig.MR_HS_LOADED_JOBS_TASKS_MAX, -1);
 
 
-    JobHistory jobHistory = new JobHitoryStubWithAllNormalSizeJobs();
+    JobHistory jobHistory = new JobHistoryStubWithAllNormalSizeJobs();
     jobHistory.init(config);
     jobHistory.init(config);
 
 
     HsJobBlock jobBlock = new HsJobBlock(jobHistory) {
     HsJobBlock jobBlock = new HsJobBlock(jobHistory) {
@@ -132,8 +132,8 @@ public class TestHsJobBlock {
     block.getWriter().flush();
     block.getWriter().flush();
     String out = outputStream.toString();
     String out = outputStream.toString();
 
 
-    Assert.assertTrue("Should display job overview for the job.",
-        out.contains("ApplicationMaster"));
+    assertTrue(out.contains("ApplicationMaster"),
+        "Should display job overview for the job.");
   }
   }
 
 
   private static HtmlBlock.Block createBlockToCreateTo(
   private static HtmlBlock.Block createBlockToCreateTo(
@@ -145,9 +145,9 @@ public class TestHsJobBlock {
       protected void subView(Class<? extends SubView> cls) {
       protected void subView(Class<? extends SubView> cls) {
       }
       }
     };
     };
-  };
+  }
 
 
-  /**
+    /**
    * A JobHistory stub that treat all jobs as oversized and therefore will
    * A JobHistory stub that treat all jobs as oversized and therefore will
    * not parse their job history files but return a UnparseJob instance.
    * not parse their job history files but return a UnparseJob instance.
    */
    */
@@ -195,7 +195,7 @@ public class TestHsJobBlock {
    * A JobHistory stub that treats all jobs as normal size and therefore will
    * A JobHistory stub that treats all jobs as normal size and therefore will
    * return a CompletedJob on HistoryFileInfo.loadJob().
    * return a CompletedJob on HistoryFileInfo.loadJob().
    */
    */
-  static class JobHitoryStubWithAllNormalSizeJobs extends  JobHistory {
+  static class JobHistoryStubWithAllNormalSizeJobs extends  JobHistory {
     @Override
     @Override
     public HistoryFileManager createHistoryFileManager() {
     public HistoryFileManager createHistoryFileManager() {
       HistoryFileManager historyFileManager;
       HistoryFileManager historyFileManager;
@@ -239,14 +239,14 @@ public class TestHsJobBlock {
       when(jobReport.getFinishTime()).thenReturn(-1L);
       when(jobReport.getFinishTime()).thenReturn(-1L);
       when(job.getReport()).thenReturn(jobReport);
       when(job.getReport()).thenReturn(jobReport);
 
 
-      when(job.getAMInfos()).thenReturn(new ArrayList<AMInfo>());
-      when(job.getDiagnostics()).thenReturn(new ArrayList<String>());
+      when(job.getAMInfos()).thenReturn(new ArrayList<>());
+      when(job.getDiagnostics()).thenReturn(new ArrayList<>());
       when(job.getName()).thenReturn("fake completed job");
       when(job.getName()).thenReturn("fake completed job");
       when(job.getQueueName()).thenReturn("default");
       when(job.getQueueName()).thenReturn("default");
       when(job.getUserName()).thenReturn("junit");
       when(job.getUserName()).thenReturn("junit");
       when(job.getState()).thenReturn(JobState.ERROR);
       when(job.getState()).thenReturn(JobState.ERROR);
       when(job.getAllCounters()).thenReturn(new Counters());
       when(job.getAllCounters()).thenReturn(new Counters());
-      when(job.getTasks()).thenReturn(new HashMap<TaskId, Task>());
+      when(job.getTasks()).thenReturn(new HashMap<>());
 
 
       return job;
       return job;
     }
     }

+ 12 - 12
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java

@@ -19,7 +19,7 @@
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 
 
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.Assert.fail;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 
 
@@ -51,7 +51,7 @@ import org.apache.hadoop.yarn.webapp.WebApp;
 import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
@@ -107,7 +107,7 @@ public class TestHsWebServices extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     verifyHSInfo(json.getJSONObject("historyInfo"));
     verifyHSInfo(json.getJSONObject("historyInfo"));
   }
   }
 
 
@@ -119,7 +119,7 @@ public class TestHsWebServices extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     verifyHSInfo(json.getJSONObject("historyInfo"));
     verifyHSInfo(json.getJSONObject("historyInfo"));
   }
   }
 
 
@@ -131,7 +131,7 @@ public class TestHsWebServices extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     verifyHSInfo(json.getJSONObject("historyInfo"));
     verifyHSInfo(json.getJSONObject("historyInfo"));
   }
   }
 
 
@@ -155,7 +155,7 @@ public class TestHsWebServices extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     verifyHSInfo(json.getJSONObject("historyInfo"));
     verifyHSInfo(json.getJSONObject("historyInfo"));
   }
   }
 
 
@@ -168,7 +168,7 @@ public class TestHsWebServices extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     verifyHSInfo(json.getJSONObject("historyInfo"));
     verifyHSInfo(json.getJSONObject("historyInfo"));
   }
   }
 
 
@@ -180,7 +180,7 @@ public class TestHsWebServices extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     verifyHSInfo(json.getJSONObject("historyInfo"));
     verifyHSInfo(json.getJSONObject("historyInfo"));
   }
   }
 
 
@@ -253,13 +253,13 @@ public class TestHsWebServices extends JerseyTestBase {
         VersionInfo.getBuildVersion(), hadoopBuildVersion);
         VersionInfo.getBuildVersion(), hadoopBuildVersion);
     WebServicesTestUtils.checkStringMatch("hadoopVersion",
     WebServicesTestUtils.checkStringMatch("hadoopVersion",
         VersionInfo.getVersion(), hadoopVersion);
         VersionInfo.getVersion(), hadoopVersion);
-    assertEquals("startedOn doesn't match: ",
-        JobHistoryServer.historyServerTimeStamp, startedOn);
+    assertEquals(JobHistoryServer.historyServerTimeStamp, startedOn,
+        "startedOn doesn't match: ");
   }
   }
 
 
   public void verifyHSInfo(JSONObject info)
   public void verifyHSInfo(JSONObject info)
       throws JSONException {
       throws JSONException {
-    assertEquals("incorrect number of elements", 4, info.length());
+    assertEquals(4, info.length(), "incorrect number of elements");
 
 
     verifyHsInfoGeneric(info.getString("hadoopVersionBuiltOn"),
     verifyHsInfoGeneric(info.getString("hadoopVersionBuiltOn"),
         info.getString("hadoopBuildVersion"), info.getString("hadoopVersion"),
         info.getString("hadoopBuildVersion"), info.getString("hadoopVersion"),
@@ -273,7 +273,7 @@ public class TestHsWebServices extends JerseyTestBase {
     is.setCharacterStream(new StringReader(xml));
     is.setCharacterStream(new StringReader(xml));
     Document dom = db.parse(is);
     Document dom = db.parse(is);
     NodeList nodes = dom.getElementsByTagName("historyInfo");
     NodeList nodes = dom.getElementsByTagName("historyInfo");
-    assertEquals("incorrect number of elements", 1, nodes.getLength());
+    assertEquals(1, nodes.getLength(), "incorrect number of elements");
 
 
     for (int i = 0; i < nodes.getLength(); i++) {
     for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);
       Element element = (Element) nodes.item(i);

+ 5 - 5
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesAcls.java

@@ -29,8 +29,8 @@ import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.Response.Status;
 
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
@@ -60,8 +60,8 @@ import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.server.webapp.LogServlet;
 import org.apache.hadoop.yarn.server.webapp.LogServlet;
 import org.apache.hadoop.yarn.webapp.WebApp;
 import org.apache.hadoop.yarn.webapp.WebApp;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -82,7 +82,7 @@ public class TestHsWebServicesAcls {
   private String taskAttemptIdStr;
   private String taskAttemptIdStr;
   private HsWebServices hsWebServices;
   private HsWebServices hsWebServices;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     this.conf = new JobConf();
     this.conf = new JobConf();
     this.conf.set(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
     this.conf.set(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,

+ 42 - 43
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesAttempts.java

@@ -20,10 +20,10 @@ package org.apache.hadoop.mapreduce.v2.hs.webapp;
 
 
 import static javax.ws.rs.core.Response.Status.NOT_FOUND;
 import static javax.ws.rs.core.Response.Status.NOT_FOUND;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -62,7 +62,7 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
@@ -201,7 +201,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
         is.setCharacterStream(new StringReader(xml));
         is.setCharacterStream(new StringReader(xml));
         Document dom = db.parse(is);
         Document dom = db.parse(is);
         NodeList attempts = dom.getElementsByTagName("taskAttempts");
         NodeList attempts = dom.getElementsByTagName("taskAttempts");
-        assertEquals("incorrect number of elements", 1, attempts.getLength());
+        assertEquals(1, attempts.getLength(), "incorrect number of elements");
 
 
         NodeList nodes = dom.getElementsByTagName("taskAttempt");
         NodeList nodes = dom.getElementsByTagName("taskAttempt");
         verifyHsTaskAttemptsXML(nodes, task);
         verifyHsTaskAttemptsXML(nodes, task);
@@ -231,7 +231,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";"
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";"
                   + JettyUtils.UTF_8, response.getMediaType().toString());
                   + JettyUtils.UTF_8, response.getMediaType().toString());
           JSONObject json = response.readEntity(JSONObject.class);
           JSONObject json = response.readEntity(JSONObject.class);
-          assertEquals("incorrect number of elements", 1, json.length());
+          assertEquals(1, json.length(), "incorrect number of elements");
           JSONObject info = json.getJSONObject("taskAttempt");
           JSONObject info = json.getJSONObject("taskAttempt");
           verifyHsTaskAttempt(info, att, task.getType());
           verifyHsTaskAttempt(info, att, task.getType());
         }
         }
@@ -261,7 +261,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";"
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";"
               + JettyUtils.UTF_8, response.getMediaType().toString());
               + JettyUtils.UTF_8, response.getMediaType().toString());
           JSONObject json = response.readEntity(JSONObject.class);
           JSONObject json = response.readEntity(JSONObject.class);
-          assertEquals("incorrect number of elements", 1, json.length());
+          assertEquals(1, json.length(), "incorrect number of elements");
           JSONObject info = json.getJSONObject("taskAttempt");
           JSONObject info = json.getJSONObject("taskAttempt");
           verifyHsTaskAttempt(info, att, task.getType());
           verifyHsTaskAttempt(info, att, task.getType());
         }
         }
@@ -291,7 +291,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
               response.getMediaType().toString());
               response.getMediaType().toString());
           JSONObject json = response.readEntity(JSONObject.class);
           JSONObject json = response.readEntity(JSONObject.class);
-          assertEquals("incorrect number of elements", 1, json.length());
+          assertEquals(1, json.length(), "incorrect number of elements");
           JSONObject info = json.getJSONObject("taskAttempt");
           JSONObject info = json.getJSONObject("taskAttempt");
           verifyHsTaskAttempt(info, att, task.getType());
           verifyHsTaskAttempt(info, att, task.getType());
         }
         }
@@ -392,7 +392,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
               + JettyUtils.UTF_8, response.getMediaType().toString());
               + JettyUtils.UTF_8, response.getMediaType().toString());
           JSONObject msg = response.readEntity(JSONObject.class);
           JSONObject msg = response.readEntity(JSONObject.class);
           JSONObject exception = msg.getJSONObject("RemoteException");
           JSONObject exception = msg.getJSONObject("RemoteException");
-          assertEquals("incorrect number of elements", 3, exception.length());
+          assertEquals(3, exception.length(), "incorrect number of elements");
           String message = exception.getString("message");
           String message = exception.getString("message");
           String type = exception.getString("exception");
           String type = exception.getString("exception");
           String classname = exception.getString("javaClassName");
           String classname = exception.getString("javaClassName");
@@ -433,9 +433,9 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
   public void verifyHsTaskAttempt(JSONObject info, TaskAttempt att,
   public void verifyHsTaskAttempt(JSONObject info, TaskAttempt att,
       TaskType ttype) throws JSONException {
       TaskType ttype) throws JSONException {
     if (ttype == TaskType.REDUCE) {
     if (ttype == TaskType.REDUCE) {
-      assertEquals("incorrect number of elements", 17, info.length());
+      assertEquals(17, info.length(), "incorrect number of elements");
     } else {
     } else {
-      assertEquals("incorrect number of elements", 12, info.length());
+      assertEquals(12, info.length(), "incorrect number of elements");
     }
     }
 
 
     verifyTaskAttemptGeneric(att, ttype, info.getString("id"),
     verifyTaskAttemptGeneric(att, ttype, info.getString("id"),
@@ -454,9 +454,9 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
 
 
   public void verifyHsTaskAttempts(JSONObject json, Task task)
   public void verifyHsTaskAttempts(JSONObject json, Task task)
       throws JSONException {
       throws JSONException {
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject attempts = json.getJSONObject("taskAttempts");
     JSONObject attempts = json.getJSONObject("taskAttempts");
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject taskAttempt = attempts.getJSONObject("taskAttempt");
     JSONObject taskAttempt = attempts.getJSONObject("taskAttempt");
     JSONArray arr = new JSONArray();
     JSONArray arr = new JSONArray();
     arr.put(taskAttempt);
     arr.put(taskAttempt);
@@ -472,13 +472,13 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
           verifyHsTaskAttempt(info, att, task.getType());
           verifyHsTaskAttempt(info, att, task.getType());
         }
         }
       }
       }
-      assertTrue("task attempt with id: " + attid
-          + " not in web service output", found);
+      assertTrue(found, "task attempt with id: " + attid
+          + " not in web service output");
     }
     }
   }
   }
 
 
   public void verifyHsTaskAttemptsXML(NodeList nodes, Task task) {
   public void verifyHsTaskAttemptsXML(NodeList nodes, Task task) {
-    assertEquals("incorrect number of elements", 1, nodes.getLength());
+    assertEquals(1, nodes.getLength(), "incorrect number of elements");
 
 
     for (TaskAttempt att : task.getAttempts().values()) {
     for (TaskAttempt att : task.getAttempts().values()) {
       TaskAttemptId id = att.getID();
       TaskAttemptId id = att.getID();
@@ -492,7 +492,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
           verifyHsTaskAttemptXML(element, att, task.getType());
           verifyHsTaskAttemptXML(element, att, task.getType());
         }
         }
       }
       }
-      assertTrue("task with id: " + attid + " not in web service output", found);
+      assertTrue(found, "task with id: " + attid + " not in web service output");
     }
     }
   }
   }
 
 
@@ -527,26 +527,25 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
         ta.getAssignedContainerID().toString(),
         ta.getAssignedContainerID().toString(),
         assignedContainerId);
         assignedContainerId);
 
 
-    assertEquals("startTime wrong", ta.getLaunchTime(), startTime);
-    assertEquals("finishTime wrong", ta.getFinishTime(), finishTime);
-    assertEquals("elapsedTime wrong", finishTime - startTime, elapsedTime);
-    assertEquals("progress wrong", ta.getProgress() * 100, progress, 1e-3f);
+    assertEquals(ta.getLaunchTime(), startTime, "startTime wrong");
+    assertEquals(ta.getFinishTime(), finishTime, "finishTime wrong");
+    assertEquals(finishTime - startTime, elapsedTime, "elapsedTime wrong");
+    assertEquals(ta.getProgress() * 100, progress, 1e-3f, "progress wrong");
   }
   }
 
 
   public void verifyReduceTaskAttemptGeneric(TaskAttempt ta,
   public void verifyReduceTaskAttemptGeneric(TaskAttempt ta,
       long shuffleFinishTime, long mergeFinishTime, long elapsedShuffleTime,
       long shuffleFinishTime, long mergeFinishTime, long elapsedShuffleTime,
       long elapsedMergeTime, long elapsedReduceTime) {
       long elapsedMergeTime, long elapsedReduceTime) {
 
 
-    assertEquals("shuffleFinishTime wrong", ta.getShuffleFinishTime(),
-        shuffleFinishTime);
-    assertEquals("mergeFinishTime wrong", ta.getSortFinishTime(),
-        mergeFinishTime);
-    assertEquals("elapsedShuffleTime wrong",
-        ta.getShuffleFinishTime() - ta.getLaunchTime(), elapsedShuffleTime);
-    assertEquals("elapsedMergeTime wrong",
-        ta.getSortFinishTime() - ta.getShuffleFinishTime(), elapsedMergeTime);
-    assertEquals("elapsedReduceTime wrong",
-        ta.getFinishTime() - ta.getSortFinishTime(), elapsedReduceTime);
+    assertEquals(ta.getShuffleFinishTime(), shuffleFinishTime,
+        "shuffleFinishTime wrong");
+    assertEquals(ta.getSortFinishTime(), mergeFinishTime, "mergeFinishTime wrong");
+    assertEquals(ta.getShuffleFinishTime() - ta.getLaunchTime(), elapsedShuffleTime,
+        "elapsedShuffleTime wrong");
+    assertEquals(ta.getSortFinishTime() - ta.getShuffleFinishTime(), elapsedMergeTime,
+        "elapsedMergeTime wrong");
+    assertEquals(ta.getFinishTime() - ta.getSortFinishTime(), elapsedReduceTime,
+        "elapsedReduceTime wrong");
   }
   }
 
 
   @Test
   @Test
@@ -571,7 +570,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";"
           assertEquals(MediaType.APPLICATION_JSON_TYPE + ";"
               + JettyUtils.UTF_8, response.getMediaType().toString());
               + JettyUtils.UTF_8, response.getMediaType().toString());
           JSONObject json = response.readEntity(JSONObject.class);
           JSONObject json = response.readEntity(JSONObject.class);
-          assertEquals("incorrect number of elements", 1, json.length());
+          assertEquals(1, json.length(), "incorrect number of elements");
           JSONObject info = json.getJSONObject("jobTaskAttemptCounters");
           JSONObject info = json.getJSONObject("jobTaskAttemptCounters");
           verifyHsJobTaskAttemptCounters(info, att);
           verifyHsJobTaskAttemptCounters(info, att);
         }
         }
@@ -616,7 +615,7 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
   public void verifyHsJobTaskAttemptCounters(JSONObject info, TaskAttempt att)
   public void verifyHsJobTaskAttemptCounters(JSONObject info, TaskAttempt att)
       throws JSONException {
       throws JSONException {
 
 
-    assertEquals("incorrect number of elements", 2, info.length());
+    assertEquals(2, info.length(), "incorrect number of elements");
 
 
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()),
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()),
         info.getString("id"));
         info.getString("id"));
@@ -627,15 +626,15 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
     for (int i = 0; i < counterGroups.length(); i++) {
     for (int i = 0; i < counterGroups.length(); i++) {
       JSONObject counterGroup = counterGroups.getJSONObject(i);
       JSONObject counterGroup = counterGroups.getJSONObject(i);
       String name = counterGroup.getString("counterGroupName");
       String name = counterGroup.getString("counterGroupName");
-      assertTrue("name not set", (name != null && !name.isEmpty()));
+      assertTrue((name != null && !name.isEmpty()), "name not set");
       JSONArray counters = counterGroup.getJSONArray("counter");
       JSONArray counters = counterGroup.getJSONArray("counter");
       for (int j = 0; j < counters.length(); j++) {
       for (int j = 0; j < counters.length(); j++) {
         JSONObject counter = counters.getJSONObject(j);
         JSONObject counter = counters.getJSONObject(j);
         String counterName = counter.getString("name");
         String counterName = counter.getString("name");
-        assertTrue("name not set",
-            (counterName != null && !counterName.isEmpty()));
+        assertTrue((counterName != null && !counterName.isEmpty()),
+            "name not set");
         long value = counter.getLong("value");
         long value = counter.getLong("value");
-        assertTrue("value  >= 0", value >= 0);
+        assertTrue(value >= 0, "value  >= 0");
       }
       }
     }
     }
   }
   }
@@ -653,20 +652,20 @@ public class TestHsWebServicesAttempts extends JerseyTestBase {
 
 
       for (int j = 0; j < groups.getLength(); j++) {
       for (int j = 0; j < groups.getLength(); j++) {
         Element counters = (Element) groups.item(j);
         Element counters = (Element) groups.item(j);
-        assertNotNull("should have counters in the web service info", counters);
+        assertNotNull(counters, "should have counters in the web service info");
         String name = WebServicesTestUtils.getXmlString(counters,
         String name = WebServicesTestUtils.getXmlString(counters,
             "counterGroupName");
             "counterGroupName");
-        assertTrue("name not set", (name != null && !name.isEmpty()));
+        assertTrue((name != null && !name.isEmpty()), "name not set");
         NodeList counterArr = counters.getElementsByTagName("counter");
         NodeList counterArr = counters.getElementsByTagName("counter");
         for (int z = 0; z < counterArr.getLength(); z++) {
         for (int z = 0; z < counterArr.getLength(); z++) {
           Element counter = (Element) counterArr.item(z);
           Element counter = (Element) counterArr.item(z);
           String counterName = WebServicesTestUtils.getXmlString(counter,
           String counterName = WebServicesTestUtils.getXmlString(counter,
               "name");
               "name");
-          assertTrue("counter name not set",
-              (counterName != null && !counterName.isEmpty()));
+          assertTrue((counterName != null && !counterName.isEmpty()),
+              "counter name not set");
 
 
           long value = WebServicesTestUtils.getXmlLong(counter, "value");
           long value = WebServicesTestUtils.getXmlLong(counter, "value");
-          assertTrue("value not >= 0", value >= 0);
+          assertTrue(value >= 0, "value not >= 0");
 
 
         }
         }
       }
       }

+ 17 - 17
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobConf.java

@@ -18,10 +18,10 @@
 
 
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -61,8 +61,8 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONObject;
-import org.junit.AfterClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
@@ -142,7 +142,7 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
     }
     }
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   static public void stop() {
   static public void stop() {
     FileUtil.fullyDelete(testConfDir);
     FileUtil.fullyDelete(testConfDir);
   }
   }
@@ -164,7 +164,7 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("conf");
       JSONObject info = json.getJSONObject("conf");
       verifyHsJobConf(info, jobsMap.get(id));
       verifyHsJobConf(info, jobsMap.get(id));
     }
     }
@@ -182,7 +182,7 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("conf");
       JSONObject info = json.getJSONObject("conf");
       verifyHsJobConf(info, jobsMap.get(id));
       verifyHsJobConf(info, jobsMap.get(id));
     }
     }
@@ -200,7 +200,7 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("conf");
       JSONObject info = json.getJSONObject("conf");
       verifyHsJobConf(info, jobsMap.get(id));
       verifyHsJobConf(info, jobsMap.get(id));
     }
     }
@@ -231,7 +231,7 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
 
 
   public void verifyHsJobConf(JSONObject info, Job job) throws JSONException {
   public void verifyHsJobConf(JSONObject info, Job job) throws JSONException {
 
 
-    assertEquals("incorrect number of elements", 2, info.length());
+    assertEquals(2, info.length(), "incorrect number of elements");
 
 
     WebServicesTestUtils.checkStringMatch("path", job.getConfFile().toString(),
     WebServicesTestUtils.checkStringMatch("path", job.getConfFile().toString(),
         info.getString("path"));
         info.getString("path"));
@@ -242,14 +242,14 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
       JSONObject prop = properties.getJSONObject(i);
       JSONObject prop = properties.getJSONObject(i);
       String name = prop.getString("name");
       String name = prop.getString("name");
       String value = prop.getString("value");
       String value = prop.getString("value");
-      assertTrue("name not set", (name != null && !name.isEmpty()));
-      assertTrue("value not set", (value != null && !value.isEmpty()));
+      assertTrue((name != null && !name.isEmpty()), "name not set");
+      assertTrue((value != null && !value.isEmpty()), "value not set");
     }
     }
   }
   }
 
 
   public void verifyHsJobConfXML(NodeList nodes, Job job) {
   public void verifyHsJobConfXML(NodeList nodes, Job job) {
 
 
-    assertEquals("incorrect number of elements", 1, nodes.getLength());
+    assertEquals(1, nodes.getLength(), "incorrect number of elements");
 
 
     for (int i = 0; i < nodes.getLength(); i++) {
     for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);
       Element element = (Element) nodes.item(i);
@@ -262,11 +262,11 @@ public class TestHsWebServicesJobConf extends JerseyTestBase {
 
 
       for (int j = 0; j < properties.getLength(); j++) {
       for (int j = 0; j < properties.getLength(); j++) {
         Element property = (Element) properties.item(j);
         Element property = (Element) properties.item(j);
-        assertNotNull("should have counters in the web service info", property);
+        assertNotNull(property, "should have counters in the web service info");
         String name = WebServicesTestUtils.getXmlString(property, "name");
         String name = WebServicesTestUtils.getXmlString(property, "name");
         String value = WebServicesTestUtils.getXmlString(property, "value");
         String value = WebServicesTestUtils.getXmlString(property, "value");
-        assertTrue("name not set", (name != null && !name.isEmpty()));
-        assertTrue("name not set", (value != null && !value.isEmpty()));
+        assertTrue((name != null && !name.isEmpty()), "name not set");
+        assertTrue((value != null && !value.isEmpty()), "name not set");
       }
       }
     }
     }
   }
   }

+ 52 - 52
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobs.java

@@ -21,9 +21,9 @@ package org.apache.hadoop.mapreduce.v2.hs.webapp;
 import static org.apache.hadoop.yarn.util.StringHelper.join;
 import static org.apache.hadoop.yarn.util.StringHelper.join;
 import static org.apache.hadoop.yarn.util.StringHelper.ujoin;
 import static org.apache.hadoop.yarn.util.StringHelper.ujoin;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -58,7 +58,7 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
@@ -121,12 +121,12 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobItem = jobs.getJSONObject("job");
     JSONObject jobItem = jobs.getJSONObject("job");
     JSONArray arr = new JSONArray();
     JSONArray arr = new JSONArray();
     arr.put(jobItem);
     arr.put(jobItem);
-    assertEquals("incorrect number of elements", 1, arr.length());
+    assertEquals(1, arr.length(), "incorrect number of elements");
     JSONObject info = arr.getJSONObject(0);
     JSONObject info = arr.getJSONObject(0);
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     VerifyJobsUtils.verifyHsJobPartial(info, job);
     VerifyJobsUtils.verifyHsJobPartial(info, job);
@@ -142,12 +142,12 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobItem = jobs.getJSONObject("job");
     JSONObject jobItem = jobs.getJSONObject("job");
     JSONArray arr = new JSONArray();
     JSONArray arr = new JSONArray();
     arr.put(jobItem);
     arr.put(jobItem);
-    assertEquals("incorrect number of elements", 1, arr.length());
+    assertEquals(1, arr.length(), "incorrect number of elements");
     JSONObject info = arr.getJSONObject(0);
     JSONObject info = arr.getJSONObject(0);
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     VerifyJobsUtils.verifyHsJobPartial(info, job);
     VerifyJobsUtils.verifyHsJobPartial(info, job);
@@ -162,12 +162,12 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobItem = jobs.getJSONObject("job");
     JSONObject jobItem = jobs.getJSONObject("job");
     JSONArray arr = new JSONArray();
     JSONArray arr = new JSONArray();
     arr.put(jobItem);
     arr.put(jobItem);
-    assertEquals("incorrect number of elements", 1, arr.length());
+    assertEquals(1, arr.length(), "incorrect number of elements");
     JSONObject info = arr.getJSONObject(0);
     JSONObject info = arr.getJSONObject(0);
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     VerifyJobsUtils.verifyHsJobPartial(info, job);
     VerifyJobsUtils.verifyHsJobPartial(info, job);
@@ -189,22 +189,22 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
     is.setCharacterStream(new StringReader(xml));
     is.setCharacterStream(new StringReader(xml));
     Document dom = db.parse(is);
     Document dom = db.parse(is);
     NodeList jobs = dom.getElementsByTagName("jobs");
     NodeList jobs = dom.getElementsByTagName("jobs");
-    assertEquals("incorrect number of elements", 1, jobs.getLength());
+    assertEquals(1, jobs.getLength(), "incorrect number of elements");
     NodeList job = dom.getElementsByTagName("job");
     NodeList job = dom.getElementsByTagName("job");
-    assertEquals("incorrect number of elements", 1, job.getLength());
+    assertEquals(1, job.getLength(), "incorrect number of elements");
     verifyHsJobPartialXML(job, appContext);
     verifyHsJobPartialXML(job, appContext);
   }
   }
 
 
   public void verifyHsJobPartialXML(NodeList nodes, MockHistoryContext appContext) {
   public void verifyHsJobPartialXML(NodeList nodes, MockHistoryContext appContext) {
 
 
-    assertEquals("incorrect number of elements", 1, nodes.getLength());
+    assertEquals(1, nodes.getLength(), "incorrect number of elements");
 
 
     for (int i = 0; i < nodes.getLength(); i++) {
     for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);
       Element element = (Element) nodes.item(i);
 
 
       Job job = appContext.getPartialJob(MRApps.toJobID(WebServicesTestUtils
       Job job = appContext.getPartialJob(MRApps.toJobID(WebServicesTestUtils
           .getXmlString(element, "id")));
           .getXmlString(element, "id")));
-      assertNotNull("Job not found - output incorrect", job);
+      assertNotNull(job, "Job not found - output incorrect");
 
 
       VerifyJobsUtils.verifyHsJobGeneric(job,
       VerifyJobsUtils.verifyHsJobGeneric(job,
           WebServicesTestUtils.getXmlString(element, "id"),
           WebServicesTestUtils.getXmlString(element, "id"),
@@ -223,14 +223,14 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
   
   
   public void verifyHsJobXML(NodeList nodes, AppContext appContext) {
   public void verifyHsJobXML(NodeList nodes, AppContext appContext) {
 
 
-    assertEquals("incorrect number of elements", 1, nodes.getLength());
+    assertEquals(1, nodes.getLength(), "incorrect number of elements");
 
 
     for (int i = 0; i < nodes.getLength(); i++) {
     for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);
       Element element = (Element) nodes.item(i);
 
 
       Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils
       Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils
           .getXmlString(element, "id")));
           .getXmlString(element, "id")));
-      assertNotNull("Job not found - output incorrect", job);
+      assertNotNull(job, "Job not found - output incorrect");
 
 
       VerifyJobsUtils.verifyHsJobGeneric(job,
       VerifyJobsUtils.verifyHsJobGeneric(job,
           WebServicesTestUtils.getXmlString(element, "id"),
           WebServicesTestUtils.getXmlString(element, "id"),
@@ -275,7 +275,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("job");
       JSONObject info = json.getJSONObject("job");
       VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
       VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
     }
     }
@@ -295,7 +295,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("job");
       JSONObject info = json.getJSONObject("job");
 
 
       VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
       VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
@@ -313,7 +313,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("job");
       JSONObject info = json.getJSONObject("job");
       VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
       VerifyJobsUtils.verifyHsJob(info, appContext.getJob(id));
     }
     }
@@ -335,7 +335,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject msg = response.readEntity(JSONObject.class);
       JSONObject msg = response.readEntity(JSONObject.class);
       JSONObject exception = msg.getJSONObject("RemoteException");
       JSONObject exception = msg.getJSONObject("RemoteException");
-      assertEquals("incorrect number of elements", 3, exception.length());
+      assertEquals(3, exception.length(), "incorrect number of elements");
       String message = exception.getString("message");
       String message = exception.getString("message");
       String type = exception.getString("exception");
       String type = exception.getString("exception");
       String classname = exception.getString("javaClassName");
       String classname = exception.getString("javaClassName");
@@ -362,7 +362,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject msg = response.readEntity(JSONObject.class);
       JSONObject msg = response.readEntity(JSONObject.class);
       JSONObject exception = msg.getJSONObject("RemoteException");
       JSONObject exception = msg.getJSONObject("RemoteException");
-      assertEquals("incorrect number of elements", 3, exception.length());
+      assertEquals(3, exception.length(), "incorrect number of elements");
       String message = exception.getString("message");
       String message = exception.getString("message");
       String type = exception.getString("exception");
       String type = exception.getString("exception");
       String classname = exception.getString("javaClassName");
       String classname = exception.getString("javaClassName");
@@ -387,7 +387,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       String entity = response.readEntity(String.class);
       String entity = response.readEntity(String.class);
       JSONObject msg = new JSONObject(entity);
       JSONObject msg = new JSONObject(entity);
       JSONObject exception = msg.getJSONObject("RemoteException");
       JSONObject exception = msg.getJSONObject("RemoteException");
-      assertEquals("incorrect number of elements", 3, exception.length());
+      assertEquals(3, exception.length(), "incorrect number of elements");
       String message = exception.getString("message");
       String message = exception.getString("message");
       String type = exception.getString("exception");
       String type = exception.getString("exception");
       String classname = exception.getString("javaClassName");
       String classname = exception.getString("javaClassName");
@@ -450,7 +450,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       String entity = response.readEntity(String.class);
       String entity = response.readEntity(String.class);
       JSONObject msg = new JSONObject(entity);
       JSONObject msg = new JSONObject(entity);
       JSONObject exception = msg.getJSONObject("RemoteException");
       JSONObject exception = msg.getJSONObject("RemoteException");
-      assertEquals("incorrect number of elements", 3, exception.length());
+      assertEquals(3, exception.length(), "incorrect number of elements");
       String message = exception.getString("message");
       String message = exception.getString("message");
       String type = exception.getString("exception");
       String type = exception.getString("exception");
       String classname = exception.getString("javaClassName");
       String classname = exception.getString("javaClassName");
@@ -497,7 +497,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobCounters");
       JSONObject info = json.getJSONObject("jobCounters");
       verifyHsJobCounters(info, appContext.getJob(id));
       verifyHsJobCounters(info, appContext.getJob(id));
     }
     }
@@ -515,7 +515,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobCounters");
       JSONObject info = json.getJSONObject("jobCounters");
       verifyHsJobCounters(info, appContext.getJob(id));
       verifyHsJobCounters(info, appContext.getJob(id));
     }
     }
@@ -534,14 +534,14 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobCounters");
       JSONObject info = json.getJSONObject("jobCounters");
       WebServicesTestUtils.checkStringMatch("id", MRApps.toString(id),
       WebServicesTestUtils.checkStringMatch("id", MRApps.toString(id),
           info.getString("id"));
           info.getString("id"));
       // The modification in this test case is because
       // The modification in this test case is because
       // we have unified all the context parameters in this unit test,
       // we have unified all the context parameters in this unit test,
       // and the value of this variable has been changed to 2.
       // and the value of this variable has been changed to 2.
-      assertTrue("Job shouldn't contain any counters", info.length() == 2);
+      assertTrue(info.length() == 2, "Job shouldn't contain any counters");
     }
     }
   }
   }
 
 
@@ -557,7 +557,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobCounters");
       JSONObject info = json.getJSONObject("jobCounters");
       verifyHsJobCounters(info, appContext.getJob(id));
       verifyHsJobCounters(info, appContext.getJob(id));
     }
     }
@@ -588,7 +588,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
   public void verifyHsJobCounters(JSONObject info, Job job)
   public void verifyHsJobCounters(JSONObject info, Job job)
       throws JSONException {
       throws JSONException {
 
 
-    assertEquals("incorrect number of elements", 2, info.length());
+    assertEquals(2, info.length(), "incorrect number of elements");
 
 
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
         info.getString("id"));
         info.getString("id"));
@@ -598,22 +598,22 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
     for (int i = 0; i < counterGroups.length(); i++) {
     for (int i = 0; i < counterGroups.length(); i++) {
       JSONObject counterGroup = counterGroups.getJSONObject(i);
       JSONObject counterGroup = counterGroups.getJSONObject(i);
       String name = counterGroup.getString("counterGroupName");
       String name = counterGroup.getString("counterGroupName");
-      assertTrue("name not set", (name != null && !name.isEmpty()));
+      assertTrue((name != null && !name.isEmpty()), "name not set");
       JSONArray counters = counterGroup.getJSONArray("counter");
       JSONArray counters = counterGroup.getJSONArray("counter");
       for (int j = 0; j < counters.length(); j++) {
       for (int j = 0; j < counters.length(); j++) {
         JSONObject counter = counters.getJSONObject(j);
         JSONObject counter = counters.getJSONObject(j);
         String counterName = counter.getString("name");
         String counterName = counter.getString("name");
-        assertTrue("counter name not set",
-            (counterName != null && !counterName.isEmpty()));
+        assertTrue((counterName != null && !counterName.isEmpty()),
+            "counter name not set");
 
 
         long mapValue = counter.getLong("mapCounterValue");
         long mapValue = counter.getLong("mapCounterValue");
-        assertTrue("mapCounterValue  >= 0", mapValue >= 0);
+        assertTrue(mapValue >= 0, "mapCounterValue  >= 0");
 
 
         long reduceValue = counter.getLong("reduceCounterValue");
         long reduceValue = counter.getLong("reduceCounterValue");
-        assertTrue("reduceCounterValue  >= 0", reduceValue >= 0);
+        assertTrue(reduceValue >= 0, "reduceCounterValue  >= 0");
 
 
         long totalValue = counter.getLong("totalCounterValue");
         long totalValue = counter.getLong("totalCounterValue");
-        assertTrue("totalCounterValue  >= 0", totalValue >= 0);
+        assertTrue(totalValue >= 0, "totalCounterValue  >= 0");
 
 
       }
       }
     }
     }
@@ -624,7 +624,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
     for (int i = 0; i < nodes.getLength(); i++) {
     for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);
       Element element = (Element) nodes.item(i);
 
 
-      assertNotNull("Job not found - output incorrect", job);
+      assertNotNull(job, "Job not found - output incorrect");
 
 
       WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
       WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
           WebServicesTestUtils.getXmlString(element, "id"));
           WebServicesTestUtils.getXmlString(element, "id"));
@@ -634,29 +634,29 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
 
 
       for (int j = 0; j < groups.getLength(); j++) {
       for (int j = 0; j < groups.getLength(); j++) {
         Element counters = (Element) groups.item(j);
         Element counters = (Element) groups.item(j);
-        assertNotNull("should have counters in the web service info", counters);
+        assertNotNull(counters, "should have counters in the web service info");
         String name = WebServicesTestUtils.getXmlString(counters,
         String name = WebServicesTestUtils.getXmlString(counters,
             "counterGroupName");
             "counterGroupName");
-        assertTrue("name not set", (name != null && !name.isEmpty()));
+        assertTrue((name != null && !name.isEmpty()), "name not set");
         NodeList counterArr = counters.getElementsByTagName("counter");
         NodeList counterArr = counters.getElementsByTagName("counter");
         for (int z = 0; z < counterArr.getLength(); z++) {
         for (int z = 0; z < counterArr.getLength(); z++) {
           Element counter = (Element) counterArr.item(z);
           Element counter = (Element) counterArr.item(z);
           String counterName = WebServicesTestUtils.getXmlString(counter,
           String counterName = WebServicesTestUtils.getXmlString(counter,
               "name");
               "name");
-          assertTrue("counter name not set",
-              (counterName != null && !counterName.isEmpty()));
+          assertTrue((counterName != null && !counterName.isEmpty()),
+              "counter name not set");
 
 
           long mapValue = WebServicesTestUtils.getXmlLong(counter,
           long mapValue = WebServicesTestUtils.getXmlLong(counter,
               "mapCounterValue");
               "mapCounterValue");
-          assertTrue("mapCounterValue not >= 0", mapValue >= 0);
+          assertTrue(mapValue >= 0, "mapCounterValue not >= 0");
 
 
           long reduceValue = WebServicesTestUtils.getXmlLong(counter,
           long reduceValue = WebServicesTestUtils.getXmlLong(counter,
               "reduceCounterValue");
               "reduceCounterValue");
-          assertTrue("reduceCounterValue  >= 0", reduceValue >= 0);
+          assertTrue(reduceValue >= 0, "reduceCounterValue  >= 0");
 
 
           long totalValue = WebServicesTestUtils.getXmlLong(counter,
           long totalValue = WebServicesTestUtils.getXmlLong(counter,
               "totalCounterValue");
               "totalCounterValue");
-          assertTrue("totalCounterValue  >= 0", totalValue >= 0);
+          assertTrue(totalValue >= 0, "totalCounterValue  >= 0");
         }
         }
       }
       }
     }
     }
@@ -674,7 +674,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobAttempts");
       JSONObject info = json.getJSONObject("jobAttempts");
       verifyHsJobAttempts(info, appContext.getJob(id));
       verifyHsJobAttempts(info, appContext.getJob(id));
     }
     }
@@ -692,7 +692,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobAttempts");
       JSONObject info = json.getJSONObject("jobAttempts");
       verifyHsJobAttempts(info, appContext.getJob(id));
       verifyHsJobAttempts(info, appContext.getJob(id));
     }
     }
@@ -711,7 +711,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject info = json.getJSONObject("jobAttempts");
       JSONObject info = json.getJSONObject("jobAttempts");
       verifyHsJobAttempts(info, appContext.getJob(id));
       verifyHsJobAttempts(info, appContext.getJob(id));
     }
     }
@@ -736,7 +736,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       is.setCharacterStream(new StringReader(xml));
       is.setCharacterStream(new StringReader(xml));
       Document dom = db.parse(is);
       Document dom = db.parse(is);
       NodeList attempts = dom.getElementsByTagName("jobAttempts");
       NodeList attempts = dom.getElementsByTagName("jobAttempts");
-      assertEquals("incorrect number of elements", 1, attempts.getLength());
+      assertEquals(1, attempts.getLength(), "incorrect number of elements");
       NodeList info = dom.getElementsByTagName("jobAttempt");
       NodeList info = dom.getElementsByTagName("jobAttempt");
       verifyHsJobAttemptsXML(info, appContext.getJob(id));
       verifyHsJobAttemptsXML(info, appContext.getJob(id));
     }
     }
@@ -746,7 +746,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
       throws JSONException {
       throws JSONException {
 
 
     JSONArray attempts = info.getJSONArray("jobAttempt");
     JSONArray attempts = info.getJSONArray("jobAttempt");
-    assertEquals("incorrect number of elements", 2, attempts.length());
+    assertEquals(2, attempts.length(), "incorrect number of elements");
     for (int i = 0; i < attempts.length(); i++) {
     for (int i = 0; i < attempts.length(); i++) {
       JSONObject attempt = attempts.getJSONObject(i);
       JSONObject attempt = attempts.getJSONObject(i);
       verifyHsJobAttemptsGeneric(job, attempt.getString("nodeHttpAddress"),
       verifyHsJobAttemptsGeneric(job, attempt.getString("nodeHttpAddress"),
@@ -759,7 +759,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
 
 
   public void verifyHsJobAttemptsXML(NodeList nodes, Job job) {
   public void verifyHsJobAttemptsXML(NodeList nodes, Job job) {
 
 
-    assertEquals("incorrect number of elements", 2, nodes.getLength());
+    assertEquals(2, nodes.getLength(), "incorrect number of elements");
     for (int i = 0; i < nodes.getLength(); i++) {
     for (int i = 0; i < nodes.getLength(); i++) {
       Element element = (Element) nodes.item(i);
       Element element = (Element) nodes.item(i);
       verifyHsJobAttemptsGeneric(job,
       verifyHsJobAttemptsGeneric(job,
@@ -784,7 +784,7 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
         int nmPort = amInfo.getNodeManagerPort();
         int nmPort = amInfo.getNodeManagerPort();
         WebServicesTestUtils.checkStringMatch("nodeHttpAddress", nmHost + ":"
         WebServicesTestUtils.checkStringMatch("nodeHttpAddress", nmHost + ":"
             + nmHttpPort, nodeHttpAddress);
             + nmHttpPort, nodeHttpAddress);
-        assertTrue("startime not greater than 0", startTime > 0);
+        assertTrue(startTime > 0, "startime not greater than 0");
         WebServicesTestUtils.checkStringMatch("containerId", amInfo
         WebServicesTestUtils.checkStringMatch("containerId", amInfo
             .getContainerId().toString(), containerId);
             .getContainerId().toString(), containerId);
 
 
@@ -792,10 +792,10 @@ public class TestHsWebServicesJobs extends JerseyTestBase {
             ujoin("logs", nodeId, containerId, MRApps.toString(job.getID()),
             ujoin("logs", nodeId, containerId, MRApps.toString(job.getID()),
                 job.getUserName()));
                 job.getUserName()));
 
 
-        assertTrue("logsLink", logsLink.contains(localLogsLink));
+        assertTrue(logsLink.contains(localLogsLink), "logsLink");
       }
       }
     }
     }
-    assertTrue("attempt: " + id + " was not found", attemptFound);
+    assertTrue(attemptFound, "attempt: " + id + " was not found");
   }
   }
 
 
 }
 }

+ 44 - 44
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesJobsQuery.java

@@ -19,8 +19,8 @@
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 
 
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -53,7 +53,7 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import org.glassfish.jersey.internal.inject.AbstractBinder;
 import org.glassfish.jersey.internal.inject.AbstractBinder;
 import org.glassfish.jersey.jettison.JettisonFeature;
 import org.glassfish.jersey.jettison.JettisonFeature;
@@ -112,7 +112,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
       jobStates.remove(entry.getValue().getState());
       jobStates.remove(entry.getValue().getState());
     }
     }
 
 
-    assertTrue("No unused job states", jobStates.size() > 0);
+    assertTrue(jobStates.size() > 0, "No unused job states");
     JobState notInUse = jobStates.get(0);
     JobState notInUse = jobStates.get(0);
 
 
     Response response = r.path("ws").path("v1").path("history")
     Response response = r.path("ws").path("v1").path("history")
@@ -122,8 +122,8 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
-    assertEquals("jobs is not empty", "", json.get("jobs").toString());
+    assertEquals(1, json.length(), "incorrect number of elements");
+    assertEquals("", json.get("jobs").toString(), "jobs is not empty");
   }
   }
 
 
   @Test
   @Test
@@ -144,12 +144,12 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jsonJobs = json.getJSONObject("jobs");
     JSONObject jsonJobs = json.getJSONObject("jobs");
     JSONObject jsonJob = jsonJobs.getJSONObject("job");
     JSONObject jsonJob = jsonJobs.getJSONObject("job");
     JSONArray arr = new JSONArray();
     JSONArray arr = new JSONArray();
     arr.put(jsonJob);
     arr.put(jsonJob);
-    assertEquals("incorrect number of elements", 1, arr.length());
+    assertEquals(1, arr.length(), "incorrect number of elements");
     JSONObject info = arr.getJSONObject(0);
     JSONObject info = arr.getJSONObject(0);
     Job job = appContext.getPartialJob(jid);
     Job job = appContext.getPartialJob(jid);
     VerifyJobsUtils.verifyHsJobPartial(info, job);
     VerifyJobsUtils.verifyHsJobPartial(info, job);
@@ -168,7 +168,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -193,8 +193,8 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
-    assertEquals("jobs is not empty", "", json.get("jobs").toString());
+    assertEquals(1, json.length(), "incorrect number of elements");
+    assertEquals("", json.get("jobs").toString(), "jobs is not empty");
   }
   }
 
 
   @Test
   @Test
@@ -207,10 +207,10 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
 
 
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
-    assertEquals("incorrect number of elements", 3, arr.length());
+    assertEquals(3, arr.length(), "incorrect number of elements");
     // just verify one of them.
     // just verify one of them.
     JSONObject info = arr.getJSONObject(0);
     JSONObject info = arr.getJSONObject(0);
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
     Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
@@ -226,11 +226,11 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
     // make sure we get 2 back
     // make sure we get 2 back
-    assertEquals("incorrect number of elements", 2, arr.length());
+    assertEquals(2, arr.length(), "incorrect number of elements");
   }
   }
 
 
   @Test
   @Test
@@ -246,7 +246,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -267,10 +267,10 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
-    assertEquals("incorrect number of elements", 3, arr.length());
+    assertEquals(3, arr.length(), "incorrect number of elements");
   }
   }
 
 
   @Test
   @Test
@@ -282,8 +282,8 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
-    assertEquals("jobs is not empty", "", json.get("jobs").toString());
+    assertEquals(1, json.length(), "incorrect number of elements");
+    assertEquals("", json.get("jobs").toString(), "jobs is not empty");
   }
   }
 
 
   @Test
   @Test
@@ -298,10 +298,10 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
-    assertEquals("incorrect number of elements", 3, arr.length());
+    assertEquals(3, arr.length(), "incorrect number of elements");
   }
   }
 
 
   @Test
   @Test
@@ -316,8 +316,8 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
-    assertEquals("jobs is not empty", "", json.get("jobs").toString());
+    assertEquals(1, json.length(), "incorrect number of elements");
+    assertEquals("", json.get("jobs").toString(), "jobs is not empty");
   }
   }
 
 
   @Test
   @Test
@@ -332,7 +332,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     }
     }
     Collections.sort(startTime);
     Collections.sort(startTime);
 
 
-    assertTrue("Error we must have atleast 3 jobs", size >= 3);
+    assertTrue(size >= 3, "Error we must have atleast 3 jobs");
     long midStartTime = startTime.get(size - 2);
     long midStartTime = startTime.get(size - 2);
 
 
     Response response = r.path("ws").path("v1").path("history")
     Response response = r.path("ws").path("v1").path("history")
@@ -343,10 +343,10 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
-    assertEquals("incorrect number of elements", size - 1, arr.length());
+    assertEquals(size - 1, arr.length(), "incorrect number of elements");
   }
   }
 
 
   @Test
   @Test
@@ -364,7 +364,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -390,7 +390,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -417,7 +417,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -444,7 +444,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -471,7 +471,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -496,7 +496,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -521,7 +521,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -548,7 +548,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -575,7 +575,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -602,7 +602,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject msg = response.readEntity(JSONObject.class);
     JSONObject exception = msg.getJSONObject("RemoteException");
     JSONObject exception = msg.getJSONObject("RemoteException");
-    assertEquals("incorrect number of elements", 3, exception.length());
+    assertEquals(3, exception.length(), "incorrect number of elements");
     String message = exception.getString("message");
     String message = exception.getString("message");
     String type = exception.getString("exception");
     String type = exception.getString("exception");
     String classname = exception.getString("javaClassName");
     String classname = exception.getString("javaClassName");
@@ -629,10 +629,10 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
-    assertEquals("incorrect number of elements", 3, arr.length());
+    assertEquals(3, arr.length(), "incorrect number of elements");
   }
   }
 
 
   @Test
   @Test
@@ -647,8 +647,8 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
-    assertEquals("jobs is not empty", "", json.get("jobs").toString());
+    assertEquals(1, json.length(), "incorrect number of elements");
+    assertEquals("", json.get("jobs").toString(), "jobs is not empty");
   }
   }
 
 
   @Test
   @Test
@@ -664,7 +664,7 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     }
     }
     Collections.sort(finishTime);
     Collections.sort(finishTime);
 
 
-    assertTrue("Error we must have atleast 3 jobs", size >= 3);
+    assertTrue(size >= 3, "Error we must have atleast 3 jobs");
     long midFinishTime = finishTime.get(size - 2);
     long midFinishTime = finishTime.get(size - 2);
 
 
     Response response = r.path("ws").path("v1").path("history")
     Response response = r.path("ws").path("v1").path("history")
@@ -675,10 +675,10 @@ public class TestHsWebServicesJobsQuery extends JerseyTestBase {
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
     assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         response.getMediaType().toString());
         response.getMediaType().toString());
     JSONObject json = response.readEntity(JSONObject.class);
     JSONObject json = response.readEntity(JSONObject.class);
-    assertEquals("incorrect number of elements", 1, json.length());
+    assertEquals(1, json.length(), "incorrect number of elements");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONObject jobs = json.getJSONObject("jobs");
     JSONArray arr = jobs.getJSONArray("job");
     JSONArray arr = jobs.getJSONArray("job");
-    assertEquals("incorrect number of elements", size - 1, arr.length());
+    assertEquals(size - 1, arr.length(), "incorrect number of elements");
   }
   }
 
 
 }
 }

+ 6 - 6
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesLogs.java

@@ -52,9 +52,9 @@ import org.apache.hadoop.yarn.webapp.BadRequestException;
 import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
 import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
 import org.apache.hadoop.yarn.webapp.JerseyTestBase;
 import org.apache.hadoop.yarn.webapp.JerseyTestBase;
 import org.apache.hadoop.yarn.webapp.WebApp;
 import org.apache.hadoop.yarn.webapp.WebApp;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
@@ -76,7 +76,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doReturn;
@@ -243,7 +243,7 @@ public class TestHsWebServicesLogs extends JerseyTestBase {
     }
     }
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setupClass() throws Exception {
   public static void setupClass() throws Exception {
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
     conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, REMOTE_LOG_ROOT_DIR);
     conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, REMOTE_LOG_ROOT_DIR);
@@ -287,7 +287,7 @@ public class TestHsWebServicesLogs extends JerseyTestBase {
   public TestHsWebServicesLogs() {
   public TestHsWebServicesLogs() {
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void tearDownClass() throws Exception {
   public static void tearDownClass() throws Exception {
     fs.delete(new Path(REMOTE_LOG_ROOT_DIR), true);
     fs.delete(new Path(REMOTE_LOG_ROOT_DIR), true);
     fs.delete(new Path(LOCAL_ROOT_LOG_DIR), true);
     fs.delete(new Path(LOCAL_ROOT_LOG_DIR), true);

+ 8 - 8
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesLogsExtend.java

@@ -52,9 +52,9 @@ import org.apache.hadoop.yarn.webapp.WebApp;
 import org.glassfish.jersey.internal.inject.AbstractBinder;
 import org.glassfish.jersey.internal.inject.AbstractBinder;
 import org.glassfish.jersey.jettison.JettisonFeature;
 import org.glassfish.jersey.jettison.JettisonFeature;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
@@ -71,9 +71,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doReturn;
@@ -241,7 +241,7 @@ public class TestHsWebServicesLogsExtend extends JerseyTestBase {
     }
     }
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setupClass() throws Exception {
   public static void setupClass() throws Exception {
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
     conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, REMOTE_LOG_ROOT_DIR);
     conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, REMOTE_LOG_ROOT_DIR);
@@ -282,7 +282,7 @@ public class TestHsWebServicesLogsExtend extends JerseyTestBase {
         "Hello-" + CONTAINER_2_2_3), NM_ID_2, FILE_NAME, USER, false);
         "Hello-" + CONTAINER_2_2_3), NM_ID_2, FILE_NAME, USER, false);
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void tearDownClass() throws Exception {
   public static void tearDownClass() throws Exception {
     fs.delete(new Path(REMOTE_LOG_ROOT_DIR), true);
     fs.delete(new Path(REMOTE_LOG_ROOT_DIR), true);
     fs.delete(new Path(LOCAL_ROOT_LOG_DIR), true);
     fs.delete(new Path(LOCAL_ROOT_LOG_DIR), true);

+ 45 - 46
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServicesTasks.java

@@ -19,9 +19,9 @@
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 
 
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
 import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 
@@ -60,7 +60,7 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
@@ -127,10 +127,10 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONArray arr = tasks.getJSONArray("task");
       JSONArray arr = tasks.getJSONArray("task");
-      assertEquals("incorrect number of elements", 2, arr.length());
+      assertEquals(2, arr.length(), "incorrect number of elements");
 
 
       verifyHsTask(arr, jobsMap.get(id), null);
       verifyHsTask(arr, jobsMap.get(id), null);
     }
     }
@@ -148,10 +148,10 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONArray arr = tasks.getJSONArray("task");
       JSONArray arr = tasks.getJSONArray("task");
-      assertEquals("incorrect number of elements", 2, arr.length());
+      assertEquals(2, arr.length(), "incorrect number of elements");
 
 
       verifyHsTask(arr, jobsMap.get(id), null);
       verifyHsTask(arr, jobsMap.get(id), null);
     }
     }
@@ -169,10 +169,10 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json =response.readEntity(JSONObject.class);
       JSONObject json =response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONArray arr = tasks.getJSONArray("task");
       JSONArray arr = tasks.getJSONArray("task");
-      assertEquals("incorrect number of elements", 2, arr.length());
+      assertEquals(2, arr.length(), "incorrect number of elements");
 
 
       verifyHsTask(arr, jobsMap.get(id), null);
       verifyHsTask(arr, jobsMap.get(id), null);
     }
     }
@@ -197,7 +197,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
       is.setCharacterStream(new StringReader(xml));
       is.setCharacterStream(new StringReader(xml));
       Document dom = db.parse(is);
       Document dom = db.parse(is);
       NodeList tasks = dom.getElementsByTagName("tasks");
       NodeList tasks = dom.getElementsByTagName("tasks");
-      assertEquals("incorrect number of elements", 1, tasks.getLength());
+      assertEquals(1, tasks.getLength(), "incorrect number of elements");
       NodeList task = dom.getElementsByTagName("task");
       NodeList task = dom.getElementsByTagName("task");
       verifyHsTaskXML(task, jobsMap.get(id));
       verifyHsTaskXML(task, jobsMap.get(id));
     }
     }
@@ -217,12 +217,12 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject task = tasks.getJSONObject("task");
       JSONObject task = tasks.getJSONObject("task");
       JSONArray arr = new JSONArray();
       JSONArray arr = new JSONArray();
       arr.put(task);
       arr.put(task);
-      assertEquals("incorrect number of elements", 1, arr.length());
+      assertEquals(1, arr.length(), "incorrect number of elements");
       verifyHsTask(arr, jobsMap.get(id), type);
       verifyHsTask(arr, jobsMap.get(id), type);
     }
     }
   }
   }
@@ -241,12 +241,12 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
       assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
           response.getMediaType().toString());
           response.getMediaType().toString());
       JSONObject json = response.readEntity(JSONObject.class);
       JSONObject json = response.readEntity(JSONObject.class);
-      assertEquals("incorrect number of elements", 1, json.length());
+      assertEquals(1, json.length(), "incorrect number of elements");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject tasks = json.getJSONObject("tasks");
       JSONObject task = tasks.getJSONObject("task");
       JSONObject task = tasks.getJSONObject("task");
       JSONArray arr = new JSONArray();
       JSONArray arr = new JSONArray();
       arr.put(task);
       arr.put(task);
-      assertEquals("incorrect number of elements", 1, arr.length());
+      assertEquals(1, arr.length(), "incorrect number of elements");
       verifyHsTask(arr, jobsMap.get(id), type);
       verifyHsTask(arr, jobsMap.get(id), type);
     }
     }
   }
   }
@@ -272,7 +272,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject exception = msg.getJSONObject("RemoteException");
         JSONObject exception = msg.getJSONObject("RemoteException");
-        assertEquals("incorrect number of elements", 3, exception.length());
+        assertEquals(3, exception.length(), "incorrect number of elements");
         String message = exception.getString("message");
         String message = exception.getString("message");
         String type = exception.getString("exception");
         String type = exception.getString("exception");
         String classname = exception.getString("javaClassName");
         String classname = exception.getString("javaClassName");
@@ -302,7 +302,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject json = response.readEntity(JSONObject.class);
         JSONObject json = response.readEntity(JSONObject.class);
-        assertEquals("incorrect number of elements", 1, json.length());
+        assertEquals(1, json.length(), "incorrect number of elements");
         JSONObject info = json.getJSONObject("task");
         JSONObject info = json.getJSONObject("task");
         verifyHsSingleTask(info, task);
         verifyHsSingleTask(info, task);
       }
       }
@@ -325,7 +325,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject json = response.readEntity(JSONObject.class);
         JSONObject json = response.readEntity(JSONObject.class);
-        assertEquals("incorrect number of elements", 1, json.length());
+        assertEquals(1, json.length(), "incorrect number of elements");
         JSONObject info = json.getJSONObject("task");
         JSONObject info = json.getJSONObject("task");
         verifyHsSingleTask(info, task);
         verifyHsSingleTask(info, task);
       }
       }
@@ -347,7 +347,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject json = response.readEntity(JSONObject.class);
         JSONObject json = response.readEntity(JSONObject.class);
-        assertEquals("incorrect number of elements", 1, json.length());
+        assertEquals(1, json.length(), "incorrect number of elements");
         JSONObject info = json.getJSONObject("task");
         JSONObject info = json.getJSONObject("task");
         verifyHsSingleTask(info, task);
         verifyHsSingleTask(info, task);
       }
       }
@@ -372,7 +372,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject exception = msg.getJSONObject("RemoteException");
         JSONObject exception = msg.getJSONObject("RemoteException");
-        assertEquals("incorrect number of elements", 3, exception.length());
+        assertEquals(3, exception.length(), "incorrect number of elements");
         String message = exception.getString("message");
         String message = exception.getString("message");
         String type = exception.getString("exception");
         String type = exception.getString("exception");
         String classname = exception.getString("javaClassName");
         String classname = exception.getString("javaClassName");
@@ -406,7 +406,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject exception = msg.getJSONObject("RemoteException");
         JSONObject exception = msg.getJSONObject("RemoteException");
-        assertEquals("incorrect number of elements", 3, exception.length());
+        assertEquals(3, exception.length(), "incorrect number of elements");
         String message = exception.getString("message");
         String message = exception.getString("message");
         String type = exception.getString("exception");
         String type = exception.getString("exception");
         String classname = exception.getString("javaClassName");
         String classname = exception.getString("javaClassName");
@@ -437,7 +437,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject exception = msg.getJSONObject("RemoteException");
         JSONObject exception = msg.getJSONObject("RemoteException");
-        assertEquals("incorrect number of elements", 3, exception.length());
+        assertEquals(3, exception.length(), "incorrect number of elements");
         String message = exception.getString("message");
         String message = exception.getString("message");
         String type = exception.getString("exception");
         String type = exception.getString("exception");
         String classname = exception.getString("javaClassName");
         String classname = exception.getString("javaClassName");
@@ -471,7 +471,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject exception = msg.getJSONObject("RemoteException");
         JSONObject exception = msg.getJSONObject("RemoteException");
-        assertEquals("incorrect number of elements", 3, exception.length());
+        assertEquals(3, exception.length(), "incorrect number of elements");
         String message = exception.getString("message");
         String message = exception.getString("message");
         String type = exception.getString("exception");
         String type = exception.getString("exception");
         String classname = exception.getString("javaClassName");
         String classname = exception.getString("javaClassName");
@@ -505,7 +505,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject msg = response.readEntity(JSONObject.class);
         JSONObject exception = msg.getJSONObject("RemoteException");
         JSONObject exception = msg.getJSONObject("RemoteException");
-        assertEquals("incorrect number of elements", 3, exception.length());
+        assertEquals(3, exception.length(), "incorrect number of elements");
         String message = exception.getString("message");
         String message = exception.getString("message");
         String type = exception.getString("exception");
         String type = exception.getString("exception");
         String classname = exception.getString("javaClassName");
         String classname = exception.getString("javaClassName");
@@ -554,7 +554,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
 
 
   public void verifyHsSingleTask(JSONObject info, Task task)
   public void verifyHsSingleTask(JSONObject info, Task task)
       throws JSONException {
       throws JSONException {
-    assertEquals("incorrect number of elements", 9, info.length());
+    assertEquals(9, info.length(), "incorrect number of elements");
 
 
     verifyTaskGeneric(task, info.getString("id"), info.getString("state"),
     verifyTaskGeneric(task, info.getString("id"), info.getString("state"),
         info.getString("type"), info.getString("successfulAttempt"),
         info.getString("type"), info.getString("successfulAttempt"),
@@ -577,7 +577,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
             verifyHsSingleTask(info, task);
             verifyHsSingleTask(info, task);
           }
           }
         }
         }
-        assertTrue("task with id: " + tid + " not in web service output", found);
+        assertTrue(found, "task with id: " + tid + " not in web service output");
       }
       }
     }
     }
   }
   }
@@ -596,11 +596,11 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
     WebServicesTestUtils.checkStringMatch("state", report.getTaskState()
     WebServicesTestUtils.checkStringMatch("state", report.getTaskState()
         .toString(), state);
         .toString(), state);
     // not easily checked without duplicating logic, just make sure its here
     // not easily checked without duplicating logic, just make sure its here
-    assertNotNull("successfulAttempt null", successfulAttempt);
-    assertEquals("startTime wrong", report.getStartTime(), startTime);
-    assertEquals("finishTime wrong", report.getFinishTime(), finishTime);
-    assertEquals("elapsedTime wrong", finishTime - startTime, elapsedTime);
-    assertEquals("progress wrong", report.getProgress() * 100, progress, 1e-3f);
+    assertNotNull(successfulAttempt, "successfulAttempt null");
+    assertEquals(report.getStartTime(), startTime, "startTime wrong");
+    assertEquals(report.getFinishTime(), finishTime, "finishTime wrong");
+    assertEquals(finishTime - startTime, elapsedTime, "elapsedTime wrong");
+    assertEquals(report.getProgress() * 100, progress, 1e-3f, "progress wrong");
   }
   }
 
 
   public void verifyHsSingleTaskXML(Element element, Task task) {
   public void verifyHsSingleTaskXML(Element element, Task task) {
@@ -616,7 +616,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
 
 
   public void verifyHsTaskXML(NodeList nodes, Job job) {
   public void verifyHsTaskXML(NodeList nodes, Job job) {
 
 
-    assertEquals("incorrect number of elements", 2, nodes.getLength());
+    assertEquals(2, nodes.getLength(), "incorrect number of elements");
 
 
     for (Task task : job.getTasks().values()) {
     for (Task task : job.getTasks().values()) {
       TaskId id = task.getID();
       TaskId id = task.getID();
@@ -630,7 +630,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
           verifyHsSingleTaskXML(element, task);
           verifyHsSingleTaskXML(element, task);
         }
         }
       }
       }
-      assertTrue("task with id: " + tid + " not in web service output", found);
+      assertTrue(found, "task with id: " + tid + " not in web service output");
     }
     }
   }
   }
 
 
@@ -650,7 +650,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject json = response.readEntity(JSONObject.class);
         JSONObject json = response.readEntity(JSONObject.class);
-        assertEquals("incorrect number of elements", 1, json.length());
+        assertEquals(1, json.length(), "incorrect number of elements");
         JSONObject info = json.getJSONObject("jobTaskCounters");
         JSONObject info = json.getJSONObject("jobTaskCounters");
         verifyHsJobTaskCounters(info, task);
         verifyHsJobTaskCounters(info, task);
       }
       }
@@ -673,7 +673,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject json = response.readEntity(JSONObject.class);
         JSONObject json = response.readEntity(JSONObject.class);
-        assertEquals("incorrect number of elements", 1, json.length());
+        assertEquals(1, json.length(), "incorrect number of elements");
         JSONObject info = json.getJSONObject("jobTaskCounters");
         JSONObject info = json.getJSONObject("jobTaskCounters");
         verifyHsJobTaskCounters(info, task);
         verifyHsJobTaskCounters(info, task);
       }
       }
@@ -695,7 +695,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
         assertEquals(MediaType.APPLICATION_JSON_TYPE + ";" + JettyUtils.UTF_8,
             response.getMediaType().toString());
             response.getMediaType().toString());
         JSONObject json = response.readEntity(JSONObject.class);
         JSONObject json = response.readEntity(JSONObject.class);
-        assertEquals("incorrect number of elements", 1, json.length());
+        assertEquals(1, json.length(), "incorrect number of elements");
         JSONObject info = json.getJSONObject("jobTaskCounters");
         JSONObject info = json.getJSONObject("jobTaskCounters");
         verifyHsJobTaskCounters(info, task);
         verifyHsJobTaskCounters(info, task);
       }
       }
@@ -732,7 +732,7 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
   public void verifyHsJobTaskCounters(JSONObject info, Task task)
   public void verifyHsJobTaskCounters(JSONObject info, Task task)
       throws JSONException {
       throws JSONException {
 
 
-    assertEquals("incorrect number of elements", 2, info.length());
+    assertEquals(2, info.length(), "incorrect number of elements");
 
 
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()),
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()),
         info.getString("id"));
         info.getString("id"));
@@ -742,15 +742,14 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
     for (int i = 0; i < counterGroups.length(); i++) {
     for (int i = 0; i < counterGroups.length(); i++) {
       JSONObject counterGroup = counterGroups.getJSONObject(i);
       JSONObject counterGroup = counterGroups.getJSONObject(i);
       String name = counterGroup.getString("counterGroupName");
       String name = counterGroup.getString("counterGroupName");
-      assertTrue("name not set", (name != null && !name.isEmpty()));
+      assertTrue((name != null && !name.isEmpty()), "name not set");
       JSONArray counters = counterGroup.getJSONArray("counter");
       JSONArray counters = counterGroup.getJSONArray("counter");
       for (int j = 0; j < counters.length(); j++) {
       for (int j = 0; j < counters.length(); j++) {
         JSONObject counter = counters.getJSONObject(j);
         JSONObject counter = counters.getJSONObject(j);
         String counterName = counter.getString("name");
         String counterName = counter.getString("name");
-        assertTrue("name not set",
-            (counterName != null && !counterName.isEmpty()));
+        assertTrue((counterName != null && !counterName.isEmpty()), "name not set");
         long value = counter.getLong("value");
         long value = counter.getLong("value");
-        assertTrue("value  >= 0", value >= 0);
+        assertTrue(value >= 0, "value  >= 0");
       }
       }
     }
     }
   }
   }
@@ -769,20 +768,20 @@ public class TestHsWebServicesTasks extends JerseyTestBase {
 
 
       for (int j = 0; j < groups.getLength(); j++) {
       for (int j = 0; j < groups.getLength(); j++) {
         Element counters = (Element) groups.item(j);
         Element counters = (Element) groups.item(j);
-        assertNotNull("should have counters in the web service info", counters);
+        assertNotNull(counters, "should have counters in the web service info");
         String name = WebServicesTestUtils.getXmlString(counters,
         String name = WebServicesTestUtils.getXmlString(counters,
             "counterGroupName");
             "counterGroupName");
-        assertTrue("name not set", (name != null && !name.isEmpty()));
+        assertTrue((name != null && !name.isEmpty()), "name not set");
         NodeList counterArr = counters.getElementsByTagName("counter");
         NodeList counterArr = counters.getElementsByTagName("counter");
         for (int z = 0; z < counterArr.getLength(); z++) {
         for (int z = 0; z < counterArr.getLength(); z++) {
           Element counter = (Element) counterArr.item(z);
           Element counter = (Element) counterArr.item(z);
           String counterName = WebServicesTestUtils.getXmlString(counter,
           String counterName = WebServicesTestUtils.getXmlString(counter,
               "name");
               "name");
-          assertTrue("counter name not set",
-              (counterName != null && !counterName.isEmpty()));
+          assertTrue((counterName != null && !counterName.isEmpty()),
+              "counter name not set");
 
 
           long value = WebServicesTestUtils.getXmlLong(counter, "value");
           long value = WebServicesTestUtils.getXmlLong(counter, "value");
-          assertTrue("value not >= 0", value >= 0);
+          assertTrue(value >= 0, "value not >= 0");
 
 
         }
         }
       }
       }

+ 25 - 25
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/VerifyJobsUtils.java

@@ -18,8 +18,8 @@
 
 
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 package org.apache.hadoop.mapreduce.v2.hs.webapp;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -33,7 +33,7 @@ import org.codehaus.jettison.json.JSONObject;
 public class VerifyJobsUtils {
 public class VerifyJobsUtils {
 
 
   public static void verifyHsJobPartial(JSONObject info, Job job) throws JSONException {
   public static void verifyHsJobPartial(JSONObject info, Job job) throws JSONException {
-    assertEquals("incorrect number of elements", 12, info.length());
+    assertEquals(12, info.length(), "incorrect number of elements");
 
 
     // everyone access fields
     // everyone access fields
     verifyHsJobGeneric(job, info.getString("id"), info.getString("user"),
     verifyHsJobGeneric(job, info.getString("id"), info.getString("user"),
@@ -45,7 +45,7 @@ public class VerifyJobsUtils {
   }
   }
   
   
   public static void verifyHsJob(JSONObject info, Job job) throws JSONException {
   public static void verifyHsJob(JSONObject info, Job job) throws JSONException {
-    assertEquals("incorrect number of elements", 25, info.length());
+    assertEquals(25, info.length(), "incorrect number of elements");
 
 
     // everyone access fields
     // everyone access fields
     verifyHsJobGeneric(job, info.getString("id"), info.getString("user"),
     verifyHsJobGeneric(job, info.getString("id"), info.getString("user"),
@@ -81,22 +81,22 @@ public class VerifyJobsUtils {
 
 
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
     WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
         id);
         id);
-    WebServicesTestUtils.checkStringMatch("user", job.getUserName().toString(),
+    WebServicesTestUtils.checkStringMatch("user", job.getUserName(),
         user);
         user);
     WebServicesTestUtils.checkStringMatch("name", job.getName(), name);
     WebServicesTestUtils.checkStringMatch("name", job.getName(), name);
     WebServicesTestUtils.checkStringMatch("state", job.getState().toString(),
     WebServicesTestUtils.checkStringMatch("state", job.getState().toString(),
         state);
         state);
     WebServicesTestUtils.checkStringMatch("queue", job.getQueueName(), queue);
     WebServicesTestUtils.checkStringMatch("queue", job.getQueueName(), queue);
 
 
-    assertEquals("startTime incorrect", report.getStartTime(), startTime);
-    assertEquals("finishTime incorrect", report.getFinishTime(), finishTime);
+    assertEquals(report.getStartTime(), startTime, "startTime incorrect");
+    assertEquals(report.getFinishTime(), finishTime, "finishTime incorrect");
 
 
-    assertEquals("mapsTotal incorrect", job.getTotalMaps(), mapsTotal);
-    assertEquals("mapsCompleted incorrect", job.getCompletedMaps(),
-        mapsCompleted);
-    assertEquals("reducesTotal incorrect", job.getTotalReduces(), reducesTotal);
-    assertEquals("reducesCompleted incorrect", job.getCompletedReduces(),
-        reducesCompleted);
+    assertEquals(job.getTotalMaps(), mapsTotal, "mapsTotal incorrect");
+    assertEquals(job.getCompletedMaps(),
+        mapsCompleted, "mapsCompleted incorrect");
+    assertEquals(job.getTotalReduces(), reducesTotal, "reducesTotal incorrect");
+    assertEquals(job.getCompletedReduces(),
+        reducesCompleted, "reducesCompleted incorrect");
   }
   }
 
 
   public static void verifyHsJobGenericSecure(Job job, Boolean uberized,
   public static void verifyHsJobGenericSecure(Job job, Boolean uberized,
@@ -117,25 +117,25 @@ public class VerifyJobsUtils {
     WebServicesTestUtils.checkStringMatch("diagnostics", diagString,
     WebServicesTestUtils.checkStringMatch("diagnostics", diagString,
         diagnostics);
         diagnostics);
 
 
-    assertEquals("isUber incorrect", job.isUber(), uberized);
+    assertEquals(job.isUber(), uberized, "isUber incorrect");
 
 
     // unfortunately the following fields are all calculated in JobInfo
     // unfortunately the following fields are all calculated in JobInfo
     // so not easily accessible without doing all the calculations again.
     // so not easily accessible without doing all the calculations again.
     // For now just make sure they are present.
     // For now just make sure they are present.
 
 
-    assertTrue("failedReduceAttempts not >= 0", failedReduceAttempts >= 0);
-    assertTrue("killedReduceAttempts not >= 0", killedReduceAttempts >= 0);
-    assertTrue("successfulReduceAttempts not >= 0",
-        successfulReduceAttempts >= 0);
+    assertTrue(failedReduceAttempts >= 0, "failedReduceAttempts not >= 0");
+    assertTrue(killedReduceAttempts >= 0, "killedReduceAttempts not >= 0");
+    assertTrue(successfulReduceAttempts >= 0,
+        "successfulReduceAttempts not >= 0");
 
 
-    assertTrue("failedMapAttempts not >= 0", failedMapAttempts >= 0);
-    assertTrue("killedMapAttempts not >= 0", killedMapAttempts >= 0);
-    assertTrue("successfulMapAttempts not >= 0", successfulMapAttempts >= 0);
+    assertTrue(failedMapAttempts >= 0, "failedMapAttempts not >= 0");
+    assertTrue(killedMapAttempts >= 0, "killedMapAttempts not >= 0");
+    assertTrue(successfulMapAttempts >= 0, "successfulMapAttempts not >= 0");
 
 
-    assertTrue("avgMapTime not >= 0", avgMapTime >= 0);
-    assertTrue("avgReduceTime not >= 0", avgReduceTime >= 0);
-    assertTrue("avgShuffleTime not >= 0", avgShuffleTime >= 0);
-    assertTrue("avgMergeTime not >= 0", avgMergeTime >= 0);
+    assertTrue(avgMapTime >= 0, "avgMapTime not >= 0");
+    assertTrue(avgReduceTime >= 0, "avgReduceTime not >= 0");
+    assertTrue(avgShuffleTime >= 0, "avgShuffleTime not >= 0");
+    assertTrue(avgMergeTime >= 0, "avgMergeTime not >= 0");
 
 
   }
   }
 
 

+ 13 - 13
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java

@@ -27,8 +27,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashMap;
 
 
-import org.junit.Assert;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.JobACLsManager;
 import org.apache.hadoop.mapred.JobACLsManager;
@@ -46,12 +44,16 @@ import org.apache.hadoop.mapreduce.v2.hs.HistoryFileManager.HistoryFileInfo;
 import org.apache.hadoop.mapreduce.v2.hs.CompletedJob;
 import org.apache.hadoop.mapreduce.v2.hs.CompletedJob;
 import org.apache.hadoop.mapreduce.v2.hs.TestJobHistoryEntities;
 import org.apache.hadoop.mapreduce.v2.hs.TestJobHistoryEntities;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
 import org.apache.hadoop.mapreduce.v2.util.MRBuilderUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 
 
 public class TestJobInfo {
 public class TestJobInfo {
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testAverageMergeTime() throws IOException {
   public void testAverageMergeTime() throws IOException {
     String historyFileName =
     String historyFileName =
         "job_1329348432655_0001-1329348443227-user-Sleep+job-1329348468601-10-1-SUCCEEDED-default.jhist";
         "job_1329348432655_0001-1329348443227-user-Sleep+job-1329348468601-10-1-SUCCEEDED-default.jhist";
@@ -72,14 +74,14 @@ public class TestJobInfo {
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getConfFile()).thenReturn(fullConfPath);
     when(info.getHistoryFile()).thenReturn(fulleHistoryPath);
     when(info.getHistoryFile()).thenReturn(fulleHistoryPath);
 
 
-    JobId jobId = MRBuilderUtils.newJobId(1329348432655l, 1, 1);
+    JobId jobId = MRBuilderUtils.newJobId(1329348432655L, 1, 1);
     CompletedJob completedJob =
     CompletedJob completedJob =
         new CompletedJob(conf, jobId, fulleHistoryPath, true, "user",
         new CompletedJob(conf, jobId, fulleHistoryPath, true, "user",
             info, jobAclsMgr);
             info, jobAclsMgr);
     JobInfo jobInfo = new JobInfo(completedJob);
     JobInfo jobInfo = new JobInfo(completedJob);
     // There are 2 tasks with merge time of 45 and 55 respectively. So average
     // There are 2 tasks with merge time of 45 and 55 respectively. So average
     // merge time should be 50.
     // merge time should be 50.
-    Assert.assertEquals(50L, jobInfo.getAvgMergeTime().longValue());
+    assertEquals(50L, jobInfo.getAvgMergeTime().longValue());
   }
   }
   
   
   @Test
   @Test
@@ -138,7 +140,7 @@ public class TestJobInfo {
   
   
     JobInfo jobInfo = new JobInfo(job);
     JobInfo jobInfo = new JobInfo(job);
   
   
-    Assert.assertEquals(11L, jobInfo.getAvgReduceTime().longValue());
+    assertEquals(11L, jobInfo.getAvgReduceTime().longValue());
   }
   }
 
 
   @Test
   @Test
@@ -155,13 +157,13 @@ public class TestJobInfo {
     when(job.getID()).thenReturn(jobId);
     when(job.getID()).thenReturn(jobId);
 
 
     JobInfo jobInfo = new JobInfo(job);
     JobInfo jobInfo = new JobInfo(job);
-    Assert.assertEquals(JobInfo.NA, jobInfo.getStartTimeStr());
+    assertEquals(JobInfo.NA, jobInfo.getStartTimeStr());
 
 
     Date date = new Date();
     Date date = new Date();
     when(jobReport.getStartTime()).thenReturn(date.getTime());
     when(jobReport.getStartTime()).thenReturn(date.getTime());
 
 
     jobInfo = new JobInfo(job);
     jobInfo = new JobInfo(job);
-    Assert.assertEquals(date.toString(), jobInfo.getStartTimeStr());
+    assertEquals(date.toString(), jobInfo.getStartTimeStr());
   }
   }
 
 
   @Test
   @Test
@@ -179,13 +181,11 @@ public class TestJobInfo {
     DateFormat dateFormat = new SimpleDateFormat();
     DateFormat dateFormat = new SimpleDateFormat();
 
 
     JobInfo jobInfo = new JobInfo(job);
     JobInfo jobInfo = new JobInfo(job);
-    Assert.assertEquals(
-        JobInfo.NA, jobInfo.getFormattedStartTimeStr(dateFormat));
+    assertEquals(JobInfo.NA, jobInfo.getFormattedStartTimeStr(dateFormat));
 
 
     Date date = new Date();
     Date date = new Date();
     when(jobReport.getStartTime()).thenReturn(date.getTime());
     when(jobReport.getStartTime()).thenReturn(date.getTime());
     jobInfo = new JobInfo(job);
     jobInfo = new JobInfo(job);
-    Assert.assertEquals(
-        dateFormat.format(date), jobInfo.getFormattedStartTimeStr(dateFormat));
+    assertEquals(dateFormat.format(date), jobInfo.getFormattedStartTimeStr(dateFormat));
   }
   }
 }
 }