소스 검색

YARN-6946. Upgrade JUnit from 4 to 5 in hadoop-yarn-common (#4717)

Co-authored-by: Ashutosh Gupta <ashugpt@amazon.com>
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
Ashutosh Gupta 2 년 전
부모
커밋
2e993fdf4e
100개의 변경된 파일3541개의 추가작업 그리고 3207개의 파일을 삭제
  1. 20 0
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml
  2. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/MockApps.java
  3. 11 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java
  4. 3 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLogAppender.java
  5. 17 17
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerResourceIncreaseRPC.java
  6. 10 10
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPCFactories.java
  7. 15 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRecordFactory.java
  8. 17 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRpcFactoryProvider.java
  9. 9 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestYarnUncaughtExceptionHandler.java
  10. 29 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/BasePBImplRecordsTest.java
  11. 25 21
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationAttemptId.java
  12. 19 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationId.java
  13. 14 10
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicatonReport.java
  14. 30 26
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java
  15. 43 50
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java
  16. 17 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestNodeId.java
  17. 182 180
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java
  18. 49 46
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPlacementConstraintPBConversion.java
  19. 69 66
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestResourcePBImpl.java
  20. 6 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestResourceRequest.java
  21. 19 14
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestTimelineEntityGroupId.java
  22. 35 28
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/TestGetApplicationsRequestPBImpl.java
  23. 50 46
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/TestResourceUtilization.java
  24. 17 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestApplicationClientProtocolRecords.java
  25. 37 28
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestApplicationSubmissionContextPBImpl.java
  26. 5 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestProtoUtils.java
  27. 23 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestSerializedExceptionPBImpl.java
  28. 79 75
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java
  29. 62 62
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timelineservice/TestTimelineServiceRecords.java
  30. 43 41
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraintTransformations.java
  31. 24 23
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/TestClientRMProxy.java
  32. 86 83
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java
  33. 28 27
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClientForATS1_5.java
  34. 105 88
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClientV2Impl.java
  35. 33 32
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineReaderClientImpl.java
  36. 52 55
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/conf/TestHAUtil.java
  37. 43 42
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfiguration.java
  38. 0 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/InlineDispatcher.java
  39. 56 45
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/TestAsyncDispatcher.java
  40. 5 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/factories/impl/pb/TestRpcClientFactoryPBImpl.java
  41. 5 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/factories/impl/pb/TestRpcServerFactoryPBImpl.java
  42. 26 27
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/ipc/TestRPCUtil.java
  43. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/LogAggregationTestUtils.java
  44. 155 154
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogDeletionService.java
  45. 48 43
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java
  46. 20 20
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogsBlock.java
  47. 3 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestContainerLogsUtils.java
  48. 27 24
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestLogAggregationMetaCollector.java
  49. 5 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/FakeLogAggregationFileController.java
  50. 16 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/TestLogAggregationFileController.java
  51. 77 65
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/TestLogAggregationFileControllerFactory.java
  52. 51 47
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/TestLogAggregationIndexedFileController.java
  53. 3 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/AggregatedLogDeletionServiceForTest.java
  54. 23 16
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/LogAggregationTestcase.java
  55. 6 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/LogAggregationTestcaseBuilder.java
  56. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/MockRMClientUtils.java
  57. 27 23
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/NodeLabelTestBase.java
  58. 154 132
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java
  59. 76 66
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
  60. 21 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestNodeLabelUtil.java
  61. 6 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/resourcetypes/ResourceTypesTestHelper.java
  62. 14 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestDockerClientConfigHandler.java
  63. 157 176
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java
  64. 37 36
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/server/security/TestApplicationACLsManager.java
  65. 17 16
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestAdHocLogDumper.java
  66. 14 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestApps.java
  67. 35 32
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestBoundedAppender.java
  68. 36 28
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java
  69. 139 129
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java
  70. 11 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestLRUCacheHashMap.java
  71. 95 100
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestLog4jWarningErrorMetricsAppender.java
  72. 130 133
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java
  73. 20 18
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestRackResolver.java
  74. 6 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestRackResolverScriptBasedMapping.java
  75. 9 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestResourceCalculatorProcessTree.java
  76. 13 12
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestTimelineServiceHelper.java
  77. 19 19
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestTimes.java
  78. 11 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestWindowsBasedProcessTree.java
  79. 16 17
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java
  80. 8 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/CustomResourceTypesConfigurationProvider.java
  81. 90 67
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceCalculator.java
  82. 119 120
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java
  83. 86 67
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResources.java
  84. 10 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/timeline/TestShortenedFlowName.java
  85. 2 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java
  86. 2 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestJAXBContextResolver.java
  87. 1 0
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java
  88. 39 27
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/TestParseRoute.java
  89. 10 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/TestSubViews.java
  90. 83 68
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/TestWebApp.java
  91. 9 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java
  92. 26 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/hamlet2/TestHamlet.java
  93. 21 8
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/hamlet2/TestHamletImpl.java
  94. 21 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/hamlet2/TestParseSelector.java
  95. 0 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/log/AggregatedLogsBlockForTest.java
  96. 25 18
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/test/TestWebAppTests.java
  97. 14 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/test/WebAppTests.java
  98. 34 31
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java
  99. 9 6
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebServiceClient.java
  100. 11 11
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/view/TestCommonViews.java

+ 20 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/pom.xml

@@ -138,6 +138,26 @@
       <artifactId>bcprov-jdk15on</artifactId>
       <artifactId>bcprov-jdk15on</artifactId>
       <scope>test</scope>
       <scope>test</scope>
     </dependency>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.platform</groupId>
+      <artifactId>junit-platform-launcher</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
     <dependency>
       <groupId>com.sun.jersey.jersey-test-framework</groupId>
       <groupId>com.sun.jersey.jersey-test-framework</groupId>
       <artifactId>jersey-test-framework-grizzly2</artifactId>
       <artifactId>jersey-test-framework-grizzly2</artifactId>

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/MockApps.java

@@ -20,11 +20,11 @@ package org.apache.hadoop.yarn;
 
 
 import java.util.Iterator;
 import java.util.Iterator;
 
 
+import org.apache.hadoop.thirdparty.com.google.common.collect.Iterators;
+
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.collect.Iterators;
-
 /**
 /**
  * Utilities to generate fake test apps
  * Utilities to generate fake test apps
  */
  */

+ 11 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java

@@ -24,8 +24,10 @@ import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.net.NetUtils;
@@ -35,12 +37,12 @@ import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
 import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.CommitResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.ContainerUpdateResponse;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
+import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.GetLocalizationStatusesRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.GetLocalizationStatusesRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.GetLocalizationStatusesResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.GetLocalizationStatusesResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse;
-import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesRequest;
-import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusesResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.ReInitializeContainerResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest;
@@ -70,8 +72,9 @@ import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
 import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
 import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
 import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /*
 /*
  * Test that the container launcher rpc times out properly. This is used
  * Test that the container launcher rpc times out properly. This is used
@@ -86,7 +89,7 @@ public class TestContainerLaunchRPC {
       .getRecordFactory(null);
       .getRecordFactory(null);
 
 
   @Test
   @Test
-  public void testHadoopProtoRPCTimeout() throws Exception {
+  void testHadoopProtoRPCTimeout() throws Exception {
     testRPCTimeout(HadoopYarnProtoRPC.class.getName());
     testRPCTimeout(HadoopYarnProtoRPC.class.getName());
   }
   }
 
 
@@ -136,16 +139,15 @@ public class TestContainerLaunchRPC {
         proxy.startContainers(allRequests);
         proxy.startContainers(allRequests);
       } catch (Exception e) {
       } catch (Exception e) {
         LOG.info(StringUtils.stringifyException(e));
         LOG.info(StringUtils.stringifyException(e));
-        Assert.assertEquals("Error, exception is not: "
-            + SocketTimeoutException.class.getName(),
-            SocketTimeoutException.class.getName(), e.getClass().getName());
+        assertEquals(SocketTimeoutException.class.getName(), e.getClass().getName(),
+            "Error, exception is not: " + SocketTimeoutException.class.getName());
         return;
         return;
       }
       }
     } finally {
     } finally {
       server.stop();
       server.stop();
     }
     }
 
 
-    Assert.fail("timeout exception should have occurred!");
+    fail("timeout exception should have occurred!");
   }
   }
 
 
   public static Token newContainerToken(NodeId nodeId, byte[] password,
   public static Token newContainerToken(NodeId nodeId, byte[] password,

+ 3 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLogAppender.java

@@ -18,14 +18,15 @@
 
 
 package org.apache.hadoop.yarn;
 package org.apache.hadoop.yarn;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.log4j.Logger;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PatternLayout;
 import org.apache.log4j.PatternLayout;
-import org.junit.Test;
 
 
 public class TestContainerLogAppender {
 public class TestContainerLogAppender {
 
 
   @Test
   @Test
-  public void testAppendInClose() throws Exception {
+  void testAppendInClose() throws Exception {
     final ContainerLogAppender claAppender = new ContainerLogAppender();
     final ContainerLogAppender claAppender = new ContainerLogAppender();
     claAppender.setName("testCLA");
     claAppender.setName("testCLA");
     claAppender.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
     claAppender.setLayout(new PatternLayout("%-5p [%t]: %m%n"));

+ 17 - 17
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerResourceIncreaseRPC.java

@@ -18,8 +18,16 @@
 
 
 package org.apache.hadoop.yarn;
 package org.apache.hadoop.yarn;
 
 
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.net.NetUtils;
@@ -59,14 +67,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
 import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
 import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
-import org.junit.Assert;
-import org.junit.Test;
 
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketTimeoutException;
-import java.util.ArrayList;
-import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /*
 /*
  * Test that the container resource increase rpc times out properly.
  * Test that the container resource increase rpc times out properly.
@@ -78,7 +81,7 @@ public class TestContainerResourceIncreaseRPC {
       TestContainerResourceIncreaseRPC.class);
       TestContainerResourceIncreaseRPC.class);
 
 
   @Test
   @Test
-  public void testHadoopProtoRPCTimeout() throws Exception {
+  void testHadoopProtoRPCTimeout() throws Exception {
     testRPCTimeout(HadoopYarnProtoRPC.class.getName());
     testRPCTimeout(HadoopYarnProtoRPC.class.getName());
   }
   }
 
 
@@ -122,15 +125,14 @@ public class TestContainerResourceIncreaseRPC {
         proxy.updateContainer(request);
         proxy.updateContainer(request);
       } catch (Exception e) {
       } catch (Exception e) {
         LOG.info(StringUtils.stringifyException(e));
         LOG.info(StringUtils.stringifyException(e));
-        Assert.assertEquals("Error, exception is not: "
-            + SocketTimeoutException.class.getName(),
-            SocketTimeoutException.class.getName(), e.getClass().getName());
+        assertEquals(SocketTimeoutException.class.getName(), e.getClass().getName(),
+            "Error, exception is not: " + SocketTimeoutException.class.getName());
         return;
         return;
       }
       }
     } finally {
     } finally {
       server.stop();
       server.stop();
     }
     }
-    Assert.fail("timeout exception should have occurred!");
+    fail("timeout exception should have occurred!");
   }
   }
 
 
   public static Token newContainerToken(NodeId nodeId, byte[] password,
   public static Token newContainerToken(NodeId nodeId, byte[] password,
@@ -157,11 +159,9 @@ public class TestContainerResourceIncreaseRPC {
     }
     }
 
 
     @Override
     @Override
-    public StopContainersResponse
-    stopContainers(StopContainersRequest requests) throws YarnException,
-        IOException {
-      Exception e = new Exception("Dummy function", new Exception(
-          "Dummy function cause"));
+    public StopContainersResponse stopContainers(StopContainersRequest requests)
+        throws YarnException, IOException {
+      Exception e = new Exception("Dummy function", new Exception("Dummy function cause"));
       throw new YarnException(e);
       throw new YarnException(e);
     }
     }
 
 

+ 10 - 10
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPCFactories.java

@@ -21,7 +21,7 @@ package org.apache.hadoop.yarn;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.InetSocketAddress;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.ipc.Server;
 import org.apache.hadoop.ipc.Server;
@@ -37,16 +37,16 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestRPCFactories {
 public class TestRPCFactories {
-  
-  
-  
+
+
   @Test
   @Test
-  public void test() {
+  void test() {
     testPbServerFactory();
     testPbServerFactory();
-    
+
     testPbClientFactory();
     testPbClientFactory();
   }
   }
   
   
@@ -64,7 +64,7 @@ public class TestRPCFactories {
       server.start();
       server.start();
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
       e.printStackTrace();
       e.printStackTrace();
-      Assert.fail("Failed to create server");
+      fail("Failed to create server");
     } finally {
     } finally {
       if (server != null) {
       if (server != null) {
         server.stop();
         server.stop();
@@ -92,12 +92,12 @@ public class TestRPCFactories {
         amrmClient = (ApplicationMasterProtocol) RpcClientFactoryPBImpl.get().getClient(ApplicationMasterProtocol.class, 1, NetUtils.getConnectAddress(server), conf);
         amrmClient = (ApplicationMasterProtocol) RpcClientFactoryPBImpl.get().getClient(ApplicationMasterProtocol.class, 1, NetUtils.getConnectAddress(server), conf);
       } catch (YarnRuntimeException e) {
       } catch (YarnRuntimeException e) {
         e.printStackTrace();
         e.printStackTrace();
-        Assert.fail("Failed to create client");
+        fail("Failed to create client");
       }
       }
       
       
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
       e.printStackTrace();
       e.printStackTrace();
-      Assert.fail("Failed to create server");
+      fail("Failed to create server");
     } finally {
     } finally {
       if (server != null) {
       if (server != null) {
         server.stop();
         server.stop();

+ 15 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRecordFactory.java

@@ -18,39 +18,41 @@
 
 
 package org.apache.hadoop.yarn;
 package org.apache.hadoop.yarn;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
-import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.apache.hadoop.yarn.factories.RecordFactory;
-import org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl;
 import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse;
 import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl;
 import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl;
 import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl;
 import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl;
-import org.junit.Test;
+import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
+import org.apache.hadoop.yarn.factories.RecordFactory;
+import org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestRecordFactory {
 public class TestRecordFactory {
-  
+
   @Test
   @Test
-  public void testPbRecordFactory() {
+  void testPbRecordFactory() {
     RecordFactory pbRecordFactory = RecordFactoryPBImpl.get();
     RecordFactory pbRecordFactory = RecordFactoryPBImpl.get();
-    
+
     try {
     try {
       AllocateResponse response =
       AllocateResponse response =
           pbRecordFactory.newRecordInstance(AllocateResponse.class);
           pbRecordFactory.newRecordInstance(AllocateResponse.class);
-      Assert.assertEquals(AllocateResponsePBImpl.class, response.getClass());
+      assertEquals(AllocateResponsePBImpl.class, response.getClass());
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
       e.printStackTrace();
       e.printStackTrace();
-      Assert.fail("Failed to crete record");
+      fail("Failed to crete record");
     }
     }
-    
+
     try {
     try {
       AllocateRequest response =
       AllocateRequest response =
           pbRecordFactory.newRecordInstance(AllocateRequest.class);
           pbRecordFactory.newRecordInstance(AllocateRequest.class);
-      Assert.assertEquals(AllocateRequestPBImpl.class, response.getClass());
+      assertEquals(AllocateRequestPBImpl.class, response.getClass());
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
       e.printStackTrace();
       e.printStackTrace();
-      Assert.fail("Failed to crete record");
+      fail("Failed to crete record");
     }
     }
   }
   }
 
 

+ 17 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRpcFactoryProvider.java

@@ -18,7 +18,7 @@
 
 
 package org.apache.hadoop.yarn;
 package org.apache.hadoop.yarn;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
@@ -28,21 +28,23 @@ import org.apache.hadoop.yarn.factories.RpcServerFactory;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl;
 import org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl;
 import org.apache.hadoop.yarn.factory.providers.RpcFactoryProvider;
 import org.apache.hadoop.yarn.factory.providers.RpcFactoryProvider;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestRpcFactoryProvider {
 public class TestRpcFactoryProvider {
 
 
   @Test
   @Test
-  public void testFactoryProvider() {
+  void testFactoryProvider() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     RpcClientFactory clientFactory = null;
     RpcClientFactory clientFactory = null;
     RpcServerFactory serverFactory = null;
     RpcServerFactory serverFactory = null;
-    
-    
+
+
     clientFactory = RpcFactoryProvider.getClientFactory(conf);
     clientFactory = RpcFactoryProvider.getClientFactory(conf);
     serverFactory = RpcFactoryProvider.getServerFactory(conf);
     serverFactory = RpcFactoryProvider.getServerFactory(conf);
-    Assert.assertEquals(RpcClientFactoryPBImpl.class, clientFactory.getClass());
-    Assert.assertEquals(RpcServerFactoryPBImpl.class, serverFactory.getClass());
+    assertEquals(RpcClientFactoryPBImpl.class, clientFactory.getClass());
+    assertEquals(RpcServerFactoryPBImpl.class, serverFactory.getClass());
 
 
     conf.set(YarnConfiguration.IPC_CLIENT_FACTORY_CLASS, "unknown");
     conf.set(YarnConfiguration.IPC_CLIENT_FACTORY_CLASS, "unknown");
     conf.set(YarnConfiguration.IPC_SERVER_FACTORY_CLASS, "unknown");
     conf.set(YarnConfiguration.IPC_SERVER_FACTORY_CLASS, "unknown");
@@ -50,28 +52,30 @@ public class TestRpcFactoryProvider {
 
 
     try {
     try {
       clientFactory = RpcFactoryProvider.getClientFactory(conf);
       clientFactory = RpcFactoryProvider.getClientFactory(conf);
-      Assert.fail("Expected an exception - unknown serializer");
+      fail("Expected an exception - unknown serializer");
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
     }
     }
     try {
     try {
       serverFactory = RpcFactoryProvider.getServerFactory(conf);
       serverFactory = RpcFactoryProvider.getServerFactory(conf);
-      Assert.fail("Expected an exception - unknown serializer");
+      fail("Expected an exception - unknown serializer");
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
     }
     }
-    
+
     conf = new Configuration();
     conf = new Configuration();
     conf.set(YarnConfiguration.IPC_CLIENT_FACTORY_CLASS, "NonExistantClass");
     conf.set(YarnConfiguration.IPC_CLIENT_FACTORY_CLASS, "NonExistantClass");
     conf.set(YarnConfiguration.IPC_SERVER_FACTORY_CLASS, RpcServerFactoryPBImpl.class.getName());
     conf.set(YarnConfiguration.IPC_SERVER_FACTORY_CLASS, RpcServerFactoryPBImpl.class.getName());
-    
+
     try {
     try {
       clientFactory = RpcFactoryProvider.getClientFactory(conf);
       clientFactory = RpcFactoryProvider.getClientFactory(conf);
-      Assert.fail("Expected an exception - unknown class");
+      fail("Expected an exception - unknown class");
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
     }
     }
     try {
     try {
       serverFactory = RpcFactoryProvider.getServerFactory(conf);
       serverFactory = RpcFactoryProvider.getServerFactory(conf);
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      Assert.fail("Error while loading factory using reflection: [" + RpcServerFactoryPBImpl.class.getName() + "]");
+      fail(
+          "Error while loading factory using reflection: [" + RpcServerFactoryPBImpl.class.getName()
+              + "]");
     }
     }
   }
   }
 }
 }

+ 9 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestYarnUncaughtExceptionHandler.java

@@ -18,18 +18,20 @@
 
 
 package org.apache.hadoop.yarn;
 package org.apache.hadoop.yarn;
 
 
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.util.ExitUtil;
 import org.apache.hadoop.util.ExitUtil;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 
 
 public class TestYarnUncaughtExceptionHandler {
 public class TestYarnUncaughtExceptionHandler {
 
 
   private static final YarnUncaughtExceptionHandler exHandler =
   private static final YarnUncaughtExceptionHandler exHandler =
         new YarnUncaughtExceptionHandler();
         new YarnUncaughtExceptionHandler();
+
   /**
   /**
    * Throw {@code YarnRuntimeException} inside thread and
    * Throw {@code YarnRuntimeException} inside thread and
    * check {@code YarnUncaughtExceptionHandler} instance
    * check {@code YarnUncaughtExceptionHandler} instance
@@ -37,7 +39,7 @@ public class TestYarnUncaughtExceptionHandler {
    * @throws InterruptedException
    * @throws InterruptedException
    */
    */
   @Test
   @Test
-  public void testUncaughtExceptionHandlerWithRuntimeException()
+  void testUncaughtExceptionHandlerWithRuntimeException()
       throws InterruptedException {
       throws InterruptedException {
     final YarnUncaughtExceptionHandler spyYarnHandler = spy(exHandler);
     final YarnUncaughtExceptionHandler spyYarnHandler = spy(exHandler);
     final YarnRuntimeException yarnException = new YarnRuntimeException(
     final YarnRuntimeException yarnException = new YarnRuntimeException(
@@ -67,7 +69,7 @@ public class TestYarnUncaughtExceptionHandler {
    * @throws InterruptedException
    * @throws InterruptedException
    */
    */
   @Test
   @Test
-  public void testUncaughtExceptionHandlerWithError()
+  void testUncaughtExceptionHandlerWithError()
       throws InterruptedException {
       throws InterruptedException {
     ExitUtil.disableSystemExit();
     ExitUtil.disableSystemExit();
     final YarnUncaughtExceptionHandler spyErrorHandler = spy(exHandler);
     final YarnUncaughtExceptionHandler spyErrorHandler = spy(exHandler);
@@ -96,7 +98,7 @@ public class TestYarnUncaughtExceptionHandler {
    * @throws InterruptedException
    * @throws InterruptedException
    */
    */
   @Test
   @Test
-  public void testUncaughtExceptionHandlerWithOutOfMemoryError()
+  void testUncaughtExceptionHandlerWithOutOfMemoryError()
       throws InterruptedException {
       throws InterruptedException {
     ExitUtil.disableSystemHalt();
     ExitUtil.disableSystemHalt();
     final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler);
     final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler);

+ 29 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/BasePBImplRecordsTest.java

@@ -17,6 +17,25 @@
  */
  */
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.nio.ByteBuffer;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.commons.lang3.Range;
 import org.apache.commons.lang3.Range;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.util.Lists;
 import org.apache.hadoop.util.Lists;
@@ -24,20 +43,12 @@ import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraints;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraints;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
-
-import org.junit.Assert;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.*;
-import java.nio.ByteBuffer;
-import java.util.*;
-
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.NODE;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.NODE;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints
-    .PlacementTargets.allocationTag;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.allocationTag;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
 import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Generic helper class to validate protocol records.
  * Generic helper class to validate protocol records.
@@ -223,7 +234,7 @@ public class BasePBImplRecordsTest {
             p.getMethod = m;
             p.getMethod = m;
             ret.put(propertyName, p);
             ret.put(propertyName, p);
           } else {
           } else {
-            Assert.fail("Multiple get method with same name: " + recordClass
+            fail("Multiple get method with same name: " + recordClass
                 + p.propertyName);
                 + p.propertyName);
           }
           }
         }
         }
@@ -284,18 +295,17 @@ public class BasePBImplRecordsTest {
       gsp.setMethod.invoke(origRecord, gsp.testValue);
       gsp.setMethod.invoke(origRecord, gsp.testValue);
     }
     }
     Object ret = getProto.invoke(origRecord);
     Object ret = getProto.invoke(origRecord);
-    Assert.assertNotNull(recordClass.getName() + "#getProto returns null", ret);
+    assertNotNull(ret, recordClass.getName() + "#getProto returns null");
     if (!(protoClass.isAssignableFrom(ret.getClass()))) {
     if (!(protoClass.isAssignableFrom(ret.getClass()))) {
-      Assert.fail("Illegal getProto method return type: " + ret.getClass());
+      fail("Illegal getProto method return type: " + ret.getClass());
     }
     }
     R deserRecord = pbConstructor.newInstance(ret);
     R deserRecord = pbConstructor.newInstance(ret);
-    Assert.assertEquals("whole " + recordClass + " records should be equal",
-        origRecord, deserRecord);
+    assertEquals(origRecord, deserRecord, "whole " + recordClass + " records should be equal");
     for (GetSetPair gsp : getSetPairs.values()) {
     for (GetSetPair gsp : getSetPairs.values()) {
       Object origValue = gsp.getMethod.invoke(origRecord);
       Object origValue = gsp.getMethod.invoke(origRecord);
       Object deserValue = gsp.getMethod.invoke(deserRecord);
       Object deserValue = gsp.getMethod.invoke(deserRecord);
-      Assert.assertEquals("property " + recordClass.getName() + "#"
-          + gsp.propertyName + " should be equal", origValue, deserValue);
+      assertEquals(origValue, deserValue, "property " + recordClass.getName() + "#"
+          + gsp.propertyName + " should be equal");
     }
     }
   }
   }
 }
 }

+ 25 - 21
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationAttemptId.java

@@ -19,41 +19,45 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.junit.Test;
+
+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.assertTrue;
 
 
 public class TestApplicationAttemptId {
 public class TestApplicationAttemptId {
 
 
   @Test
   @Test
-  public void testApplicationAttemptId() {
+  void testApplicationAttemptId() {
     ApplicationAttemptId a1 = createAppAttemptId(10l, 1, 1);
     ApplicationAttemptId a1 = createAppAttemptId(10l, 1, 1);
     ApplicationAttemptId a2 = createAppAttemptId(10l, 1, 2);
     ApplicationAttemptId a2 = createAppAttemptId(10l, 1, 2);
     ApplicationAttemptId a3 = createAppAttemptId(10l, 2, 1);
     ApplicationAttemptId a3 = createAppAttemptId(10l, 2, 1);
     ApplicationAttemptId a4 = createAppAttemptId(8l, 1, 4);
     ApplicationAttemptId a4 = createAppAttemptId(8l, 1, 4);
     ApplicationAttemptId a5 = createAppAttemptId(10l, 1, 1);
     ApplicationAttemptId a5 = createAppAttemptId(10l, 1, 1);
-    
-    Assert.assertTrue(a1.equals(a5));
-    Assert.assertFalse(a1.equals(a2));
-    Assert.assertFalse(a1.equals(a3));
-    Assert.assertFalse(a1.equals(a4));
-    
-    Assert.assertTrue(a1.compareTo(a5) == 0);
-    Assert.assertTrue(a1.compareTo(a2) < 0);
-    Assert.assertTrue(a1.compareTo(a3) < 0);
-    Assert.assertTrue(a1.compareTo(a4) > 0);
-    
-    Assert.assertTrue(a1.hashCode() == a5.hashCode());
-    Assert.assertFalse(a1.hashCode() == a2.hashCode());
-    Assert.assertFalse(a1.hashCode() == a3.hashCode());
-    Assert.assertFalse(a1.hashCode() == a4.hashCode());
-    
+
+    assertEquals(a1, a5);
+    assertNotEquals(a1, a2);
+    assertNotEquals(a1, a3);
+    assertNotEquals(a1, a4);
+
+    assertTrue(a1.compareTo(a5) == 0);
+    assertTrue(a1.compareTo(a2) < 0);
+    assertTrue(a1.compareTo(a3) < 0);
+    assertTrue(a1.compareTo(a4) > 0);
+
+    assertTrue(a1.hashCode() == a5.hashCode());
+    assertFalse(a1.hashCode() == a2.hashCode());
+    assertFalse(a1.hashCode() == a3.hashCode());
+    assertFalse(a1.hashCode() == a4.hashCode());
+
     long ts = System.currentTimeMillis();
     long ts = System.currentTimeMillis();
     ApplicationAttemptId a6 = createAppAttemptId(ts, 543627, 33492611);
     ApplicationAttemptId a6 = createAppAttemptId(ts, 543627, 33492611);
-    Assert.assertEquals("appattempt_10_0001_000001", a1.toString());
-    Assert.assertEquals("appattempt_" + ts + "_543627_33492611", a6.toString());
+    assertEquals("appattempt_10_0001_000001", a1.toString());
+    assertEquals("appattempt_" + ts + "_543627_33492611", a6.toString());
   }
   }
 
 
   private ApplicationAttemptId createAppAttemptId(
   private ApplicationAttemptId createAppAttemptId(

+ 19 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationId.java

@@ -18,36 +18,40 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.junit.Test;
+
+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.assertTrue;
 
 
 public class TestApplicationId {
 public class TestApplicationId {
 
 
   @Test
   @Test
-  public void testApplicationId() {
+  void testApplicationId() {
     ApplicationId a1 = ApplicationId.newInstance(10l, 1);
     ApplicationId a1 = ApplicationId.newInstance(10l, 1);
     ApplicationId a2 = ApplicationId.newInstance(10l, 2);
     ApplicationId a2 = ApplicationId.newInstance(10l, 2);
     ApplicationId a3 = ApplicationId.newInstance(10l, 1);
     ApplicationId a3 = ApplicationId.newInstance(10l, 1);
     ApplicationId a4 = ApplicationId.newInstance(8l, 3);
     ApplicationId a4 = ApplicationId.newInstance(8l, 3);
 
 
-    Assert.assertFalse(a1.equals(a2));
-    Assert.assertFalse(a1.equals(a4));
-    Assert.assertTrue(a1.equals(a3));
+    assertNotEquals(a1, a2);
+    assertNotEquals(a1, a4);
+    assertEquals(a1, a3);
+
+    assertTrue(a1.compareTo(a2) < 0);
+    assertTrue(a1.compareTo(a3) == 0);
+    assertTrue(a1.compareTo(a4) > 0);
 
 
-    Assert.assertTrue(a1.compareTo(a2) < 0);
-    Assert.assertTrue(a1.compareTo(a3) == 0);
-    Assert.assertTrue(a1.compareTo(a4) > 0);
+    assertTrue(a1.hashCode() == a3.hashCode());
+    assertFalse(a1.hashCode() == a2.hashCode());
+    assertFalse(a2.hashCode() == a4.hashCode());
 
 
-    Assert.assertTrue(a1.hashCode() == a3.hashCode());
-    Assert.assertFalse(a1.hashCode() == a2.hashCode());
-    Assert.assertFalse(a2.hashCode() == a4.hashCode());
-    
     long ts = System.currentTimeMillis();
     long ts = System.currentTimeMillis();
     ApplicationId a5 = ApplicationId.newInstance(ts, 45436343);
     ApplicationId a5 = ApplicationId.newInstance(ts, 45436343);
-    Assert.assertEquals("application_10_0001", a1.toString());
-    Assert.assertEquals("application_" + ts + "_45436343", a5.toString());
+    assertEquals("application_10_0001", a1.toString());
+    assertEquals("application_" + ts + "_45436343", a5.toString());
   }
   }
 
 
 }
 }

+ 14 - 10
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicatonReport.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
@@ -25,13 +27,15 @@ import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 public class TestApplicatonReport {
 public class TestApplicatonReport {
 
 
   @Test
   @Test
-  public void testApplicationReport() {
+  void testApplicationReport() {
     long timestamp = System.currentTimeMillis();
     long timestamp = System.currentTimeMillis();
     ApplicationReport appReport1 =
     ApplicationReport appReport1 =
         createApplicationReport(1, 1, timestamp);
         createApplicationReport(1, 1, timestamp);
@@ -39,15 +43,15 @@ public class TestApplicatonReport {
         createApplicationReport(1, 1, timestamp);
         createApplicationReport(1, 1, timestamp);
     ApplicationReport appReport3 =
     ApplicationReport appReport3 =
         createApplicationReport(1, 1, timestamp);
         createApplicationReport(1, 1, timestamp);
-    Assert.assertEquals(appReport1, appReport2);
-    Assert.assertEquals(appReport2, appReport3);
+    assertEquals(appReport1, appReport2);
+    assertEquals(appReport2, appReport3);
     appReport1.setApplicationId(null);
     appReport1.setApplicationId(null);
-    Assert.assertNull(appReport1.getApplicationId());
-    Assert.assertNotSame(appReport1, appReport2);
+    assertNull(appReport1.getApplicationId());
+    assertNotSame(appReport1, appReport2);
     appReport2.setCurrentApplicationAttemptId(null);
     appReport2.setCurrentApplicationAttemptId(null);
-    Assert.assertNull(appReport2.getCurrentApplicationAttemptId());
-    Assert.assertNotSame(appReport2, appReport3);
-    Assert.assertNull(appReport1.getAMRMToken());
+    assertNull(appReport2.getCurrentApplicationAttemptId());
+    assertNotSame(appReport2, appReport3);
+    assertNull(appReport1.getAMRMToken());
   }
   }
 
 
   protected static ApplicationReport createApplicationReport(
   protected static ApplicationReport createApplicationReport(

+ 30 - 26
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java

@@ -19,57 +19,61 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.junit.Test;
+
+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.assertTrue;
 
 
 public class TestContainerId {
 public class TestContainerId {
 
 
   @Test
   @Test
-  public void testContainerId() {
+  void testContainerId() {
     ContainerId c1 = newContainerId(1, 1, 10l, 1);
     ContainerId c1 = newContainerId(1, 1, 10l, 1);
     ContainerId c2 = newContainerId(1, 1, 10l, 2);
     ContainerId c2 = newContainerId(1, 1, 10l, 2);
     ContainerId c3 = newContainerId(1, 1, 10l, 1);
     ContainerId c3 = newContainerId(1, 1, 10l, 1);
     ContainerId c4 = newContainerId(1, 3, 10l, 1);
     ContainerId c4 = newContainerId(1, 3, 10l, 1);
     ContainerId c5 = newContainerId(1, 3, 8l, 1);
     ContainerId c5 = newContainerId(1, 3, 8l, 1);
 
 
-    Assert.assertTrue(c1.equals(c3));
-    Assert.assertFalse(c1.equals(c2));
-    Assert.assertFalse(c1.equals(c4));
-    Assert.assertFalse(c1.equals(c5));
+    assertEquals(c1, c3);
+    assertNotEquals(c1, c2);
+    assertNotEquals(c1, c4);
+    assertNotEquals(c1, c5);
+
+    assertTrue(c1.compareTo(c3) == 0);
+    assertTrue(c1.compareTo(c2) < 0);
+    assertTrue(c1.compareTo(c4) < 0);
+    assertTrue(c1.compareTo(c5) > 0);
 
 
-    Assert.assertTrue(c1.compareTo(c3) == 0);
-    Assert.assertTrue(c1.compareTo(c2) < 0);
-    Assert.assertTrue(c1.compareTo(c4) < 0);
-    Assert.assertTrue(c1.compareTo(c5) > 0);
+    assertTrue(c1.hashCode() == c3.hashCode());
+    assertFalse(c1.hashCode() == c2.hashCode());
+    assertFalse(c1.hashCode() == c4.hashCode());
+    assertFalse(c1.hashCode() == c5.hashCode());
 
 
-    Assert.assertTrue(c1.hashCode() == c3.hashCode());
-    Assert.assertFalse(c1.hashCode() == c2.hashCode());
-    Assert.assertFalse(c1.hashCode() == c4.hashCode());
-    Assert.assertFalse(c1.hashCode() == c5.hashCode());
-    
     long ts = System.currentTimeMillis();
     long ts = System.currentTimeMillis();
     ContainerId c6 = newContainerId(36473, 4365472, ts, 25645811);
     ContainerId c6 = newContainerId(36473, 4365472, ts, 25645811);
-    Assert.assertEquals("container_10_0001_01_000001", c1.toString());
-    Assert.assertEquals(25645811, 0xffffffffffL & c6.getContainerId());
-    Assert.assertEquals(0, c6.getContainerId() >> 40);
-    Assert.assertEquals("container_" + ts + "_36473_4365472_25645811",
+    assertEquals("container_10_0001_01_000001", c1.toString());
+    assertEquals(25645811, 0xffffffffffL & c6.getContainerId());
+    assertEquals(0, c6.getContainerId() >> 40);
+    assertEquals("container_" + ts + "_36473_4365472_25645811",
         c6.toString());
         c6.toString());
 
 
     ContainerId c7 = newContainerId(36473, 4365472, ts, 4298334883325L);
     ContainerId c7 = newContainerId(36473, 4365472, ts, 4298334883325L);
-    Assert.assertEquals(999799999997L, 0xffffffffffL & c7.getContainerId());
-    Assert.assertEquals(3, c7.getContainerId() >> 40);
-    Assert.assertEquals(
+    assertEquals(999799999997L, 0xffffffffffL & c7.getContainerId());
+    assertEquals(3, c7.getContainerId() >> 40);
+    assertEquals(
         "container_e03_" + ts + "_36473_4365472_999799999997",
         "container_e03_" + ts + "_36473_4365472_999799999997",
         c7.toString());
         c7.toString());
 
 
     ContainerId c8 = newContainerId(36473, 4365472, ts, 844424930131965L);
     ContainerId c8 = newContainerId(36473, 4365472, ts, 844424930131965L);
-    Assert.assertEquals(1099511627773L, 0xffffffffffL & c8.getContainerId());
-    Assert.assertEquals(767, c8.getContainerId() >> 40);
-    Assert.assertEquals(
+    assertEquals(1099511627773L, 0xffffffffffL & c8.getContainerId());
+    assertEquals(767, c8.getContainerId() >> 40);
+    assertEquals(
         "container_e767_" + ts + "_36473_4365472_1099511627773",
         "container_e767_" + ts + "_36473_4365472_1099511627773",
         c8.toString());
         c8.toString());
   }
   }

+ 43 - 50
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestGetApplicationsRequest.java

@@ -21,93 +21,86 @@ import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Set;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.commons.lang3.Range;
 import org.apache.commons.lang3.Range;
 import org.apache.hadoop.yarn.api.protocolrecords.ApplicationsRequestScope;
 import org.apache.hadoop.yarn.api.protocolrecords.ApplicationsRequestScope;
 import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsRequestPBImpl;
 import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.GetApplicationsRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestGetApplicationsRequest {
 public class TestGetApplicationsRequest {
 
 
   @Test
   @Test
-  public void testGetApplicationsRequest(){
+  void testGetApplicationsRequest() {
     GetApplicationsRequest request = GetApplicationsRequest.newInstance();
     GetApplicationsRequest request = GetApplicationsRequest.newInstance();
-    
-    EnumSet<YarnApplicationState> appStates = 
-      EnumSet.of(YarnApplicationState.ACCEPTED);
+
+    EnumSet<YarnApplicationState> appStates =
+        EnumSet.of(YarnApplicationState.ACCEPTED);
     request.setApplicationStates(appStates);
     request.setApplicationStates(appStates);
-    
+
     Set<String> tags = new HashSet<String>();
     Set<String> tags = new HashSet<String>();
     tags.add("tag1");
     tags.add("tag1");
     request.setApplicationTags(tags);
     request.setApplicationTags(tags);
-    
+
     Set<String> types = new HashSet<String>();
     Set<String> types = new HashSet<String>();
     types.add("type1");
     types.add("type1");
     request.setApplicationTypes(types);
     request.setApplicationTypes(types);
-    
+
     long startBegin = System.currentTimeMillis();
     long startBegin = System.currentTimeMillis();
     long startEnd = System.currentTimeMillis() + 1;
     long startEnd = System.currentTimeMillis() + 1;
     request.setStartRange(startBegin, startEnd);
     request.setStartRange(startBegin, startEnd);
     long finishBegin = System.currentTimeMillis() + 2;
     long finishBegin = System.currentTimeMillis() + 2;
     long finishEnd = System.currentTimeMillis() + 3;
     long finishEnd = System.currentTimeMillis() + 3;
     request.setFinishRange(finishBegin, finishEnd);
     request.setFinishRange(finishBegin, finishEnd);
-    
+
     long limit = 100L;
     long limit = 100L;
     request.setLimit(limit);
     request.setLimit(limit);
-    
+
     Set<String> queues = new HashSet<String>();
     Set<String> queues = new HashSet<String>();
     queues.add("queue1");
     queues.add("queue1");
     request.setQueues(queues);
     request.setQueues(queues);
-    
-    
+
+
     Set<String> users = new HashSet<String>();
     Set<String> users = new HashSet<String>();
     users.add("user1");
     users.add("user1");
     request.setUsers(users);
     request.setUsers(users);
-    
+
     ApplicationsRequestScope scope = ApplicationsRequestScope.ALL;
     ApplicationsRequestScope scope = ApplicationsRequestScope.ALL;
     request.setScope(scope);
     request.setScope(scope);
-    
+
     GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(
     GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(
-        ((GetApplicationsRequestPBImpl)request).getProto());
-    
+        ((GetApplicationsRequestPBImpl) request).getProto());
+
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals(requestFromProto, request);
+    assertEquals(requestFromProto, request);
 
 
     // verify all properties are the same as original request
     // verify all properties are the same as original request
-    Assert.assertEquals(
-        "ApplicationStates from proto is not the same with original request",
-        requestFromProto.getApplicationStates(), appStates);
-    
-    Assert.assertEquals(
-        "ApplicationTags from proto is not the same with original request",
-        requestFromProto.getApplicationTags(), tags);
-    
-    Assert.assertEquals(
-        "ApplicationTypes from proto is not the same with original request",
-        requestFromProto.getApplicationTypes(), types);
-    
-    Assert.assertEquals(
-        "StartRange from proto is not the same with original request",
-        requestFromProto.getStartRange(), Range.between(startBegin, startEnd));
-    
-    Assert.assertEquals(
-        "FinishRange from proto is not the same with original request",
-        requestFromProto.getFinishRange(),
-          Range.between(finishBegin, finishEnd));
-    
-    Assert.assertEquals(
-        "Limit from proto is not the same with original request",
-        requestFromProto.getLimit(), limit);
-    
-    Assert.assertEquals(
-        "Queues from proto is not the same with original request",
-        requestFromProto.getQueues(), queues);
-    
-    Assert.assertEquals(
-        "Users from proto is not the same with original request",
-        requestFromProto.getUsers(), users);
+    assertEquals(requestFromProto.getApplicationStates(), appStates,
+        "ApplicationStates from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getApplicationTags(), tags,
+        "ApplicationTags from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getApplicationTypes(), types,
+        "ApplicationTypes from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getStartRange(), Range.between(startBegin, startEnd),
+        "StartRange from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getFinishRange(), Range.between(finishBegin, finishEnd),
+        "FinishRange from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getLimit(), limit,
+        "Limit from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getQueues(), queues,
+        "Queues from proto is not the same with original request");
+
+    assertEquals(requestFromProto.getUsers(), users,
+        "Users from proto is not the same with original request");
   }
   }
 
 
 }
 }

+ 17 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestNodeId.java

@@ -18,32 +18,36 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeId;
-import org.junit.Test;
+
+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.assertTrue;
 
 
 public class TestNodeId {
 public class TestNodeId {
   @Test
   @Test
-  public void testNodeId() {
+  void testNodeId() {
     NodeId nodeId1 = NodeId.newInstance("10.18.52.124", 8041);
     NodeId nodeId1 = NodeId.newInstance("10.18.52.124", 8041);
     NodeId nodeId2 = NodeId.newInstance("10.18.52.125", 8038);
     NodeId nodeId2 = NodeId.newInstance("10.18.52.125", 8038);
     NodeId nodeId3 = NodeId.newInstance("10.18.52.124", 8041);
     NodeId nodeId3 = NodeId.newInstance("10.18.52.124", 8041);
     NodeId nodeId4 = NodeId.newInstance("10.18.52.124", 8039);
     NodeId nodeId4 = NodeId.newInstance("10.18.52.124", 8039);
 
 
-    Assert.assertTrue(nodeId1.equals(nodeId3));
-    Assert.assertFalse(nodeId1.equals(nodeId2));
-    Assert.assertFalse(nodeId3.equals(nodeId4));
+    assertEquals(nodeId1, nodeId3);
+    assertNotEquals(nodeId1, nodeId2);
+    assertNotEquals(nodeId3, nodeId4);
 
 
-    Assert.assertTrue(nodeId1.compareTo(nodeId3) == 0);
-    Assert.assertTrue(nodeId1.compareTo(nodeId2) < 0);
-    Assert.assertTrue(nodeId3.compareTo(nodeId4) > 0);
+    assertTrue(nodeId1.compareTo(nodeId3) == 0);
+    assertTrue(nodeId1.compareTo(nodeId2) < 0);
+    assertTrue(nodeId3.compareTo(nodeId4) > 0);
 
 
-    Assert.assertTrue(nodeId1.hashCode() == nodeId3.hashCode());
-    Assert.assertFalse(nodeId1.hashCode() == nodeId2.hashCode());
-    Assert.assertFalse(nodeId3.hashCode() == nodeId4.hashCode());
+    assertTrue(nodeId1.hashCode() == nodeId3.hashCode());
+    assertFalse(nodeId1.hashCode() == nodeId2.hashCode());
+    assertFalse(nodeId3.hashCode() == nodeId4.hashCode());
 
 
-    Assert.assertEquals("10.18.52.124:8041", nodeId1.toString());
+    assertEquals("10.18.52.124:8041", nodeId1.toString());
   }
   }
 
 
 }
 }

+ 182 - 180
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java

@@ -16,9 +16,15 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
+
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Arrays;
 
 
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
 import org.apache.commons.lang3.Range;
 import org.apache.commons.lang3.Range;
 import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto;
 import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenRequestProto;
 import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto;
 import org.apache.hadoop.security.proto.SecurityProtos.CancelDelegationTokenResponseProto;
@@ -133,8 +139,8 @@ import org.apache.hadoop.yarn.api.records.LocalResource;
 import org.apache.hadoop.yarn.api.records.LogAggregationContext;
 import org.apache.hadoop.yarn.api.records.LogAggregationContext;
 import org.apache.hadoop.yarn.api.records.NMToken;
 import org.apache.hadoop.yarn.api.records.NMToken;
 import org.apache.hadoop.yarn.api.records.NodeAttribute;
 import org.apache.hadoop.yarn.api.records.NodeAttribute;
-import org.apache.hadoop.yarn.api.records.NodeAttributeKey;
 import org.apache.hadoop.yarn.api.records.NodeAttributeInfo;
 import org.apache.hadoop.yarn.api.records.NodeAttributeInfo;
+import org.apache.hadoop.yarn.api.records.NodeAttributeKey;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.api.records.NodeReport;
 import org.apache.hadoop.yarn.api.records.NodeReport;
@@ -189,8 +195,8 @@ import org.apache.hadoop.yarn.api.records.impl.pb.EnhancedHeadroomPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ExecutionTypeRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ExecutionTypeRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.LocalResourcePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.LocalResourcePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl;
-import org.apache.hadoop.yarn.api.records.impl.pb.NodeAttributeKeyPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeAttributeInfoPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeAttributeInfoPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.NodeAttributeKeyPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeAttributePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeAttributePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl;
@@ -201,8 +207,8 @@ import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionContractPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionMessagePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionMessagePBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionResourceRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.PreemptionResourceRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.PriorityPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.PriorityPBImpl;
-import org.apache.hadoop.yarn.api.records.impl.pb.QueueInfoPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.QueueConfigurationsPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.QueueConfigurationsPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.QueueInfoPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.QueueUserACLInfoPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.QueueUserACLInfoPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ResourceBlacklistRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ResourceBlacklistRequestPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ResourceOptionPBImpl;
 import org.apache.hadoop.yarn.api.records.impl.pb.ResourceOptionPBImpl;
@@ -232,8 +238,8 @@ import org.apache.hadoop.yarn.proto.YarnProtos.ContainerRetryContextProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ExecutionTypeRequestProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ExecutionTypeRequestProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.NodeAttributeKeyProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeAttributeInfoProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeAttributeInfoProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.NodeAttributeKeyProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeAttributeProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeAttributeProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto;
@@ -245,8 +251,8 @@ import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionContractProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionResourceRequestProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueConfigurationsProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueConfigurationsProto;
+import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceOptionProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceOptionProto;
@@ -374,19 +380,15 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.ReplaceLabelsOn
 import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceRequestPBImpl;
 import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceRequestPBImpl;
 import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceResponsePBImpl;
 import org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.UpdateNodeResourceResponsePBImpl;
 import org.apache.hadoop.yarn.util.resource.Resources;
 import org.apache.hadoop.yarn.util.resource.Resources;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 /**
 /**
  * Test class for YARN API protocol records.
  * Test class for YARN API protocol records.
  */
  */
 public class TestPBImplRecords extends BasePBImplRecordsTest {
 public class TestPBImplRecords extends BasePBImplRecordsTest {
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws Exception {
   public static void setup() throws Exception {
     typeValueCache.put(Range.class, Range.between(1000L, 2000L));
     typeValueCache.put(Range.class, Range.between(1000L, 2000L));
     typeValueCache.put(URL.class, URL.newInstance(
     typeValueCache.put(URL.class, URL.newInstance(
@@ -474,326 +476,326 @@ public class TestPBImplRecords extends BasePBImplRecordsTest {
   }
   }
 
 
   @Test
   @Test
-  public void testAllocateRequestPBImpl() throws Exception {
+  void testAllocateRequestPBImpl() throws Exception {
     validatePBImplRecord(AllocateRequestPBImpl.class, AllocateRequestProto.class);
     validatePBImplRecord(AllocateRequestPBImpl.class, AllocateRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testAllocateResponsePBImpl() throws Exception {
+  void testAllocateResponsePBImpl() throws Exception {
     validatePBImplRecord(AllocateResponsePBImpl.class, AllocateResponseProto.class);
     validatePBImplRecord(AllocateResponsePBImpl.class, AllocateResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testCancelDelegationTokenRequestPBImpl() throws Exception {
+  void testCancelDelegationTokenRequestPBImpl() throws Exception {
     validatePBImplRecord(CancelDelegationTokenRequestPBImpl.class,
     validatePBImplRecord(CancelDelegationTokenRequestPBImpl.class,
         CancelDelegationTokenRequestProto.class);
         CancelDelegationTokenRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testCancelDelegationTokenResponsePBImpl() throws Exception {
+  void testCancelDelegationTokenResponsePBImpl() throws Exception {
     validatePBImplRecord(CancelDelegationTokenResponsePBImpl.class,
     validatePBImplRecord(CancelDelegationTokenResponsePBImpl.class,
         CancelDelegationTokenResponseProto.class);
         CancelDelegationTokenResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testFinishApplicationMasterRequestPBImpl() throws Exception {
+  void testFinishApplicationMasterRequestPBImpl() throws Exception {
     validatePBImplRecord(FinishApplicationMasterRequestPBImpl.class,
     validatePBImplRecord(FinishApplicationMasterRequestPBImpl.class,
         FinishApplicationMasterRequestProto.class);
         FinishApplicationMasterRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testFinishApplicationMasterResponsePBImpl() throws Exception {
+  void testFinishApplicationMasterResponsePBImpl() throws Exception {
     validatePBImplRecord(FinishApplicationMasterResponsePBImpl.class,
     validatePBImplRecord(FinishApplicationMasterResponsePBImpl.class,
         FinishApplicationMasterResponseProto.class);
         FinishApplicationMasterResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationAttemptReportRequestPBImpl() throws Exception {
+  void testGetApplicationAttemptReportRequestPBImpl() throws Exception {
     validatePBImplRecord(GetApplicationAttemptReportRequestPBImpl.class,
     validatePBImplRecord(GetApplicationAttemptReportRequestPBImpl.class,
         GetApplicationAttemptReportRequestProto.class);
         GetApplicationAttemptReportRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationAttemptReportResponsePBImpl() throws Exception {
+  void testGetApplicationAttemptReportResponsePBImpl() throws Exception {
     validatePBImplRecord(GetApplicationAttemptReportResponsePBImpl.class,
     validatePBImplRecord(GetApplicationAttemptReportResponsePBImpl.class,
         GetApplicationAttemptReportResponseProto.class);
         GetApplicationAttemptReportResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationAttemptsRequestPBImpl() throws Exception {
+  void testGetApplicationAttemptsRequestPBImpl() throws Exception {
     validatePBImplRecord(GetApplicationAttemptsRequestPBImpl.class,
     validatePBImplRecord(GetApplicationAttemptsRequestPBImpl.class,
         GetApplicationAttemptsRequestProto.class);
         GetApplicationAttemptsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationAttemptsResponsePBImpl() throws Exception {
+  void testGetApplicationAttemptsResponsePBImpl() throws Exception {
     validatePBImplRecord(GetApplicationAttemptsResponsePBImpl.class,
     validatePBImplRecord(GetApplicationAttemptsResponsePBImpl.class,
         GetApplicationAttemptsResponseProto.class);
         GetApplicationAttemptsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationReportRequestPBImpl() throws Exception {
+  void testGetApplicationReportRequestPBImpl() throws Exception {
     validatePBImplRecord(GetApplicationReportRequestPBImpl.class,
     validatePBImplRecord(GetApplicationReportRequestPBImpl.class,
         GetApplicationReportRequestProto.class);
         GetApplicationReportRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationReportResponsePBImpl() throws Exception {
+  void testGetApplicationReportResponsePBImpl() throws Exception {
     validatePBImplRecord(GetApplicationReportResponsePBImpl.class,
     validatePBImplRecord(GetApplicationReportResponsePBImpl.class,
         GetApplicationReportResponseProto.class);
         GetApplicationReportResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationsRequestPBImpl() throws Exception {
+  void testGetApplicationsRequestPBImpl() throws Exception {
     validatePBImplRecord(GetApplicationsRequestPBImpl.class,
     validatePBImplRecord(GetApplicationsRequestPBImpl.class,
         GetApplicationsRequestProto.class);
         GetApplicationsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplicationsResponsePBImpl() throws Exception {
+  void testGetApplicationsResponsePBImpl() throws Exception {
     validatePBImplRecord(GetApplicationsResponsePBImpl.class,
     validatePBImplRecord(GetApplicationsResponsePBImpl.class,
         GetApplicationsResponseProto.class);
         GetApplicationsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterMetricsRequestPBImpl() throws Exception {
+  void testGetClusterMetricsRequestPBImpl() throws Exception {
     validatePBImplRecord(GetClusterMetricsRequestPBImpl.class,
     validatePBImplRecord(GetClusterMetricsRequestPBImpl.class,
         GetClusterMetricsRequestProto.class);
         GetClusterMetricsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterMetricsResponsePBImpl() throws Exception {
+  void testGetClusterMetricsResponsePBImpl() throws Exception {
     validatePBImplRecord(GetClusterMetricsResponsePBImpl.class,
     validatePBImplRecord(GetClusterMetricsResponsePBImpl.class,
         GetClusterMetricsResponseProto.class);
         GetClusterMetricsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterNodesRequestPBImpl() throws Exception {
+  void testGetClusterNodesRequestPBImpl() throws Exception {
     validatePBImplRecord(GetClusterNodesRequestPBImpl.class,
     validatePBImplRecord(GetClusterNodesRequestPBImpl.class,
         GetClusterNodesRequestProto.class);
         GetClusterNodesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterNodesResponsePBImpl() throws Exception {
+  void testGetClusterNodesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetClusterNodesResponsePBImpl.class,
     validatePBImplRecord(GetClusterNodesResponsePBImpl.class,
         GetClusterNodesResponseProto.class);
         GetClusterNodesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainerReportRequestPBImpl() throws Exception {
+  void testGetContainerReportRequestPBImpl() throws Exception {
     validatePBImplRecord(GetContainerReportRequestPBImpl.class,
     validatePBImplRecord(GetContainerReportRequestPBImpl.class,
         GetContainerReportRequestProto.class);
         GetContainerReportRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainerReportResponsePBImpl() throws Exception {
+  void testGetContainerReportResponsePBImpl() throws Exception {
     validatePBImplRecord(GetContainerReportResponsePBImpl.class,
     validatePBImplRecord(GetContainerReportResponsePBImpl.class,
         GetContainerReportResponseProto.class);
         GetContainerReportResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainersRequestPBImpl() throws Exception {
+  void testGetContainersRequestPBImpl() throws Exception {
     validatePBImplRecord(GetContainersRequestPBImpl.class,
     validatePBImplRecord(GetContainersRequestPBImpl.class,
         GetContainersRequestProto.class);
         GetContainersRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainersResponsePBImpl() throws Exception {
+  void testGetContainersResponsePBImpl() throws Exception {
     validatePBImplRecord(GetContainersResponsePBImpl.class,
     validatePBImplRecord(GetContainersResponsePBImpl.class,
         GetContainersResponseProto.class);
         GetContainersResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainerStatusesRequestPBImpl() throws Exception {
+  void testGetContainerStatusesRequestPBImpl() throws Exception {
     validatePBImplRecord(GetContainerStatusesRequestPBImpl.class,
     validatePBImplRecord(GetContainerStatusesRequestPBImpl.class,
         GetContainerStatusesRequestProto.class);
         GetContainerStatusesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainerStatusesResponsePBImpl() throws Exception {
+  void testGetContainerStatusesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetContainerStatusesResponsePBImpl.class,
     validatePBImplRecord(GetContainerStatusesResponsePBImpl.class,
         GetContainerStatusesResponseProto.class);
         GetContainerStatusesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetDelegationTokenRequestPBImpl() throws Exception {
+  void testGetDelegationTokenRequestPBImpl() throws Exception {
     validatePBImplRecord(GetDelegationTokenRequestPBImpl.class,
     validatePBImplRecord(GetDelegationTokenRequestPBImpl.class,
         GetDelegationTokenRequestProto.class);
         GetDelegationTokenRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetDelegationTokenResponsePBImpl() throws Exception {
+  void testGetDelegationTokenResponsePBImpl() throws Exception {
     validatePBImplRecord(GetDelegationTokenResponsePBImpl.class,
     validatePBImplRecord(GetDelegationTokenResponsePBImpl.class,
         GetDelegationTokenResponseProto.class);
         GetDelegationTokenResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetNewApplicationRequestPBImpl() throws Exception {
+  void testGetNewApplicationRequestPBImpl() throws Exception {
     validatePBImplRecord(GetNewApplicationRequestPBImpl.class,
     validatePBImplRecord(GetNewApplicationRequestPBImpl.class,
         GetNewApplicationRequestProto.class);
         GetNewApplicationRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetNewApplicationResponsePBImpl() throws Exception {
+  void testGetNewApplicationResponsePBImpl() throws Exception {
     validatePBImplRecord(GetNewApplicationResponsePBImpl.class,
     validatePBImplRecord(GetNewApplicationResponsePBImpl.class,
         GetNewApplicationResponseProto.class);
         GetNewApplicationResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetQueueInfoRequestPBImpl() throws Exception {
+  void testGetQueueInfoRequestPBImpl() throws Exception {
     validatePBImplRecord(GetQueueInfoRequestPBImpl.class,
     validatePBImplRecord(GetQueueInfoRequestPBImpl.class,
         GetQueueInfoRequestProto.class);
         GetQueueInfoRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetQueueInfoResponsePBImpl() throws Exception {
+  void testGetQueueInfoResponsePBImpl() throws Exception {
     validatePBImplRecord(GetQueueInfoResponsePBImpl.class,
     validatePBImplRecord(GetQueueInfoResponsePBImpl.class,
         GetQueueInfoResponseProto.class);
         GetQueueInfoResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetQueueUserAclsInfoRequestPBImpl() throws Exception {
+  void testGetQueueUserAclsInfoRequestPBImpl() throws Exception {
     validatePBImplRecord(GetQueueUserAclsInfoRequestPBImpl.class,
     validatePBImplRecord(GetQueueUserAclsInfoRequestPBImpl.class,
         GetQueueUserAclsInfoRequestProto.class);
         GetQueueUserAclsInfoRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetQueueUserAclsInfoResponsePBImpl() throws Exception {
+  void testGetQueueUserAclsInfoResponsePBImpl() throws Exception {
     validatePBImplRecord(GetQueueUserAclsInfoResponsePBImpl.class,
     validatePBImplRecord(GetQueueUserAclsInfoResponsePBImpl.class,
         GetQueueUserAclsInfoResponseProto.class);
         GetQueueUserAclsInfoResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testKillApplicationRequestPBImpl() throws Exception {
+  void testKillApplicationRequestPBImpl() throws Exception {
     validatePBImplRecord(KillApplicationRequestPBImpl.class,
     validatePBImplRecord(KillApplicationRequestPBImpl.class,
         KillApplicationRequestProto.class);
         KillApplicationRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testKillApplicationResponsePBImpl() throws Exception {
+  void testKillApplicationResponsePBImpl() throws Exception {
     validatePBImplRecord(KillApplicationResponsePBImpl.class,
     validatePBImplRecord(KillApplicationResponsePBImpl.class,
         KillApplicationResponseProto.class);
         KillApplicationResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testMoveApplicationAcrossQueuesRequestPBImpl() throws Exception {
+  void testMoveApplicationAcrossQueuesRequestPBImpl() throws Exception {
     validatePBImplRecord(MoveApplicationAcrossQueuesRequestPBImpl.class,
     validatePBImplRecord(MoveApplicationAcrossQueuesRequestPBImpl.class,
         MoveApplicationAcrossQueuesRequestProto.class);
         MoveApplicationAcrossQueuesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testMoveApplicationAcrossQueuesResponsePBImpl() throws Exception {
+  void testMoveApplicationAcrossQueuesResponsePBImpl() throws Exception {
     validatePBImplRecord(MoveApplicationAcrossQueuesResponsePBImpl.class,
     validatePBImplRecord(MoveApplicationAcrossQueuesResponsePBImpl.class,
         MoveApplicationAcrossQueuesResponseProto.class);
         MoveApplicationAcrossQueuesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRegisterApplicationMasterRequestPBImpl() throws Exception {
+  void testRegisterApplicationMasterRequestPBImpl() throws Exception {
     validatePBImplRecord(RegisterApplicationMasterRequestPBImpl.class,
     validatePBImplRecord(RegisterApplicationMasterRequestPBImpl.class,
         RegisterApplicationMasterRequestProto.class);
         RegisterApplicationMasterRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRegisterApplicationMasterResponsePBImpl() throws Exception {
+  void testRegisterApplicationMasterResponsePBImpl() throws Exception {
     validatePBImplRecord(RegisterApplicationMasterResponsePBImpl.class,
     validatePBImplRecord(RegisterApplicationMasterResponsePBImpl.class,
         RegisterApplicationMasterResponseProto.class);
         RegisterApplicationMasterResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRenewDelegationTokenRequestPBImpl() throws Exception {
+  void testRenewDelegationTokenRequestPBImpl() throws Exception {
     validatePBImplRecord(RenewDelegationTokenRequestPBImpl.class,
     validatePBImplRecord(RenewDelegationTokenRequestPBImpl.class,
         RenewDelegationTokenRequestProto.class);
         RenewDelegationTokenRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRenewDelegationTokenResponsePBImpl() throws Exception {
+  void testRenewDelegationTokenResponsePBImpl() throws Exception {
     validatePBImplRecord(RenewDelegationTokenResponsePBImpl.class,
     validatePBImplRecord(RenewDelegationTokenResponsePBImpl.class,
         RenewDelegationTokenResponseProto.class);
         RenewDelegationTokenResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testStartContainerRequestPBImpl() throws Exception {
+  void testStartContainerRequestPBImpl() throws Exception {
     validatePBImplRecord(StartContainerRequestPBImpl.class,
     validatePBImplRecord(StartContainerRequestPBImpl.class,
         StartContainerRequestProto.class);
         StartContainerRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testStartContainersRequestPBImpl() throws Exception {
+  void testStartContainersRequestPBImpl() throws Exception {
     validatePBImplRecord(StartContainersRequestPBImpl.class,
     validatePBImplRecord(StartContainersRequestPBImpl.class,
         StartContainersRequestProto.class);
         StartContainersRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testStartContainersResponsePBImpl() throws Exception {
+  void testStartContainersResponsePBImpl() throws Exception {
     validatePBImplRecord(StartContainersResponsePBImpl.class,
     validatePBImplRecord(StartContainersResponsePBImpl.class,
         StartContainersResponseProto.class);
         StartContainersResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testStopContainersRequestPBImpl() throws Exception {
+  void testStopContainersRequestPBImpl() throws Exception {
     validatePBImplRecord(StopContainersRequestPBImpl.class,
     validatePBImplRecord(StopContainersRequestPBImpl.class,
         StopContainersRequestProto.class);
         StopContainersRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testStopContainersResponsePBImpl() throws Exception {
+  void testStopContainersResponsePBImpl() throws Exception {
     validatePBImplRecord(StopContainersResponsePBImpl.class,
     validatePBImplRecord(StopContainersResponsePBImpl.class,
         StopContainersResponseProto.class);
         StopContainersResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testIncreaseContainersResourceRequestPBImpl() throws Exception {
+  void testIncreaseContainersResourceRequestPBImpl() throws Exception {
     validatePBImplRecord(IncreaseContainersResourceRequestPBImpl.class,
     validatePBImplRecord(IncreaseContainersResourceRequestPBImpl.class,
         IncreaseContainersResourceRequestProto.class);
         IncreaseContainersResourceRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testIncreaseContainersResourceResponsePBImpl() throws Exception {
+  void testIncreaseContainersResourceResponsePBImpl() throws Exception {
     validatePBImplRecord(IncreaseContainersResourceResponsePBImpl.class,
     validatePBImplRecord(IncreaseContainersResourceResponsePBImpl.class,
         IncreaseContainersResourceResponseProto.class);
         IncreaseContainersResourceResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testSubmitApplicationRequestPBImpl() throws Exception {
+  void testSubmitApplicationRequestPBImpl() throws Exception {
     validatePBImplRecord(SubmitApplicationRequestPBImpl.class,
     validatePBImplRecord(SubmitApplicationRequestPBImpl.class,
         SubmitApplicationRequestProto.class);
         SubmitApplicationRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testSubmitApplicationResponsePBImpl() throws Exception {
+  void testSubmitApplicationResponsePBImpl() throws Exception {
     validatePBImplRecord(SubmitApplicationResponsePBImpl.class,
     validatePBImplRecord(SubmitApplicationResponsePBImpl.class,
         SubmitApplicationResponseProto.class);
         SubmitApplicationResponseProto.class);
   }
   }
 
 
-  @Test
-  @Ignore
   // ignore cause ApplicationIdPBImpl is immutable
   // ignore cause ApplicationIdPBImpl is immutable
-  public void testApplicationAttemptIdPBImpl() throws Exception {
+  @Test
+  @Disabled
+  void testApplicationAttemptIdPBImpl() throws Exception {
     validatePBImplRecord(ApplicationAttemptIdPBImpl.class,
     validatePBImplRecord(ApplicationAttemptIdPBImpl.class,
         ApplicationAttemptIdProto.class);
         ApplicationAttemptIdProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testApplicationAttemptReportPBImpl() throws Exception {
+  void testApplicationAttemptReportPBImpl() throws Exception {
     validatePBImplRecord(ApplicationAttemptReportPBImpl.class,
     validatePBImplRecord(ApplicationAttemptReportPBImpl.class,
         ApplicationAttemptReportProto.class);
         ApplicationAttemptReportProto.class);
   }
   }
 
 
-  @Test
-  @Ignore
   // ignore cause ApplicationIdPBImpl is immutable
   // ignore cause ApplicationIdPBImpl is immutable
-  public void testApplicationIdPBImpl() throws Exception {
+  @Test
+  @Disabled
+  void testApplicationIdPBImpl() throws Exception {
     validatePBImplRecord(ApplicationIdPBImpl.class, ApplicationIdProto.class);
     validatePBImplRecord(ApplicationIdPBImpl.class, ApplicationIdProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testApplicationReportPBImpl() throws Exception {
+  void testApplicationReportPBImpl() throws Exception {
     validatePBImplRecord(ApplicationReportPBImpl.class,
     validatePBImplRecord(ApplicationReportPBImpl.class,
         ApplicationReportProto.class);
         ApplicationReportProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testApplicationResourceUsageReportPBImpl() throws Exception {
+  void testApplicationResourceUsageReportPBImpl() throws Exception {
     excludedPropertiesMap.put(ApplicationResourceUsageReportPBImpl.class.getClass(),
     excludedPropertiesMap.put(ApplicationResourceUsageReportPBImpl.class.getClass(),
         Arrays.asList("PreemptedResourceSecondsMap", "ResourceSecondsMap"));
         Arrays.asList("PreemptedResourceSecondsMap", "ResourceSecondsMap"));
     validatePBImplRecord(ApplicationResourceUsageReportPBImpl.class,
     validatePBImplRecord(ApplicationResourceUsageReportPBImpl.class,
@@ -801,550 +803,550 @@ public class TestPBImplRecords extends BasePBImplRecordsTest {
   }
   }
 
 
   @Test
   @Test
-  public void testApplicationSubmissionContextPBImpl() throws Exception {
+  void testApplicationSubmissionContextPBImpl() throws Exception {
     validatePBImplRecord(ApplicationSubmissionContextPBImpl.class,
     validatePBImplRecord(ApplicationSubmissionContextPBImpl.class,
         ApplicationSubmissionContextProto.class);
         ApplicationSubmissionContextProto.class);
-    
+
     ApplicationSubmissionContext ctx =
     ApplicationSubmissionContext ctx =
         ApplicationSubmissionContext.newInstance(null, null, null, null, null,
         ApplicationSubmissionContext.newInstance(null, null, null, null, null,
             false, false, 0, Resources.none(), null, false, null, null);
             false, false, 0, Resources.none(), null, false, null, null);
-    
-    Assert.assertNotNull(ctx.getResource());
+
+    assertNotNull(ctx.getResource());
   }
   }
 
 
-  @Test
-  @Ignore
   // ignore cause ApplicationIdPBImpl is immutable
   // ignore cause ApplicationIdPBImpl is immutable
-  public void testContainerIdPBImpl() throws Exception {
+  @Test
+  @Disabled
+  void testContainerIdPBImpl() throws Exception {
     validatePBImplRecord(ContainerIdPBImpl.class, ContainerIdProto.class);
     validatePBImplRecord(ContainerIdPBImpl.class, ContainerIdProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testContainerRetryPBImpl() throws Exception {
+  void testContainerRetryPBImpl() throws Exception {
     validatePBImplRecord(ContainerRetryContextPBImpl.class,
     validatePBImplRecord(ContainerRetryContextPBImpl.class,
         ContainerRetryContextProto.class);
         ContainerRetryContextProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testContainerLaunchContextPBImpl() throws Exception {
+  void testContainerLaunchContextPBImpl() throws Exception {
     validatePBImplRecord(ContainerLaunchContextPBImpl.class,
     validatePBImplRecord(ContainerLaunchContextPBImpl.class,
         ContainerLaunchContextProto.class);
         ContainerLaunchContextProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceLocalizationRequest() throws Exception {
+  void testResourceLocalizationRequest() throws Exception {
     validatePBImplRecord(ResourceLocalizationRequestPBImpl.class,
     validatePBImplRecord(ResourceLocalizationRequestPBImpl.class,
         YarnServiceProtos.ResourceLocalizationRequestProto.class);
         YarnServiceProtos.ResourceLocalizationRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceLocalizationResponse() throws Exception {
+  void testResourceLocalizationResponse() throws Exception {
     validatePBImplRecord(ResourceLocalizationResponsePBImpl.class,
     validatePBImplRecord(ResourceLocalizationResponsePBImpl.class,
         YarnServiceProtos.ResourceLocalizationResponseProto.class);
         YarnServiceProtos.ResourceLocalizationResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testContainerPBImpl() throws Exception {
+  void testContainerPBImpl() throws Exception {
     validatePBImplRecord(ContainerPBImpl.class, ContainerProto.class);
     validatePBImplRecord(ContainerPBImpl.class, ContainerProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testContainerReportPBImpl() throws Exception {
+  void testContainerReportPBImpl() throws Exception {
     validatePBImplRecord(ContainerReportPBImpl.class, ContainerReportProto.class);
     validatePBImplRecord(ContainerReportPBImpl.class, ContainerReportProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testUpdateContainerRequestPBImpl() throws Exception {
+  void testUpdateContainerRequestPBImpl() throws Exception {
     validatePBImplRecord(UpdateContainerRequestPBImpl.class,
     validatePBImplRecord(UpdateContainerRequestPBImpl.class,
         YarnServiceProtos.UpdateContainerRequestProto.class);
         YarnServiceProtos.UpdateContainerRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testContainerStatusPBImpl() throws Exception {
+  void testContainerStatusPBImpl() throws Exception {
     validatePBImplRecord(ContainerStatusPBImpl.class, ContainerStatusProto.class);
     validatePBImplRecord(ContainerStatusPBImpl.class, ContainerStatusProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testLocalResourcePBImpl() throws Exception {
+  void testLocalResourcePBImpl() throws Exception {
     validatePBImplRecord(LocalResourcePBImpl.class, LocalResourceProto.class);
     validatePBImplRecord(LocalResourcePBImpl.class, LocalResourceProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNMTokenPBImpl() throws Exception {
+  void testNMTokenPBImpl() throws Exception {
     validatePBImplRecord(NMTokenPBImpl.class, NMTokenProto.class);
     validatePBImplRecord(NMTokenPBImpl.class, NMTokenProto.class);
   }
   }
 
 
-  @Test
-  @Ignore
   // ignore cause ApplicationIdPBImpl is immutable
   // ignore cause ApplicationIdPBImpl is immutable
-  public void testNodeIdPBImpl() throws Exception {
+  @Test
+  @Disabled
+  void testNodeIdPBImpl() throws Exception {
     validatePBImplRecord(NodeIdPBImpl.class, NodeIdProto.class);
     validatePBImplRecord(NodeIdPBImpl.class, NodeIdProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodeReportPBImpl() throws Exception {
+  void testNodeReportPBImpl() throws Exception {
     validatePBImplRecord(NodeReportPBImpl.class, NodeReportProto.class);
     validatePBImplRecord(NodeReportPBImpl.class, NodeReportProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testPreemptionContainerPBImpl() throws Exception {
+  void testPreemptionContainerPBImpl() throws Exception {
     validatePBImplRecord(PreemptionContainerPBImpl.class,
     validatePBImplRecord(PreemptionContainerPBImpl.class,
         PreemptionContainerProto.class);
         PreemptionContainerProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testPreemptionContractPBImpl() throws Exception {
+  void testPreemptionContractPBImpl() throws Exception {
     validatePBImplRecord(PreemptionContractPBImpl.class,
     validatePBImplRecord(PreemptionContractPBImpl.class,
         PreemptionContractProto.class);
         PreemptionContractProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testPreemptionMessagePBImpl() throws Exception {
+  void testPreemptionMessagePBImpl() throws Exception {
     validatePBImplRecord(PreemptionMessagePBImpl.class,
     validatePBImplRecord(PreemptionMessagePBImpl.class,
         PreemptionMessageProto.class);
         PreemptionMessageProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testPreemptionResourceRequestPBImpl() throws Exception {
+  void testPreemptionResourceRequestPBImpl() throws Exception {
     validatePBImplRecord(PreemptionResourceRequestPBImpl.class,
     validatePBImplRecord(PreemptionResourceRequestPBImpl.class,
         PreemptionResourceRequestProto.class);
         PreemptionResourceRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testPriorityPBImpl() throws Exception {
+  void testPriorityPBImpl() throws Exception {
     validatePBImplRecord(PriorityPBImpl.class, PriorityProto.class);
     validatePBImplRecord(PriorityPBImpl.class, PriorityProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testQueueInfoPBImpl() throws Exception {
+  void testQueueInfoPBImpl() throws Exception {
     validatePBImplRecord(QueueInfoPBImpl.class, QueueInfoProto.class);
     validatePBImplRecord(QueueInfoPBImpl.class, QueueInfoProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testQueueConfigurationsPBImpl() throws Exception{
+  void testQueueConfigurationsPBImpl() throws Exception {
     validatePBImplRecord(QueueConfigurationsPBImpl.class,
     validatePBImplRecord(QueueConfigurationsPBImpl.class,
         QueueConfigurationsProto.class);
         QueueConfigurationsProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testQueueUserACLInfoPBImpl() throws Exception {
+  void testQueueUserACLInfoPBImpl() throws Exception {
     validatePBImplRecord(QueueUserACLInfoPBImpl.class,
     validatePBImplRecord(QueueUserACLInfoPBImpl.class,
         QueueUserACLInfoProto.class);
         QueueUserACLInfoProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceBlacklistRequestPBImpl() throws Exception {
+  void testResourceBlacklistRequestPBImpl() throws Exception {
     validatePBImplRecord(ResourceBlacklistRequestPBImpl.class,
     validatePBImplRecord(ResourceBlacklistRequestPBImpl.class,
         ResourceBlacklistRequestProto.class);
         ResourceBlacklistRequestProto.class);
   }
   }
 
 
-  @Test
-  @Ignore
   // ignore as ResourceOptionPBImpl is immutable
   // ignore as ResourceOptionPBImpl is immutable
-  public void testResourceOptionPBImpl() throws Exception {
+  @Test
+  @Disabled
+  void testResourceOptionPBImpl() throws Exception {
     validatePBImplRecord(ResourceOptionPBImpl.class, ResourceOptionProto.class);
     validatePBImplRecord(ResourceOptionPBImpl.class, ResourceOptionProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourcePBImpl() throws Exception {
+  void testResourcePBImpl() throws Exception {
     validatePBImplRecord(ResourcePBImpl.class, ResourceProto.class);
     validatePBImplRecord(ResourcePBImpl.class, ResourceProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceRequestPBImpl() throws Exception {
+  void testResourceRequestPBImpl() throws Exception {
     validatePBImplRecord(ResourceRequestPBImpl.class, ResourceRequestProto.class);
     validatePBImplRecord(ResourceRequestPBImpl.class, ResourceRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceSizingPBImpl() throws Exception {
+  void testResourceSizingPBImpl() throws Exception {
     validatePBImplRecord(ResourceSizingPBImpl.class, ResourceSizingProto.class);
     validatePBImplRecord(ResourceSizingPBImpl.class, ResourceSizingProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testSchedulingRequestPBImpl() throws Exception {
+  void testSchedulingRequestPBImpl() throws Exception {
     validatePBImplRecord(SchedulingRequestPBImpl.class,
     validatePBImplRecord(SchedulingRequestPBImpl.class,
         SchedulingRequestProto.class);
         SchedulingRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testSerializedExceptionPBImpl() throws Exception {
+  void testSerializedExceptionPBImpl() throws Exception {
     validatePBImplRecord(SerializedExceptionPBImpl.class,
     validatePBImplRecord(SerializedExceptionPBImpl.class,
         SerializedExceptionProto.class);
         SerializedExceptionProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testStrictPreemptionContractPBImpl() throws Exception {
+  void testStrictPreemptionContractPBImpl() throws Exception {
     validatePBImplRecord(StrictPreemptionContractPBImpl.class,
     validatePBImplRecord(StrictPreemptionContractPBImpl.class,
         StrictPreemptionContractProto.class);
         StrictPreemptionContractProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testTokenPBImpl() throws Exception {
+  void testTokenPBImpl() throws Exception {
     validatePBImplRecord(TokenPBImpl.class, TokenProto.class);
     validatePBImplRecord(TokenPBImpl.class, TokenProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testURLPBImpl() throws Exception {
+  void testURLPBImpl() throws Exception {
     validatePBImplRecord(URLPBImpl.class, URLProto.class);
     validatePBImplRecord(URLPBImpl.class, URLProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testYarnClusterMetricsPBImpl() throws Exception {
+  void testYarnClusterMetricsPBImpl() throws Exception {
     validatePBImplRecord(YarnClusterMetricsPBImpl.class,
     validatePBImplRecord(YarnClusterMetricsPBImpl.class,
         YarnClusterMetricsProto.class);
         YarnClusterMetricsProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshAdminAclsRequestPBImpl() throws Exception {
+  void testRefreshAdminAclsRequestPBImpl() throws Exception {
     validatePBImplRecord(RefreshAdminAclsRequestPBImpl.class,
     validatePBImplRecord(RefreshAdminAclsRequestPBImpl.class,
         RefreshAdminAclsRequestProto.class);
         RefreshAdminAclsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshAdminAclsResponsePBImpl() throws Exception {
+  void testRefreshAdminAclsResponsePBImpl() throws Exception {
     validatePBImplRecord(RefreshAdminAclsResponsePBImpl.class,
     validatePBImplRecord(RefreshAdminAclsResponsePBImpl.class,
         RefreshAdminAclsResponseProto.class);
         RefreshAdminAclsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshNodesRequestPBImpl() throws Exception {
+  void testRefreshNodesRequestPBImpl() throws Exception {
     validatePBImplRecord(RefreshNodesRequestPBImpl.class,
     validatePBImplRecord(RefreshNodesRequestPBImpl.class,
         RefreshNodesRequestProto.class);
         RefreshNodesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshNodesResponsePBImpl() throws Exception {
+  void testRefreshNodesResponsePBImpl() throws Exception {
     validatePBImplRecord(RefreshNodesResponsePBImpl.class,
     validatePBImplRecord(RefreshNodesResponsePBImpl.class,
         RefreshNodesResponseProto.class);
         RefreshNodesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshQueuesRequestPBImpl() throws Exception {
+  void testRefreshQueuesRequestPBImpl() throws Exception {
     validatePBImplRecord(RefreshQueuesRequestPBImpl.class,
     validatePBImplRecord(RefreshQueuesRequestPBImpl.class,
         RefreshQueuesRequestProto.class);
         RefreshQueuesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshQueuesResponsePBImpl() throws Exception {
+  void testRefreshQueuesResponsePBImpl() throws Exception {
     validatePBImplRecord(RefreshQueuesResponsePBImpl.class,
     validatePBImplRecord(RefreshQueuesResponsePBImpl.class,
         RefreshQueuesResponseProto.class);
         RefreshQueuesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshNodesResourcesRequestPBImpl() throws Exception {
+  void testRefreshNodesResourcesRequestPBImpl() throws Exception {
     validatePBImplRecord(RefreshNodesResourcesRequestPBImpl.class,
     validatePBImplRecord(RefreshNodesResourcesRequestPBImpl.class,
         RefreshNodesResourcesRequestProto.class);
         RefreshNodesResourcesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshNodesResourcesResponsePBImpl() throws Exception {
+  void testRefreshNodesResourcesResponsePBImpl() throws Exception {
     validatePBImplRecord(RefreshNodesResourcesResponsePBImpl.class,
     validatePBImplRecord(RefreshNodesResourcesResponsePBImpl.class,
         RefreshNodesResourcesResponseProto.class);
         RefreshNodesResourcesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshServiceAclsRequestPBImpl() throws Exception {
+  void testRefreshServiceAclsRequestPBImpl() throws Exception {
     validatePBImplRecord(RefreshServiceAclsRequestPBImpl.class,
     validatePBImplRecord(RefreshServiceAclsRequestPBImpl.class,
         RefreshServiceAclsRequestProto.class);
         RefreshServiceAclsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshServiceAclsResponsePBImpl() throws Exception {
+  void testRefreshServiceAclsResponsePBImpl() throws Exception {
     validatePBImplRecord(RefreshServiceAclsResponsePBImpl.class,
     validatePBImplRecord(RefreshServiceAclsResponsePBImpl.class,
         RefreshServiceAclsResponseProto.class);
         RefreshServiceAclsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshSuperUserGroupsConfigurationRequestPBImpl()
+  void testRefreshSuperUserGroupsConfigurationRequestPBImpl()
       throws Exception {
       throws Exception {
     validatePBImplRecord(RefreshSuperUserGroupsConfigurationRequestPBImpl.class,
     validatePBImplRecord(RefreshSuperUserGroupsConfigurationRequestPBImpl.class,
         RefreshSuperUserGroupsConfigurationRequestProto.class);
         RefreshSuperUserGroupsConfigurationRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshSuperUserGroupsConfigurationResponsePBImpl()
+  void testRefreshSuperUserGroupsConfigurationResponsePBImpl()
       throws Exception {
       throws Exception {
     validatePBImplRecord(RefreshSuperUserGroupsConfigurationResponsePBImpl.class,
     validatePBImplRecord(RefreshSuperUserGroupsConfigurationResponsePBImpl.class,
         RefreshSuperUserGroupsConfigurationResponseProto.class);
         RefreshSuperUserGroupsConfigurationResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshUserToGroupsMappingsRequestPBImpl() throws Exception {
+  void testRefreshUserToGroupsMappingsRequestPBImpl() throws Exception {
     validatePBImplRecord(RefreshUserToGroupsMappingsRequestPBImpl.class,
     validatePBImplRecord(RefreshUserToGroupsMappingsRequestPBImpl.class,
         RefreshUserToGroupsMappingsRequestProto.class);
         RefreshUserToGroupsMappingsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshUserToGroupsMappingsResponsePBImpl() throws Exception {
+  void testRefreshUserToGroupsMappingsResponsePBImpl() throws Exception {
     validatePBImplRecord(RefreshUserToGroupsMappingsResponsePBImpl.class,
     validatePBImplRecord(RefreshUserToGroupsMappingsResponsePBImpl.class,
         RefreshUserToGroupsMappingsResponseProto.class);
         RefreshUserToGroupsMappingsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testUpdateNodeResourceRequestPBImpl() throws Exception {
+  void testUpdateNodeResourceRequestPBImpl() throws Exception {
     validatePBImplRecord(UpdateNodeResourceRequestPBImpl.class,
     validatePBImplRecord(UpdateNodeResourceRequestPBImpl.class,
         UpdateNodeResourceRequestProto.class);
         UpdateNodeResourceRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testUpdateNodeResourceResponsePBImpl() throws Exception {
+  void testUpdateNodeResourceResponsePBImpl() throws Exception {
     validatePBImplRecord(UpdateNodeResourceResponsePBImpl.class,
     validatePBImplRecord(UpdateNodeResourceResponsePBImpl.class,
         UpdateNodeResourceResponseProto.class);
         UpdateNodeResourceResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationSubmissionRequestPBImpl() throws Exception {
+  void testReservationSubmissionRequestPBImpl() throws Exception {
     validatePBImplRecord(ReservationSubmissionRequestPBImpl.class,
     validatePBImplRecord(ReservationSubmissionRequestPBImpl.class,
         ReservationSubmissionRequestProto.class);
         ReservationSubmissionRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationSubmissionResponsePBImpl() throws Exception {
+  void testReservationSubmissionResponsePBImpl() throws Exception {
     validatePBImplRecord(ReservationSubmissionResponsePBImpl.class,
     validatePBImplRecord(ReservationSubmissionResponsePBImpl.class,
         ReservationSubmissionResponseProto.class);
         ReservationSubmissionResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationUpdateRequestPBImpl() throws Exception {
+  void testReservationUpdateRequestPBImpl() throws Exception {
     validatePBImplRecord(ReservationUpdateRequestPBImpl.class,
     validatePBImplRecord(ReservationUpdateRequestPBImpl.class,
         ReservationUpdateRequestProto.class);
         ReservationUpdateRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationUpdateResponsePBImpl() throws Exception {
+  void testReservationUpdateResponsePBImpl() throws Exception {
     validatePBImplRecord(ReservationUpdateResponsePBImpl.class,
     validatePBImplRecord(ReservationUpdateResponsePBImpl.class,
         ReservationUpdateResponseProto.class);
         ReservationUpdateResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationDeleteRequestPBImpl() throws Exception {
+  void testReservationDeleteRequestPBImpl() throws Exception {
     validatePBImplRecord(ReservationDeleteRequestPBImpl.class,
     validatePBImplRecord(ReservationDeleteRequestPBImpl.class,
         ReservationDeleteRequestProto.class);
         ReservationDeleteRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationDeleteResponsePBImpl() throws Exception {
+  void testReservationDeleteResponsePBImpl() throws Exception {
     validatePBImplRecord(ReservationDeleteResponsePBImpl.class,
     validatePBImplRecord(ReservationDeleteResponsePBImpl.class,
         ReservationDeleteResponseProto.class);
         ReservationDeleteResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationListRequestPBImpl() throws Exception {
+  void testReservationListRequestPBImpl() throws Exception {
     validatePBImplRecord(ReservationListRequestPBImpl.class,
     validatePBImplRecord(ReservationListRequestPBImpl.class,
-            ReservationListRequestProto.class);
+        ReservationListRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReservationListResponsePBImpl() throws Exception {
+  void testReservationListResponsePBImpl() throws Exception {
     validatePBImplRecord(ReservationListResponsePBImpl.class,
     validatePBImplRecord(ReservationListResponsePBImpl.class,
-            ReservationListResponseProto.class);
+        ReservationListResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testAddToClusterNodeLabelsRequestPBImpl() throws Exception {
+  void testAddToClusterNodeLabelsRequestPBImpl() throws Exception {
     validatePBImplRecord(AddToClusterNodeLabelsRequestPBImpl.class,
     validatePBImplRecord(AddToClusterNodeLabelsRequestPBImpl.class,
         AddToClusterNodeLabelsRequestProto.class);
         AddToClusterNodeLabelsRequestProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testAddToClusterNodeLabelsResponsePBImpl() throws Exception {
+  void testAddToClusterNodeLabelsResponsePBImpl() throws Exception {
     validatePBImplRecord(AddToClusterNodeLabelsResponsePBImpl.class,
     validatePBImplRecord(AddToClusterNodeLabelsResponsePBImpl.class,
         AddToClusterNodeLabelsResponseProto.class);
         AddToClusterNodeLabelsResponseProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testRemoveFromClusterNodeLabelsRequestPBImpl() throws Exception {
+  void testRemoveFromClusterNodeLabelsRequestPBImpl() throws Exception {
     validatePBImplRecord(RemoveFromClusterNodeLabelsRequestPBImpl.class,
     validatePBImplRecord(RemoveFromClusterNodeLabelsRequestPBImpl.class,
         RemoveFromClusterNodeLabelsRequestProto.class);
         RemoveFromClusterNodeLabelsRequestProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testRemoveFromClusterNodeLabelsResponsePBImpl() throws Exception {
+  void testRemoveFromClusterNodeLabelsResponsePBImpl() throws Exception {
     validatePBImplRecord(RemoveFromClusterNodeLabelsResponsePBImpl.class,
     validatePBImplRecord(RemoveFromClusterNodeLabelsResponsePBImpl.class,
         RemoveFromClusterNodeLabelsResponseProto.class);
         RemoveFromClusterNodeLabelsResponseProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testGetClusterNodeLabelsRequestPBImpl() throws Exception {
+  void testGetClusterNodeLabelsRequestPBImpl() throws Exception {
     validatePBImplRecord(GetClusterNodeLabelsRequestPBImpl.class,
     validatePBImplRecord(GetClusterNodeLabelsRequestPBImpl.class,
         GetClusterNodeLabelsRequestProto.class);
         GetClusterNodeLabelsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterNodeLabelsResponsePBImpl() throws Exception {
+  void testGetClusterNodeLabelsResponsePBImpl() throws Exception {
     validatePBImplRecord(GetClusterNodeLabelsResponsePBImpl.class,
     validatePBImplRecord(GetClusterNodeLabelsResponsePBImpl.class,
         GetClusterNodeLabelsResponseProto.class);
         GetClusterNodeLabelsResponseProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testReplaceLabelsOnNodeRequestPBImpl() throws Exception {
+  void testReplaceLabelsOnNodeRequestPBImpl() throws Exception {
     validatePBImplRecord(ReplaceLabelsOnNodeRequestPBImpl.class,
     validatePBImplRecord(ReplaceLabelsOnNodeRequestPBImpl.class,
         ReplaceLabelsOnNodeRequestProto.class);
         ReplaceLabelsOnNodeRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testReplaceLabelsOnNodeResponsePBImpl() throws Exception {
+  void testReplaceLabelsOnNodeResponsePBImpl() throws Exception {
     validatePBImplRecord(ReplaceLabelsOnNodeResponsePBImpl.class,
     validatePBImplRecord(ReplaceLabelsOnNodeResponsePBImpl.class,
         ReplaceLabelsOnNodeResponseProto.class);
         ReplaceLabelsOnNodeResponseProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testGetNodeToLabelsRequestPBImpl() throws Exception {
+  void testGetNodeToLabelsRequestPBImpl() throws Exception {
     validatePBImplRecord(GetNodesToLabelsRequestPBImpl.class,
     validatePBImplRecord(GetNodesToLabelsRequestPBImpl.class,
         GetNodesToLabelsRequestProto.class);
         GetNodesToLabelsRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetNodeToLabelsResponsePBImpl() throws Exception {
+  void testGetNodeToLabelsResponsePBImpl() throws Exception {
     validatePBImplRecord(GetNodesToLabelsResponsePBImpl.class,
     validatePBImplRecord(GetNodesToLabelsResponsePBImpl.class,
         GetNodesToLabelsResponseProto.class);
         GetNodesToLabelsResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetLabelsToNodesRequestPBImpl() throws Exception {
+  void testGetLabelsToNodesRequestPBImpl() throws Exception {
     validatePBImplRecord(GetLabelsToNodesRequestPBImpl.class,
     validatePBImplRecord(GetLabelsToNodesRequestPBImpl.class,
         GetLabelsToNodesRequestProto.class);
         GetLabelsToNodesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetLabelsToNodesResponsePBImpl() throws Exception {
+  void testGetLabelsToNodesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetLabelsToNodesResponsePBImpl.class,
     validatePBImplRecord(GetLabelsToNodesResponsePBImpl.class,
         GetLabelsToNodesResponseProto.class);
         GetLabelsToNodesResponseProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testNodeLabelAttributesPBImpl() throws Exception {
+  void testNodeLabelAttributesPBImpl() throws Exception {
     validatePBImplRecord(NodeLabelPBImpl.class,
     validatePBImplRecord(NodeLabelPBImpl.class,
         NodeLabelProto.class);
         NodeLabelProto.class);
   }
   }
-  
+
   @Test
   @Test
-  public void testCheckForDecommissioningNodesRequestPBImpl() throws Exception {
+  void testCheckForDecommissioningNodesRequestPBImpl() throws Exception {
     validatePBImplRecord(CheckForDecommissioningNodesRequestPBImpl.class,
     validatePBImplRecord(CheckForDecommissioningNodesRequestPBImpl.class,
         CheckForDecommissioningNodesRequestProto.class);
         CheckForDecommissioningNodesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testCheckForDecommissioningNodesResponsePBImpl() throws Exception {
+  void testCheckForDecommissioningNodesResponsePBImpl() throws Exception {
     validatePBImplRecord(CheckForDecommissioningNodesResponsePBImpl.class,
     validatePBImplRecord(CheckForDecommissioningNodesResponsePBImpl.class,
         CheckForDecommissioningNodesResponseProto.class);
         CheckForDecommissioningNodesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testExecutionTypeRequestPBImpl() throws Exception {
+  void testExecutionTypeRequestPBImpl() throws Exception {
     validatePBImplRecord(ExecutionTypeRequestPBImpl.class,
     validatePBImplRecord(ExecutionTypeRequestPBImpl.class,
         ExecutionTypeRequestProto.class);
         ExecutionTypeRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetAllResourceProfilesResponsePBImpl() throws Exception {
+  void testGetAllResourceProfilesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetAllResourceProfilesResponsePBImpl.class,
     validatePBImplRecord(GetAllResourceProfilesResponsePBImpl.class,
         GetAllResourceProfilesResponseProto.class);
         GetAllResourceProfilesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceProfileRequestPBImpl() throws Exception {
+  void testGetResourceProfileRequestPBImpl() throws Exception {
     validatePBImplRecord(GetResourceProfileRequestPBImpl.class,
     validatePBImplRecord(GetResourceProfileRequestPBImpl.class,
         GetResourceProfileRequestProto.class);
         GetResourceProfileRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceProfileResponsePBImpl() throws Exception {
+  void testGetResourceProfileResponsePBImpl() throws Exception {
     validatePBImplRecord(GetResourceProfileResponsePBImpl.class,
     validatePBImplRecord(GetResourceProfileResponsePBImpl.class,
         GetResourceProfileResponseProto.class);
         GetResourceProfileResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceTypesInfoPBImpl() throws Exception {
+  void testResourceTypesInfoPBImpl() throws Exception {
     validatePBImplRecord(ResourceTypeInfoPBImpl.class,
     validatePBImplRecord(ResourceTypeInfoPBImpl.class,
         YarnProtos.ResourceTypeInfoProto.class);
         YarnProtos.ResourceTypeInfoProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetAllResourceTypesInfoRequestPBImpl() throws Exception {
+  void testGetAllResourceTypesInfoRequestPBImpl() throws Exception {
     validatePBImplRecord(GetAllResourceTypeInfoRequestPBImpl.class,
     validatePBImplRecord(GetAllResourceTypeInfoRequestPBImpl.class,
         YarnServiceProtos.GetAllResourceTypeInfoRequestProto.class);
         YarnServiceProtos.GetAllResourceTypeInfoRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetAllResourceTypesInfoResponsePBImpl() throws Exception {
+  void testGetAllResourceTypesInfoResponsePBImpl() throws Exception {
     validatePBImplRecord(GetAllResourceTypeInfoResponsePBImpl.class,
     validatePBImplRecord(GetAllResourceTypeInfoResponsePBImpl.class,
         YarnServiceProtos.GetAllResourceTypeInfoResponseProto.class);
         YarnServiceProtos.GetAllResourceTypeInfoResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodeAttributeKeyPBImpl() throws Exception {
+  void testNodeAttributeKeyPBImpl() throws Exception {
     validatePBImplRecord(NodeAttributeKeyPBImpl.class,
     validatePBImplRecord(NodeAttributeKeyPBImpl.class,
         NodeAttributeKeyProto.class);
         NodeAttributeKeyProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodeToAttributeValuePBImpl() throws Exception {
+  void testNodeToAttributeValuePBImpl() throws Exception {
     validatePBImplRecord(NodeToAttributeValuePBImpl.class,
     validatePBImplRecord(NodeToAttributeValuePBImpl.class,
         NodeToAttributeValueProto.class);
         NodeToAttributeValueProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodeAttributePBImpl() throws Exception {
+  void testNodeAttributePBImpl() throws Exception {
     validatePBImplRecord(NodeAttributePBImpl.class, NodeAttributeProto.class);
     validatePBImplRecord(NodeAttributePBImpl.class, NodeAttributeProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodeAttributeInfoPBImpl() throws Exception {
+  void testNodeAttributeInfoPBImpl() throws Exception {
     validatePBImplRecord(NodeAttributeInfoPBImpl.class,
     validatePBImplRecord(NodeAttributeInfoPBImpl.class,
         NodeAttributeInfoProto.class);
         NodeAttributeInfoProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodeToAttributesPBImpl() throws Exception {
+  void testNodeToAttributesPBImpl() throws Exception {
     validatePBImplRecord(NodeToAttributesPBImpl.class,
     validatePBImplRecord(NodeToAttributesPBImpl.class,
         NodeToAttributesProto.class);
         NodeToAttributesProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testNodesToAttributesMappingRequestPBImpl() throws Exception {
+  void testNodesToAttributesMappingRequestPBImpl() throws Exception {
     validatePBImplRecord(NodesToAttributesMappingRequestPBImpl.class,
     validatePBImplRecord(NodesToAttributesMappingRequestPBImpl.class,
         NodesToAttributesMappingRequestProto.class);
         NodesToAttributesMappingRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetAttributesToNodesRequestPBImpl() throws Exception {
+  void testGetAttributesToNodesRequestPBImpl() throws Exception {
     validatePBImplRecord(GetAttributesToNodesRequestPBImpl.class,
     validatePBImplRecord(GetAttributesToNodesRequestPBImpl.class,
         YarnServiceProtos.GetAttributesToNodesRequestProto.class);
         YarnServiceProtos.GetAttributesToNodesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetAttributesToNodesResponsePBImpl() throws Exception {
+  void testGetAttributesToNodesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetAttributesToNodesResponsePBImpl.class,
     validatePBImplRecord(GetAttributesToNodesResponsePBImpl.class,
         YarnServiceProtos.GetAttributesToNodesResponseProto.class);
         YarnServiceProtos.GetAttributesToNodesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterNodeAttributesRequestPBImpl() throws Exception {
+  void testGetClusterNodeAttributesRequestPBImpl() throws Exception {
     validatePBImplRecord(GetClusterNodeAttributesRequestPBImpl.class,
     validatePBImplRecord(GetClusterNodeAttributesRequestPBImpl.class,
         YarnServiceProtos.GetClusterNodeAttributesRequestProto.class);
         YarnServiceProtos.GetClusterNodeAttributesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetClusterNodeAttributesResponsePBImpl() throws Exception {
+  void testGetClusterNodeAttributesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetClusterNodeAttributesResponsePBImpl.class,
     validatePBImplRecord(GetClusterNodeAttributesResponsePBImpl.class,
         YarnServiceProtos.GetClusterNodeAttributesResponseProto.class);
         YarnServiceProtos.GetClusterNodeAttributesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetNodesToAttributesRequestPBImpl() throws Exception {
+  void testGetNodesToAttributesRequestPBImpl() throws Exception {
     validatePBImplRecord(GetNodesToAttributesRequestPBImpl.class,
     validatePBImplRecord(GetNodesToAttributesRequestPBImpl.class,
         YarnServiceProtos.GetNodesToAttributesRequestProto.class);
         YarnServiceProtos.GetNodesToAttributesRequestProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetNodesToAttributesResponsePBImpl() throws Exception {
+  void testGetNodesToAttributesResponsePBImpl() throws Exception {
     validatePBImplRecord(GetNodesToAttributesResponsePBImpl.class,
     validatePBImplRecord(GetNodesToAttributesResponsePBImpl.class,
         YarnServiceProtos.GetNodesToAttributesResponseProto.class);
         YarnServiceProtos.GetNodesToAttributesResponseProto.class);
   }
   }
 
 
   @Test
   @Test
-  public void testGetEnhancedHeadroomPBImpl() throws Exception {
+  void testGetEnhancedHeadroomPBImpl() throws Exception {
     validatePBImplRecord(EnhancedHeadroomPBImpl.class,
     validatePBImplRecord(EnhancedHeadroomPBImpl.class,
         YarnServiceProtos.EnhancedHeadroomProto.class);
         YarnServiceProtos.EnhancedHeadroomProto.class);
   }
   }

+ 49 - 46
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPlacementConstraintPBConversion.java

@@ -18,17 +18,10 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.NODE;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.RACK;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.cardinality;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.maxCardinality;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.or;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetCardinality;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.allocationTag;
-
 import java.util.Iterator;
 import java.util.Iterator;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.pb.PlacementConstraintFromProtoConverter;
 import org.apache.hadoop.yarn.api.pb.PlacementConstraintFromProtoConverter;
 import org.apache.hadoop.yarn.api.pb.PlacementConstraintToProtoConverter;
 import org.apache.hadoop.yarn.api.pb.PlacementConstraintToProtoConverter;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint;
@@ -40,8 +33,18 @@ import org.apache.hadoop.yarn.proto.YarnProtos.CompositePlacementConstraintProto
 import org.apache.hadoop.yarn.proto.YarnProtos.CompositePlacementConstraintProto.CompositeType;
 import org.apache.hadoop.yarn.proto.YarnProtos.CompositePlacementConstraintProto.CompositeType;
 import org.apache.hadoop.yarn.proto.YarnProtos.PlacementConstraintProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PlacementConstraintProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.SimplePlacementConstraintProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.SimplePlacementConstraintProto;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.NODE;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.allocationTag;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.RACK;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.cardinality;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.maxCardinality;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.or;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetCardinality;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test class for {@link PlacementConstraintToProtoConverter} and
  * Test class for {@link PlacementConstraintToProtoConverter} and
@@ -50,10 +53,10 @@ import org.junit.Test;
 public class TestPlacementConstraintPBConversion {
 public class TestPlacementConstraintPBConversion {
 
 
   @Test
   @Test
-  public void testTargetConstraintProtoConverter() {
+  void testTargetConstraintProtoConverter() {
     AbstractConstraint sConstraintExpr =
     AbstractConstraint sConstraintExpr =
         targetIn(NODE, allocationTag("hbase-m"));
         targetIn(NODE, allocationTag("hbase-m"));
-    Assert.assertTrue(sConstraintExpr instanceof SingleConstraint);
+    assertTrue(sConstraintExpr instanceof SingleConstraint);
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     PlacementConstraint sConstraint =
     PlacementConstraint sConstraint =
         PlacementConstraints.build(sConstraintExpr);
         PlacementConstraints.build(sConstraintExpr);
@@ -63,14 +66,14 @@ public class TestPlacementConstraintPBConversion {
         new PlacementConstraintToProtoConverter(sConstraint);
         new PlacementConstraintToProtoConverter(sConstraint);
     PlacementConstraintProto protoConstraint = toProtoConverter.convert();
     PlacementConstraintProto protoConstraint = toProtoConverter.convert();
 
 
-    Assert.assertTrue(protoConstraint.hasSimpleConstraint());
-    Assert.assertFalse(protoConstraint.hasCompositeConstraint());
+    assertTrue(protoConstraint.hasSimpleConstraint());
+    assertFalse(protoConstraint.hasCompositeConstraint());
     SimplePlacementConstraintProto sProto =
     SimplePlacementConstraintProto sProto =
         protoConstraint.getSimpleConstraint();
         protoConstraint.getSimpleConstraint();
-    Assert.assertEquals(single.getScope(), sProto.getScope());
-    Assert.assertEquals(single.getMinCardinality(), sProto.getMinCardinality());
-    Assert.assertEquals(single.getMaxCardinality(), sProto.getMaxCardinality());
-    Assert.assertEquals(single.getTargetExpressions().size(),
+    assertEquals(single.getScope(), sProto.getScope());
+    assertEquals(single.getMinCardinality(), sProto.getMinCardinality());
+    assertEquals(single.getMaxCardinality(), sProto.getMaxCardinality());
+    assertEquals(single.getTargetExpressions().size(),
         sProto.getTargetExpressionsList().size());
         sProto.getTargetExpressionsList().size());
 
 
     // Convert from proto.
     // Convert from proto.
@@ -79,21 +82,21 @@ public class TestPlacementConstraintPBConversion {
     PlacementConstraint newConstraint = fromProtoConverter.convert();
     PlacementConstraint newConstraint = fromProtoConverter.convert();
 
 
     AbstractConstraint newConstraintExpr = newConstraint.getConstraintExpr();
     AbstractConstraint newConstraintExpr = newConstraint.getConstraintExpr();
-    Assert.assertTrue(newConstraintExpr instanceof SingleConstraint);
+    assertTrue(newConstraintExpr instanceof SingleConstraint);
     SingleConstraint newSingle = (SingleConstraint) newConstraintExpr;
     SingleConstraint newSingle = (SingleConstraint) newConstraintExpr;
-    Assert.assertEquals(single.getScope(), newSingle.getScope());
-    Assert.assertEquals(single.getMinCardinality(),
+    assertEquals(single.getScope(), newSingle.getScope());
+    assertEquals(single.getMinCardinality(),
         newSingle.getMinCardinality());
         newSingle.getMinCardinality());
-    Assert.assertEquals(single.getMaxCardinality(),
+    assertEquals(single.getMaxCardinality(),
         newSingle.getMaxCardinality());
         newSingle.getMaxCardinality());
-    Assert.assertEquals(single.getTargetExpressions(),
+    assertEquals(single.getTargetExpressions(),
         newSingle.getTargetExpressions());
         newSingle.getTargetExpressions());
   }
   }
 
 
   @Test
   @Test
-  public void testCardinalityConstraintProtoConverter() {
+  void testCardinalityConstraintProtoConverter() {
     AbstractConstraint sConstraintExpr = cardinality(RACK, 3, 10);
     AbstractConstraint sConstraintExpr = cardinality(RACK, 3, 10);
-    Assert.assertTrue(sConstraintExpr instanceof SingleConstraint);
+    assertTrue(sConstraintExpr instanceof SingleConstraint);
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     PlacementConstraint sConstraint =
     PlacementConstraint sConstraint =
         PlacementConstraints.build(sConstraintExpr);
         PlacementConstraints.build(sConstraintExpr);
@@ -111,17 +114,17 @@ public class TestPlacementConstraintPBConversion {
     PlacementConstraint newConstraint = fromProtoConverter.convert();
     PlacementConstraint newConstraint = fromProtoConverter.convert();
 
 
     AbstractConstraint newConstraintExpr = newConstraint.getConstraintExpr();
     AbstractConstraint newConstraintExpr = newConstraint.getConstraintExpr();
-    Assert.assertTrue(newConstraintExpr instanceof SingleConstraint);
+    assertTrue(newConstraintExpr instanceof SingleConstraint);
     SingleConstraint newSingle = (SingleConstraint) newConstraintExpr;
     SingleConstraint newSingle = (SingleConstraint) newConstraintExpr;
     compareSimpleConstraints(single, newSingle);
     compareSimpleConstraints(single, newSingle);
   }
   }
 
 
   @Test
   @Test
-  public void testCompositeConstraintProtoConverter() {
+  void testCompositeConstraintProtoConverter() {
     AbstractConstraint constraintExpr =
     AbstractConstraint constraintExpr =
         or(targetIn(RACK, allocationTag("spark")), maxCardinality(NODE, 3),
         or(targetIn(RACK, allocationTag("spark")), maxCardinality(NODE, 3),
             targetCardinality(RACK, 2, 10, allocationTag("zk")));
             targetCardinality(RACK, 2, 10, allocationTag("zk")));
-    Assert.assertTrue(constraintExpr instanceof Or);
+    assertTrue(constraintExpr instanceof Or);
     PlacementConstraint constraint = PlacementConstraints.build(constraintExpr);
     PlacementConstraint constraint = PlacementConstraints.build(constraintExpr);
     Or orExpr = (Or) constraintExpr;
     Or orExpr = (Or) constraintExpr;
 
 
@@ -130,14 +133,14 @@ public class TestPlacementConstraintPBConversion {
         new PlacementConstraintToProtoConverter(constraint);
         new PlacementConstraintToProtoConverter(constraint);
     PlacementConstraintProto protoConstraint = toProtoConverter.convert();
     PlacementConstraintProto protoConstraint = toProtoConverter.convert();
 
 
-    Assert.assertFalse(protoConstraint.hasSimpleConstraint());
-    Assert.assertTrue(protoConstraint.hasCompositeConstraint());
+    assertFalse(protoConstraint.hasSimpleConstraint());
+    assertTrue(protoConstraint.hasCompositeConstraint());
     CompositePlacementConstraintProto cProto =
     CompositePlacementConstraintProto cProto =
         protoConstraint.getCompositeConstraint();
         protoConstraint.getCompositeConstraint();
 
 
-    Assert.assertEquals(CompositeType.OR, cProto.getCompositeType());
-    Assert.assertEquals(3, cProto.getChildConstraintsCount());
-    Assert.assertEquals(0, cProto.getTimedChildConstraintsCount());
+    assertEquals(CompositeType.OR, cProto.getCompositeType());
+    assertEquals(3, cProto.getChildConstraintsCount());
+    assertEquals(0, cProto.getTimedChildConstraintsCount());
     Iterator<AbstractConstraint> orChildren = orExpr.getChildren().iterator();
     Iterator<AbstractConstraint> orChildren = orExpr.getChildren().iterator();
     Iterator<PlacementConstraintProto> orProtoChildren =
     Iterator<PlacementConstraintProto> orProtoChildren =
         cProto.getChildConstraintsList().iterator();
         cProto.getChildConstraintsList().iterator();
@@ -153,9 +156,9 @@ public class TestPlacementConstraintPBConversion {
     PlacementConstraint newConstraint = fromProtoConverter.convert();
     PlacementConstraint newConstraint = fromProtoConverter.convert();
 
 
     AbstractConstraint newConstraintExpr = newConstraint.getConstraintExpr();
     AbstractConstraint newConstraintExpr = newConstraint.getConstraintExpr();
-    Assert.assertTrue(newConstraintExpr instanceof Or);
+    assertTrue(newConstraintExpr instanceof Or);
     Or newOrExpr = (Or) newConstraintExpr;
     Or newOrExpr = (Or) newConstraintExpr;
-    Assert.assertEquals(3, newOrExpr.getChildren().size());
+    assertEquals(3, newOrExpr.getChildren().size());
     orChildren = orExpr.getChildren().iterator();
     orChildren = orExpr.getChildren().iterator();
     Iterator<AbstractConstraint> newOrChildren =
     Iterator<AbstractConstraint> newOrChildren =
         newOrExpr.getChildren().iterator();
         newOrExpr.getChildren().iterator();
@@ -169,26 +172,26 @@ public class TestPlacementConstraintPBConversion {
 
 
   private void compareSimpleConstraintToProto(SingleConstraint constraint,
   private void compareSimpleConstraintToProto(SingleConstraint constraint,
       PlacementConstraintProto proto) {
       PlacementConstraintProto proto) {
-    Assert.assertTrue(proto.hasSimpleConstraint());
-    Assert.assertFalse(proto.hasCompositeConstraint());
+    assertTrue(proto.hasSimpleConstraint());
+    assertFalse(proto.hasCompositeConstraint());
     SimplePlacementConstraintProto sProto = proto.getSimpleConstraint();
     SimplePlacementConstraintProto sProto = proto.getSimpleConstraint();
-    Assert.assertEquals(constraint.getScope(), sProto.getScope());
-    Assert.assertEquals(constraint.getMinCardinality(),
+    assertEquals(constraint.getScope(), sProto.getScope());
+    assertEquals(constraint.getMinCardinality(),
         sProto.getMinCardinality());
         sProto.getMinCardinality());
-    Assert.assertEquals(constraint.getMaxCardinality(),
+    assertEquals(constraint.getMaxCardinality(),
         sProto.getMaxCardinality());
         sProto.getMaxCardinality());
-    Assert.assertEquals(constraint.getTargetExpressions().size(),
+    assertEquals(constraint.getTargetExpressions().size(),
         sProto.getTargetExpressionsList().size());
         sProto.getTargetExpressionsList().size());
   }
   }
 
 
   private void compareSimpleConstraints(SingleConstraint single,
   private void compareSimpleConstraints(SingleConstraint single,
       SingleConstraint newSingle) {
       SingleConstraint newSingle) {
-    Assert.assertEquals(single.getScope(), newSingle.getScope());
-    Assert.assertEquals(single.getMinCardinality(),
+    assertEquals(single.getScope(), newSingle.getScope());
+    assertEquals(single.getMinCardinality(),
         newSingle.getMinCardinality());
         newSingle.getMinCardinality());
-    Assert.assertEquals(single.getMaxCardinality(),
+    assertEquals(single.getMaxCardinality(),
         newSingle.getMaxCardinality());
         newSingle.getMaxCardinality());
-    Assert.assertEquals(single.getTargetExpressions(),
+    assertEquals(single.getTargetExpressions(),
         newSingle.getTargetExpressions());
         newSingle.getTargetExpressions());
   }
   }
 
 

+ 69 - 66
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestResourcePBImpl.java

@@ -20,6 +20,10 @@ package org.apache.hadoop.yarn.api;
 
 
 import java.io.File;
 import java.io.File;
 
 
+import org.junit.jupiter.api.AfterEach;
+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.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
@@ -29,20 +33,19 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.proto.YarnProtos;
 import org.apache.hadoop.yarn.proto.YarnProtos;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.ResourceUtils;
 import org.apache.hadoop.yarn.util.resource.TestResourceUtils;
 import org.apache.hadoop.yarn.util.resource.TestResourceUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
 
 
 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.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.assertTrue;
 
 
 /**
 /**
  * Test class to handle various proto related tests for resources.
  * Test class to handle various proto related tests for resources.
  */
  */
 public class TestResourcePBImpl {
 public class TestResourcePBImpl {
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     ResourceUtils.resetResourceTypes();
     ResourceUtils.resetResourceTypes();
 
 
@@ -51,7 +54,7 @@ public class TestResourcePBImpl {
     TestResourceUtils.setupResourceTypes(conf, resourceTypesFile);
     TestResourceUtils.setupResourceTypes(conf, resourceTypesFile);
   }
   }
 
 
-  @After
+  @AfterEach
   public void teardown() {
   public void teardown() {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     File source = new File(
     File source = new File(
@@ -63,80 +66,80 @@ public class TestResourcePBImpl {
   }
   }
 
 
   @Test
   @Test
-  public void testEmptyResourcePBInit() throws Exception {
+  void testEmptyResourcePBInit() throws Exception {
     Resource res = new ResourcePBImpl();
     Resource res = new ResourcePBImpl();
     // Assert to check it sets resource value and unit to default.
     // Assert to check it sets resource value and unit to default.
-    Assert.assertEquals(0, res.getMemorySize());
-    Assert.assertEquals(ResourceInformation.MEMORY_MB.getUnits(),
+    assertEquals(0, res.getMemorySize());
+    assertEquals(ResourceInformation.MEMORY_MB.getUnits(),
         res.getResourceInformation(ResourceInformation.MEMORY_MB.getName())
         res.getResourceInformation(ResourceInformation.MEMORY_MB.getName())
             .getUnits());
             .getUnits());
-    Assert.assertEquals(ResourceInformation.VCORES.getUnits(),
+    assertEquals(ResourceInformation.VCORES.getUnits(),
         res.getResourceInformation(ResourceInformation.VCORES.getName())
         res.getResourceInformation(ResourceInformation.VCORES.getName())
             .getUnits());
             .getUnits());
   }
   }
 
 
   @Test
   @Test
-  public void testResourcePBInitFromOldPB() throws Exception {
+  void testResourcePBInitFromOldPB() throws Exception {
     YarnProtos.ResourceProto proto =
     YarnProtos.ResourceProto proto =
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).setVirtualCores(3)
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).setVirtualCores(3)
             .build();
             .build();
     // Assert to check it sets resource value and unit to default.
     // Assert to check it sets resource value and unit to default.
     Resource res = new ResourcePBImpl(proto);
     Resource res = new ResourcePBImpl(proto);
-    Assert.assertEquals(1024, res.getMemorySize());
-    Assert.assertEquals(3, res.getVirtualCores());
-    Assert.assertEquals(ResourceInformation.MEMORY_MB.getUnits(),
+    assertEquals(1024, res.getMemorySize());
+    assertEquals(3, res.getVirtualCores());
+    assertEquals(ResourceInformation.MEMORY_MB.getUnits(),
         res.getResourceInformation(ResourceInformation.MEMORY_MB.getName())
         res.getResourceInformation(ResourceInformation.MEMORY_MB.getName())
             .getUnits());
             .getUnits());
-    Assert.assertEquals(ResourceInformation.VCORES.getUnits(),
+    assertEquals(ResourceInformation.VCORES.getUnits(),
         res.getResourceInformation(ResourceInformation.VCORES.getName())
         res.getResourceInformation(ResourceInformation.VCORES.getName())
             .getUnits());
             .getUnits());
   }
   }
 
 
   @Test
   @Test
   @SuppressWarnings("deprecation")
   @SuppressWarnings("deprecation")
-  public void testGetMemory() {
+  void testGetMemory() {
     Resource res = new ResourcePBImpl();
     Resource res = new ResourcePBImpl();
     long memorySize = Integer.MAX_VALUE + 1L;
     long memorySize = Integer.MAX_VALUE + 1L;
     res.setMemorySize(memorySize);
     res.setMemorySize(memorySize);
 
 
-    assertEquals("No need to cast if both are long", memorySize,
-        res.getMemorySize());
-    assertEquals("Cast to Integer.MAX_VALUE if the long is greater than "
-            + "Integer.MAX_VALUE", Integer.MAX_VALUE, res.getMemory());
+    assertEquals(memorySize, res.getMemorySize(), "No need to cast if both are long");
+    assertEquals(Integer.MAX_VALUE, res.getMemory(),
+        "Cast to Integer.MAX_VALUE if the long is greater than " + "Integer.MAX_VALUE");
   }
   }
 
 
   @Test
   @Test
-  public void testGetVirtualCores() {
+  void testGetVirtualCores() {
     Resource res = new ResourcePBImpl();
     Resource res = new ResourcePBImpl();
     long vcores = Integer.MAX_VALUE + 1L;
     long vcores = Integer.MAX_VALUE + 1L;
     res.getResourceInformation("vcores").setValue(vcores);
     res.getResourceInformation("vcores").setValue(vcores);
 
 
-    assertEquals("No need to cast if both are long", vcores,
-        res.getResourceInformation("vcores").getValue());
-    assertEquals("Cast to Integer.MAX_VALUE if the long is greater than "
-        + "Integer.MAX_VALUE", Integer.MAX_VALUE, res.getVirtualCores());
+    assertEquals(vcores,
+        res.getResourceInformation("vcores").getValue(),
+        "No need to cast if both are long");
+    assertEquals(Integer.MAX_VALUE, res.getVirtualCores(),
+        "Cast to Integer.MAX_VALUE if the long is greater than " + "Integer.MAX_VALUE");
   }
   }
 
 
   @Test
   @Test
-  public void testResourcePBWithExtraResources() throws Exception {
+  void testResourcePBWithExtraResources() throws Exception {
 
 
     //Resource 'resource1' has been passed as 4T
     //Resource 'resource1' has been passed as 4T
     //4T should be converted to 4000G
     //4T should be converted to 4000G
     YarnProtos.ResourceInformationProto riProto =
     YarnProtos.ResourceInformationProto riProto =
         YarnProtos.ResourceInformationProto.newBuilder().setType(
         YarnProtos.ResourceInformationProto.newBuilder().setType(
             YarnProtos.ResourceTypeInfoProto.newBuilder().
             YarnProtos.ResourceTypeInfoProto.newBuilder().
-            setName("resource1").setType(
+                setName("resource1").setType(
                 YarnProtos.ResourceTypesProto.COUNTABLE).getType()).
                 YarnProtos.ResourceTypesProto.COUNTABLE).getType()).
-        setValue(4).setUnits("T").setKey("resource1").build();
+            setValue(4).setUnits("T").setKey("resource1").build();
 
 
     YarnProtos.ResourceProto proto =
     YarnProtos.ResourceProto proto =
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).
-        setVirtualCores(3).addResourceValueMap(riProto).build();
+            setVirtualCores(3).addResourceValueMap(riProto).build();
     Resource res = new ResourcePBImpl(proto);
     Resource res = new ResourcePBImpl(proto);
 
 
-    Assert.assertEquals(4000,
+    assertEquals(4000,
         res.getResourceInformation("resource1").getValue());
         res.getResourceInformation("resource1").getValue());
-    Assert.assertEquals("G",
+    assertEquals("G",
         res.getResourceInformation("resource1").getUnits());
         res.getResourceInformation("resource1").getUnits());
 
 
     //Resource 'resource2' has been passed as 4M
     //Resource 'resource2' has been passed as 4M
@@ -144,18 +147,18 @@ public class TestResourcePBImpl {
     YarnProtos.ResourceInformationProto riProto1 =
     YarnProtos.ResourceInformationProto riProto1 =
         YarnProtos.ResourceInformationProto.newBuilder().setType(
         YarnProtos.ResourceInformationProto.newBuilder().setType(
             YarnProtos.ResourceTypeInfoProto.newBuilder().
             YarnProtos.ResourceTypeInfoProto.newBuilder().
-            setName("resource2").setType(
+                setName("resource2").setType(
                 YarnProtos.ResourceTypesProto.COUNTABLE).getType()).
                 YarnProtos.ResourceTypesProto.COUNTABLE).getType()).
-        setValue(4).setUnits("M").setKey("resource2").build();
+            setValue(4).setUnits("M").setKey("resource2").build();
 
 
     YarnProtos.ResourceProto proto1 =
     YarnProtos.ResourceProto proto1 =
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).
-        setVirtualCores(3).addResourceValueMap(riProto1).build();
+            setVirtualCores(3).addResourceValueMap(riProto1).build();
     Resource res1 = new ResourcePBImpl(proto1);
     Resource res1 = new ResourcePBImpl(proto1);
 
 
-    Assert.assertEquals(4000000000L,
+    assertEquals(4000000000L,
         res1.getResourceInformation("resource2").getValue());
         res1.getResourceInformation("resource2").getValue());
-    Assert.assertEquals("m",
+    assertEquals("m",
         res1.getResourceInformation("resource2").getUnits());
         res1.getResourceInformation("resource2").getUnits());
 
 
     //Resource 'resource1' has been passed as 3M
     //Resource 'resource1' has been passed as 3M
@@ -163,23 +166,23 @@ public class TestResourcePBImpl {
     YarnProtos.ResourceInformationProto riProto2 =
     YarnProtos.ResourceInformationProto riProto2 =
         YarnProtos.ResourceInformationProto.newBuilder().setType(
         YarnProtos.ResourceInformationProto.newBuilder().setType(
             YarnProtos.ResourceTypeInfoProto.newBuilder().
             YarnProtos.ResourceTypeInfoProto.newBuilder().
-            setName("resource1").setType(
+                setName("resource1").setType(
                 YarnProtos.ResourceTypesProto.COUNTABLE).getType()).
                 YarnProtos.ResourceTypesProto.COUNTABLE).getType()).
-        setValue(3).setUnits("M").setKey("resource1").build();
+            setValue(3).setUnits("M").setKey("resource1").build();
 
 
     YarnProtos.ResourceProto proto2 =
     YarnProtos.ResourceProto proto2 =
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).
         YarnProtos.ResourceProto.newBuilder().setMemory(1024).
-        setVirtualCores(3).addResourceValueMap(riProto2).build();
+            setVirtualCores(3).addResourceValueMap(riProto2).build();
     Resource res2 = new ResourcePBImpl(proto2);
     Resource res2 = new ResourcePBImpl(proto2);
 
 
-    Assert.assertEquals(0,
+    assertEquals(0,
         res2.getResourceInformation("resource1").getValue());
         res2.getResourceInformation("resource1").getValue());
-    Assert.assertEquals("G",
+    assertEquals("G",
         res2.getResourceInformation("resource1").getUnits());
         res2.getResourceInformation("resource1").getUnits());
   }
   }
 
 
   @Test
   @Test
-  public void testResourceTags() {
+  void testResourceTags() {
     YarnProtos.ResourceInformationProto riProto =
     YarnProtos.ResourceInformationProto riProto =
         YarnProtos.ResourceInformationProto.newBuilder()
         YarnProtos.ResourceInformationProto.newBuilder()
             .setType(
             .setType(
@@ -201,19 +204,19 @@ public class TestResourcePBImpl {
             .build();
             .build();
     Resource res = new ResourcePBImpl(proto);
     Resource res = new ResourcePBImpl(proto);
 
 
-    Assert.assertNotNull(res.getResourceInformation("yarn.io/test-volume"));
-    Assert.assertEquals(10,
+    assertNotNull(res.getResourceInformation("yarn.io/test-volume"));
+    assertEquals(10,
         res.getResourceInformation("yarn.io/test-volume")
         res.getResourceInformation("yarn.io/test-volume")
             .getValue());
             .getValue());
-    Assert.assertEquals("G",
+    assertEquals("G",
         res.getResourceInformation("yarn.io/test-volume")
         res.getResourceInformation("yarn.io/test-volume")
             .getUnits());
             .getUnits());
-    Assert.assertEquals(3,
+    assertEquals(3,
         res.getResourceInformation("yarn.io/test-volume")
         res.getResourceInformation("yarn.io/test-volume")
             .getTags().size());
             .getTags().size());
-    Assert.assertFalse(res.getResourceInformation("yarn.io/test-volume")
+    assertFalse(res.getResourceInformation("yarn.io/test-volume")
         .getTags().isEmpty());
         .getTags().isEmpty());
-    Assert.assertTrue(res.getResourceInformation("yarn.io/test-volume")
+    assertTrue(res.getResourceInformation("yarn.io/test-volume")
         .getAttributes().isEmpty());
         .getAttributes().isEmpty());
 
 
     boolean protoConvertExpected = false;
     boolean protoConvertExpected = false;
@@ -225,13 +228,13 @@ public class TestResourcePBImpl {
             && pf.getTagsCount() == 3;
             && pf.getTagsCount() == 3;
       }
       }
     }
     }
-    Assert.assertTrue("Expecting resource's protobuf message"
-        + " contains 0 attributes and 3 tags",
-        protoConvertExpected);
+    assertTrue(protoConvertExpected,
+        "Expecting resource's protobuf message"
+            + " contains 0 attributes and 3 tags");
   }
   }
 
 
   @Test
   @Test
-  public void testResourceAttributes() {
+  void testResourceAttributes() {
     YarnProtos.ResourceInformationProto riProto =
     YarnProtos.ResourceInformationProto riProto =
         YarnProtos.ResourceInformationProto.newBuilder()
         YarnProtos.ResourceInformationProto.newBuilder()
             .setType(
             .setType(
@@ -260,19 +263,19 @@ public class TestResourcePBImpl {
             .build();
             .build();
     Resource res = new ResourcePBImpl(proto);
     Resource res = new ResourcePBImpl(proto);
 
 
-    Assert.assertNotNull(res.getResourceInformation("yarn.io/test-volume"));
-    Assert.assertEquals(10,
+    assertNotNull(res.getResourceInformation("yarn.io/test-volume"));
+    assertEquals(10,
         res.getResourceInformation("yarn.io/test-volume")
         res.getResourceInformation("yarn.io/test-volume")
             .getValue());
             .getValue());
-    Assert.assertEquals("G",
+    assertEquals("G",
         res.getResourceInformation("yarn.io/test-volume")
         res.getResourceInformation("yarn.io/test-volume")
             .getUnits());
             .getUnits());
-    Assert.assertEquals(2,
+    assertEquals(2,
         res.getResourceInformation("yarn.io/test-volume")
         res.getResourceInformation("yarn.io/test-volume")
             .getAttributes().size());
             .getAttributes().size());
-    Assert.assertTrue(res.getResourceInformation("yarn.io/test-volume")
+    assertTrue(res.getResourceInformation("yarn.io/test-volume")
         .getTags().isEmpty());
         .getTags().isEmpty());
-    Assert.assertFalse(res.getResourceInformation("yarn.io/test-volume")
+    assertFalse(res.getResourceInformation("yarn.io/test-volume")
         .getAttributes().isEmpty());
         .getAttributes().isEmpty());
 
 
     boolean protoConvertExpected = false;
     boolean protoConvertExpected = false;
@@ -284,20 +287,20 @@ public class TestResourcePBImpl {
             && pf.getTagsCount() == 0;
             && pf.getTagsCount() == 0;
       }
       }
     }
     }
-    Assert.assertTrue("Expecting resource's protobuf message"
-            + " contains 2 attributes and 0 tags",
-        protoConvertExpected);
+    assertTrue(protoConvertExpected,
+        "Expecting resource's protobuf message"
+            + " contains 2 attributes and 0 tags");
   }
   }
 
 
   @Test
   @Test
-  public void testParsingResourceTags() {
+  void testParsingResourceTags() {
     ResourceInformation info =
     ResourceInformation info =
         ResourceUtils.getResourceTypes().get("resource3");
         ResourceUtils.getResourceTypes().get("resource3");
-    Assert.assertTrue(info.getAttributes().isEmpty());
-    Assert.assertFalse(info.getTags().isEmpty());
+    assertTrue(info.getAttributes().isEmpty());
+    assertFalse(info.getTags().isEmpty());
     assertThat(info.getTags()).hasSize(2);
     assertThat(info.getTags()).hasSize(2);
     info.getTags().remove("resource3_tag_1");
     info.getTags().remove("resource3_tag_1");
     info.getTags().remove("resource3_tag_2");
     info.getTags().remove("resource3_tag_2");
-    Assert.assertTrue(info.getTags().isEmpty());
+    assertTrue(info.getTags().isEmpty());
   }
   }
 }
 }

+ 6 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestResourceRequest.java

@@ -17,13 +17,15 @@
  */
  */
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.records.ExecutionType;
 import org.apache.hadoop.yarn.api.records.ExecutionType;
 import org.apache.hadoop.yarn.api.records.ExecutionTypeRequest;
 import org.apache.hadoop.yarn.api.records.ExecutionTypeRequest;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Priority;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceRequest;
 import org.apache.hadoop.yarn.api.records.ResourceRequest;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 
 /**
 /**
  * The class to test {@link ResourceRequest}.
  * The class to test {@link ResourceRequest}.
@@ -31,7 +33,7 @@ import org.junit.Test;
 public class TestResourceRequest {
 public class TestResourceRequest {
 
 
   @Test
   @Test
-  public void testEqualsOnExecutionTypeRequest() {
+  void testEqualsOnExecutionTypeRequest() {
     ResourceRequest resourceRequestA =
     ResourceRequest resourceRequestA =
         ResourceRequest.newInstance(Priority.newInstance(0), "localhost",
         ResourceRequest.newInstance(Priority.newInstance(0), "localhost",
             Resource.newInstance(1024, 1), 1, false, "",
             Resource.newInstance(1024, 1), 1, false, "",
@@ -42,6 +44,6 @@ public class TestResourceRequest {
             Resource.newInstance(1024, 1), 1, false, "",
             Resource.newInstance(1024, 1), 1, false, "",
             ExecutionTypeRequest.newInstance(ExecutionType.GUARANTEED, false));
             ExecutionTypeRequest.newInstance(ExecutionType.GUARANTEED, false));
 
 
-    Assert.assertFalse(resourceRequestA.equals(resourceRequestB));
+    assertNotEquals(resourceRequestA, resourceRequestB);
   }
   }
 }
 }

+ 19 - 14
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestTimelineEntityGroupId.java

@@ -18,15 +18,20 @@
 
 
 package org.apache.hadoop.yarn.api;
 package org.apache.hadoop.yarn.api;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId;
-import org.junit.Assert;
-import org.junit.Test;
+
+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.assertTrue;
 
 
 public class TestTimelineEntityGroupId {
 public class TestTimelineEntityGroupId {
 
 
   @Test
   @Test
-  public void testTimelineEntityGroupId() {
+  void testTimelineEntityGroupId() {
     ApplicationId appId1 = ApplicationId.newInstance(1234, 1);
     ApplicationId appId1 = ApplicationId.newInstance(1234, 1);
     ApplicationId appId2 = ApplicationId.newInstance(1234, 2);
     ApplicationId appId2 = ApplicationId.newInstance(1234, 2);
     TimelineEntityGroupId group1 = TimelineEntityGroupId.newInstance(appId1, "1");
     TimelineEntityGroupId group1 = TimelineEntityGroupId.newInstance(appId1, "1");
@@ -34,19 +39,19 @@ public class TestTimelineEntityGroupId {
     TimelineEntityGroupId group3 = TimelineEntityGroupId.newInstance(appId2, "1");
     TimelineEntityGroupId group3 = TimelineEntityGroupId.newInstance(appId2, "1");
     TimelineEntityGroupId group4 = TimelineEntityGroupId.newInstance(appId1, "1");
     TimelineEntityGroupId group4 = TimelineEntityGroupId.newInstance(appId1, "1");
 
 
-    Assert.assertTrue(group1.equals(group4));
-    Assert.assertFalse(group1.equals(group2));
-    Assert.assertFalse(group1.equals(group3));
+    assertEquals(group1, group4);
+    assertNotEquals(group1, group2);
+    assertNotEquals(group1, group3);
 
 
-    Assert.assertTrue(group1.compareTo(group4) == 0);
-    Assert.assertTrue(group1.compareTo(group2) < 0);
-    Assert.assertTrue(group1.compareTo(group3) < 0);
+    assertTrue(group1.compareTo(group4) == 0);
+    assertTrue(group1.compareTo(group2) < 0);
+    assertTrue(group1.compareTo(group3) < 0);
 
 
-    Assert.assertTrue(group1.hashCode() == group4.hashCode());
-    Assert.assertFalse(group1.hashCode() == group2.hashCode());
-    Assert.assertFalse(group1.hashCode() == group3.hashCode());
+    assertTrue(group1.hashCode() == group4.hashCode());
+    assertFalse(group1.hashCode() == group2.hashCode());
+    assertFalse(group1.hashCode() == group3.hashCode());
 
 
-    Assert.assertEquals("timelineEntityGroupId_1234_1_1", group1.toString());
-    Assert.assertEquals(TimelineEntityGroupId.fromString("timelineEntityGroupId_1234_1_1"), group1);
+    assertEquals("timelineEntityGroupId_1234_1_1", group1.toString());
+    assertEquals(TimelineEntityGroupId.fromString("timelineEntityGroupId_1234_1_1"), group1);
   }
   }
 }
 }

+ 35 - 28
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/TestGetApplicationsRequestPBImpl.java

@@ -18,57 +18,64 @@
 
 
 package org.apache.hadoop.yarn.api.protocolrecords.impl.pb;
 package org.apache.hadoop.yarn.api.protocolrecords.impl.pb;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.List;
 import java.util.List;
 
 
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsRequestProto;
 import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetApplicationsRequestProto;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
 
 
-@RunWith(Parameterized.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
 public class TestGetApplicationsRequestPBImpl {
 public class TestGetApplicationsRequestPBImpl {
-  @Parameter
   @SuppressWarnings("checkstyle:visibilitymodifier")
   @SuppressWarnings("checkstyle:visibilitymodifier")
   public GetApplicationsRequestPBImpl impl;
   public GetApplicationsRequestPBImpl impl;
 
 
-  @Test
-  public void testAppTagsLowerCaseConversionDefault() {
-    impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
-    impl.getApplicationTags().forEach(s ->
-        assertEquals(s, s.toLowerCase()));
+  @MethodSource("data")
+  @ParameterizedTest
+  void testAppTagsLowerCaseConversionDefault(
+      GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
+    initTestGetApplicationsRequestPBImpl(applicationsRequestPBImpl);
+    applicationsRequestPBImpl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
+    applicationsRequestPBImpl.getApplicationTags().forEach(s -> assertEquals(s, s.toLowerCase()));
   }
   }
 
 
-  @Test
-  public void testAppTagsLowerCaseConversionDisabled() {
+  @MethodSource("data")
+  @ParameterizedTest
+  void testAppTagsLowerCaseConversionDisabled(
+      GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
+    initTestGetApplicationsRequestPBImpl(applicationsRequestPBImpl);
     GetApplicationsRequestPBImpl.setForceLowerCaseTags(false);
     GetApplicationsRequestPBImpl.setForceLowerCaseTags(false);
-    impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
-    impl.getApplicationTags().forEach(s ->
-        assertNotEquals(s, s.toLowerCase()));
+    applicationsRequestPBImpl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
+    applicationsRequestPBImpl.getApplicationTags()
+        .forEach(s -> assertNotEquals(s, s.toLowerCase()));
   }
   }
 
 
-  @Test
-  public void testAppTagsLowerCaseConversionEnabled() {
+  @MethodSource("data")
+  @ParameterizedTest
+  void testAppTagsLowerCaseConversionEnabled(
+      GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
+    initTestGetApplicationsRequestPBImpl(applicationsRequestPBImpl);
     GetApplicationsRequestPBImpl.setForceLowerCaseTags(true);
     GetApplicationsRequestPBImpl.setForceLowerCaseTags(true);
-    impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
-    impl.getApplicationTags().forEach(s ->
-        assertEquals(s, s.toLowerCase()));
+    applicationsRequestPBImpl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
+    applicationsRequestPBImpl.getApplicationTags().forEach(s -> assertEquals(s, s.toLowerCase()));
   }
   }
 
 
-  @Parameters
   public static Collection<Object[]> data() {
   public static Collection<Object[]> data() {
     List<Object[]> list = new ArrayList<>();
     List<Object[]> list = new ArrayList<>();
-    list.add(new Object[] {new GetApplicationsRequestPBImpl()});
-    list.add(new Object[] {new GetApplicationsRequestPBImpl(
+    list.add(new Object[]{new GetApplicationsRequestPBImpl()});
+    list.add(new Object[]{new GetApplicationsRequestPBImpl(
         GetApplicationsRequestProto.newBuilder().build())});
         GetApplicationsRequestProto.newBuilder().build())});
 
 
     return list;
     return list;
   }
   }
+
+  public void initTestGetApplicationsRequestPBImpl(
+      GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
+    this.impl = impl;
+  }
 }
 }

+ 50 - 46
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/TestResourceUtilization.java

@@ -18,54 +18,58 @@
 
 
 package org.apache.hadoop.yarn.api.records;
 package org.apache.hadoop.yarn.api.records;
 
 
-import org.junit.Assert;
-import org.junit.Test;
-
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import org.junit.jupiter.api.Test;
+
+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.assertTrue;
+
 public class TestResourceUtilization {
 public class TestResourceUtilization {
 
 
   @Test
   @Test
-  public void testResourceUtilization() {
+  void testResourceUtilization() {
     ResourceUtilization u1 = ResourceUtilization.newInstance(10, 20, 0.5f);
     ResourceUtilization u1 = ResourceUtilization.newInstance(10, 20, 0.5f);
     ResourceUtilization u2 = ResourceUtilization.newInstance(u1);
     ResourceUtilization u2 = ResourceUtilization.newInstance(u1);
     ResourceUtilization u3 = ResourceUtilization.newInstance(10, 20, 0.5f);
     ResourceUtilization u3 = ResourceUtilization.newInstance(10, 20, 0.5f);
     ResourceUtilization u4 = ResourceUtilization.newInstance(20, 20, 0.5f);
     ResourceUtilization u4 = ResourceUtilization.newInstance(20, 20, 0.5f);
     ResourceUtilization u5 = ResourceUtilization.newInstance(30, 40, 0.8f);
     ResourceUtilization u5 = ResourceUtilization.newInstance(30, 40, 0.8f);
 
 
-    Assert.assertEquals(u1, u2);
-    Assert.assertEquals(u1, u3);
-    Assert.assertNotEquals(u1, u4);
-    Assert.assertNotEquals(u2, u5);
-    Assert.assertNotEquals(u4, u5);
+    assertEquals(u1, u2);
+    assertEquals(u1, u3);
+    assertNotEquals(u1, u4);
+    assertNotEquals(u2, u5);
+    assertNotEquals(u4, u5);
 
 
-    Assert.assertTrue(u1.hashCode() == u2.hashCode());
-    Assert.assertTrue(u1.hashCode() == u3.hashCode());
-    Assert.assertFalse(u1.hashCode() == u4.hashCode());
-    Assert.assertFalse(u2.hashCode() == u5.hashCode());
-    Assert.assertFalse(u4.hashCode() == u5.hashCode());
+    assertTrue(u1.hashCode() == u2.hashCode());
+    assertTrue(u1.hashCode() == u3.hashCode());
+    assertFalse(u1.hashCode() == u4.hashCode());
+    assertFalse(u2.hashCode() == u5.hashCode());
+    assertFalse(u4.hashCode() == u5.hashCode());
 
 
-    Assert.assertTrue(u1.getPhysicalMemory() == 10);
-    Assert.assertFalse(u1.getVirtualMemory() == 10);
-    Assert.assertTrue(u1.getCPU() == 0.5f);
+    assertTrue(u1.getPhysicalMemory() == 10);
+    assertFalse(u1.getVirtualMemory() == 10);
+    assertTrue(u1.getCPU() == 0.5f);
 
 
-    Assert.assertEquals("<pmem:10, vmem:" + u1.getVirtualMemory()
+    assertEquals("<pmem:10, vmem:" + u1.getVirtualMemory()
         + ", vCores:0.5>", u1.toString());
         + ", vCores:0.5>", u1.toString());
 
 
     u1.addTo(10, 0, 0.0f);
     u1.addTo(10, 0, 0.0f);
-    Assert.assertNotEquals(u1, u2);
-    Assert.assertEquals(u1, u4);
+    assertNotEquals(u1, u2);
+    assertEquals(u1, u4);
     u1.addTo(10, 20, 0.3f);
     u1.addTo(10, 20, 0.3f);
-    Assert.assertEquals(u1, u5);
+    assertEquals(u1, u5);
     u1.subtractFrom(10, 20, 0.3f);
     u1.subtractFrom(10, 20, 0.3f);
-    Assert.assertEquals(u1, u4);
+    assertEquals(u1, u4);
     u1.subtractFrom(10, 0, 0.0f);
     u1.subtractFrom(10, 0, 0.0f);
-    Assert.assertEquals(u1, u3);
+    assertEquals(u1, u3);
   }
   }
 
 
   @Test
   @Test
-  public void testResourceUtilizationWithCustomResource() {
+  void testResourceUtilizationWithCustomResource() {
     Map<String, Float> customResources = new HashMap<>();
     Map<String, Float> customResources = new HashMap<>();
     customResources.put(ResourceInformation.GPU_URI, 5.0f);
     customResources.put(ResourceInformation.GPU_URI, 5.0f);
     ResourceUtilization u1 = ResourceUtilization.
     ResourceUtilization u1 = ResourceUtilization.
@@ -78,35 +82,35 @@ public class TestResourceUtilization {
     ResourceUtilization u5 = ResourceUtilization.
     ResourceUtilization u5 = ResourceUtilization.
         newInstance(30, 40, 0.8f, customResources);
         newInstance(30, 40, 0.8f, customResources);
 
 
-    Assert.assertEquals(u1, u2);
-    Assert.assertEquals(u1, u3);
-    Assert.assertNotEquals(u1, u4);
-    Assert.assertNotEquals(u2, u5);
-    Assert.assertNotEquals(u4, u5);
-
-    Assert.assertTrue(u1.hashCode() == u2.hashCode());
-    Assert.assertTrue(u1.hashCode() == u3.hashCode());
-    Assert.assertFalse(u1.hashCode() == u4.hashCode());
-    Assert.assertFalse(u2.hashCode() == u5.hashCode());
-    Assert.assertFalse(u4.hashCode() == u5.hashCode());
-
-    Assert.assertTrue(u1.getPhysicalMemory() == 10);
-    Assert.assertFalse(u1.getVirtualMemory() == 10);
-    Assert.assertTrue(u1.getCPU() == 0.5f);
-    Assert.assertTrue(u1.
+    assertEquals(u1, u2);
+    assertEquals(u1, u3);
+    assertNotEquals(u1, u4);
+    assertNotEquals(u2, u5);
+    assertNotEquals(u4, u5);
+
+    assertTrue(u1.hashCode() == u2.hashCode());
+    assertTrue(u1.hashCode() == u3.hashCode());
+    assertFalse(u1.hashCode() == u4.hashCode());
+    assertFalse(u2.hashCode() == u5.hashCode());
+    assertFalse(u4.hashCode() == u5.hashCode());
+
+    assertTrue(u1.getPhysicalMemory() == 10);
+    assertFalse(u1.getVirtualMemory() == 10);
+    assertTrue(u1.getCPU() == 0.5f);
+    assertTrue(u1.
         getCustomResource(ResourceInformation.GPU_URI) == 5.0f);
         getCustomResource(ResourceInformation.GPU_URI) == 5.0f);
 
 
-    Assert.assertEquals("<pmem:10, vmem:" + u1.getVirtualMemory()
+    assertEquals("<pmem:10, vmem:" + u1.getVirtualMemory()
         + ", vCores:0.5, yarn.io/gpu:5.0>", u1.toString());
         + ", vCores:0.5, yarn.io/gpu:5.0>", u1.toString());
 
 
     u1.addTo(10, 0, 0.0f);
     u1.addTo(10, 0, 0.0f);
-    Assert.assertNotEquals(u1, u2);
-    Assert.assertEquals(u1, u4);
+    assertNotEquals(u1, u2);
+    assertEquals(u1, u4);
     u1.addTo(10, 20, 0.3f);
     u1.addTo(10, 20, 0.3f);
-    Assert.assertEquals(u1, u5);
+    assertEquals(u1, u5);
     u1.subtractFrom(10, 20, 0.3f);
     u1.subtractFrom(10, 20, 0.3f);
-    Assert.assertEquals(u1, u4);
+    assertEquals(u1, u4);
     u1.subtractFrom(10, 0, 0.0f);
     u1.subtractFrom(10, 0, 0.0f);
-    Assert.assertEquals(u1, u3);
+    assertEquals(u1, u3);
   }
   }
 }
 }

+ 17 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestApplicationClientProtocolRecords.java

@@ -25,6 +25,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.Credentials;
@@ -36,8 +38,10 @@ import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
 import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.api.records.URL;
 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.junit.Assert;
-import org.junit.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;
 
 
 public class TestApplicationClientProtocolRecords {
 public class TestApplicationClientProtocolRecords {
 
 
@@ -47,7 +51,7 @@ public class TestApplicationClientProtocolRecords {
    *
    *
    */
    */
   @Test
   @Test
-  public void testCLCPBImplNullEnv() throws IOException {
+  void testCLCPBImplNullEnv() throws IOException {
     Map<String, LocalResource> localResources = Collections.emptyMap();
     Map<String, LocalResource> localResources = Collections.emptyMap();
     Map<String, String> environment = new HashMap<String, String>();
     Map<String, String> environment = new HashMap<String, String>();
     List<String> commands = Collections.emptyList();
     List<String> commands = Collections.emptyList();
@@ -68,7 +72,7 @@ public class TestApplicationClientProtocolRecords {
     ContainerLaunchContext clcProto = new ContainerLaunchContextPBImpl(
     ContainerLaunchContext clcProto = new ContainerLaunchContextPBImpl(
         ((ContainerLaunchContextPBImpl) clc).getProto());
         ((ContainerLaunchContextPBImpl) clc).getProto());
 
 
-    Assert.assertEquals("",
+    assertEquals("",
         clcProto.getEnvironment().get("testCLCPBImplNullEnv"));
         clcProto.getEnvironment().get("testCLCPBImplNullEnv"));
 
 
   }
   }
@@ -78,7 +82,7 @@ public class TestApplicationClientProtocolRecords {
    * local resource URL.
    * local resource URL.
    */
    */
   @Test
   @Test
-  public void testCLCPBImplNullResourceURL() throws IOException {
+  void testCLCPBImplNullResourceURL() throws IOException {
     RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
     RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
     try {
     try {
       LocalResource rsrc_alpha = recordFactory.newRecordInstance(LocalResource.class);
       LocalResource rsrc_alpha = recordFactory.newRecordInstance(LocalResource.class);
@@ -92,9 +96,9 @@ public class TestApplicationClientProtocolRecords {
       localResources.put("null_url_resource", rsrc_alpha);
       localResources.put("null_url_resource", rsrc_alpha);
       ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
       ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
       containerLaunchContext.setLocalResources(localResources);
       containerLaunchContext.setLocalResources(localResources);
-      Assert.fail("Setting an invalid local resource should be an error!");
+      fail("Setting an invalid local resource should be an error!");
     } catch (NullPointerException e) {
     } catch (NullPointerException e) {
-      Assert.assertTrue(e.getMessage().contains("Null resource URL for local resource"));
+      assertTrue(e.getMessage().contains("Null resource URL for local resource"));
     }
     }
   }
   }
 
 
@@ -103,7 +107,7 @@ public class TestApplicationClientProtocolRecords {
    * local resource type.
    * local resource type.
    */
    */
   @Test
   @Test
-  public void testCLCPBImplNullResourceType() throws IOException {
+  void testCLCPBImplNullResourceType() throws IOException {
     RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
     RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
     try {
     try {
       LocalResource resource = recordFactory.newRecordInstance(LocalResource.class);
       LocalResource resource = recordFactory.newRecordInstance(LocalResource.class);
@@ -117,9 +121,9 @@ public class TestApplicationClientProtocolRecords {
       localResources.put("null_type_resource", resource);
       localResources.put("null_type_resource", resource);
       ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
       ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
       containerLaunchContext.setLocalResources(localResources);
       containerLaunchContext.setLocalResources(localResources);
-      Assert.fail("Setting an invalid local resource should be an error!");
+      fail("Setting an invalid local resource should be an error!");
     } catch (NullPointerException e) {
     } catch (NullPointerException e) {
-      Assert.assertTrue(e.getMessage().contains("Null resource type for local resource"));
+      assertTrue(e.getMessage().contains("Null resource type for local resource"));
     }
     }
   }
   }
 
 
@@ -128,7 +132,7 @@ public class TestApplicationClientProtocolRecords {
    * local resource type.
    * local resource type.
    */
    */
   @Test
   @Test
-  public void testCLCPBImplNullResourceVisibility() throws IOException {
+  void testCLCPBImplNullResourceVisibility() throws IOException {
     RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
     RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
     try {
     try {
       LocalResource resource = recordFactory.newRecordInstance(LocalResource.class);
       LocalResource resource = recordFactory.newRecordInstance(LocalResource.class);
@@ -142,9 +146,9 @@ public class TestApplicationClientProtocolRecords {
       localResources.put("null_visibility_resource", resource);
       localResources.put("null_visibility_resource", resource);
       ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
       ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
       containerLaunchContext.setLocalResources(localResources);
       containerLaunchContext.setLocalResources(localResources);
-      Assert.fail("Setting an invalid local resource should be an error!");
+      fail("Setting an invalid local resource should be an error!");
     } catch (NullPointerException e) {
     } catch (NullPointerException e) {
-      Assert.assertTrue(e.getMessage().contains("Null resource visibility for local resource"));
+      assertTrue(e.getMessage().contains("Null resource visibility for local resource"));
     }
     }
   }
   }
 }
 }

+ 37 - 28
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestApplicationSubmissionContextPBImpl.java

@@ -18,57 +18,66 @@
 
 
 package org.apache.hadoop.yarn.api.records.impl.pb;
 package org.apache.hadoop.yarn.api.records.impl.pb;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.List;
 import java.util.List;
 
 
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
 
 
-@RunWith(Parameterized.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
 public class TestApplicationSubmissionContextPBImpl {
 public class TestApplicationSubmissionContextPBImpl {
-  @Parameter
   @SuppressWarnings("checkstyle:visibilitymodifier")
   @SuppressWarnings("checkstyle:visibilitymodifier")
   public ApplicationSubmissionContextPBImpl impl;
   public ApplicationSubmissionContextPBImpl impl;
 
 
-  @Test
-  public void testAppTagsLowerCaseConversionDefault() {
-    impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
-    impl.getApplicationTags().forEach(s ->
-        assertEquals(s, s.toLowerCase()));
+  @MethodSource("data")
+  @ParameterizedTest
+  void testAppTagsLowerCaseConversionDefault(
+      ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
+    initTestApplicationSubmissionContextPBImpl(applicationSubmissionContextPB);
+    applicationSubmissionContextPB.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
+    applicationSubmissionContextPB.getApplicationTags()
+        .forEach(s -> assertEquals(s, s.toLowerCase()));
   }
   }
 
 
-  @Test
-  public void testAppTagsLowerCaseConversionDisabled() {
+  @MethodSource("data")
+  @ParameterizedTest
+  void testAppTagsLowerCaseConversionDisabled(
+      ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
+    initTestApplicationSubmissionContextPBImpl(applicationSubmissionContextPB);
     ApplicationSubmissionContextPBImpl.setForceLowerCaseTags(false);
     ApplicationSubmissionContextPBImpl.setForceLowerCaseTags(false);
-    impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
-    impl.getApplicationTags().forEach(s ->
-        assertNotEquals(s, s.toLowerCase()));
+    applicationSubmissionContextPB.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
+    applicationSubmissionContextPB.getApplicationTags()
+        .forEach(s -> assertNotEquals(s, s.toLowerCase()));
   }
   }
 
 
-  @Test
-  public void testAppTagsLowerCaseConversionEnabled() {
+  @MethodSource("data")
+  @ParameterizedTest
+  void testAppTagsLowerCaseConversionEnabled(
+      ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
+    initTestApplicationSubmissionContextPBImpl(applicationSubmissionContextPB);
     ApplicationSubmissionContextPBImpl.setForceLowerCaseTags(true);
     ApplicationSubmissionContextPBImpl.setForceLowerCaseTags(true);
-    impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
-    impl.getApplicationTags().forEach(s ->
-        assertEquals(s, s.toLowerCase()));
+    applicationSubmissionContextPB.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
+    applicationSubmissionContextPB.getApplicationTags()
+        .forEach(s -> assertEquals(s, s.toLowerCase()));
   }
   }
 
 
-  @Parameters
   public static Collection<Object[]> data() {
   public static Collection<Object[]> data() {
     List<Object[]> list = new ArrayList<>();
     List<Object[]> list = new ArrayList<>();
-    list.add(new Object[] {new ApplicationSubmissionContextPBImpl()});
-    list.add(new Object[] {new ApplicationSubmissionContextPBImpl(
+    list.add(new Object[]{new ApplicationSubmissionContextPBImpl()});
+    list.add(new Object[]{new ApplicationSubmissionContextPBImpl(
         ApplicationSubmissionContextProto.newBuilder().build())});
         ApplicationSubmissionContextProto.newBuilder().build())});
 
 
     return list;
     return list;
   }
   }
+
+  public void initTestApplicationSubmissionContextPBImpl(
+      ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
+    this.impl = applicationSubmissionContextPB;
+  }
 }
 }

+ 5 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestProtoUtils.java

@@ -17,20 +17,21 @@
  */
  */
 package org.apache.hadoop.yarn.api.records.impl.pb;
 package org.apache.hadoop.yarn.api.records.impl.pb;
 
 
-import static org.junit.Assert.*;
-
 import java.util.stream.Stream;
 import java.util.stream.Stream;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.ContainerSubState;
 import org.apache.hadoop.yarn.api.records.ContainerSubState;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerSubStateProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerSubStateProto;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestProtoUtils {
 public class TestProtoUtils {
 
 
   @Test
   @Test
-  public void testConvertFromOrToProtoFormat() {
+  void testConvertFromOrToProtoFormat() {
     // Check if utility has all enum values
     // Check if utility has all enum values
     try {
     try {
       Stream.of(ContainerState.values())
       Stream.of(ContainerState.values())

+ 23 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/impl/pb/TestSerializedExceptionPBImpl.java

@@ -20,71 +20,75 @@ package org.apache.hadoop.yarn.api.records.impl.pb;
 
 
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ClosedChannelException;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.SerializedExceptionProto;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestSerializedExceptionPBImpl {
 public class TestSerializedExceptionPBImpl {
   @Test
   @Test
-  public void testSerializedException() throws Exception {
+  void testSerializedException() throws Exception {
     SerializedExceptionPBImpl orig = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl orig = new SerializedExceptionPBImpl();
     orig.init(new Exception("test exception"));
     orig.init(new Exception("test exception"));
     SerializedExceptionProto proto = orig.getProto();
     SerializedExceptionProto proto = orig.getProto();
     SerializedExceptionPBImpl deser = new SerializedExceptionPBImpl(proto);
     SerializedExceptionPBImpl deser = new SerializedExceptionPBImpl(proto);
-    Assert.assertEquals(orig, deser);
-    Assert.assertEquals(orig.getMessage(), deser.getMessage());
-    Assert.assertEquals(orig.getRemoteTrace(), deser.getRemoteTrace());
-    Assert.assertEquals(orig.getCause(), deser.getCause());
+    assertEquals(orig, deser);
+    assertEquals(orig.getMessage(), deser.getMessage());
+    assertEquals(orig.getRemoteTrace(), deser.getRemoteTrace());
+    assertEquals(orig.getCause(), deser.getCause());
   }
   }
 
 
   @Test
   @Test
-  public void testDeserialize() throws Exception {
+  void testDeserialize() throws Exception {
     Exception ex = new Exception("test exception");
     Exception ex = new Exception("test exception");
     SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
 
 
     try {
     try {
       pb.deSerialize();
       pb.deSerialize();
-      Assert.fail("deSerialze should throw YarnRuntimeException");
+      fail("deSerialze should throw YarnRuntimeException");
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      Assert.assertEquals(ClassNotFoundException.class,
+      assertEquals(ClassNotFoundException.class,
           e.getCause().getClass());
           e.getCause().getClass());
     }
     }
 
 
     pb.init(ex);
     pb.init(ex);
-    Assert.assertEquals(ex.toString(), pb.deSerialize().toString());
+    assertEquals(ex.toString(), pb.deSerialize().toString());
   }
   }
 
 
   @Test
   @Test
-  public void testDeserializeWithDefaultConstructor() {
+  void testDeserializeWithDefaultConstructor() {
     // Init SerializedException with an Exception with default constructor.
     // Init SerializedException with an Exception with default constructor.
     ClosedChannelException ex = new ClosedChannelException();
     ClosedChannelException ex = new ClosedChannelException();
     SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
     pb.init(ex);
     pb.init(ex);
-    Assert.assertEquals(ex.getClass(), pb.deSerialize().getClass());
+    assertEquals(ex.getClass(), pb.deSerialize().getClass());
   }
   }
 
 
   @Test
   @Test
-  public void testBeforeInit() throws Exception {
+  void testBeforeInit() throws Exception {
     SerializedExceptionProto defaultProto =
     SerializedExceptionProto defaultProto =
         SerializedExceptionProto.newBuilder().build();
         SerializedExceptionProto.newBuilder().build();
 
 
     SerializedExceptionPBImpl pb1 = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl pb1 = new SerializedExceptionPBImpl();
-    Assert.assertNull(pb1.getCause());
+    assertNull(pb1.getCause());
 
 
     SerializedExceptionPBImpl pb2 = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl pb2 = new SerializedExceptionPBImpl();
-    Assert.assertEquals(defaultProto, pb2.getProto());
+    assertEquals(defaultProto, pb2.getProto());
 
 
     SerializedExceptionPBImpl pb3 = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl pb3 = new SerializedExceptionPBImpl();
-    Assert.assertEquals(defaultProto.getTrace(), pb3.getRemoteTrace());
+    assertEquals(defaultProto.getTrace(), pb3.getRemoteTrace());
   }
   }
 
 
   @Test
   @Test
-  public void testThrowableDeserialization() {
+  void testThrowableDeserialization() {
     // java.lang.Error should also be serializable
     // java.lang.Error should also be serializable
     Error ex = new Error();
     Error ex = new Error();
     SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
     SerializedExceptionPBImpl pb = new SerializedExceptionPBImpl();
     pb.init(ex);
     pb.init(ex);
-    Assert.assertEquals(ex.getClass(), pb.deSerialize().getClass());
+    assertEquals(ex.getClass(), pb.deSerialize().getClass());
   }
   }
 }
 }

+ 79 - 75
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timeline/TestTimelineRecords.java

@@ -27,12 +27,16 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeMap;
 import java.util.WeakHashMap;
 import java.util.WeakHashMap;
 
 
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError;
 import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError;
 import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
 import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestTimelineRecords {
 public class TestTimelineRecords {
 
 
@@ -40,7 +44,7 @@ public class TestTimelineRecords {
       LoggerFactory.getLogger(TestTimelineRecords.class);
       LoggerFactory.getLogger(TestTimelineRecords.class);
 
 
   @Test
   @Test
-  public void testEntities() throws Exception {
+  void testEntities() throws Exception {
     TimelineEntities entities = new TimelineEntities();
     TimelineEntities entities = new TimelineEntities();
     for (int j = 0; j < 2; ++j) {
     for (int j = 0; j < 2; ++j) {
       TimelineEntity entity = new TimelineEntity();
       TimelineEntity entity = new TimelineEntity();
@@ -67,27 +71,27 @@ public class TestTimelineRecords {
     LOG.info("Entities in JSON:");
     LOG.info("Entities in JSON:");
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(entities, true));
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(entities, true));
 
 
-    Assert.assertEquals(2, entities.getEntities().size());
+    assertEquals(2, entities.getEntities().size());
     TimelineEntity entity1 = entities.getEntities().get(0);
     TimelineEntity entity1 = entities.getEntities().get(0);
-    Assert.assertEquals("entity id 0", entity1.getEntityId());
-    Assert.assertEquals("entity type 0", entity1.getEntityType());
-    Assert.assertEquals(2, entity1.getRelatedEntities().size());
-    Assert.assertEquals(2, entity1.getEvents().size());
-    Assert.assertEquals(2, entity1.getPrimaryFilters().size());
-    Assert.assertEquals(2, entity1.getOtherInfo().size());
-    Assert.assertEquals("domain id 0", entity1.getDomainId());
+    assertEquals("entity id 0", entity1.getEntityId());
+    assertEquals("entity type 0", entity1.getEntityType());
+    assertEquals(2, entity1.getRelatedEntities().size());
+    assertEquals(2, entity1.getEvents().size());
+    assertEquals(2, entity1.getPrimaryFilters().size());
+    assertEquals(2, entity1.getOtherInfo().size());
+    assertEquals("domain id 0", entity1.getDomainId());
     TimelineEntity entity2 = entities.getEntities().get(1);
     TimelineEntity entity2 = entities.getEntities().get(1);
-    Assert.assertEquals("entity id 1", entity2.getEntityId());
-    Assert.assertEquals("entity type 1", entity2.getEntityType());
-    Assert.assertEquals(2, entity2.getRelatedEntities().size());
-    Assert.assertEquals(2, entity2.getEvents().size());
-    Assert.assertEquals(2, entity2.getPrimaryFilters().size());
-    Assert.assertEquals(2, entity2.getOtherInfo().size());
-    Assert.assertEquals("domain id 1", entity2.getDomainId());
+    assertEquals("entity id 1", entity2.getEntityId());
+    assertEquals("entity type 1", entity2.getEntityType());
+    assertEquals(2, entity2.getRelatedEntities().size());
+    assertEquals(2, entity2.getEvents().size());
+    assertEquals(2, entity2.getPrimaryFilters().size());
+    assertEquals(2, entity2.getOtherInfo().size());
+    assertEquals("domain id 1", entity2.getDomainId());
   }
   }
 
 
   @Test
   @Test
-  public void testEvents() throws Exception {
+  void testEvents() throws Exception {
     TimelineEvents events = new TimelineEvents();
     TimelineEvents events = new TimelineEvents();
     for (int j = 0; j < 2; ++j) {
     for (int j = 0; j < 2; ++j) {
       TimelineEvents.EventsOfOneEntity partEvents =
       TimelineEvents.EventsOfOneEntity partEvents =
@@ -107,31 +111,31 @@ public class TestTimelineRecords {
     LOG.info("Events in JSON:");
     LOG.info("Events in JSON:");
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(events, true));
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(events, true));
 
 
-    Assert.assertEquals(2, events.getAllEvents().size());
+    assertEquals(2, events.getAllEvents().size());
     TimelineEvents.EventsOfOneEntity partEvents1 = events.getAllEvents().get(0);
     TimelineEvents.EventsOfOneEntity partEvents1 = events.getAllEvents().get(0);
-    Assert.assertEquals("entity id 0", partEvents1.getEntityId());
-    Assert.assertEquals("entity type 0", partEvents1.getEntityType());
-    Assert.assertEquals(2, partEvents1.getEvents().size());
+    assertEquals("entity id 0", partEvents1.getEntityId());
+    assertEquals("entity type 0", partEvents1.getEntityType());
+    assertEquals(2, partEvents1.getEvents().size());
     TimelineEvent event11 = partEvents1.getEvents().get(0);
     TimelineEvent event11 = partEvents1.getEvents().get(0);
-    Assert.assertEquals("event type 0", event11.getEventType());
-    Assert.assertEquals(2, event11.getEventInfo().size());
+    assertEquals("event type 0", event11.getEventType());
+    assertEquals(2, event11.getEventInfo().size());
     TimelineEvent event12 = partEvents1.getEvents().get(1);
     TimelineEvent event12 = partEvents1.getEvents().get(1);
-    Assert.assertEquals("event type 1", event12.getEventType());
-    Assert.assertEquals(2, event12.getEventInfo().size());
+    assertEquals("event type 1", event12.getEventType());
+    assertEquals(2, event12.getEventInfo().size());
     TimelineEvents.EventsOfOneEntity partEvents2 = events.getAllEvents().get(1);
     TimelineEvents.EventsOfOneEntity partEvents2 = events.getAllEvents().get(1);
-    Assert.assertEquals("entity id 1", partEvents2.getEntityId());
-    Assert.assertEquals("entity type 1", partEvents2.getEntityType());
-    Assert.assertEquals(2, partEvents2.getEvents().size());
+    assertEquals("entity id 1", partEvents2.getEntityId());
+    assertEquals("entity type 1", partEvents2.getEntityType());
+    assertEquals(2, partEvents2.getEvents().size());
     TimelineEvent event21 = partEvents2.getEvents().get(0);
     TimelineEvent event21 = partEvents2.getEvents().get(0);
-    Assert.assertEquals("event type 0", event21.getEventType());
-    Assert.assertEquals(2, event21.getEventInfo().size());
+    assertEquals("event type 0", event21.getEventType());
+    assertEquals(2, event21.getEventInfo().size());
     TimelineEvent event22 = partEvents2.getEvents().get(1);
     TimelineEvent event22 = partEvents2.getEvents().get(1);
-    Assert.assertEquals("event type 1", event22.getEventType());
-    Assert.assertEquals(2, event22.getEventInfo().size());
+    assertEquals("event type 1", event22.getEventType());
+    assertEquals(2, event22.getEventInfo().size());
   }
   }
 
 
   @Test
   @Test
-  public void testTimelinePutErrors() throws Exception {
+  void testTimelinePutErrors() throws Exception {
     TimelinePutResponse TimelinePutErrors = new TimelinePutResponse();
     TimelinePutResponse TimelinePutErrors = new TimelinePutResponse();
     TimelinePutError error1 = new TimelinePutError();
     TimelinePutError error1 = new TimelinePutError();
     error1.setEntityId("entity id 1");
     error1.setEntityId("entity id 1");
@@ -149,23 +153,23 @@ public class TestTimelineRecords {
     LOG.info("Errors in JSON:");
     LOG.info("Errors in JSON:");
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(TimelinePutErrors, true));
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(TimelinePutErrors, true));
 
 
-    Assert.assertEquals(3, TimelinePutErrors.getErrors().size());
+    assertEquals(3, TimelinePutErrors.getErrors().size());
     TimelinePutError e = TimelinePutErrors.getErrors().get(0);
     TimelinePutError e = TimelinePutErrors.getErrors().get(0);
-    Assert.assertEquals(error1.getEntityId(), e.getEntityId());
-    Assert.assertEquals(error1.getEntityType(), e.getEntityType());
-    Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
+    assertEquals(error1.getEntityId(), e.getEntityId());
+    assertEquals(error1.getEntityType(), e.getEntityType());
+    assertEquals(error1.getErrorCode(), e.getErrorCode());
     e = TimelinePutErrors.getErrors().get(1);
     e = TimelinePutErrors.getErrors().get(1);
-    Assert.assertEquals(error1.getEntityId(), e.getEntityId());
-    Assert.assertEquals(error1.getEntityType(), e.getEntityType());
-    Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
+    assertEquals(error1.getEntityId(), e.getEntityId());
+    assertEquals(error1.getEntityType(), e.getEntityType());
+    assertEquals(error1.getErrorCode(), e.getErrorCode());
     e = TimelinePutErrors.getErrors().get(2);
     e = TimelinePutErrors.getErrors().get(2);
-    Assert.assertEquals(error2.getEntityId(), e.getEntityId());
-    Assert.assertEquals(error2.getEntityType(), e.getEntityType());
-    Assert.assertEquals(error2.getErrorCode(), e.getErrorCode());
+    assertEquals(error2.getEntityId(), e.getEntityId());
+    assertEquals(error2.getEntityType(), e.getEntityType());
+    assertEquals(error2.getErrorCode(), e.getErrorCode());
   }
   }
 
 
   @Test
   @Test
-  public void testTimelineDomain() throws Exception {
+  void testTimelineDomain() throws Exception {
     TimelineDomains domains = new TimelineDomains();
     TimelineDomains domains = new TimelineDomains();
 
 
     TimelineDomain domain = null;
     TimelineDomain domain = null;
@@ -185,25 +189,25 @@ public class TestTimelineRecords {
     LOG.info("Domain in JSON:");
     LOG.info("Domain in JSON:");
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(domains, true));
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(domains, true));
 
 
-    Assert.assertEquals(2, domains.getDomains().size());
+    assertEquals(2, domains.getDomains().size());
 
 
     for (int i = 0; i < domains.getDomains().size(); ++i) {
     for (int i = 0; i < domains.getDomains().size(); ++i) {
       domain = domains.getDomains().get(i);
       domain = domains.getDomains().get(i);
-      Assert.assertEquals("test id " + (i + 1), domain.getId());
-      Assert.assertEquals("test description " + (i + 1),
+      assertEquals("test id " + (i + 1), domain.getId());
+      assertEquals("test description " + (i + 1),
           domain.getDescription());
           domain.getDescription());
-      Assert.assertEquals("test owner " + (i + 1), domain.getOwner());
-      Assert.assertEquals("test_reader_user_" + (i + 1) +
+      assertEquals("test owner " + (i + 1), domain.getOwner());
+      assertEquals("test_reader_user_" + (i + 1) +
           " test_reader_group+" + (i + 1), domain.getReaders());
           " test_reader_group+" + (i + 1), domain.getReaders());
-      Assert.assertEquals("test_writer_user_" + (i + 1) +
+      assertEquals("test_writer_user_" + (i + 1) +
           " test_writer_group+" + (i + 1), domain.getWriters());
           " test_writer_group+" + (i + 1), domain.getWriters());
-      Assert.assertEquals(new Long(0L), domain.getCreatedTime());
-      Assert.assertEquals(new Long(1L), domain.getModifiedTime());
+      assertEquals(Long.valueOf(0L), domain.getCreatedTime());
+      assertEquals(Long.valueOf(1L), domain.getModifiedTime());
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testMapInterfaceOrTimelineRecords() throws Exception {
+  void testMapInterfaceOrTimelineRecords() throws Exception {
     TimelineEntity entity = new TimelineEntity();
     TimelineEntity entity = new TimelineEntity();
     List<Map<String, Set<Object>>> primaryFiltersList =
     List<Map<String, Set<Object>>> primaryFiltersList =
         new ArrayList<Map<String, Set<Object>>>();
         new ArrayList<Map<String, Set<Object>>>();
@@ -284,36 +288,36 @@ public class TestTimelineRecords {
   }
   }
 
 
   private static void assertPrimaryFilters(TimelineEntity entity) {
   private static void assertPrimaryFilters(TimelineEntity entity) {
-    Assert.assertNotNull(entity.getPrimaryFilters());
-    Assert.assertNotNull(entity.getPrimaryFiltersJAXB());
-    Assert.assertTrue(entity.getPrimaryFilters() instanceof HashMap);
-    Assert.assertTrue(entity.getPrimaryFiltersJAXB() instanceof HashMap);
-    Assert.assertEquals(
+    assertNotNull(entity.getPrimaryFilters());
+    assertNotNull(entity.getPrimaryFiltersJAXB());
+    assertTrue(entity.getPrimaryFilters() instanceof HashMap);
+    assertTrue(entity.getPrimaryFiltersJAXB() instanceof HashMap);
+    assertEquals(
         entity.getPrimaryFilters(), entity.getPrimaryFiltersJAXB());
         entity.getPrimaryFilters(), entity.getPrimaryFiltersJAXB());
   }
   }
 
 
   private static void assertRelatedEntities(TimelineEntity entity) {
   private static void assertRelatedEntities(TimelineEntity entity) {
-    Assert.assertNotNull(entity.getRelatedEntities());
-    Assert.assertNotNull(entity.getRelatedEntitiesJAXB());
-    Assert.assertTrue(entity.getRelatedEntities() instanceof HashMap);
-    Assert.assertTrue(entity.getRelatedEntitiesJAXB() instanceof HashMap);
-    Assert.assertEquals(
+    assertNotNull(entity.getRelatedEntities());
+    assertNotNull(entity.getRelatedEntitiesJAXB());
+    assertTrue(entity.getRelatedEntities() instanceof HashMap);
+    assertTrue(entity.getRelatedEntitiesJAXB() instanceof HashMap);
+    assertEquals(
         entity.getRelatedEntities(), entity.getRelatedEntitiesJAXB());
         entity.getRelatedEntities(), entity.getRelatedEntitiesJAXB());
   }
   }
 
 
   private static void assertOtherInfo(TimelineEntity entity) {
   private static void assertOtherInfo(TimelineEntity entity) {
-    Assert.assertNotNull(entity.getOtherInfo());
-    Assert.assertNotNull(entity.getOtherInfoJAXB());
-    Assert.assertTrue(entity.getOtherInfo() instanceof HashMap);
-    Assert.assertTrue(entity.getOtherInfoJAXB() instanceof HashMap);
-    Assert.assertEquals(entity.getOtherInfo(), entity.getOtherInfoJAXB());
+    assertNotNull(entity.getOtherInfo());
+    assertNotNull(entity.getOtherInfoJAXB());
+    assertTrue(entity.getOtherInfo() instanceof HashMap);
+    assertTrue(entity.getOtherInfoJAXB() instanceof HashMap);
+    assertEquals(entity.getOtherInfo(), entity.getOtherInfoJAXB());
   }
   }
 
 
   private static void assertEventInfo(TimelineEvent event) {
   private static void assertEventInfo(TimelineEvent event) {
-    Assert.assertNotNull(event);
-    Assert.assertNotNull(event.getEventInfoJAXB());
-    Assert.assertTrue(event.getEventInfo() instanceof HashMap);
-    Assert.assertTrue(event.getEventInfoJAXB() instanceof HashMap);
-    Assert.assertEquals(event.getEventInfo(), event.getEventInfoJAXB());
+    assertNotNull(event);
+    assertNotNull(event.getEventInfoJAXB());
+    assertTrue(event.getEventInfo() instanceof HashMap);
+    assertTrue(event.getEventInfoJAXB() instanceof HashMap);
+    assertEquals(event.getEventInfo(), event.getEventInfoJAXB());
   }
   }
 }
 }

+ 62 - 62
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/records/timelineservice/TestTimelineServiceRecords.java

@@ -17,22 +17,28 @@
  */
  */
 package org.apache.hadoop.yarn.api.records.timelineservice;
 package org.apache.hadoop.yarn.api.records.timelineservice;
 
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
 import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
-import org.junit.Test;
-import org.junit.Assert;
 
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 
 
 public class TestTimelineServiceRecords {
 public class TestTimelineServiceRecords {
@@ -40,7 +46,7 @@ public class TestTimelineServiceRecords {
       LoggerFactory.getLogger(TestTimelineServiceRecords.class);
       LoggerFactory.getLogger(TestTimelineServiceRecords.class);
 
 
   @Test
   @Test
-  public void testTimelineEntities() throws Exception {
+  void testTimelineEntities() throws Exception {
     TimelineEntity entity = new TimelineEntity();
     TimelineEntity entity = new TimelineEntity();
     entity.setType("test type 1");
     entity.setType("test type 1");
     entity.setId("test id 1");
     entity.setId("test id 1");
@@ -48,7 +54,7 @@ public class TestTimelineServiceRecords {
     entity.addInfo("test info key 2",
     entity.addInfo("test info key 2",
         Arrays.asList("test info value 2", "test info value 3"));
         Arrays.asList("test info value 2", "test info value 3"));
     entity.addInfo("test info key 3", true);
     entity.addInfo("test info key 3", true);
-    Assert.assertTrue(
+    assertTrue(
         entity.getInfo().get("test info key 3") instanceof Boolean);
         entity.getInfo().get("test info key 3") instanceof Boolean);
     entity.addConfig("test config key 1", "test config value 1");
     entity.addConfig("test config key 1", "test config value 1");
     entity.addConfig("test config key 2", "test config value 2");
     entity.addConfig("test config key 2", "test config value 2");
@@ -59,43 +65,43 @@ public class TestTimelineServiceRecords {
     metric1.addValue(1L, 1.0F);
     metric1.addValue(1L, 1.0F);
     metric1.addValue(3L, 3.0D);
     metric1.addValue(3L, 3.0D);
     metric1.addValue(2L, 2);
     metric1.addValue(2L, 2);
-    Assert.assertEquals(TimelineMetric.Type.TIME_SERIES, metric1.getType());
+    assertEquals(TimelineMetric.Type.TIME_SERIES, metric1.getType());
     Iterator<Map.Entry<Long, Number>> itr =
     Iterator<Map.Entry<Long, Number>> itr =
         metric1.getValues().entrySet().iterator();
         metric1.getValues().entrySet().iterator();
     Map.Entry<Long, Number> entry = itr.next();
     Map.Entry<Long, Number> entry = itr.next();
-    Assert.assertEquals(new Long(3L), entry.getKey());
-    Assert.assertEquals(3.0D, entry.getValue());
+    assertEquals(Long.valueOf(3L), entry.getKey());
+    assertEquals(3.0D, entry.getValue());
     entry = itr.next();
     entry = itr.next();
-    Assert.assertEquals(new Long(2L), entry.getKey());
-    Assert.assertEquals(2, entry.getValue());
+    assertEquals(Long.valueOf(2L), entry.getKey());
+    assertEquals(2, entry.getValue());
     entry = itr.next();
     entry = itr.next();
-    Assert.assertEquals(new Long(1L), entry.getKey());
-    Assert.assertEquals(1.0F, entry.getValue());
-    Assert.assertFalse(itr.hasNext());
+    assertEquals(Long.valueOf(1L), entry.getKey());
+    assertEquals(1.0F, entry.getValue());
+    assertFalse(itr.hasNext());
     entity.addMetric(metric1);
     entity.addMetric(metric1);
 
 
     TimelineMetric metric2 =
     TimelineMetric metric2 =
         new TimelineMetric(TimelineMetric.Type.SINGLE_VALUE);
         new TimelineMetric(TimelineMetric.Type.SINGLE_VALUE);
     metric2.setId("test metric id 1");
     metric2.setId("test metric id 1");
     metric2.addValue(3L, (short) 3);
     metric2.addValue(3L, (short) 3);
-    Assert.assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric2.getType());
-    Assert.assertTrue(
+    assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric2.getType());
+    assertTrue(
         metric2.getValues().values().iterator().next() instanceof Short);
         metric2.getValues().values().iterator().next() instanceof Short);
     Map<Long, Number> points = new HashMap<>();
     Map<Long, Number> points = new HashMap<>();
     points.put(4L, 4.0D);
     points.put(4L, 4.0D);
     points.put(5L, 5.0D);
     points.put(5L, 5.0D);
     try {
     try {
       metric2.setValues(points);
       metric2.setValues(points);
-      Assert.fail();
+      fail();
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e.getMessage().contains(
           "Values cannot contain more than one point in"));
           "Values cannot contain more than one point in"));
     }
     }
     try {
     try {
       metric2.addValues(points);
       metric2.addValues(points);
-      Assert.fail();
+      fail();
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e.getMessage().contains(
           "Values cannot contain more than one point in"));
           "Values cannot contain more than one point in"));
     }
     }
     entity.addMetric(metric2);
     entity.addMetric(metric2);
@@ -104,9 +110,8 @@ public class TestTimelineServiceRecords {
         new TimelineMetric(TimelineMetric.Type.SINGLE_VALUE);
         new TimelineMetric(TimelineMetric.Type.SINGLE_VALUE);
     metric3.setId("test metric id 1");
     metric3.setId("test metric id 1");
     metric3.addValue(4L, (short) 4);
     metric3.addValue(4L, (short) 4);
-    Assert.assertEquals("metric3 should equal to metric2! ", metric3, metric2);
-    Assert.assertNotEquals("metric1 should not equal to metric2! ",
-        metric1, metric2);
+    assertEquals(metric3, metric2, "metric3 should equal to metric2! ");
+    assertNotEquals(metric1, metric2, "metric1 should not equal to metric2! ");
 
 
     TimelineEvent event1 = new TimelineEvent();
     TimelineEvent event1 = new TimelineEvent();
     event1.setId("test event id 1");
     event1.setId("test event id 1");
@@ -114,7 +119,7 @@ public class TestTimelineServiceRecords {
     event1.addInfo("test info key 2",
     event1.addInfo("test info key 2",
         Arrays.asList("test info value 2", "test info value 3"));
         Arrays.asList("test info value 2", "test info value 3"));
     event1.addInfo("test info key 3", true);
     event1.addInfo("test info key 3", true);
-    Assert.assertTrue(
+    assertTrue(
         event1.getInfo().get("test info key 3") instanceof Boolean);
         event1.getInfo().get("test info key 3") instanceof Boolean);
     event1.setTimestamp(1L);
     event1.setTimestamp(1L);
     entity.addEvent(event1);
     entity.addEvent(event1);
@@ -125,19 +130,17 @@ public class TestTimelineServiceRecords {
     event2.addInfo("test info key 2",
     event2.addInfo("test info key 2",
         Arrays.asList("test info value 2", "test info value 3"));
         Arrays.asList("test info value 2", "test info value 3"));
     event2.addInfo("test info key 3", true);
     event2.addInfo("test info key 3", true);
-    Assert.assertTrue(
+    assertTrue(
         event2.getInfo().get("test info key 3") instanceof Boolean);
         event2.getInfo().get("test info key 3") instanceof Boolean);
     event2.setTimestamp(2L);
     event2.setTimestamp(2L);
     entity.addEvent(event2);
     entity.addEvent(event2);
 
 
-    Assert.assertFalse("event1 should not equal to event2! ",
-        event1.equals(event2));
+    assertNotEquals(event1, event2);
     TimelineEvent event3 = new TimelineEvent();
     TimelineEvent event3 = new TimelineEvent();
     event3.setId("test event id 1");
     event3.setId("test event id 1");
     event3.setTimestamp(1L);
     event3.setTimestamp(1L);
-    Assert.assertEquals("event1 should equal to event3! ", event3, event1);
-    Assert.assertNotEquals("event1 should not equal to event2! ",
-        event1, event2);
+    assertEquals(event3, event1, "event1 should equal to event3! ");
+    assertNotEquals(event1, event2, "event1 should not equal to event2! ");
 
 
     entity.setCreatedTime(0L);
     entity.setCreatedTime(0L);
     entity.addRelatesToEntity("test type 2", "test id 2");
     entity.addRelatesToEntity("test type 2", "test id 2");
@@ -153,25 +156,22 @@ public class TestTimelineServiceRecords {
     entities.addEntity(entity2);
     entities.addEntity(entity2);
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(entities, true));
     LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(entities, true));
 
 
-    Assert.assertFalse("entity 1 should not be valid without type and id",
-        entity1.isValid());
+    assertFalse(entity1.isValid(),
+        "entity 1 should not be valid without type and id");
     entity1.setId("test id 2");
     entity1.setId("test id 2");
     entity1.setType("test type 2");
     entity1.setType("test type 2");
     entity2.setId("test id 1");
     entity2.setId("test id 1");
     entity2.setType("test type 1");
     entity2.setType("test type 1");
 
 
-    Assert.assertEquals("Timeline entity should equal to entity2! ",
-        entity, entity2);
-    Assert.assertNotEquals("entity1 should not equal to entity! ",
-        entity1, entity);
-    Assert.assertEquals("entity should be less than entity1! ",
-        entity1.compareTo(entity), 1);
-    Assert.assertEquals("entity's hash code should be -28727840 but not "
-        + entity.hashCode(), entity.hashCode(), -28727840);
+    assertEquals(entity, entity2, "Timeline entity should equal to entity2! ");
+    assertNotEquals(entity1, entity, "entity1 should not equal to entity! ");
+    assertEquals(entity1.compareTo(entity), 1, "entity should be less than entity1! ");
+    assertEquals(entity.hashCode(), -28727840, "entity's hash code should be -28727840 but not "
+        + entity.hashCode());
   }
   }
 
 
   @Test
   @Test
-  public void testFirstClassCitizenEntities() throws Exception {
+  void testFirstClassCitizenEntities() throws Exception {
     UserEntity user = new UserEntity();
     UserEntity user = new UserEntity();
     user.setId("test user id");
     user.setId("test user id");
 
 
@@ -245,49 +245,49 @@ public class TestTimelineServiceRecords {
 
 
 
 
     // Check parent/children APIs
     // Check parent/children APIs
-    Assert.assertNotNull(app1.getParent());
-    Assert.assertEquals(flow2.getType(), app1.getParent().getType());
-    Assert.assertEquals(flow2.getId(), app1.getParent().getId());
+    assertNotNull(app1.getParent());
+    assertEquals(flow2.getType(), app1.getParent().getType());
+    assertEquals(flow2.getId(), app1.getParent().getId());
     app1.addInfo(ApplicationEntity.PARENT_INFO_KEY, "invalid parent object");
     app1.addInfo(ApplicationEntity.PARENT_INFO_KEY, "invalid parent object");
     try {
     try {
       app1.getParent();
       app1.getParent();
-      Assert.fail();
+      fail();
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.assertTrue(e instanceof YarnRuntimeException);
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e instanceof YarnRuntimeException);
+      assertTrue(e.getMessage().contains(
           "Parent info is invalid identifier object"));
           "Parent info is invalid identifier object"));
     }
     }
 
 
-    Assert.assertNotNull(app1.getChildren());
-    Assert.assertEquals(1, app1.getChildren().size());
-    Assert.assertEquals(
+    assertNotNull(app1.getChildren());
+    assertEquals(1, app1.getChildren().size());
+    assertEquals(
         appAttempt.getType(), app1.getChildren().iterator().next().getType());
         appAttempt.getType(), app1.getChildren().iterator().next().getType());
-    Assert.assertEquals(
+    assertEquals(
         appAttempt.getId(), app1.getChildren().iterator().next().getId());
         appAttempt.getId(), app1.getChildren().iterator().next().getId());
     app1.addInfo(ApplicationEntity.CHILDREN_INFO_KEY,
     app1.addInfo(ApplicationEntity.CHILDREN_INFO_KEY,
         Collections.singletonList("invalid children set"));
         Collections.singletonList("invalid children set"));
     try {
     try {
       app1.getChildren();
       app1.getChildren();
-      Assert.fail();
+      fail();
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.assertTrue(e instanceof YarnRuntimeException);
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e instanceof YarnRuntimeException);
+      assertTrue(e.getMessage().contains(
           "Children info is invalid identifier set"));
           "Children info is invalid identifier set"));
     }
     }
     app1.addInfo(ApplicationEntity.CHILDREN_INFO_KEY,
     app1.addInfo(ApplicationEntity.CHILDREN_INFO_KEY,
         Collections.singleton("invalid child object"));
         Collections.singleton("invalid child object"));
     try {
     try {
       app1.getChildren();
       app1.getChildren();
-      Assert.fail();
+      fail();
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.assertTrue(e instanceof YarnRuntimeException);
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e instanceof YarnRuntimeException);
+      assertTrue(e.getMessage().contains(
           "Children info contains invalid identifier object"));
           "Children info contains invalid identifier object"));
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testUser() throws Exception {
+  void testUser() throws Exception {
     UserEntity user = new UserEntity();
     UserEntity user = new UserEntity();
     user.setId("test user id");
     user.setId("test user id");
     user.addInfo("test info key 1", "test info value 1");
     user.addInfo("test info key 1", "test info value 1");
@@ -296,7 +296,7 @@ public class TestTimelineServiceRecords {
   }
   }
 
 
   @Test
   @Test
-  public void testQueue() throws Exception {
+  void testQueue() throws Exception {
     QueueEntity queue = new QueueEntity();
     QueueEntity queue = new QueueEntity();
     queue.setId("test queue id");
     queue.setId("test queue id");
     queue.addInfo("test info key 1", "test info value 1");
     queue.addInfo("test info key 1", "test info value 1");

+ 43 - 41
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/resource/TestPlacementConstraintTransformations.java

@@ -18,18 +18,12 @@
 
 
 package org.apache.hadoop.yarn.api.resource;
 package org.apache.hadoop.yarn.api.resource;
 
 
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.NODE;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.RACK;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.maxCardinality;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.or;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetCardinality;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
-import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.allocationTag;
-
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.CardinalityConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.CardinalityConstraint;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.Or;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraint.Or;
@@ -39,8 +33,16 @@ import org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetConstraint.
 import org.apache.hadoop.yarn.api.resource.PlacementConstraintTransformations.SingleConstraintTransformer;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraintTransformations.SingleConstraintTransformer;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraintTransformations.SpecializedConstraintTransformer;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraintTransformations.SpecializedConstraintTransformer;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets;
 import org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.NODE;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets.allocationTag;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.RACK;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.maxCardinality;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.or;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetCardinality;
+import static org.apache.hadoop.yarn.api.resource.PlacementConstraints.targetIn;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test class for {@link PlacementConstraintTransformations}.
  * Test class for {@link PlacementConstraintTransformations}.
@@ -48,10 +50,10 @@ import org.junit.Test;
 public class TestPlacementConstraintTransformations {
 public class TestPlacementConstraintTransformations {
 
 
   @Test
   @Test
-  public void testTargetConstraint() {
+  void testTargetConstraint() {
     AbstractConstraint sConstraintExpr =
     AbstractConstraint sConstraintExpr =
         targetIn(NODE, allocationTag("hbase-m"));
         targetIn(NODE, allocationTag("hbase-m"));
-    Assert.assertTrue(sConstraintExpr instanceof SingleConstraint);
+    assertTrue(sConstraintExpr instanceof SingleConstraint);
     PlacementConstraint sConstraint =
     PlacementConstraint sConstraint =
         PlacementConstraints.build(sConstraintExpr);
         PlacementConstraints.build(sConstraintExpr);
 
 
@@ -61,17 +63,17 @@ public class TestPlacementConstraintTransformations {
     PlacementConstraint tConstraint = specTransformer.transform();
     PlacementConstraint tConstraint = specTransformer.transform();
 
 
     AbstractConstraint tConstraintExpr = tConstraint.getConstraintExpr();
     AbstractConstraint tConstraintExpr = tConstraint.getConstraintExpr();
-    Assert.assertTrue(tConstraintExpr instanceof TargetConstraint);
+    assertTrue(tConstraintExpr instanceof TargetConstraint);
 
 
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     TargetConstraint target = (TargetConstraint) tConstraintExpr;
     TargetConstraint target = (TargetConstraint) tConstraintExpr;
 
 
     // Make sure the expression string is consistent
     // Make sure the expression string is consistent
     // before and after transforming
     // before and after transforming
-    Assert.assertEquals(single.toString(), target.toString());
-    Assert.assertEquals(single.getScope(), target.getScope());
-    Assert.assertEquals(TargetOperator.IN, target.getOp());
-    Assert.assertEquals(single.getTargetExpressions(),
+    assertEquals(single.toString(), target.toString());
+    assertEquals(single.getScope(), target.getScope());
+    assertEquals(TargetOperator.IN, target.getOp());
+    assertEquals(single.getTargetExpressions(),
         target.getTargetExpressions());
         target.getTargetExpressions());
 
 
     // Transform from specialized TargetConstraint to SimpleConstraint
     // Transform from specialized TargetConstraint to SimpleConstraint
@@ -80,18 +82,18 @@ public class TestPlacementConstraintTransformations {
     sConstraint = singleTransformer.transform();
     sConstraint = singleTransformer.transform();
 
 
     sConstraintExpr = sConstraint.getConstraintExpr();
     sConstraintExpr = sConstraint.getConstraintExpr();
-    Assert.assertTrue(sConstraintExpr instanceof SingleConstraint);
+    assertTrue(sConstraintExpr instanceof SingleConstraint);
 
 
     single = (SingleConstraint) sConstraintExpr;
     single = (SingleConstraint) sConstraintExpr;
-    Assert.assertEquals(target.getScope(), single.getScope());
-    Assert.assertEquals(1, single.getMinCardinality());
-    Assert.assertEquals(Integer.MAX_VALUE, single.getMaxCardinality());
-    Assert.assertEquals(single.getTargetExpressions(),
+    assertEquals(target.getScope(), single.getScope());
+    assertEquals(1, single.getMinCardinality());
+    assertEquals(Integer.MAX_VALUE, single.getMaxCardinality());
+    assertEquals(single.getTargetExpressions(),
         target.getTargetExpressions());
         target.getTargetExpressions());
   }
   }
 
 
   @Test
   @Test
-  public void testCardinalityConstraint() {
+  void testCardinalityConstraint() {
     CardinalityConstraint cardinality = new CardinalityConstraint(RACK, 3, 10,
     CardinalityConstraint cardinality = new CardinalityConstraint(RACK, 3, 10,
         new HashSet<>(Arrays.asList("hb")));
         new HashSet<>(Arrays.asList("hb")));
     PlacementConstraint cConstraint = PlacementConstraints.build(cardinality);
     PlacementConstraint cConstraint = PlacementConstraints.build(cardinality);
@@ -102,27 +104,27 @@ public class TestPlacementConstraintTransformations {
     PlacementConstraint sConstraint = singleTransformer.transform();
     PlacementConstraint sConstraint = singleTransformer.transform();
 
 
     AbstractConstraint sConstraintExpr = sConstraint.getConstraintExpr();
     AbstractConstraint sConstraintExpr = sConstraint.getConstraintExpr();
-    Assert.assertTrue(sConstraintExpr instanceof SingleConstraint);
+    assertTrue(sConstraintExpr instanceof SingleConstraint);
 
 
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     SingleConstraint single = (SingleConstraint) sConstraintExpr;
     // Make sure the consistent expression string is consistent
     // Make sure the consistent expression string is consistent
     // before and after transforming
     // before and after transforming
-    Assert.assertEquals(single.toString(), cardinality.toString());
-    Assert.assertEquals(cardinality.getScope(), single.getScope());
-    Assert.assertEquals(cardinality.getMinCardinality(),
+    assertEquals(single.toString(), cardinality.toString());
+    assertEquals(cardinality.getScope(), single.getScope());
+    assertEquals(cardinality.getMinCardinality(),
         single.getMinCardinality());
         single.getMinCardinality());
-    Assert.assertEquals(cardinality.getMaxCardinality(),
+    assertEquals(cardinality.getMaxCardinality(),
         single.getMaxCardinality());
         single.getMaxCardinality());
-    Assert.assertEquals(
+    assertEquals(
         new HashSet<>(Arrays.asList(PlacementTargets.allocationTag("hb"))),
         new HashSet<>(Arrays.asList(PlacementTargets.allocationTag("hb"))),
         single.getTargetExpressions());
         single.getTargetExpressions());
   }
   }
 
 
   @Test
   @Test
-  public void testTargetCardinalityConstraint() {
+  void testTargetCardinalityConstraint() {
     AbstractConstraint constraintExpr =
     AbstractConstraint constraintExpr =
         targetCardinality(RACK, 3, 10, allocationTag("zk"));
         targetCardinality(RACK, 3, 10, allocationTag("zk"));
-    Assert.assertTrue(constraintExpr instanceof SingleConstraint);
+    assertTrue(constraintExpr instanceof SingleConstraint);
     PlacementConstraint constraint = PlacementConstraints.build(constraintExpr);
     PlacementConstraint constraint = PlacementConstraints.build(constraintExpr);
 
 
     // Apply transformation. Should be a no-op.
     // Apply transformation. Should be a no-op.
@@ -131,19 +133,19 @@ public class TestPlacementConstraintTransformations {
     PlacementConstraint newConstraint = specTransformer.transform();
     PlacementConstraint newConstraint = specTransformer.transform();
 
 
     // The constraint expression should be the same.
     // The constraint expression should be the same.
-    Assert.assertEquals(constraintExpr, newConstraint.getConstraintExpr());
+    assertEquals(constraintExpr, newConstraint.getConstraintExpr());
   }
   }
 
 
   @Test
   @Test
-  public void testCompositeConstraint() {
+  void testCompositeConstraint() {
     AbstractConstraint constraintExpr =
     AbstractConstraint constraintExpr =
         or(targetIn(RACK, allocationTag("spark")), maxCardinality(NODE, 3),
         or(targetIn(RACK, allocationTag("spark")), maxCardinality(NODE, 3),
             targetCardinality(RACK, 2, 10, allocationTag("zk")));
             targetCardinality(RACK, 2, 10, allocationTag("zk")));
-    Assert.assertTrue(constraintExpr instanceof Or);
+    assertTrue(constraintExpr instanceof Or);
     PlacementConstraint constraint = PlacementConstraints.build(constraintExpr);
     PlacementConstraint constraint = PlacementConstraints.build(constraintExpr);
     Or orExpr = (Or) constraintExpr;
     Or orExpr = (Or) constraintExpr;
     for (AbstractConstraint child : orExpr.getChildren()) {
     for (AbstractConstraint child : orExpr.getChildren()) {
-      Assert.assertTrue(child instanceof SingleConstraint);
+      assertTrue(child instanceof SingleConstraint);
     }
     }
 
 
     // Apply transformation. Should transform target and cardinality constraints
     // Apply transformation. Should transform target and cardinality constraints
@@ -154,19 +156,19 @@ public class TestPlacementConstraintTransformations {
 
 
     Or specOrExpr = (Or) specConstraint.getConstraintExpr();
     Or specOrExpr = (Or) specConstraint.getConstraintExpr();
     List<AbstractConstraint> specChildren = specOrExpr.getChildren();
     List<AbstractConstraint> specChildren = specOrExpr.getChildren();
-    Assert.assertEquals(3, specChildren.size());
-    Assert.assertTrue(specChildren.get(0) instanceof TargetConstraint);
-    Assert.assertTrue(specChildren.get(1) instanceof SingleConstraint);
-    Assert.assertTrue(specChildren.get(2) instanceof SingleConstraint);
+    assertEquals(3, specChildren.size());
+    assertTrue(specChildren.get(0) instanceof TargetConstraint);
+    assertTrue(specChildren.get(1) instanceof SingleConstraint);
+    assertTrue(specChildren.get(2) instanceof SingleConstraint);
 
 
     // Transform from specialized TargetConstraint to SimpleConstraint
     // Transform from specialized TargetConstraint to SimpleConstraint
     SingleConstraintTransformer singleTransformer =
     SingleConstraintTransformer singleTransformer =
         new SingleConstraintTransformer(specConstraint);
         new SingleConstraintTransformer(specConstraint);
     PlacementConstraint simConstraint = singleTransformer.transform();
     PlacementConstraint simConstraint = singleTransformer.transform();
-    Assert.assertTrue(simConstraint.getConstraintExpr() instanceof Or);
+    assertTrue(simConstraint.getConstraintExpr() instanceof Or);
     Or simOrExpr = (Or) specConstraint.getConstraintExpr();
     Or simOrExpr = (Or) specConstraint.getConstraintExpr();
     for (AbstractConstraint child : simOrExpr.getChildren()) {
     for (AbstractConstraint child : simOrExpr.getChildren()) {
-      Assert.assertTrue(child instanceof SingleConstraint);
+      assertTrue(child instanceof SingleConstraint);
     }
     }
   }
   }
 
 

+ 24 - 23
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/TestClientRMProxy.java

@@ -18,6 +18,12 @@
 
 
 package org.apache.hadoop.yarn.client;
 package org.apache.hadoop.yarn.client;
 
 
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.PrivilegedExceptionAction;
+
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -29,20 +35,15 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
 import org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.ipc.YarnRPC;
 import org.apache.hadoop.yarn.util.Records;
 import org.apache.hadoop.yarn.util.Records;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.security.PrivilegedExceptionAction;
 
 
-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.junit.jupiter.api.Assertions.fail;
 
 
 public class TestClientRMProxy {
 public class TestClientRMProxy {
   @Test
   @Test
-  public void testGetRMDelegationTokenService() {
+  void testGetRMDelegationTokenService() {
     String defaultRMAddress = YarnConfiguration.DEFAULT_RM_ADDRESS;
     String defaultRMAddress = YarnConfiguration.DEFAULT_RM_ADDRESS;
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
 
 
@@ -51,8 +52,8 @@ public class TestClientRMProxy {
     String[] services = tokenService.toString().split(",");
     String[] services = tokenService.toString().split(",");
     assertEquals(1, services.length);
     assertEquals(1, services.length);
     for (String service : services) {
     for (String service : services) {
-      assertTrue("Incorrect token service name",
-          service.contains(defaultRMAddress));
+      assertTrue(service.contains(defaultRMAddress),
+          "Incorrect token service name");
     }
     }
 
 
     // HA is enabled
     // HA is enabled
@@ -66,13 +67,13 @@ public class TestClientRMProxy {
     services = tokenService.toString().split(",");
     services = tokenService.toString().split(",");
     assertEquals(2, services.length);
     assertEquals(2, services.length);
     for (String service : services) {
     for (String service : services) {
-      assertTrue("Incorrect token service name",
-          service.contains(defaultRMAddress));
+      assertTrue(service.contains(defaultRMAddress),
+          "Incorrect token service name");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testGetAMRMTokenService() {
+  void testGetAMRMTokenService() {
     String defaultRMAddress = YarnConfiguration.DEFAULT_RM_SCHEDULER_ADDRESS;
     String defaultRMAddress = YarnConfiguration.DEFAULT_RM_SCHEDULER_ADDRESS;
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
 
 
@@ -81,8 +82,8 @@ public class TestClientRMProxy {
     String[] services = tokenService.toString().split(",");
     String[] services = tokenService.toString().split(",");
     assertEquals(1, services.length);
     assertEquals(1, services.length);
     for (String service : services) {
     for (String service : services) {
-      assertTrue("Incorrect token service name",
-          service.contains(defaultRMAddress));
+      assertTrue(service.contains(defaultRMAddress),
+          "Incorrect token service name");
     }
     }
 
 
     // HA is enabled
     // HA is enabled
@@ -96,8 +97,8 @@ public class TestClientRMProxy {
     services = tokenService.toString().split(",");
     services = tokenService.toString().split(",");
     assertEquals(2, services.length);
     assertEquals(2, services.length);
     for (String service : services) {
     for (String service : services) {
-      assertTrue("Incorrect token service name",
-          service.contains(defaultRMAddress));
+      assertTrue(service.contains(defaultRMAddress),
+          "Incorrect token service name");
     }
     }
   }
   }
 
 
@@ -109,7 +110,7 @@ public class TestClientRMProxy {
    * @throws Exception an Exception occurred
    * @throws Exception an Exception occurred
    */
    */
   @Test
   @Test
-  public void testProxyUserCorrectUGI() throws Exception {
+  void testProxyUserCorrectUGI() throws Exception {
     final YarnConfiguration conf = new YarnConfiguration();
     final YarnConfiguration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
     conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
     conf.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
     conf.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
@@ -129,7 +130,7 @@ public class TestClientRMProxy {
     UserGroupInformation realUser = UserGroupInformation.getCurrentUser();
     UserGroupInformation realUser = UserGroupInformation.getCurrentUser();
     UserGroupInformation proxyUser =
     UserGroupInformation proxyUser =
         UserGroupInformation.createProxyUserForTesting("proxy", realUser,
         UserGroupInformation.createProxyUserForTesting("proxy", realUser,
-        new String[] {"group1"});
+            new String[]{"group1"});
 
 
     // Create the RMProxy using the proxyUser
     // Create the RMProxy using the proxyUser
     ApplicationClientProtocol rmProxy = proxyUser.doAs(
     ApplicationClientProtocol rmProxy = proxyUser.doAs(
@@ -163,7 +164,7 @@ public class TestClientRMProxy {
         UGICapturingHadoopYarnProtoRPC.lastCurrentUser;
         UGICapturingHadoopYarnProtoRPC.lastCurrentUser;
     assertNotNull(lastCurrentUser);
     assertNotNull(lastCurrentUser);
     assertEquals("proxy", lastCurrentUser.getShortUserName());
     assertEquals("proxy", lastCurrentUser.getShortUserName());
-    Assert.assertEquals(UserGroupInformation.AuthenticationMethod.PROXY,
+    assertEquals(UserGroupInformation.AuthenticationMethod.PROXY,
         lastCurrentUser.getAuthenticationMethod());
         lastCurrentUser.getAuthenticationMethod());
     assertEquals(UserGroupInformation.getCurrentUser(),
     assertEquals(UserGroupInformation.getCurrentUser(),
         lastCurrentUser.getRealUser());
         lastCurrentUser.getRealUser());
@@ -187,7 +188,7 @@ public class TestClientRMProxy {
       try {
       try {
         currentUser = UserGroupInformation.getCurrentUser();
         currentUser = UserGroupInformation.getCurrentUser();
       } catch (IOException ioe) {
       } catch (IOException ioe) {
-        Assert.fail("Unable to get current user\n"
+        fail("Unable to get current user\n"
             + StringUtils.stringifyException(ioe));
             + StringUtils.stringifyException(ioe));
       }
       }
       lastCurrentUser = currentUser;
       lastCurrentUser = currentUser;

+ 86 - 83
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClient.java

@@ -18,22 +18,19 @@
 
 
 package org.apache.hadoop.yarn.client.api.impl;
 package org.apache.hadoop.yarn.client.api.impl;
 
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.times;
-
 import java.io.IOException;
 import java.io.IOException;
 import java.net.ConnectException;
 import java.net.ConnectException;
 import java.net.SocketTimeoutException;
 import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.net.URI;
 import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedExceptionAction;
 
 
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientHandlerException;
+import com.sun.jersey.api.client.ClientResponse;
+import org.junit.jupiter.api.AfterEach;
+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.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.http.HttpConfig.Policy;
 import org.apache.hadoop.http.HttpConfig.Policy;
@@ -42,7 +39,6 @@ import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager;
 import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager;
-import static org.apache.hadoop.security.ssl.FileBasedKeyStoresFactory.SSL_MONITORING_THREAD_NAME;
 import org.apache.hadoop.test.TestGenericTestUtils;
 import org.apache.hadoop.test.TestGenericTestUtils;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineDomain;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineDomain;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
@@ -52,14 +48,22 @@ import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
 
 
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientHandlerException;
-import com.sun.jersey.api.client.ClientResponse;
+import static org.apache.hadoop.security.ssl.FileBasedKeyStoresFactory.SSL_MONITORING_THREAD_NAME;
+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.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 
 public class TestTimelineClient {
 public class TestTimelineClient {
 
 
@@ -68,7 +72,7 @@ public class TestTimelineClient {
   private String keystoresDir;
   private String keystoresDir;
   private String sslConfDir;
   private String sslConfDir;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
@@ -76,7 +80,7 @@ public class TestTimelineClient {
     client = createTimelineClient(conf);
     client = createTimelineClient(conf);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (client != null) {
     if (client != null) {
       client.stop();
       client.stop();
@@ -87,113 +91,113 @@ public class TestTimelineClient {
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntities() throws Exception {
+  void testPostEntities() throws Exception {
     mockEntityClientResponse(spyTimelineWriter, ClientResponse.Status.OK,
     mockEntityClientResponse(spyTimelineWriter, ClientResponse.Status.OK,
-      false, false);
+        false, false);
     try {
     try {
       TimelinePutResponse response = client.putEntities(generateEntity());
       TimelinePutResponse response = client.putEntities(generateEntity());
-      Assert.assertEquals(0, response.getErrors().size());
+      assertEquals(0, response.getErrors().size());
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Exception is not expected");
+      fail("Exception is not expected");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntitiesWithError() throws Exception {
+  void testPostEntitiesWithError() throws Exception {
     mockEntityClientResponse(spyTimelineWriter, ClientResponse.Status.OK, true,
     mockEntityClientResponse(spyTimelineWriter, ClientResponse.Status.OK, true,
-      false);
+        false);
     try {
     try {
       TimelinePutResponse response = client.putEntities(generateEntity());
       TimelinePutResponse response = client.putEntities(generateEntity());
-      Assert.assertEquals(1, response.getErrors().size());
-      Assert.assertEquals("test entity id", response.getErrors().get(0)
+      assertEquals(1, response.getErrors().size());
+      assertEquals("test entity id", response.getErrors().get(0)
           .getEntityId());
           .getEntityId());
-      Assert.assertEquals("test entity type", response.getErrors().get(0)
+      assertEquals("test entity type", response.getErrors().get(0)
           .getEntityType());
           .getEntityType());
-      Assert.assertEquals(TimelinePutResponse.TimelinePutError.IO_EXCEPTION,
+      assertEquals(TimelinePutResponse.TimelinePutError.IO_EXCEPTION,
           response.getErrors().get(0).getErrorCode());
           response.getErrors().get(0).getErrorCode());
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Exception is not expected");
+      fail("Exception is not expected");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPostIncompleteEntities() throws Exception {
+  void testPostIncompleteEntities() throws Exception {
     try {
     try {
       client.putEntities(new TimelineEntity());
       client.putEntities(new TimelineEntity());
-      Assert.fail("Exception should have been thrown");
+      fail("Exception should have been thrown");
     } catch (YarnException e) {
     } catch (YarnException e) {
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntitiesNoResponse() throws Exception {
+  void testPostEntitiesNoResponse() throws Exception {
     mockEntityClientResponse(spyTimelineWriter,
     mockEntityClientResponse(spyTimelineWriter,
-      ClientResponse.Status.INTERNAL_SERVER_ERROR, false, false);
+        ClientResponse.Status.INTERNAL_SERVER_ERROR, false, false);
     try {
     try {
       client.putEntities(generateEntity());
       client.putEntities(generateEntity());
-      Assert.fail("Exception is expected");
+      fail("Exception is expected");
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e.getMessage().contains(
           "Failed to get the response from the timeline server."));
           "Failed to get the response from the timeline server."));
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntitiesConnectionRefused() throws Exception {
+  void testPostEntitiesConnectionRefused() throws Exception {
     mockEntityClientResponse(spyTimelineWriter, null, false, true);
     mockEntityClientResponse(spyTimelineWriter, null, false, true);
     try {
     try {
       client.putEntities(generateEntity());
       client.putEntities(generateEntity());
-      Assert.fail("RuntimeException is expected");
+      fail("RuntimeException is expected");
     } catch (RuntimeException re) {
     } catch (RuntimeException re) {
-      Assert.assertTrue(re instanceof ClientHandlerException);
+      assertTrue(re instanceof ClientHandlerException);
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPutDomain() throws Exception {
+  void testPutDomain() throws Exception {
     mockDomainClientResponse(spyTimelineWriter, ClientResponse.Status.OK, false);
     mockDomainClientResponse(spyTimelineWriter, ClientResponse.Status.OK, false);
     try {
     try {
       client.putDomain(generateDomain());
       client.putDomain(generateDomain());
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Exception is not expected");
+      fail("Exception is not expected");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPutDomainNoResponse() throws Exception {
+  void testPutDomainNoResponse() throws Exception {
     mockDomainClientResponse(spyTimelineWriter,
     mockDomainClientResponse(spyTimelineWriter,
         ClientResponse.Status.FORBIDDEN, false);
         ClientResponse.Status.FORBIDDEN, false);
     try {
     try {
       client.putDomain(generateDomain());
       client.putDomain(generateDomain());
-      Assert.fail("Exception is expected");
+      fail("Exception is expected");
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.assertTrue(e.getMessage().contains(
+      assertTrue(e.getMessage().contains(
           "Failed to get the response from the timeline server."));
           "Failed to get the response from the timeline server."));
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPutDomainConnectionRefused() throws Exception {
+  void testPutDomainConnectionRefused() throws Exception {
     mockDomainClientResponse(spyTimelineWriter, null, true);
     mockDomainClientResponse(spyTimelineWriter, null, true);
     try {
     try {
       client.putDomain(generateDomain());
       client.putDomain(generateDomain());
-      Assert.fail("RuntimeException is expected");
+      fail("RuntimeException is expected");
     } catch (RuntimeException re) {
     } catch (RuntimeException re) {
-      Assert.assertTrue(re instanceof ClientHandlerException);
+      assertTrue(re instanceof ClientHandlerException);
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testCheckRetryCount() throws Exception {
+  void testCheckRetryCount() throws Exception {
     try {
     try {
       YarnConfiguration conf = new YarnConfiguration();
       YarnConfiguration conf = new YarnConfiguration();
       conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
       conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
       conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES,
       conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES,
-        -2);
+          -2);
       createTimelineClient(conf);
       createTimelineClient(conf);
-      Assert.fail();
-    } catch(IllegalArgumentException e) {
-      Assert.assertTrue(e.getMessage().contains(
+      fail();
+    } catch (IllegalArgumentException e) {
+      assertTrue(e.getMessage().contains(
           YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES));
           YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES));
     }
     }
 
 
@@ -201,46 +205,46 @@ public class TestTimelineClient {
       YarnConfiguration conf = new YarnConfiguration();
       YarnConfiguration conf = new YarnConfiguration();
       conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
       conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
       conf.setLong(YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS,
       conf.setLong(YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS,
-        0);
+          0);
       createTimelineClient(conf);
       createTimelineClient(conf);
-      Assert.fail();
-    } catch(IllegalArgumentException e) {
-      Assert.assertTrue(e.getMessage().contains(
+      fail();
+    } catch (IllegalArgumentException e) {
+      assertTrue(e.getMessage().contains(
           YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS));
           YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS));
     }
     }
     int newMaxRetries = 5;
     int newMaxRetries = 5;
     long newIntervalMs = 500;
     long newIntervalMs = 500;
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES,
     conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES,
-      newMaxRetries);
+        newMaxRetries);
     conf.setLong(YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS,
     conf.setLong(YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS,
-      newIntervalMs);
+        newIntervalMs);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     TimelineClientImpl client = createTimelineClient(conf);
     TimelineClientImpl client = createTimelineClient(conf);
     try {
     try {
       // This call should fail because there is no timeline server
       // This call should fail because there is no timeline server
       client.putEntities(generateEntity());
       client.putEntities(generateEntity());
-      Assert.fail("Exception expected! "
+      fail("Exception expected! "
           + "Timeline server should be off to run this test. ");
           + "Timeline server should be off to run this test. ");
     } catch (RuntimeException ce) {
     } catch (RuntimeException ce) {
-      Assert.assertTrue(
-          "Handler exception for reason other than retry: " + ce.getMessage(),
-          ce.getMessage().contains("Connection retries limit exceeded"));
+      assertTrue(
+          ce.getMessage().contains("Connection retries limit exceeded"),
+          "Handler exception for reason other than retry: " + ce.getMessage());
       // we would expect this exception here, check if the client has retried
       // we would expect this exception here, check if the client has retried
-      Assert.assertTrue("Retry filter didn't perform any retries! ",
-          client.connector.connectionRetry.getRetired());
+      assertTrue(client.connector.connectionRetry.getRetired(),
+          "Retry filter didn't perform any retries! ");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testDelegationTokenOperationsRetry() throws Exception {
+  void testDelegationTokenOperationsRetry() throws Exception {
     int newMaxRetries = 5;
     int newMaxRetries = 5;
     long newIntervalMs = 500;
     long newIntervalMs = 500;
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES,
     conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES,
-      newMaxRetries);
+        newMaxRetries);
     conf.setLong(YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS,
     conf.setLong(YarnConfiguration.TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS,
-      newIntervalMs);
+        newIntervalMs);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     // use kerberos to bypass the issue in HADOOP-11215
     // use kerberos to bypass the issue in HADOOP-11215
     conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
     conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
@@ -260,7 +264,7 @@ public class TestTimelineClient {
       try {
       try {
         // try getting a delegation token
         // try getting a delegation token
         client.getDelegationToken(
         client.getDelegationToken(
-          UserGroupInformation.getCurrentUser().getShortUserName());
+            UserGroupInformation.getCurrentUser().getShortUserName());
         assertFail();
         assertFail();
       } catch (RuntimeException ce) {
       } catch (RuntimeException ce) {
         assertException(client, ce);
         assertException(client, ce);
@@ -323,7 +327,7 @@ public class TestTimelineClient {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testDelegationTokenDisabledOnSimpleAuth() throws Exception {
+  void testDelegationTokenDisabledOnSimpleAuth() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.set(YarnConfiguration.TIMELINE_HTTP_AUTH_TYPE, "simple");
     conf.set(YarnConfiguration.TIMELINE_HTTP_AUTH_TYPE, "simple");
@@ -336,15 +340,15 @@ public class TestTimelineClient {
       // try getting a delegation token
       // try getting a delegation token
       Token<TimelineDelegationTokenIdentifier> identifierToken =
       Token<TimelineDelegationTokenIdentifier> identifierToken =
           tClient.getDelegationToken(
           tClient.getDelegationToken(
-          UserGroupInformation.getCurrentUser().getShortUserName());
+              UserGroupInformation.getCurrentUser().getShortUserName());
       // Get a null token when using simple auth
       // Get a null token when using simple auth
-      Assert.assertNull(identifierToken);
+      assertNull(identifierToken);
 
 
       // try renew a delegation token
       // try renew a delegation token
       Token<TimelineDelegationTokenIdentifier> dummyToken = new Token<>();
       Token<TimelineDelegationTokenIdentifier> dummyToken = new Token<>();
       long renewTime = tClient.renewDelegationToken(dummyToken);
       long renewTime = tClient.renewDelegationToken(dummyToken);
       // Get invalid expiration time so that RM skips renewal
       // Get invalid expiration time so that RM skips renewal
-      Assert.assertEquals(renewTime, -1);
+      assertEquals(renewTime, -1);
 
 
       // try cancel a delegation token
       // try cancel a delegation token
       tClient.cancelDelegationToken(dummyToken);
       tClient.cancelDelegationToken(dummyToken);
@@ -356,17 +360,16 @@ public class TestTimelineClient {
   }
   }
 
 
   private static void assertFail() {
   private static void assertFail() {
-    Assert.fail("Exception expected! "
+    fail("Exception expected! "
         + "Timeline server should be off to run this test.");
         + "Timeline server should be off to run this test.");
   }
   }
 
 
   private void assertException(TimelineClientImpl client, RuntimeException ce) {
   private void assertException(TimelineClientImpl client, RuntimeException ce) {
-    Assert.assertTrue(
-        "Handler exception for reason other than retry: " + ce.toString(), ce
-            .getMessage().contains("Connection retries limit exceeded"));
+    assertTrue(ce.getMessage().contains("Connection retries limit exceeded"),
+        "Handler exception for reason other than retry: " + ce.toString());
     // we would expect this exception here, check if the client has retried
     // we would expect this exception here, check if the client has retried
-    Assert.assertTrue("Retry filter didn't perform any retries! ",
-        client.connector.connectionRetry.getRetired());
+    assertTrue(client.connector.connectionRetry.getRetired(),
+        "Retry filter didn't perform any retries! ");
   }
   }
 
 
   public static ClientResponse mockEntityClientResponse(
   public static ClientResponse mockEntityClientResponse(
@@ -495,7 +498,7 @@ public class TestTimelineClient {
   }
   }
 
 
   @Test
   @Test
-  public void testTimelineClientCleanup() throws Exception {
+  void testTimelineClientCleanup() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES, 0);
     conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES, 0);
@@ -520,7 +523,7 @@ public class TestTimelineClient {
         reloaderThread = thread;
         reloaderThread = thread;
       }
       }
     }
     }
-    Assert.assertTrue("Reloader is not alive", reloaderThread.isAlive());
+    assertTrue(reloaderThread.isAlive(), "Reloader is not alive");
 
 
     client.close();
     client.close();
 
 
@@ -532,11 +535,11 @@ public class TestTimelineClient {
       }
       }
       Thread.sleep(1000);
       Thread.sleep(1000);
     }
     }
-    Assert.assertFalse("Reloader is still alive", reloaderStillAlive);
+    assertFalse(reloaderStillAlive, "Reloader is still alive");
   }
   }
 
 
   @Test
   @Test
-  public void testTimelineConnectorDestroy() {
+  void testTimelineConnectorDestroy() {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     TimelineClientImpl client = createTimelineClient(conf);
     TimelineClientImpl client = createTimelineClient(conf);

+ 28 - 27
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClientForATS1_5.java

@@ -18,20 +18,18 @@
 
 
 package org.apache.hadoop.yarn.client.api.impl;
 package org.apache.hadoop.yarn.client.api.impl;
 
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.reset;
-
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
 
 
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
@@ -42,13 +40,16 @@ import org.apache.hadoop.yarn.api.records.timeline.TimelineDomain;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId;
 import org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
 
 
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
+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.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 
 public class TestTimelineClientForATS1_5 {
 public class TestTimelineClientForATS1_5 {
 
 
@@ -61,7 +62,7 @@ public class TestTimelineClientForATS1_5 {
   private TimelineWriter spyTimelineWriter;
   private TimelineWriter spyTimelineWriter;
   private UserGroupInformation authUgi;
   private UserGroupInformation authUgi;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     localFS = FileContext.getLocalFSFileContext();
     localFS = FileContext.getLocalFSFileContext();
     localActiveDir =
     localActiveDir =
@@ -85,7 +86,7 @@ public class TestTimelineClientForATS1_5 {
     return conf;
     return conf;
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (client != null) {
     if (client != null) {
       client.stop();
       client.stop();
@@ -94,13 +95,13 @@ public class TestTimelineClientForATS1_5 {
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntities() throws Exception {
+  void testPostEntities() throws Exception {
     client = createTimelineClient(getConfigurations());
     client = createTimelineClient(getConfigurations());
     verifyForPostEntities(false);
     verifyForPostEntities(false);
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntitiesToKeepUnderUserDir() throws Exception {
+  void testPostEntitiesToKeepUnderUserDir() throws Exception {
     YarnConfiguration conf = getConfigurations();
     YarnConfiguration conf = getConfigurations();
     conf.setBoolean(
     conf.setBoolean(
         YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
         YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
@@ -137,7 +138,7 @@ public class TestTimelineClientForATS1_5 {
       TimelineEntity[] entityTDB = new TimelineEntity[1];
       TimelineEntity[] entityTDB = new TimelineEntity[1];
       entityTDB[0] = entities[0];
       entityTDB[0] = entities[0];
       verify(spyTimelineWriter, times(1)).putEntities(entityTDB);
       verify(spyTimelineWriter, times(1)).putEntities(entityTDB);
-      Assert.assertTrue(localFS.util().exists(
+      assertTrue(localFS.util().exists(
           new Path(getAppAttemptDir(attemptId1, storeInsideUserDir),
           new Path(getAppAttemptDir(attemptId1, storeInsideUserDir),
               "summarylog-"
               "summarylog-"
             + attemptId1.toString())));
             + attemptId1.toString())));
@@ -152,32 +153,32 @@ public class TestTimelineClientForATS1_5 {
       client.putEntities(attemptId2, groupId2, entities);
       client.putEntities(attemptId2, groupId2, entities);
       verify(spyTimelineWriter, times(0)).putEntities(
       verify(spyTimelineWriter, times(0)).putEntities(
         any(TimelineEntity[].class));
         any(TimelineEntity[].class));
-      Assert.assertTrue(localFS.util().exists(
+      assertTrue(localFS.util().exists(
           new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
           new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
               "summarylog-"
               "summarylog-"
             + attemptId2.toString())));
             + attemptId2.toString())));
-      Assert.assertTrue(localFS.util().exists(
+      assertTrue(localFS.util().exists(
           new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
           new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
               "entitylog-"
               "entitylog-"
             + groupId.toString())));
             + groupId.toString())));
-      Assert.assertTrue(localFS.util().exists(
+      assertTrue(localFS.util().exists(
           new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
           new Path(getAppAttemptDir(attemptId2, storeInsideUserDir),
               "entitylog-"
               "entitylog-"
             + groupId2.toString())));
             + groupId2.toString())));
       reset(spyTimelineWriter);
       reset(spyTimelineWriter);
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.fail("Exception is not expected. " + e);
+      fail("Exception is not expected. " + e);
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testPutDomain() {
+  void testPutDomain() {
     client = createTimelineClient(getConfigurations());
     client = createTimelineClient(getConfigurations());
     verifyForPutDomain(false);
     verifyForPutDomain(false);
   }
   }
 
 
   @Test
   @Test
-  public void testPutDomainToKeepUnderUserDir() {
+  void testPutDomainToKeepUnderUserDir() {
     YarnConfiguration conf = getConfigurations();
     YarnConfiguration conf = getConfigurations();
     conf.setBoolean(
     conf.setBoolean(
         YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
         YarnConfiguration.TIMELINE_SERVICE_ENTITYGROUP_FS_STORE_WITH_USER_DIR,
@@ -200,12 +201,12 @@ public class TestTimelineClientForATS1_5 {
 
 
       client.putDomain(attemptId1, domain);
       client.putDomain(attemptId1, domain);
       verify(spyTimelineWriter, times(0)).putDomain(domain);
       verify(spyTimelineWriter, times(0)).putDomain(domain);
-      Assert.assertTrue(localFS.util()
+      assertTrue(localFS.util()
           .exists(new Path(getAppAttemptDir(attemptId1, storeInsideUserDir),
           .exists(new Path(getAppAttemptDir(attemptId1, storeInsideUserDir),
               "domainlog-" + attemptId1.toString())));
               "domainlog-" + attemptId1.toString())));
       reset(spyTimelineWriter);
       reset(spyTimelineWriter);
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.fail("Exception is not expected." + e);
+      fail("Exception is not expected." + e);
     }
     }
   }
   }
 
 

+ 105 - 88
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineClientV2Impl.java

@@ -18,20 +18,19 @@
 
 
 package org.apache.hadoop.yarn.client.api.impl;
 package org.apache.hadoop.yarn.client.api.impl;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
-
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.MultivaluedMap;
 
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -42,12 +41,13 @@ import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestTimelineClientV2Impl {
 public class TestTimelineClientV2Impl {
   private static final Logger LOG =
   private static final Logger LOG =
@@ -56,20 +56,25 @@ public class TestTimelineClientV2Impl {
   private static final long TIME_TO_SLEEP = 150L;
   private static final long TIME_TO_SLEEP = 150L;
   private static final String EXCEPTION_MSG = "Exception in the content";
   private static final String EXCEPTION_MSG = "Exception in the content";
 
 
-  @Before
-  public void setup() {
+  @BeforeEach
+  public void setup(TestInfo testInfo) {
     conf = new YarnConfiguration();
     conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
     conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 2.0f);
     conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 2.0f);
     conf.setInt(YarnConfiguration.NUMBER_OF_ASYNC_ENTITIES_TO_MERGE, 3);
     conf.setInt(YarnConfiguration.NUMBER_OF_ASYNC_ENTITIES_TO_MERGE, 3);
-    if (!currTestName.getMethodName()
+    if (!testInfo.getDisplayName()
         .contains("testRetryOnConnectionFailure")) {
         .contains("testRetryOnConnectionFailure")) {
       client = createTimelineClient(conf);
       client = createTimelineClient(conf);
     }
     }
   }
   }
 
 
-  @Rule
-  public TestName currTestName = new TestName();
+  @Test
+  void getTestInfo(TestInfo testInfo) {
+    System.out.println(testInfo.getDisplayName());
+    System.out.println(testInfo.getTestMethod());
+    System.out.println(testInfo.getTestClass());
+    System.out.println(testInfo.getTags());
+  }
   private YarnConfiguration conf;
   private YarnConfiguration conf;
 
 
   private TestV2TimelineClient createTimelineClient(YarnConfiguration config) {
   private TestV2TimelineClient createTimelineClient(YarnConfiguration config) {
@@ -116,8 +121,8 @@ public class TestTimelineClientV2Impl {
     private List<TimelineEntities> publishedEntities;
     private List<TimelineEntities> publishedEntities;
 
 
     public TimelineEntities getPublishedEntities(int putIndex) {
     public TimelineEntities getPublishedEntities(int putIndex) {
-      Assert.assertTrue("Not So many entities Published",
-          putIndex < publishedEntities.size());
+      assertTrue(putIndex < publishedEntities.size(),
+          "Not So many entities Published");
       return publishedEntities.get(putIndex);
       return publishedEntities.get(putIndex);
     }
     }
 
 
@@ -152,7 +157,7 @@ public class TestTimelineClientV2Impl {
   }
   }
 
 
   @Test
   @Test
-  public void testExceptionMultipleRetry() {
+  void testExceptionMultipleRetry() {
     TestV2TimelineClientForExceptionHandling c =
     TestV2TimelineClientForExceptionHandling c =
         new TestV2TimelineClientForExceptionHandling(
         new TestV2TimelineClientForExceptionHandling(
             ApplicationId.newInstance(0, 0));
             ApplicationId.newInstance(0, 0));
@@ -165,42 +170,42 @@ public class TestTimelineClientV2Impl {
     try {
     try {
       c.putEntities(new TimelineEntity());
       c.putEntities(new TimelineEntity());
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.fail("YARN exception is expected");
+      fail("YARN exception is expected");
     } catch (YarnException e) {
     } catch (YarnException e) {
       Throwable cause = e.getCause();
       Throwable cause = e.getCause();
-      Assert.assertTrue("IOException is expected",
-          cause instanceof IOException);
-      Assert.assertTrue("YARN exception is expected",
-          cause.getMessage().contains(
-              "TimelineClient has reached to max retry times : " + maxRetries));
+      assertTrue(cause instanceof IOException,
+          "IOException is expected");
+      assertTrue(cause.getMessage().contains(
+              "TimelineClient has reached to max retry times : " + maxRetries),
+          "YARN exception is expected");
     }
     }
 
 
     c.setThrowYarnException(true);
     c.setThrowYarnException(true);
     try {
     try {
       c.putEntities(new TimelineEntity());
       c.putEntities(new TimelineEntity());
     } catch (IOException e) {
     } catch (IOException e) {
-      Assert.fail("YARN exception is expected");
+      fail("YARN exception is expected");
     } catch (YarnException e) {
     } catch (YarnException e) {
       Throwable cause = e.getCause();
       Throwable cause = e.getCause();
-      Assert.assertTrue("YARN exception is expected",
-          cause instanceof YarnException);
-      Assert.assertTrue("YARN exception is expected",
-          cause.getMessage().contains(EXCEPTION_MSG));
+      assertTrue(cause instanceof YarnException,
+          "YARN exception is expected");
+      assertTrue(cause.getMessage().contains(EXCEPTION_MSG),
+          "YARN exception is expected");
     }
     }
     c.stop();
     c.stop();
   }
   }
 
 
   @Test
   @Test
-  public void testPostEntities() throws Exception {
+  void testPostEntities() throws Exception {
     try {
     try {
       client.putEntities(generateEntity("1"));
       client.putEntities(generateEntity("1"));
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Exception is not expected");
+      fail("Exception is not expected");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testASyncCallMerge() throws Exception {
+  void testASyncCallMerge() throws Exception {
     client.setSleepBeforeReturn(true);
     client.setSleepBeforeReturn(true);
     try {
     try {
       client.putEntitiesAsync(generateEntity("1"));
       client.putEntitiesAsync(generateEntity("1"));
@@ -209,7 +214,7 @@ public class TestTimelineClientV2Impl {
       client.putEntitiesAsync(generateEntity("2"));
       client.putEntitiesAsync(generateEntity("2"));
       client.putEntitiesAsync(generateEntity("3"));
       client.putEntitiesAsync(generateEntity("3"));
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Exception is not expected");
+      fail("Exception is not expected");
     }
     }
     for (int i = 0; i < 4; i++) {
     for (int i = 0; i < 4; i++) {
       if (client.getNumOfTimelineEntitiesPublished() == 2) {
       if (client.getNumOfTimelineEntitiesPublished() == 2) {
@@ -217,20 +222,24 @@ public class TestTimelineClientV2Impl {
       }
       }
       Thread.sleep(TIME_TO_SLEEP);
       Thread.sleep(TIME_TO_SLEEP);
     }
     }
-    Assert.assertEquals("two merged TimelineEntities needs to be published", 2,
-        client.getNumOfTimelineEntitiesPublished());
+    assertEquals(2,
+        client.getNumOfTimelineEntitiesPublished(),
+        "two merged TimelineEntities needs to be published");
     TimelineEntities secondPublishedEntities = client.getPublishedEntities(1);
     TimelineEntities secondPublishedEntities = client.getPublishedEntities(1);
-    Assert.assertEquals(
-        "Merged TimelineEntities Object needs to 2 TimelineEntity Object", 2,
-        secondPublishedEntities.getEntities().size());
-    Assert.assertEquals("Order of Async Events Needs to be FIFO", "2",
-        secondPublishedEntities.getEntities().get(0).getId());
-    Assert.assertEquals("Order of Async Events Needs to be FIFO", "3",
-        secondPublishedEntities.getEntities().get(1).getId());
+    assertEquals(
+        2,
+        secondPublishedEntities.getEntities().size(),
+        "Merged TimelineEntities Object needs to 2 TimelineEntity Object");
+    assertEquals("2",
+        secondPublishedEntities.getEntities().get(0).getId(),
+        "Order of Async Events Needs to be FIFO");
+    assertEquals("3",
+        secondPublishedEntities.getEntities().get(1).getId(),
+        "Order of Async Events Needs to be FIFO");
   }
   }
 
 
   @Test
   @Test
-  public void testSyncCall() throws Exception {
+  void testSyncCall() throws Exception {
     try {
     try {
       // sync entity should not be be merged with Async
       // sync entity should not be be merged with Async
       client.putEntities(generateEntity("1"));
       client.putEntities(generateEntity("1"));
@@ -239,7 +248,7 @@ public class TestTimelineClientV2Impl {
       // except for the sync call above 2 should be merged
       // except for the sync call above 2 should be merged
       client.putEntities(generateEntity("4"));
       client.putEntities(generateEntity("4"));
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Exception is not expected");
+      fail("Exception is not expected");
     }
     }
     for (int i = 0; i < 4; i++) {
     for (int i = 0; i < 4; i++) {
       if (client.getNumOfTimelineEntitiesPublished() == 3) {
       if (client.getNumOfTimelineEntitiesPublished() == 3) {
@@ -253,57 +262,65 @@ public class TestTimelineClientV2Impl {
     int lastPublishIndex = asyncPushesMerged ? 2 : 3;
     int lastPublishIndex = asyncPushesMerged ? 2 : 3;
 
 
     TimelineEntities firstPublishedEntities = client.getPublishedEntities(0);
     TimelineEntities firstPublishedEntities = client.getPublishedEntities(0);
-    Assert.assertEquals("sync entities should not be merged with async", 1,
-        firstPublishedEntities.getEntities().size());
+    assertEquals(1,
+        firstPublishedEntities.getEntities().size(),
+        "sync entities should not be merged with async");
 
 
     // async push does not guarantee a merge but is FIFO
     // async push does not guarantee a merge but is FIFO
     if (asyncPushesMerged) {
     if (asyncPushesMerged) {
       TimelineEntities secondPublishedEntities = client.getPublishedEntities(1);
       TimelineEntities secondPublishedEntities = client.getPublishedEntities(1);
-      Assert.assertEquals(
-          "async entities should be merged before publishing sync", 2,
-          secondPublishedEntities.getEntities().size());
-      Assert.assertEquals("Order of Async Events Needs to be FIFO", "2",
-          secondPublishedEntities.getEntities().get(0).getId());
-      Assert.assertEquals("Order of Async Events Needs to be FIFO", "3",
-          secondPublishedEntities.getEntities().get(1).getId());
+      assertEquals(
+          2,
+          secondPublishedEntities.getEntities().size(),
+          "async entities should be merged before publishing sync");
+      assertEquals("2",
+          secondPublishedEntities.getEntities().get(0).getId(),
+          "Order of Async Events Needs to be FIFO");
+      assertEquals("3",
+          secondPublishedEntities.getEntities().get(1).getId(),
+          "Order of Async Events Needs to be FIFO");
     } else {
     } else {
       TimelineEntities secondAsyncPublish = client.getPublishedEntities(1);
       TimelineEntities secondAsyncPublish = client.getPublishedEntities(1);
-      Assert.assertEquals("Order of Async Events Needs to be FIFO", "2",
-          secondAsyncPublish.getEntities().get(0).getId());
+      assertEquals("2",
+          secondAsyncPublish.getEntities().get(0).getId(),
+          "Order of Async Events Needs to be FIFO");
       TimelineEntities thirdAsyncPublish = client.getPublishedEntities(2);
       TimelineEntities thirdAsyncPublish = client.getPublishedEntities(2);
-      Assert.assertEquals("Order of Async Events Needs to be FIFO", "3",
-          thirdAsyncPublish.getEntities().get(0).getId());
+      assertEquals("3",
+          thirdAsyncPublish.getEntities().get(0).getId(),
+          "Order of Async Events Needs to be FIFO");
     }
     }
 
 
     // test the last entity published is sync put
     // test the last entity published is sync put
     TimelineEntities thirdPublishedEntities =
     TimelineEntities thirdPublishedEntities =
         client.getPublishedEntities(lastPublishIndex);
         client.getPublishedEntities(lastPublishIndex);
-    Assert.assertEquals("sync entities had to be published at the last", 1,
-        thirdPublishedEntities.getEntities().size());
-    Assert.assertEquals("Expected last sync Event is not proper", "4",
-        thirdPublishedEntities.getEntities().get(0).getId());
+    assertEquals(1,
+        thirdPublishedEntities.getEntities().size(),
+        "sync entities had to be published at the last");
+    assertEquals("4",
+        thirdPublishedEntities.getEntities().get(0).getId(),
+        "Expected last sync Event is not proper");
   }
   }
 
 
   @Test
   @Test
-  public void testExceptionCalls() throws Exception {
+  void testExceptionCalls() throws Exception {
     client.setThrowYarnException(true);
     client.setThrowYarnException(true);
     try {
     try {
       client.putEntitiesAsync(generateEntity("1"));
       client.putEntitiesAsync(generateEntity("1"));
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("Async calls are not expected to throw exception");
+      fail("Async calls are not expected to throw exception");
     }
     }
 
 
     try {
     try {
       client.putEntities(generateEntity("2"));
       client.putEntities(generateEntity("2"));
-      Assert.fail("Sync calls are expected to throw exception");
+      fail("Sync calls are expected to throw exception");
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.assertEquals("Same exception needs to be thrown",
-          "ActualException", e.getCause().getMessage());
+      assertEquals("ActualException", e.getCause().getMessage(),
+          "Same exception needs to be thrown");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testConfigurableNumberOfMerges() throws Exception {
+  void testConfigurableNumberOfMerges() throws Exception {
     client.setSleepBeforeReturn(true);
     client.setSleepBeforeReturn(true);
     try {
     try {
       // At max 3 entities need to be merged
       // At max 3 entities need to be merged
@@ -318,52 +335,52 @@ public class TestTimelineClientV2Impl {
       client.putEntitiesAsync(generateEntity("9"));
       client.putEntitiesAsync(generateEntity("9"));
       client.putEntitiesAsync(generateEntity("10"));
       client.putEntitiesAsync(generateEntity("10"));
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("No exception expected");
+      fail("No exception expected");
     }
     }
     // not having the same logic here as it doesn't depend on how many times
     // not having the same logic here as it doesn't depend on how many times
     // events are published.
     // events are published.
     Thread.sleep(2 * TIME_TO_SLEEP);
     Thread.sleep(2 * TIME_TO_SLEEP);
     printReceivedEntities();
     printReceivedEntities();
     for (TimelineEntities publishedEntities : client.publishedEntities) {
     for (TimelineEntities publishedEntities : client.publishedEntities) {
-      Assert.assertTrue(
+      assertTrue(
+          publishedEntities.getEntities().size() <= 3,
           "Number of entities should not be greater than 3 for each publish,"
           "Number of entities should not be greater than 3 for each publish,"
-              + " but was " + publishedEntities.getEntities().size(),
-          publishedEntities.getEntities().size() <= 3);
+              + " but was " + publishedEntities.getEntities().size());
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testSetTimelineToken() throws Exception {
+  void testSetTimelineToken() throws Exception {
     UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
     UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
     assertEquals(0, ugi.getTokens().size());
     assertEquals(0, ugi.getTokens().size());
-    assertNull("Timeline token in v2 client should not be set",
-        client.currentTimelineToken);
+    assertNull(client.currentTimelineToken,
+        "Timeline token in v2 client should not be set");
 
 
     Token token = Token.newInstance(
     Token token = Token.newInstance(
         new byte[0], "kind", new byte[0], "service");
         new byte[0], "kind", new byte[0], "service");
     client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
     client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
-    assertNull("Timeline token in v2 client should not be set as token kind " +
-        "is unexepcted.", client.currentTimelineToken);
+    assertNull(client.currentTimelineToken,
+        "Timeline token in v2 client should not be set as token kind " + "is unexepcted.");
     assertEquals(0, ugi.getTokens().size());
     assertEquals(0, ugi.getTokens().size());
 
 
     token = Token.newInstance(new byte[0], TimelineDelegationTokenIdentifier.
     token = Token.newInstance(new byte[0], TimelineDelegationTokenIdentifier.
         KIND_NAME.toString(), new byte[0], null);
         KIND_NAME.toString(), new byte[0], null);
     client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
     client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
-    assertNull("Timeline token in v2 client should not be set as serice is " +
-        "not set.", client.currentTimelineToken);
+    assertNull(client.currentTimelineToken,
+        "Timeline token in v2 client should not be set as serice is " + "not set.");
     assertEquals(0, ugi.getTokens().size());
     assertEquals(0, ugi.getTokens().size());
 
 
     TimelineDelegationTokenIdentifier ident =
     TimelineDelegationTokenIdentifier ident =
         new TimelineDelegationTokenIdentifier(new Text(ugi.getUserName()),
         new TimelineDelegationTokenIdentifier(new Text(ugi.getUserName()),
-        new Text("renewer"), null);
+            new Text("renewer"), null);
     ident.setSequenceNumber(1);
     ident.setSequenceNumber(1);
     token = Token.newInstance(ident.getBytes(),
     token = Token.newInstance(ident.getBytes(),
         TimelineDelegationTokenIdentifier.KIND_NAME.toString(), new byte[0],
         TimelineDelegationTokenIdentifier.KIND_NAME.toString(), new byte[0],
         "localhost:1234");
         "localhost:1234");
     client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
     client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
     assertEquals(1, ugi.getTokens().size());
     assertEquals(1, ugi.getTokens().size());
-    assertNotNull("Timeline token should be set in v2 client.",
-        client.currentTimelineToken);
+    assertNotNull(client.currentTimelineToken,
+        "Timeline token should be set in v2 client.");
     assertEquals(token, client.currentTimelineToken);
     assertEquals(token, client.currentTimelineToken);
 
 
     ident.setSequenceNumber(20);
     ident.setSequenceNumber(20);
@@ -377,7 +394,7 @@ public class TestTimelineClientV2Impl {
   }
   }
 
 
   @Test
   @Test
-  public void testAfterStop() throws Exception {
+  void testAfterStop() throws Exception {
     client.setSleepBeforeReturn(true);
     client.setSleepBeforeReturn(true);
     try {
     try {
       // At max 3 entities need to be merged
       // At max 3 entities need to be merged
@@ -388,12 +405,12 @@ public class TestTimelineClientV2Impl {
       client.stop();
       client.stop();
       try {
       try {
         client.putEntitiesAsync(generateEntity("50"));
         client.putEntitiesAsync(generateEntity("50"));
-        Assert.fail("Exception expected");
+        fail("Exception expected");
       } catch (YarnException e) {
       } catch (YarnException e) {
         // expected
         // expected
       }
       }
     } catch (YarnException e) {
     } catch (YarnException e) {
-      Assert.fail("No exception expected");
+      fail("No exception expected");
     }
     }
     // not having the same logic here as it doesn't depend on how many times
     // not having the same logic here as it doesn't depend on how many times
     // events are published.
     // events are published.
@@ -411,7 +428,7 @@ public class TestTimelineClientV2Impl {
         client.publishedEntities.get(client.publishedEntities.size() - 1);
         client.publishedEntities.get(client.publishedEntities.size() - 1);
     TimelineEntity timelineEntity = publishedEntities.getEntities()
     TimelineEntity timelineEntity = publishedEntities.getEntities()
         .get(publishedEntities.getEntities().size() - 1);
         .get(publishedEntities.getEntities().size() - 1);
-    Assert.assertEquals("", "19", timelineEntity.getId());
+    assertEquals("19", timelineEntity.getId(), "");
   }
   }
 
 
   private void printReceivedEntities() {
   private void printReceivedEntities() {
@@ -435,7 +452,7 @@ public class TestTimelineClientV2Impl {
     return entity;
     return entity;
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (client != null) {
     if (client != null) {
       client.stop();
       client.stop();

+ 33 - 32
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestTimelineReaderClientImpl.java

@@ -18,30 +18,31 @@
 
 
 package org.apache.hadoop.yarn.client.api.impl;
 package org.apache.hadoop.yarn.client.api.impl;
 
 
-import static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType.YARN_APPLICATION_ATTEMPT;
-import static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType.YARN_CONTAINER;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.core.MultivaluedMap;
 
 
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
 import com.sun.jersey.api.client.ClientResponse;
 import com.sun.jersey.api.client.ClientResponse;
+import org.junit.jupiter.api.AfterEach;
+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.thirdparty.com.google.common.collect.ImmutableMap;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
 import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
 import org.apache.hadoop.yarn.client.api.TimelineReaderClient;
 import org.apache.hadoop.yarn.client.api.TimelineReaderClient;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
 
 
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
+import static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType.YARN_APPLICATION_ATTEMPT;
+import static org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType.YARN_CONTAINER;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 /**
 /**
  * Test class for Timeline Reader Client.
  * Test class for Timeline Reader Client.
@@ -52,7 +53,7 @@ public class TestTimelineReaderClientImpl {
       "\"id\":\"appattempt_1234_0001_000001\"}";
       "\"id\":\"appattempt_1234_0001_000001\"}";
   private TimelineReaderClient client;
   private TimelineReaderClient client;
 
 
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     client = new MockTimelineReaderClient();
     client = new MockTimelineReaderClient();
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
@@ -63,64 +64,64 @@ public class TestTimelineReaderClientImpl {
   }
   }
 
 
   @Test
   @Test
-  public void testGetApplication() throws Exception {
+  void testGetApplication() throws Exception {
     ApplicationId applicationId =
     ApplicationId applicationId =
         ApplicationId.fromString("application_1234_0001");
         ApplicationId.fromString("application_1234_0001");
     TimelineEntity entity = client.getApplicationEntity(applicationId,
     TimelineEntity entity = client.getApplicationEntity(applicationId,
         null, null);
         null, null);
-    Assert.assertEquals("mockApp1", entity.getId());
+    assertEquals("mockApp1", entity.getId());
   }
   }
 
 
   @Test
   @Test
-  public void getApplicationAttemptEntity() throws Exception {
+  void getApplicationAttemptEntity() throws Exception {
     ApplicationAttemptId attemptId =
     ApplicationAttemptId attemptId =
         ApplicationAttemptId.fromString("appattempt_1234_0001_000001");
         ApplicationAttemptId.fromString("appattempt_1234_0001_000001");
     TimelineEntity entity = client.getApplicationAttemptEntity(attemptId,
     TimelineEntity entity = client.getApplicationAttemptEntity(attemptId,
         null, null);
         null, null);
-    Assert.assertEquals("mockAppAttempt1", entity.getId());
+    assertEquals("mockAppAttempt1", entity.getId());
   }
   }
 
 
   @Test
   @Test
-  public void getApplicationAttemptEntities() throws Exception {
+  void getApplicationAttemptEntities() throws Exception {
     ApplicationId applicationId =
     ApplicationId applicationId =
         ApplicationId.fromString("application_1234_0001");
         ApplicationId.fromString("application_1234_0001");
     List<TimelineEntity> entities =
     List<TimelineEntity> entities =
         client.getApplicationAttemptEntities(applicationId, null,
         client.getApplicationAttemptEntities(applicationId, null,
             null, 0, null);
             null, 0, null);
-    Assert.assertEquals(2, entities.size());
-    Assert.assertEquals("mockAppAttempt2", entities.get(1).getId());
+    assertEquals(2, entities.size());
+    assertEquals("mockAppAttempt2", entities.get(1).getId());
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainer() throws Exception {
+  void testGetContainer() throws Exception {
     ContainerId containerId =
     ContainerId containerId =
         ContainerId.fromString("container_1234_0001_01_000001");
         ContainerId.fromString("container_1234_0001_01_000001");
     TimelineEntity entity = client.getContainerEntity(containerId,
     TimelineEntity entity = client.getContainerEntity(containerId,
         null, null);
         null, null);
-    Assert.assertEquals("mockContainer1", entity.getId());
+    assertEquals("mockContainer1", entity.getId());
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainers() throws Exception {
+  void testGetContainers() throws Exception {
     ApplicationId appId =
     ApplicationId appId =
         ApplicationId.fromString("application_1234_0001");
         ApplicationId.fromString("application_1234_0001");
     List<TimelineEntity> entities = client.getContainerEntities(appId,
     List<TimelineEntity> entities = client.getContainerEntities(appId,
         null, null, 0, null);
         null, null, 0, null);
-    Assert.assertEquals(2, entities.size());
-    Assert.assertEquals("mockContainer2", entities.get(1).getId());
+    assertEquals(2, entities.size());
+    assertEquals("mockContainer2", entities.get(1).getId());
   }
   }
 
 
   @Test
   @Test
-  public void testGetContainersForAppAttempt() throws Exception {
+  void testGetContainersForAppAttempt() throws Exception {
     ApplicationId appId =
     ApplicationId appId =
         ApplicationId.fromString("application_1234_0001");
         ApplicationId.fromString("application_1234_0001");
     List<TimelineEntity> entities = client.getContainerEntities(appId,
     List<TimelineEntity> entities = client.getContainerEntities(appId,
         null, ImmutableMap.of("infofilters", appAttemptInfoFilter), 0, null);
         null, ImmutableMap.of("infofilters", appAttemptInfoFilter), 0, null);
-    Assert.assertEquals(2, entities.size());
-    Assert.assertEquals("mockContainer4", entities.get(1).getId());
+    assertEquals(2, entities.size());
+    assertEquals("mockContainer4", entities.get(1).getId());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() {
   public void tearDown() {
     if (client != null) {
     if (client != null) {
       client.stop();
       client.stop();
@@ -154,7 +155,7 @@ public class TestTimelineReaderClientImpl {
         when(mockClientResponse.getEntity(TimelineEntity[].class)).thenReturn(
         when(mockClientResponse.getEntity(TimelineEntity[].class)).thenReturn(
             createTimelineEntities("mockContainer1", "mockContainer2"));
             createTimelineEntities("mockContainer1", "mockContainer2"));
       } else if (path.contains(YARN_CONTAINER.toString()) && params.containsKey("infofilters")) {
       } else if (path.contains(YARN_CONTAINER.toString()) && params.containsKey("infofilters")) {
-        Assert.assertEquals(encodeValue(appAttemptInfoFilter), params.get("infofilters").get(0));
+        assertEquals(encodeValue(appAttemptInfoFilter), params.get("infofilters").get(0));
         when(mockClientResponse.getEntity(TimelineEntity[].class)).thenReturn(
         when(mockClientResponse.getEntity(TimelineEntity[].class)).thenReturn(
             createTimelineEntities("mockContainer3", "mockContainer4"));
             createTimelineEntities("mockContainer3", "mockContainer4"));
       } else if (path.contains(YARN_APPLICATION_ATTEMPT.toString())) {
       } else if (path.contains(YARN_APPLICATION_ATTEMPT.toString())) {

+ 52 - 55
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/conf/TestHAUtil.java

@@ -18,20 +18,20 @@
 
 
 package org.apache.hadoop.yarn.conf;
 package org.apache.hadoop.yarn.conf;
 
 
-import org.apache.hadoop.conf.Configuration;
+import java.util.Collection;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Collection;
 
 
-import static org.junit.Assert.assertEquals;
-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;
 
 
 public class TestHAUtil {
 public class TestHAUtil {
   private Configuration conf;
   private Configuration conf;
@@ -48,7 +48,7 @@ public class TestHAUtil {
   private static final String RM_NODE_IDS_UNTRIMMED = RM1_NODE_ID_UNTRIMMED + "," + RM2_NODE_ID;
   private static final String RM_NODE_IDS_UNTRIMMED = RM1_NODE_ID_UNTRIMMED + "," + RM2_NODE_ID;
   private static final String RM_NODE_IDS = RM1_NODE_ID + "," + RM2_NODE_ID;
   private static final String RM_NODE_IDS = RM1_NODE_ID + "," + RM2_NODE_ID;
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     conf = new Configuration();
     conf = new Configuration();
     conf.set(YarnConfiguration.RM_HA_IDS, RM_NODE_IDS_UNTRIMMED);
     conf.set(YarnConfiguration.RM_HA_IDS, RM_NODE_IDS_UNTRIMMED);
@@ -62,7 +62,7 @@ public class TestHAUtil {
   }
   }
 
 
   @Test
   @Test
-  public void testGetRMServiceId() throws Exception {
+  void testGetRMServiceId() throws Exception {
     conf.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID);
     conf.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID);
     Collection<String> rmhaIds = HAUtil.getRMHAIds(conf);
     Collection<String> rmhaIds = HAUtil.getRMHAIds(conf);
     assertEquals(2, rmhaIds.size());
     assertEquals(2, rmhaIds.size());
@@ -73,18 +73,18 @@ public class TestHAUtil {
   }
   }
 
 
   @Test
   @Test
-  public void testGetRMId() throws Exception {
+  void testGetRMId() throws Exception {
     conf.set(YarnConfiguration.RM_HA_ID, RM1_NODE_ID);
     conf.set(YarnConfiguration.RM_HA_ID, RM1_NODE_ID);
-    assertEquals("Does not honor " + YarnConfiguration.RM_HA_ID,
-      RM1_NODE_ID, HAUtil.getRMHAId(conf));
+    assertEquals(RM1_NODE_ID, HAUtil.getRMHAId(conf),
+        "Does not honor " + YarnConfiguration.RM_HA_ID);
 
 
     conf.clear();
     conf.clear();
-    assertNull("Return null when " + YarnConfiguration.RM_HA_ID
-        + " is not set", HAUtil.getRMHAId(conf));
+    assertNull(HAUtil.getRMHAId(conf), "Return null when " + YarnConfiguration.RM_HA_ID
+        + " is not set");
   }
   }
 
 
   @Test
   @Test
-  public void testVerifyAndSetConfiguration() throws Exception {
+  void testVerifyAndSetConfiguration() throws Exception {
     Configuration myConf = new Configuration(conf);
     Configuration myConf = new Configuration(conf);
 
 
     try {
     try {
@@ -93,14 +93,12 @@ public class TestHAUtil {
       fail("Should not throw any exceptions.");
       fail("Should not throw any exceptions.");
     }
     }
 
 
-    assertEquals("Should be saved as Trimmed collection",
-        StringUtils.getStringCollection(RM_NODE_IDS),
-        HAUtil.getRMHAIds(myConf));
-    assertEquals("Should be saved as Trimmed string",
-        RM1_NODE_ID, HAUtil.getRMHAId(myConf));
+    assertEquals(StringUtils.getStringCollection(RM_NODE_IDS),
+        HAUtil.getRMHAIds(myConf),
+        "Should be saved as Trimmed collection");
+    assertEquals(RM1_NODE_ID, HAUtil.getRMHAId(myConf), "Should be saved as Trimmed string");
     for (String confKey : YarnConfiguration.getServiceAddressConfKeys(myConf)) {
     for (String confKey : YarnConfiguration.getServiceAddressConfKeys(myConf)) {
-      assertEquals("RPC address not set for " + confKey,
-          RM1_ADDRESS, myConf.get(confKey));
+      assertEquals(RM1_ADDRESS, myConf.get(confKey), "RPC address not set for " + confKey);
     }
     }
 
 
     myConf = new Configuration(conf);
     myConf = new Configuration(conf);
@@ -108,12 +106,12 @@ public class TestHAUtil {
     try {
     try {
       HAUtil.verifyAndSetConfiguration(myConf);
       HAUtil.verifyAndSetConfiguration(myConf);
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      assertEquals("YarnRuntimeException by verifyAndSetRMHAIds()",
-        HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
+      assertEquals(HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
           HAUtil.getInvalidValueMessage(YarnConfiguration.RM_HA_IDS,
           HAUtil.getInvalidValueMessage(YarnConfiguration.RM_HA_IDS,
               myConf.get(YarnConfiguration.RM_HA_IDS) +
               myConf.get(YarnConfiguration.RM_HA_IDS) +
-              "\nHA mode requires atleast two RMs"),
-        e.getMessage());
+                  "\nHA mode requires atleast two RMs"),
+          e.getMessage(),
+          "YarnRuntimeException by verifyAndSetRMHAIds()");
     }
     }
 
 
     myConf = new Configuration(conf);
     myConf = new Configuration(conf);
@@ -127,10 +125,10 @@ public class TestHAUtil {
     try {
     try {
       HAUtil.verifyAndSetConfiguration(myConf);
       HAUtil.verifyAndSetConfiguration(myConf);
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      assertEquals("YarnRuntimeException by getRMId()",
-        HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
+      assertEquals(HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
           HAUtil.getNeedToSetValueMessage(YarnConfiguration.RM_HA_ID),
           HAUtil.getNeedToSetValueMessage(YarnConfiguration.RM_HA_ID),
-        e.getMessage());
+          e.getMessage(),
+          "YarnRuntimeException by getRMId()");
     }
     }
 
 
     myConf = new Configuration(conf);
     myConf = new Configuration(conf);
@@ -144,11 +142,11 @@ public class TestHAUtil {
     try {
     try {
       HAUtil.verifyAndSetConfiguration(myConf);
       HAUtil.verifyAndSetConfiguration(myConf);
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      assertEquals("YarnRuntimeException by addSuffix()",
-        HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
+      assertEquals(HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
           HAUtil.getInvalidValueMessage(YarnConfiguration.RM_HA_ID,
           HAUtil.getInvalidValueMessage(YarnConfiguration.RM_HA_ID,
-            RM_INVALID_NODE_ID),
-        e.getMessage());
+              RM_INVALID_NODE_ID),
+          e.getMessage(),
+          "YarnRuntimeException by addSuffix()");
     }
     }
 
 
     myConf = new Configuration();
     myConf = new Configuration();
@@ -160,11 +158,10 @@ public class TestHAUtil {
       fail("Should throw YarnRuntimeException. by Configuration#set()");
       fail("Should throw YarnRuntimeException. by Configuration#set()");
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
       String confKey =
       String confKey =
-        HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, RM1_NODE_ID);
-      assertEquals("YarnRuntimeException by Configuration#set()",
-        HAUtil.BAD_CONFIG_MESSAGE_PREFIX + HAUtil.getNeedToSetValueMessage(
-            HAUtil.addSuffix(YarnConfiguration.RM_HOSTNAME, RM1_NODE_ID)
-            + " or " + confKey), e.getMessage());
+          HAUtil.addSuffix(YarnConfiguration.RM_ADDRESS, RM1_NODE_ID);
+      assertEquals(HAUtil.BAD_CONFIG_MESSAGE_PREFIX + HAUtil.getNeedToSetValueMessage(
+          HAUtil.addSuffix(YarnConfiguration.RM_HOSTNAME, RM1_NODE_ID)
+              + " or " + confKey), e.getMessage(), "YarnRuntimeException by Configuration#set()");
     }
     }
 
 
     // simulate the case YarnConfiguration.RM_HA_IDS doesn't contain
     // simulate the case YarnConfiguration.RM_HA_IDS doesn't contain
@@ -180,10 +177,10 @@ public class TestHAUtil {
     try {
     try {
       HAUtil.verifyAndSetConfiguration(myConf);
       HAUtil.verifyAndSetConfiguration(myConf);
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      assertEquals("YarnRuntimeException by getRMId()'s validation",
-        HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
-        HAUtil.getRMHAIdNeedToBeIncludedMessage("[rm2, rm3]", RM1_NODE_ID),
-          e.getMessage());
+      assertEquals(HAUtil.BAD_CONFIG_MESSAGE_PREFIX +
+          HAUtil.getRMHAIdNeedToBeIncludedMessage("[rm2, rm3]", RM1_NODE_ID),
+          e.getMessage(),
+          "YarnRuntimeException by getRMId()'s validation");
     }
     }
 
 
     // simulate the case that no leader election is enabled
     // simulate the case that no leader election is enabled
@@ -196,19 +193,19 @@ public class TestHAUtil {
     try {
     try {
       HAUtil.verifyAndSetConfiguration(myConf);
       HAUtil.verifyAndSetConfiguration(myConf);
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      assertEquals("YarnRuntimeException by getRMId()'s validation",
-          HAUtil.BAD_CONFIG_MESSAGE_PREFIX + HAUtil.NO_LEADER_ELECTION_MESSAGE,
-          e.getMessage());
+      assertEquals(HAUtil.BAD_CONFIG_MESSAGE_PREFIX + HAUtil.NO_LEADER_ELECTION_MESSAGE,
+          e.getMessage(),
+          "YarnRuntimeException by getRMId()'s validation");
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testGetConfKeyForRMInstance() {
-    assertTrue("RM instance id is not suffixed",
-        HAUtil.getConfKeyForRMInstance(YarnConfiguration.RM_ADDRESS, conf)
-            .contains(HAUtil.getRMHAId(conf)));
-    assertFalse("RM instance id is suffixed",
-        HAUtil.getConfKeyForRMInstance(YarnConfiguration.NM_ADDRESS, conf)
-            .contains(HAUtil.getRMHAId(conf)));
+  void testGetConfKeyForRMInstance() {
+    assertTrue(HAUtil.getConfKeyForRMInstance(YarnConfiguration.RM_ADDRESS, conf)
+            .contains(HAUtil.getRMHAId(conf)),
+        "RM instance id is not suffixed");
+    assertFalse(HAUtil.getConfKeyForRMInstance(YarnConfiguration.NM_ADDRESS, conf)
+            .contains(HAUtil.getRMHAId(conf)),
+        "RM instance id is suffixed");
   }
   }
 }
 }

+ 43 - 42
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/conf/TestYarnConfiguration.java

@@ -18,28 +18,29 @@
 
 
 package org.apache.hadoop.yarn.conf;
 package org.apache.hadoop.yarn.conf;
 
 
-import org.junit.Assert;
+import java.net.InetSocketAddress;
 
 
-import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
-import java.net.InetSocketAddress;
+import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestYarnConfiguration {
 public class TestYarnConfiguration {
 
 
   @Test
   @Test
-  public void testDefaultRMWebUrl() throws Exception {
+  void testDefaultRMWebUrl() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     String rmWebUrl = WebAppUtils.getRMWebAppURLWithScheme(conf);
     String rmWebUrl = WebAppUtils.getRMWebAppURLWithScheme(conf);
     // shouldn't have a "/" on the end of the url as all the other uri routinnes
     // shouldn't have a "/" on the end of the url as all the other uri routinnes
     // specifically add slashes and Jetty doesn't handle double slashes.
     // specifically add slashes and Jetty doesn't handle double slashes.
-    Assert.assertNotSame("RM Web Url is not correct", "http://0.0.0.0:8088",
-        rmWebUrl);
+    assertNotSame("http://0.0.0.0:8088",
+        rmWebUrl,
+        "RM Web Url is not correct");
 
 
     // test it in HA scenario
     // test it in HA scenario
     conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
     conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
@@ -47,7 +48,7 @@ public class TestYarnConfiguration {
     conf.set("yarn.resourcemanager.webapp.address.rm1", "10.10.10.10:18088");
     conf.set("yarn.resourcemanager.webapp.address.rm1", "10.10.10.10:18088");
     conf.set("yarn.resourcemanager.webapp.address.rm2", "20.20.20.20:28088");
     conf.set("yarn.resourcemanager.webapp.address.rm2", "20.20.20.20:28088");
     String rmWebUrlinHA = WebAppUtils.getRMWebAppURLWithScheme(conf);
     String rmWebUrlinHA = WebAppUtils.getRMWebAppURLWithScheme(conf);
-    Assert.assertEquals("http://10.10.10.10:18088", rmWebUrlinHA);
+    assertEquals("http://10.10.10.10:18088", rmWebUrlinHA);
 
 
     YarnConfiguration conf2 = new YarnConfiguration();
     YarnConfiguration conf2 = new YarnConfiguration();
     conf2.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
     conf2.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
@@ -55,17 +56,17 @@ public class TestYarnConfiguration {
     conf2.set("yarn.resourcemanager.hostname.rm1", "30.30.30.30");
     conf2.set("yarn.resourcemanager.hostname.rm1", "30.30.30.30");
     conf2.set("yarn.resourcemanager.hostname.rm2", "40.40.40.40");
     conf2.set("yarn.resourcemanager.hostname.rm2", "40.40.40.40");
     String rmWebUrlinHA2 = WebAppUtils.getRMWebAppURLWithScheme(conf2);
     String rmWebUrlinHA2 = WebAppUtils.getRMWebAppURLWithScheme(conf2);
-    Assert.assertEquals("http://30.30.30.30:8088", rmWebUrlinHA2);
+    assertEquals("http://30.30.30.30:8088", rmWebUrlinHA2);
 
 
     rmWebUrlinHA2 = WebAppUtils.getRMWebAppURLWithScheme(conf2, 0);
     rmWebUrlinHA2 = WebAppUtils.getRMWebAppURLWithScheme(conf2, 0);
-    Assert.assertEquals("http://30.30.30.30:8088", rmWebUrlinHA2);
+    assertEquals("http://30.30.30.30:8088", rmWebUrlinHA2);
 
 
     rmWebUrlinHA2 = WebAppUtils.getRMWebAppURLWithScheme(conf2, 1);
     rmWebUrlinHA2 = WebAppUtils.getRMWebAppURLWithScheme(conf2, 1);
-    Assert.assertEquals("http://40.40.40.40:8088", rmWebUrlinHA2);
+    assertEquals("http://40.40.40.40:8088", rmWebUrlinHA2);
   }
   }
 
 
   @Test
   @Test
-  public void testRMWebUrlSpecified() throws Exception {
+  void testRMWebUrlSpecified() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     // seems a bit odd but right now we are forcing webapp for RM to be
     // seems a bit odd but right now we are forcing webapp for RM to be
     // RM_ADDRESS
     // RM_ADDRESS
@@ -74,15 +75,15 @@ public class TestYarnConfiguration {
     conf.set(YarnConfiguration.RM_ADDRESS, "rmtesting:9999");
     conf.set(YarnConfiguration.RM_ADDRESS, "rmtesting:9999");
     String rmWebUrl = WebAppUtils.getRMWebAppURLWithScheme(conf);
     String rmWebUrl = WebAppUtils.getRMWebAppURLWithScheme(conf);
     String[] parts = rmWebUrl.split(":");
     String[] parts = rmWebUrl.split(":");
-    Assert.assertEquals("RM Web URL Port is incrrect", 24543,
-        Integer.parseInt(parts[parts.length - 1]));
-    Assert.assertNotSame(
-        "RM Web Url not resolved correctly. Should not be rmtesting",
-        "http://rmtesting:24543", rmWebUrl);
+    assertEquals(24543,
+        Integer.parseInt(parts[parts.length - 1]),
+        "RM Web URL Port is incrrect");
+    assertNotSame("http://rmtesting:24543", rmWebUrl,
+        "RM Web Url not resolved correctly. Should not be rmtesting");
   }
   }
 
 
   @Test
   @Test
-  public void testGetSocketAddressForNMWithHA() {
+  void testGetSocketAddressForNMWithHA() {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
 
 
     // Set NM address
     // Set NM address
@@ -100,7 +101,7 @@ public class TestYarnConfiguration {
   }
   }
 
 
   @Test
   @Test
-  public void testGetSocketAddr() throws Exception {
+  void testGetSocketAddr() throws Exception {
 
 
     YarnConfiguration conf;
     YarnConfiguration conf;
     InetSocketAddress resourceTrackerAddress;
     InetSocketAddress resourceTrackerAddress;
@@ -113,9 +114,9 @@ public class TestYarnConfiguration {
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
     assertEquals(
     assertEquals(
-      new InetSocketAddress(
-        YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[0],
-        YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
+        new InetSocketAddress(
+            YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS.split(":")[0],
+            YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
         resourceTrackerAddress);
         resourceTrackerAddress);
 
 
     //with address
     //with address
@@ -126,9 +127,9 @@ public class TestYarnConfiguration {
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
     assertEquals(
     assertEquals(
-      new InetSocketAddress(
-        "10.0.0.1",
-        YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
+        new InetSocketAddress(
+            "10.0.0.1",
+            YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
         resourceTrackerAddress);
         resourceTrackerAddress);
 
 
     //address and socket
     //address and socket
@@ -139,9 +140,9 @@ public class TestYarnConfiguration {
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
     assertEquals(
     assertEquals(
-      new InetSocketAddress(
-        "10.0.0.2",
-        5001),
+        new InetSocketAddress(
+            "10.0.0.2",
+            5001),
         resourceTrackerAddress);
         resourceTrackerAddress);
 
 
     //bind host only
     //bind host only
@@ -153,9 +154,9 @@ public class TestYarnConfiguration {
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
     assertEquals(
     assertEquals(
-      new InetSocketAddress(
-        "10.0.0.3",
-        YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
+        new InetSocketAddress(
+            "10.0.0.3",
+            YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
         resourceTrackerAddress);
         resourceTrackerAddress);
 
 
     //bind host and address no port
     //bind host and address no port
@@ -167,9 +168,9 @@ public class TestYarnConfiguration {
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
     assertEquals(
     assertEquals(
-      new InetSocketAddress(
-        "0.0.0.0",
-        YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
+        new InetSocketAddress(
+            "0.0.0.0",
+            YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT),
         resourceTrackerAddress);
         resourceTrackerAddress);
 
 
     //bind host and address with port
     //bind host and address with port
@@ -181,15 +182,15 @@ public class TestYarnConfiguration {
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS,
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
         YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT);
     assertEquals(
     assertEquals(
-      new InetSocketAddress(
-        "0.0.0.0",
-        5003),
+        new InetSocketAddress(
+            "0.0.0.0",
+            5003),
         resourceTrackerAddress);
         resourceTrackerAddress);
 
 
   }
   }
 
 
   @Test
   @Test
-  public void testUpdateConnectAddr() throws Exception {
+  void testUpdateConnectAddr() throws Exception {
     YarnConfiguration conf;
     YarnConfiguration conf;
     InetSocketAddress resourceTrackerConnectAddress;
     InetSocketAddress resourceTrackerConnectAddress;
     InetSocketAddress serverAddress;
     InetSocketAddress serverAddress;

+ 0 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/InlineDispatcher.java

@@ -20,9 +20,6 @@ package org.apache.hadoop.yarn.event;
 
 
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
-import org.apache.hadoop.yarn.event.AsyncDispatcher;
-import org.apache.hadoop.yarn.event.Event;
-import org.apache.hadoop.yarn.event.EventHandler;
 
 
 @SuppressWarnings({"unchecked", "rawtypes"})
 @SuppressWarnings({"unchecked", "rawtypes"})
 public class InlineDispatcher extends AsyncDispatcher {
 public class InlineDispatcher extends AsyncDispatcher {

+ 56 - 45
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/TestAsyncDispatcher.java

@@ -27,23 +27,30 @@ import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
 
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.slf4j.Logger;
 
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.metrics2.AbstractMetric;
 import org.apache.hadoop.metrics2.AbstractMetric;
 import org.apache.hadoop.metrics2.MetricsRecord;
 import org.apache.hadoop.metrics2.MetricsRecord;
 import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl;
 import org.apache.hadoop.metrics2.impl.MetricsCollectorImpl;
 import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
 import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.apache.hadoop.yarn.metrics.GenericEventTypeMetrics;
-import org.slf4j.Logger;
-import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.apache.hadoop.yarn.metrics.GenericEventTypeMetrics;
 
 
 import static org.apache.hadoop.metrics2.lib.Interns.info;
 import static org.apache.hadoop.metrics2.lib.Interns.info;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 
 public class TestAsyncDispatcher {
 public class TestAsyncDispatcher {
 
 
@@ -52,9 +59,10 @@ public class TestAsyncDispatcher {
    * 1. A thread which was putting event to event queue is interrupted.
    * 1. A thread which was putting event to event queue is interrupted.
    * 2. Event queue is empty on close.
    * 2. Event queue is empty on close.
    */
    */
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Test(timeout=10000)
-  public void testDispatcherOnCloseIfQueueEmpty() throws Exception {
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  @Test
+  @Timeout(10000)
+  void testDispatcherOnCloseIfQueueEmpty() throws Exception {
     BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>());
     BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>());
     Event event = mock(Event.class);
     Event event = mock(Event.class);
     doThrow(new InterruptedException()).when(eventQueue).put(event);
     doThrow(new InterruptedException()).when(eventQueue).put(event);
@@ -66,19 +74,20 @@ public class TestAsyncDispatcher {
     disp.waitForEventThreadToWait();
     disp.waitForEventThreadToWait();
     try {
     try {
       disp.getEventHandler().handle(event);
       disp.getEventHandler().handle(event);
-      Assert.fail("Expected YarnRuntimeException");
+      fail("Expected YarnRuntimeException");
     } catch (YarnRuntimeException e) {
     } catch (YarnRuntimeException e) {
-      Assert.assertTrue(e.getCause() instanceof InterruptedException);
+      assertTrue(e.getCause() instanceof InterruptedException);
     }
     }
     // Queue should be empty and dispatcher should not hang on close
     // Queue should be empty and dispatcher should not hang on close
-    Assert.assertTrue("Event Queue should have been empty",
-        eventQueue.isEmpty());
+    assertTrue(eventQueue.isEmpty(),
+        "Event Queue should have been empty");
     disp.close();
     disp.close();
   }
   }
 
 
   // Test dispatcher should timeout on draining events.
   // Test dispatcher should timeout on draining events.
-  @Test(timeout=10000)
-  public void testDispatchStopOnTimeout() throws Exception {
+  @Test
+  @Timeout(10000)
+  void testDispatchStopOnTimeout() throws Exception {
     BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>();
     BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>();
     eventQueue = spy(eventQueue);
     eventQueue = spy(eventQueue);
     // simulate dispatcher is not drained.
     // simulate dispatcher is not drained.
@@ -143,9 +152,10 @@ public class TestAsyncDispatcher {
   }
   }
 
 
   // Test if drain dispatcher drains events on stop.
   // Test if drain dispatcher drains events on stop.
-  @SuppressWarnings({ "rawtypes" })
-  @Test(timeout=10000)
-  public void testDrainDispatcherDrainEventsOnStop() throws Exception {
+  @SuppressWarnings({"rawtypes"})
+  @Test
+  @Timeout(10000)
+  void testDrainDispatcherDrainEventsOnStop() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setInt(YarnConfiguration.DISPATCHER_DRAIN_EVENTS_TIMEOUT, 2000);
     conf.setInt(YarnConfiguration.DISPATCHER_DRAIN_EVENTS_TIMEOUT, 2000);
     BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>();
     BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>();
@@ -161,11 +171,12 @@ public class TestAsyncDispatcher {
   }
   }
 
 
   //Test print dispatcher details when the blocking queue is heavy
   //Test print dispatcher details when the blocking queue is heavy
-  @Test(timeout = 10000)
-  public void testPrintDispatcherEventDetails() throws Exception {
+  @Test
+  @Timeout(10000)
+  void testPrintDispatcherEventDetails() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     conf.setInt(YarnConfiguration.
     conf.setInt(YarnConfiguration.
-            YARN_DISPATCHER_PRINT_EVENTS_INFO_THRESHOLD, 5000);
+        YARN_DISPATCHER_PRINT_EVENTS_INFO_THRESHOLD, 5000);
     Logger log = mock(Logger.class);
     Logger log = mock(Logger.class);
     AsyncDispatcher dispatcher = new AsyncDispatcher();
     AsyncDispatcher dispatcher = new AsyncDispatcher();
     dispatcher.init(conf);
     dispatcher.init(conf);
@@ -190,7 +201,7 @@ public class TestAsyncDispatcher {
       Thread.sleep(2000);
       Thread.sleep(2000);
       //Make sure more than one event to take
       //Make sure more than one event to take
       verify(log, atLeastOnce()).
       verify(log, atLeastOnce()).
-              info("Latest dispatch event type: TestEventType");
+          info("Latest dispatch event type: TestEventType");
     } finally {
     } finally {
       //... restore logger object
       //... restore logger object
       logger.set(null, oldLog);
       logger.set(null, oldLog);
@@ -199,8 +210,9 @@ public class TestAsyncDispatcher {
   }
   }
 
 
   //Test print dispatcher details when the blocking queue is heavy
   //Test print dispatcher details when the blocking queue is heavy
-  @Test(timeout = 60000)
-  public void testPrintDispatcherEventDetailsAvoidDeadLoop() throws Exception {
+  @Test
+  @Timeout(60000)
+  void testPrintDispatcherEventDetailsAvoidDeadLoop() throws Exception {
     for (int i = 0; i < 5; i++) {
     for (int i = 0; i < 5; i++) {
       testPrintDispatcherEventDetailsAvoidDeadLoopInternal();
       testPrintDispatcherEventDetailsAvoidDeadLoopInternal();
     }
     }
@@ -241,7 +253,7 @@ public class TestAsyncDispatcher {
   }
   }
 
 
   @Test
   @Test
-  public void testMetricsForDispatcher() throws Exception {
+  void testMetricsForDispatcher() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     AsyncDispatcher dispatcher = null;
     AsyncDispatcher dispatcher = null;
 
 
@@ -252,7 +264,7 @@ public class TestAsyncDispatcher {
           new GenericEventTypeMetrics.EventTypeMetricsBuilder()
           new GenericEventTypeMetrics.EventTypeMetricsBuilder()
               .setMs(DefaultMetricsSystem.instance())
               .setMs(DefaultMetricsSystem.instance())
               .setInfo(info("GenericEventTypeMetrics for "
               .setInfo(info("GenericEventTypeMetrics for "
-                      + TestEnum.class.getName(),
+                  + TestEnum.class.getName(),
                   "Metrics for " + dispatcher.getName()))
                   "Metrics for " + dispatcher.getName()))
               .setEnumClass(TestEnum.class)
               .setEnumClass(TestEnum.class)
               .setEnums(TestEnum.class.getEnumConstants())
               .setEnums(TestEnum.class.getEnumConstants())
@@ -287,34 +299,34 @@ public class TestAsyncDispatcher {
           get(TestEnum.TestEventType2) == 2, 1000, 10000);
           get(TestEnum.TestEventType2) == 2, 1000, 10000);
 
 
       // Check time spend.
       // Check time spend.
-      Assert.assertTrue(genericEventTypeMetrics.
+      assertTrue(genericEventTypeMetrics.
           getTotalProcessingTime(TestEnum.TestEventType)
           getTotalProcessingTime(TestEnum.TestEventType)
-          >= 1500*3);
-      Assert.assertTrue(genericEventTypeMetrics.
+          >= 1500 * 3);
+      assertTrue(genericEventTypeMetrics.
           getTotalProcessingTime(TestEnum.TestEventType)
           getTotalProcessingTime(TestEnum.TestEventType)
-          < 1500*4);
+          < 1500 * 4);
 
 
-      Assert.assertTrue(genericEventTypeMetrics.
+      assertTrue(genericEventTypeMetrics.
           getTotalProcessingTime(TestEnum.TestEventType2)
           getTotalProcessingTime(TestEnum.TestEventType2)
-          >= 1500*2);
-      Assert.assertTrue(genericEventTypeMetrics.
+          >= 1500 * 2);
+      assertTrue(genericEventTypeMetrics.
           getTotalProcessingTime(TestEnum.TestEventType2)
           getTotalProcessingTime(TestEnum.TestEventType2)
-          < 1500*3);
+          < 1500 * 3);
 
 
       // Make sure metrics consistent.
       // Make sure metrics consistent.
-      Assert.assertEquals(Long.toString(genericEventTypeMetrics.
+      assertEquals(Long.toString(genericEventTypeMetrics.
               get(TestEnum.TestEventType)),
               get(TestEnum.TestEventType)),
           genericEventTypeMetrics.
           genericEventTypeMetrics.
               getRegistry().get("TestEventType_event_count").toString());
               getRegistry().get("TestEventType_event_count").toString());
-      Assert.assertEquals(Long.toString(genericEventTypeMetrics.
+      assertEquals(Long.toString(genericEventTypeMetrics.
               get(TestEnum.TestEventType2)),
               get(TestEnum.TestEventType2)),
           genericEventTypeMetrics.
           genericEventTypeMetrics.
               getRegistry().get("TestEventType2_event_count").toString());
               getRegistry().get("TestEventType2_event_count").toString());
-      Assert.assertEquals(Long.toString(genericEventTypeMetrics.
+      assertEquals(Long.toString(genericEventTypeMetrics.
               getTotalProcessingTime(TestEnum.TestEventType)),
               getTotalProcessingTime(TestEnum.TestEventType)),
           genericEventTypeMetrics.
           genericEventTypeMetrics.
               getRegistry().get("TestEventType_processing_time").toString());
               getRegistry().get("TestEventType_processing_time").toString());
-      Assert.assertEquals(Long.toString(genericEventTypeMetrics.
+      assertEquals(Long.toString(genericEventTypeMetrics.
               getTotalProcessingTime(TestEnum.TestEventType2)),
               getTotalProcessingTime(TestEnum.TestEventType2)),
           genericEventTypeMetrics.
           genericEventTypeMetrics.
               getRegistry().get("TestEventType2_processing_time").toString());
               getRegistry().get("TestEventType2_processing_time").toString());
@@ -326,7 +338,7 @@ public class TestAsyncDispatcher {
   }
   }
 
 
   @Test
   @Test
-  public void testDispatcherMetricsHistogram() throws Exception {
+  void testDispatcherMetricsHistogram() throws Exception {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     AsyncDispatcher dispatcher = null;
     AsyncDispatcher dispatcher = null;
 
 
@@ -337,7 +349,7 @@ public class TestAsyncDispatcher {
           new GenericEventTypeMetrics.EventTypeMetricsBuilder()
           new GenericEventTypeMetrics.EventTypeMetricsBuilder()
               .setMs(DefaultMetricsSystem.instance())
               .setMs(DefaultMetricsSystem.instance())
               .setInfo(info("GenericEventTypeMetrics for "
               .setInfo(info("GenericEventTypeMetrics for "
-                      + TestEnum.class.getName(),
+                  + TestEnum.class.getName(),
                   "Metrics for " + dispatcher.getName()))
                   "Metrics for " + dispatcher.getName()))
               .setEnumClass(TestEnum.class)
               .setEnumClass(TestEnum.class)
               .setEnums(TestEnum.class.getEnumConstants())
               .setEnums(TestEnum.class.getEnumConstants())
@@ -393,14 +405,13 @@ public class TestAsyncDispatcher {
           String metricName = metric.name();
           String metricName = metric.name();
           if (expectedValues.containsKey(metricName)) {
           if (expectedValues.containsKey(metricName)) {
             Long expectedValue = expectedValues.get(metricName);
             Long expectedValue = expectedValues.get(metricName);
-            Assert.assertEquals(
-                "Metric " + metricName + " doesn't have expected value",
-                expectedValue, metric.value());
+            assertEquals(expectedValue, metric.value(),
+                "Metric " + metricName + " doesn't have expected value");
             testResults.add(metricName);
             testResults.add(metricName);
           }
           }
         }
         }
       }
       }
-      Assert.assertEquals(expectedValues.keySet(), testResults);
+      assertEquals(expectedValues.keySet(), testResults);
 
 
     } finally {
     } finally {
       dispatcher.close();
       dispatcher.close();

+ 5 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/factories/impl/pb/TestRpcClientFactoryPBImpl.java

@@ -18,11 +18,12 @@
 
 
 package org.apache.hadoop.yarn.factories.impl.pb;
 package org.apache.hadoop.yarn.factories.impl.pb;
 
 
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
-
 import java.net.InetSocketAddress;
 import java.net.InetSocketAddress;
 
 
+import org.junit.jupiter.api.Test;
+
+import org.apache.hadoop.conf.Configuration;
+
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -33,7 +34,7 @@ import static org.mockito.Mockito.verify;
  */
  */
 public class TestRpcClientFactoryPBImpl {
 public class TestRpcClientFactoryPBImpl {
   @Test
   @Test
-  public void testToUseCustomClassloader() throws Exception {
+  void testToUseCustomClassloader() throws Exception {
     Configuration configuration = mock(Configuration.class);
     Configuration configuration = mock(Configuration.class);
     RpcClientFactoryPBImpl rpcClientFactoryPB = RpcClientFactoryPBImpl.get();
     RpcClientFactoryPBImpl rpcClientFactoryPB = RpcClientFactoryPBImpl.get();
     try {
     try {

+ 5 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/factories/impl/pb/TestRpcServerFactoryPBImpl.java

@@ -18,11 +18,12 @@
 
 
 package org.apache.hadoop.yarn.factories.impl.pb;
 package org.apache.hadoop.yarn.factories.impl.pb;
 
 
-import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
-
 import java.net.InetSocketAddress;
 import java.net.InetSocketAddress;
 
 
+import org.junit.jupiter.api.Test;
+
+import org.apache.hadoop.conf.Configuration;
+
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
@@ -33,7 +34,7 @@ import static org.mockito.Mockito.verify;
  */
  */
 public class TestRpcServerFactoryPBImpl {
 public class TestRpcServerFactoryPBImpl {
   @Test
   @Test
-  public void testToUseCustomClassloader() throws Exception {
+  void testToUseCustomClassloader() throws Exception {
     Configuration configuration = mock(Configuration.class);
     Configuration configuration = mock(Configuration.class);
     RpcServerFactoryPBImpl rpcServerFactoryPB = RpcServerFactoryPBImpl.get();
     RpcServerFactoryPBImpl rpcServerFactoryPB = RpcServerFactoryPBImpl.get();
     try {
     try {

+ 26 - 27
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/ipc/TestRPCUtil.java

@@ -21,71 +21,71 @@ package org.apache.hadoop.yarn.ipc;
 import java.io.FileNotFoundException;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.IOException;
 
 
-import org.junit.Assert;
+import org.apache.hadoop.thirdparty.protobuf.ServiceException;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.junit.Test;
 
 
-import org.apache.hadoop.thirdparty.protobuf.ServiceException;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestRPCUtil {
 public class TestRPCUtil {
 
 
   @Test
   @Test
-  public void testUnknownExceptionUnwrapping() {
+  void testUnknownExceptionUnwrapping() {
     Class<? extends Throwable> exception = YarnException.class;
     Class<? extends Throwable> exception = YarnException.class;
     String className = "UnknownException.class";
     String className = "UnknownException.class";
     verifyRemoteExceptionUnwrapping(exception, className);
     verifyRemoteExceptionUnwrapping(exception, className);
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteIOExceptionUnwrapping() {
+  void testRemoteIOExceptionUnwrapping() {
     Class<? extends Throwable> exception = IOException.class;
     Class<? extends Throwable> exception = IOException.class;
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteIOExceptionDerivativeUnwrapping() {
+  void testRemoteIOExceptionDerivativeUnwrapping() {
     // Test IOException sub-class
     // Test IOException sub-class
     Class<? extends Throwable> exception = FileNotFoundException.class;
     Class<? extends Throwable> exception = FileNotFoundException.class;
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteYarnExceptionUnwrapping() {
+  void testRemoteYarnExceptionUnwrapping() {
     Class<? extends Throwable> exception = YarnException.class;
     Class<? extends Throwable> exception = YarnException.class;
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
 
 
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteYarnExceptionDerivativeUnwrapping() {
+  void testRemoteYarnExceptionDerivativeUnwrapping() {
     Class<? extends Throwable> exception = YarnTestException.class;
     Class<? extends Throwable> exception = YarnTestException.class;
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteRuntimeExceptionUnwrapping() {
+  void testRemoteRuntimeExceptionUnwrapping() {
     Class<? extends Throwable> exception = NullPointerException.class;
     Class<? extends Throwable> exception = NullPointerException.class;
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
     verifyRemoteExceptionUnwrapping(exception, exception.getName());
   }
   }
 
 
   @Test
   @Test
-  public void testUnexpectedRemoteExceptionUnwrapping() {
+  void testUnexpectedRemoteExceptionUnwrapping() {
     // Non IOException, YarnException thrown by the remote side.
     // Non IOException, YarnException thrown by the remote side.
     Class<? extends Throwable> exception = Exception.class;
     Class<? extends Throwable> exception = Exception.class;
     verifyRemoteExceptionUnwrapping(RemoteException.class, exception.getName());
     verifyRemoteExceptionUnwrapping(RemoteException.class, exception.getName());
   }
   }
-  
+
   @Test
   @Test
-  public void testRemoteYarnExceptionWithoutStringConstructor() {
+  void testRemoteYarnExceptionWithoutStringConstructor() {
     // Derivatives of YarnException should always define a string constructor.
     // Derivatives of YarnException should always define a string constructor.
     Class<? extends Throwable> exception = YarnTestExceptionNoConstructor.class;
     Class<? extends Throwable> exception = YarnTestExceptionNoConstructor.class;
     verifyRemoteExceptionUnwrapping(RemoteException.class, exception.getName());
     verifyRemoteExceptionUnwrapping(RemoteException.class, exception.getName());
   }
   }
-  
+
   @Test
   @Test
-  public void testRPCServiceExceptionUnwrapping() {
+  void testRPCServiceExceptionUnwrapping() {
     String message = "ServiceExceptionMessage";
     String message = "ServiceExceptionMessage";
     ServiceException se = new ServiceException(message);
     ServiceException se = new ServiceException(message);
 
 
@@ -96,12 +96,12 @@ public class TestRPCUtil {
       t = thrown;
       t = thrown;
     }
     }
 
 
-    Assert.assertTrue(IOException.class.isInstance(t));
-    Assert.assertTrue(t.getMessage().contains(message));
+    assertTrue(IOException.class.isInstance(t));
+    assertTrue(t.getMessage().contains(message));
   }
   }
 
 
   @Test
   @Test
-  public void testRPCIOExceptionUnwrapping() {
+  void testRPCIOExceptionUnwrapping() {
     String message = "DirectIOExceptionMessage";
     String message = "DirectIOExceptionMessage";
     IOException ioException = new FileNotFoundException(message);
     IOException ioException = new FileNotFoundException(message);
     ServiceException se = new ServiceException(ioException);
     ServiceException se = new ServiceException(ioException);
@@ -112,12 +112,12 @@ public class TestRPCUtil {
     } catch (Throwable thrown) {
     } catch (Throwable thrown) {
       t = thrown;
       t = thrown;
     }
     }
-    Assert.assertTrue(FileNotFoundException.class.isInstance(t));
-    Assert.assertTrue(t.getMessage().contains(message));
+    assertTrue(FileNotFoundException.class.isInstance(t));
+    assertTrue(t.getMessage().contains(message));
   }
   }
 
 
   @Test
   @Test
-  public void testRPCRuntimeExceptionUnwrapping() {
+  void testRPCRuntimeExceptionUnwrapping() {
     String message = "RPCRuntimeExceptionUnwrapping";
     String message = "RPCRuntimeExceptionUnwrapping";
     RuntimeException re = new NullPointerException(message);
     RuntimeException re = new NullPointerException(message);
     ServiceException se = new ServiceException(re);
     ServiceException se = new ServiceException(re);
@@ -129,8 +129,8 @@ public class TestRPCUtil {
       t = thrown;
       t = thrown;
     }
     }
 
 
-    Assert.assertTrue(NullPointerException.class.isInstance(t));
-    Assert.assertTrue(t.getMessage().contains(message));
+    assertTrue(NullPointerException.class.isInstance(t));
+    assertTrue(t.getMessage().contains(message));
   }
   }
 
 
   private void verifyRemoteExceptionUnwrapping(
   private void verifyRemoteExceptionUnwrapping(
@@ -147,11 +147,10 @@ public class TestRPCUtil {
       t = thrown;
       t = thrown;
     }
     }
 
 
-    Assert.assertTrue("Expected exception [" + expectedLocalException
-        + "] but found " + t, expectedLocalException.isInstance(t));
-    Assert.assertTrue(
-        "Expected message [" + message + "] but found " + t.getMessage(), t
-            .getMessage().contains(message));
+    assertTrue(expectedLocalException.isInstance(t), "Expected exception [" + expectedLocalException
+        + "] but found " + t);
+    assertTrue(t.getMessage().contains(message),
+        "Expected message [" + message + "] but found " + t.getMessage());
   }
   }
 
 
   private static class YarnTestException extends YarnException {
   private static class YarnTestException extends YarnException {

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/LogAggregationTestUtils.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.hadoop.yarn.logaggregation;
 package org.apache.hadoop.yarn.logaggregation;
 
 
+import java.util.List;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController;
 
 
-import java.util.List;
-
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_CONTROLLER_FMT;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_CONTROLLER_FMT;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_REMOTE_APP_LOG_DIR_FMT;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_REMOTE_APP_LOG_DIR_FMT;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_REMOTE_APP_LOG_DIR_SUFFIX_FMT;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_REMOTE_APP_LOG_DIR_SUFFIX_FMT;

+ 155 - 154
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogDeletionService.java

@@ -18,6 +18,15 @@
 
 
 package org.apache.hadoop.yarn.logaggregation;
 package org.apache.hadoop.yarn.logaggregation;
 
 
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
@@ -32,14 +41,6 @@ import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcase;
 import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder;
 import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder;
 import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.AppDescriptor;
 import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.AppDescriptor;
 import org.apache.log4j.Level;
 import org.apache.log4j.Level;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.List;
 
 
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_CONTROLLER_FMT;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_CONTROLLER_FMT;
 import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.enableFileControllers;
 import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.enableFileControllers;
@@ -64,12 +65,12 @@ public class TestAggregatedLogDeletionService {
           LogAggregationTFileController.class);
           LogAggregationTFileController.class);
   public static final List<String> ALL_FILE_CONTROLLER_NAMES = Arrays.asList(I_FILE, T_FILE);
   public static final List<String> ALL_FILE_CONTROLLER_NAMES = Arrays.asList(I_FILE, T_FILE);
 
 
-  @BeforeClass
+  @BeforeAll
   public static void beforeClass() {
   public static void beforeClass() {
     org.apache.log4j.Logger.getRootLogger().setLevel(Level.DEBUG);
     org.apache.log4j.Logger.getRootLogger().setLevel(Level.DEBUG);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void closeFilesystems() throws IOException {
   public void closeFilesystems() throws IOException {
     // prevent the same mockfs instance from being reused due to FS cache
     // prevent the same mockfs instance from being reused due to FS cache
     FileSystem.closeAll();
     FileSystem.closeAll();
@@ -91,7 +92,7 @@ public class TestAggregatedLogDeletionService {
   }
   }
 
 
   @Test
   @Test
-  public void testDeletion() throws Exception {
+  void testDeletion() throws Exception {
     long now = System.currentTimeMillis();
     long now = System.currentTimeMillis();
     long toDeleteTime = now - (2000 * 1000);
     long toDeleteTime = now - (2000 * 1000);
     long toKeepTime = now - (1500 * 1000);
     long toKeepTime = now - (1500 * 1000);
@@ -99,36 +100,36 @@ public class TestAggregatedLogDeletionService {
     Configuration conf = setupConfiguration(1800, -1);
     Configuration conf = setupConfiguration(1800, -1);
     long timeout = 2000L;
     long timeout = 2000L;
     LogAggregationTestcaseBuilder.create(conf)
     LogAggregationTestcaseBuilder.create(conf)
-            .withRootPath(ROOT)
-            .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
-            .withUserDir(USER_ME, toKeepTime)
-            .withSuffixDir(SUFFIX, toDeleteTime)
-            .withBucketDir(toDeleteTime)
-            .withApps(Lists.newArrayList(
-                    new AppDescriptor(toDeleteTime, Lists.newArrayList()),
-                    new AppDescriptor(toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toKeepTime))),
-                    new AppDescriptor(toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toDeleteTime))),
-                    new AppDescriptor(toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toKeepTime)))))
-            .withFinishedApps(1, 2, 3)
-            .withRunningApps(4)
-            .injectExceptionForAppDirDeletion(3)
-            .build()
-            .startDeletionService()
-            .verifyAppDirsDeleted(timeout, 1, 3)
-            .verifyAppDirsNotDeleted(timeout, 2, 4)
-            .verifyAppFileDeleted(4, 1, timeout)
-            .verifyAppFileNotDeleted(4, 2, timeout)
-            .teardown(1);
+        .withRootPath(ROOT)
+        .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
+        .withUserDir(USER_ME, toKeepTime)
+        .withSuffixDir(SUFFIX, toDeleteTime)
+        .withBucketDir(toDeleteTime)
+        .withApps(Lists.newArrayList(
+            new AppDescriptor(toDeleteTime, Lists.newArrayList()),
+            new AppDescriptor(toDeleteTime, Lists.newArrayList(
+                Pair.of(DIR_HOST1, toDeleteTime),
+                Pair.of(DIR_HOST2, toKeepTime))),
+            new AppDescriptor(toDeleteTime, Lists.newArrayList(
+                Pair.of(DIR_HOST1, toDeleteTime),
+                Pair.of(DIR_HOST2, toDeleteTime))),
+            new AppDescriptor(toDeleteTime, Lists.newArrayList(
+                Pair.of(DIR_HOST1, toDeleteTime),
+                Pair.of(DIR_HOST2, toKeepTime)))))
+        .withFinishedApps(1, 2, 3)
+        .withRunningApps(4)
+        .injectExceptionForAppDirDeletion(3)
+        .build()
+        .startDeletionService()
+        .verifyAppDirsDeleted(timeout, 1, 3)
+        .verifyAppDirsNotDeleted(timeout, 2, 4)
+        .verifyAppFileDeleted(4, 1, timeout)
+        .verifyAppFileNotDeleted(4, 2, timeout)
+        .teardown(1);
   }
   }
 
 
   @Test
   @Test
-  public void testRefreshLogRetentionSettings() throws Exception {
+  void testRefreshLogRetentionSettings() throws Exception {
     long now = System.currentTimeMillis();
     long now = System.currentTimeMillis();
     long before2000Secs = now - (2000 * 1000);
     long before2000Secs = now - (2000 * 1000);
     long before50Secs = now - (50 * 1000);
     long before50Secs = now - (50 * 1000);
@@ -138,51 +139,51 @@ public class TestAggregatedLogDeletionService {
     Configuration conf = setupConfiguration(1800, 1);
     Configuration conf = setupConfiguration(1800, 1);
 
 
     LogAggregationTestcase testcase = LogAggregationTestcaseBuilder.create(conf)
     LogAggregationTestcase testcase = LogAggregationTestcaseBuilder.create(conf)
-            .withRootPath(ROOT)
-            .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
-            .withUserDir(USER_ME, before50Secs)
-            .withSuffixDir(SUFFIX, before50Secs)
-            .withBucketDir(before50Secs)
-            .withApps(Lists.newArrayList(
-                    //Set time last modified of app1Dir directory and its files to before2000Secs
-                    new AppDescriptor(before2000Secs, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, before2000Secs))),
-                    //Set time last modified of app1Dir directory and its files to before50Secs
-                    new AppDescriptor(before50Secs, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, before50Secs))))
-            )
-            .withFinishedApps(1, 2)
-            .withRunningApps()
-            .build();
-    
+        .withRootPath(ROOT)
+        .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
+        .withUserDir(USER_ME, before50Secs)
+        .withSuffixDir(SUFFIX, before50Secs)
+        .withBucketDir(before50Secs)
+        .withApps(Lists.newArrayList(
+            //Set time last modified of app1Dir directory and its files to before2000Secs
+            new AppDescriptor(before2000Secs, Lists.newArrayList(
+                Pair.of(DIR_HOST1, before2000Secs))),
+            //Set time last modified of app1Dir directory and its files to before50Secs
+            new AppDescriptor(before50Secs, Lists.newArrayList(
+                Pair.of(DIR_HOST1, before50Secs))))
+        )
+        .withFinishedApps(1, 2)
+        .withRunningApps()
+        .build();
+
     testcase
     testcase
-            .startDeletionService()
-            //app1Dir would be deleted since it is done above log retention period
-            .verifyAppDirDeleted(1, 10000L)
-            //app2Dir is not expected to be deleted since it is below the threshold
-            .verifyAppDirNotDeleted(2, 3000L);
+        .startDeletionService()
+        //app1Dir would be deleted since it is done above log retention period
+        .verifyAppDirDeleted(1, 10000L)
+        //app2Dir is not expected to be deleted since it is below the threshold
+        .verifyAppDirNotDeleted(2, 3000L);
 
 
     //Now, let's change the log aggregation retention configs
     //Now, let's change the log aggregation retention configs
     conf.setInt(YarnConfiguration.LOG_AGGREGATION_RETAIN_SECONDS, 50);
     conf.setInt(YarnConfiguration.LOG_AGGREGATION_RETAIN_SECONDS, 50);
     conf.setInt(YarnConfiguration.LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS,
     conf.setInt(YarnConfiguration.LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS,
-            checkIntervalSeconds);
+        checkIntervalSeconds);
 
 
     testcase
     testcase
-            //We have not called refreshLogSettings, hence don't expect to see
-            // the changed conf values
-            .verifyCheckIntervalMilliSecondsNotEqualTo(checkIntervalMilliSeconds)
-            //refresh the log settings
-            .refreshLogRetentionSettings()
-            //Check interval time should reflect the new value
-            .verifyCheckIntervalMilliSecondsEqualTo(checkIntervalMilliSeconds)
-            //app2Dir should be deleted since it falls above the threshold
-            .verifyAppDirDeleted(2, 10000L)
-            //Close expected 2 times: once for refresh and once for stopping
-            .teardown(2);
+        //We have not called refreshLogSettings, hence don't expect to see
+        // the changed conf values
+        .verifyCheckIntervalMilliSecondsNotEqualTo(checkIntervalMilliSeconds)
+        //refresh the log settings
+        .refreshLogRetentionSettings()
+        //Check interval time should reflect the new value
+        .verifyCheckIntervalMilliSecondsEqualTo(checkIntervalMilliSeconds)
+        //app2Dir should be deleted since it falls above the threshold
+        .verifyAppDirDeleted(2, 10000L)
+        //Close expected 2 times: once for refresh and once for stopping
+        .teardown(2);
   }
   }
-  
+
   @Test
   @Test
-  public void testCheckInterval() throws Exception {
+  void testCheckInterval() throws Exception {
     long now = System.currentTimeMillis();
     long now = System.currentTimeMillis();
     long toDeleteTime = now - TEN_DAYS_IN_SECONDS * 1000;
     long toDeleteTime = now - TEN_DAYS_IN_SECONDS * 1000;
 
 
@@ -192,32 +193,32 @@ public class TestAggregatedLogDeletionService {
     FileSystem.closeAll();
     FileSystem.closeAll();
 
 
     LogAggregationTestcaseBuilder.create(conf)
     LogAggregationTestcaseBuilder.create(conf)
-            .withRootPath(ROOT)
-            .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
-            .withUserDir(USER_ME, now)
-            .withSuffixDir(SUFFIX, now)
-            .withBucketDir(now)
-            .withApps(Lists.newArrayList(
-                    new AppDescriptor(now,
-                            Lists.newArrayList(Pair.of(DIR_HOST1, now))),
-                    new AppDescriptor(now)))
-            .withFinishedApps(1)
-            .withRunningApps()
-            .build()
-            .startDeletionService()
-            .verifyAnyPathListedAtLeast(4, 10000L)
-            .verifyAppDirNotDeleted(1, NO_TIMEOUT)
-            // modify the timestamp of the logs and verify if it is picked up quickly
-            .changeModTimeOfApp(1, toDeleteTime)
-            .changeModTimeOfAppLogDir(1, 1, toDeleteTime)
-            .changeModTimeOfBucketDir(toDeleteTime)
-            .reinitAllPaths()
-            .verifyAppDirDeleted(1, 10000L)
-            .teardown(1);
+        .withRootPath(ROOT)
+        .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
+        .withUserDir(USER_ME, now)
+        .withSuffixDir(SUFFIX, now)
+        .withBucketDir(now)
+        .withApps(Lists.newArrayList(
+            new AppDescriptor(now,
+                Lists.newArrayList(Pair.of(DIR_HOST1, now))),
+            new AppDescriptor(now)))
+        .withFinishedApps(1)
+        .withRunningApps()
+        .build()
+        .startDeletionService()
+        .verifyAnyPathListedAtLeast(4, 10000L)
+        .verifyAppDirNotDeleted(1, NO_TIMEOUT)
+        // modify the timestamp of the logs and verify if it is picked up quickly
+        .changeModTimeOfApp(1, toDeleteTime)
+        .changeModTimeOfAppLogDir(1, 1, toDeleteTime)
+        .changeModTimeOfBucketDir(toDeleteTime)
+        .reinitAllPaths()
+        .verifyAppDirDeleted(1, 10000L)
+        .teardown(1);
   }
   }
 
 
   @Test
   @Test
-  public void testRobustLogDeletion() throws Exception {
+  void testRobustLogDeletion() throws Exception {
     Configuration conf = setupConfiguration(TEN_DAYS_IN_SECONDS, 1);
     Configuration conf = setupConfiguration(TEN_DAYS_IN_SECONDS, 1);
 
 
     // prevent us from picking up the same mockfs instance from another test
     // prevent us from picking up the same mockfs instance from another test
@@ -225,26 +226,26 @@ public class TestAggregatedLogDeletionService {
     long modTime = 0L;
     long modTime = 0L;
 
 
     LogAggregationTestcaseBuilder.create(conf)
     LogAggregationTestcaseBuilder.create(conf)
-            .withRootPath(ROOT)
-            .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
-            .withUserDir(USER_ME, modTime)
-            .withSuffixDir(SUFFIX, modTime)
-            .withBucketDir(modTime, "0")
-            .withApps(Lists.newArrayList(
-                    new AppDescriptor(modTime),
-                    new AppDescriptor(modTime),
-                    new AppDescriptor(modTime, Lists.newArrayList(Pair.of(DIR_HOST1, modTime)))))
-            .withAdditionalAppDirs(Lists.newArrayList(Pair.of("application_a", modTime)))
-            .withFinishedApps(1, 3)
-            .withRunningApps()
-            .injectExceptionForAppDirDeletion(1)
-            .build()
-            .runDeletionTask(TEN_DAYS_IN_SECONDS)
-            .verifyAppDirDeleted(3, NO_TIMEOUT);
+        .withRootPath(ROOT)
+        .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
+        .withUserDir(USER_ME, modTime)
+        .withSuffixDir(SUFFIX, modTime)
+        .withBucketDir(modTime, "0")
+        .withApps(Lists.newArrayList(
+            new AppDescriptor(modTime),
+            new AppDescriptor(modTime),
+            new AppDescriptor(modTime, Lists.newArrayList(Pair.of(DIR_HOST1, modTime)))))
+        .withAdditionalAppDirs(Lists.newArrayList(Pair.of("application_a", modTime)))
+        .withFinishedApps(1, 3)
+        .withRunningApps()
+        .injectExceptionForAppDirDeletion(1)
+        .build()
+        .runDeletionTask(TEN_DAYS_IN_SECONDS)
+        .verifyAppDirDeleted(3, NO_TIMEOUT);
   }
   }
 
 
   @Test
   @Test
-  public void testDeletionTwoControllers() throws IOException {
+  void testDeletionTwoControllers() throws IOException {
     long now = System.currentTimeMillis();
     long now = System.currentTimeMillis();
     long toDeleteTime = now - (2000 * 1000);
     long toDeleteTime = now - (2000 * 1000);
     long toKeepTime = now - (1500 * 1000);
     long toKeepTime = now - (1500 * 1000);
@@ -252,48 +253,48 @@ public class TestAggregatedLogDeletionService {
 
 
     Configuration conf = setupConfiguration(1800, -1);
     Configuration conf = setupConfiguration(1800, -1);
     enableFileControllers(conf, REMOTE_ROOT_LOG_DIR, ALL_FILE_CONTROLLERS,
     enableFileControllers(conf, REMOTE_ROOT_LOG_DIR, ALL_FILE_CONTROLLERS,
-            ALL_FILE_CONTROLLER_NAMES);
+        ALL_FILE_CONTROLLER_NAMES);
     long timeout = 2000L;
     long timeout = 2000L;
     LogAggregationTestcaseBuilder.create(conf)
     LogAggregationTestcaseBuilder.create(conf)
-            .withRootPath(ROOT)
-            .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
-            .withBothFileControllers()
-            .withUserDir(USER_ME, toKeepTime)
-            .withSuffixDir(SUFFIX, toDeleteTime)
-            .withBucketDir(toDeleteTime)
-            .withApps(//Apps for TFile
-                    Lists.newArrayList(
-                            new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList()),
-                    new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toKeepTime))),
-                    new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toDeleteTime))),
-                    new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toKeepTime))),
-                    //Apps for IFile
-                    new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList()),
-                    new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toKeepTime))),
-                    new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toDeleteTime))),
-                    new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
-                            Pair.of(DIR_HOST1, toDeleteTime),
-                            Pair.of(DIR_HOST2, toKeepTime)))))
-            .withFinishedApps(1, 2, 3, 5, 6, 7)
-            .withRunningApps(4, 8)
-            .injectExceptionForAppDirDeletion(3, 6)
-            .build()
-            .startDeletionService()
-            .verifyAppDirsDeleted(timeout, 1, 3, 5, 7)
-            .verifyAppDirsNotDeleted(timeout, 2, 4, 6, 8)
-            .verifyAppFilesDeleted(timeout, Lists.newArrayList(Pair.of(4, 1), Pair.of(8, 1)))
-            .verifyAppFilesNotDeleted(timeout, Lists.newArrayList(Pair.of(4, 2), Pair.of(8, 2)))
-            .teardown(1);
+        .withRootPath(ROOT)
+        .withRemoteRootLogPath(REMOTE_ROOT_LOG_DIR)
+        .withBothFileControllers()
+        .withUserDir(USER_ME, toKeepTime)
+        .withSuffixDir(SUFFIX, toDeleteTime)
+        .withBucketDir(toDeleteTime)
+        .withApps(//Apps for TFile
+            Lists.newArrayList(
+                new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList()),
+                new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
+                    Pair.of(DIR_HOST1, toDeleteTime),
+                    Pair.of(DIR_HOST2, toKeepTime))),
+                new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
+                    Pair.of(DIR_HOST1, toDeleteTime),
+                    Pair.of(DIR_HOST2, toDeleteTime))),
+                new AppDescriptor(T_FILE, toDeleteTime, Lists.newArrayList(
+                    Pair.of(DIR_HOST1, toDeleteTime),
+                    Pair.of(DIR_HOST2, toKeepTime))),
+                //Apps for IFile
+                new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList()),
+                new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
+                    Pair.of(DIR_HOST1, toDeleteTime),
+                    Pair.of(DIR_HOST2, toKeepTime))),
+                new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
+                    Pair.of(DIR_HOST1, toDeleteTime),
+                    Pair.of(DIR_HOST2, toDeleteTime))),
+                new AppDescriptor(I_FILE, toDeleteTime, Lists.newArrayList(
+                    Pair.of(DIR_HOST1, toDeleteTime),
+                    Pair.of(DIR_HOST2, toKeepTime)))))
+        .withFinishedApps(1, 2, 3, 5, 6, 7)
+        .withRunningApps(4, 8)
+        .injectExceptionForAppDirDeletion(3, 6)
+        .build()
+        .startDeletionService()
+        .verifyAppDirsDeleted(timeout, 1, 3, 5, 7)
+        .verifyAppDirsNotDeleted(timeout, 2, 4, 6, 8)
+        .verifyAppFilesDeleted(timeout, Lists.newArrayList(Pair.of(4, 1), Pair.of(8, 1)))
+        .verifyAppFilesNotDeleted(timeout, Lists.newArrayList(Pair.of(4, 2), Pair.of(8, 2)))
+        .teardown(1);
   }
   }
 
 
   static class MockFileSystem extends FilterFileSystem {
   static class MockFileSystem extends FilterFileSystem {

+ 48 - 43
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java

@@ -18,10 +18,6 @@
 
 
 package org.apache.hadoop.yarn.logaggregation;
 package org.apache.hadoop.yarn.logaggregation;
 
 
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.doThrow;
-
 import java.io.BufferedReader;
 import java.io.BufferedReader;
 import java.io.DataInputStream;
 import java.io.DataInputStream;
 import java.io.File;
 import java.io.File;
@@ -41,9 +37,14 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
 
 
-import org.junit.Assert;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 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.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
@@ -62,10 +63,15 @@ import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogReader;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogValue;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogValue;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogWriter;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogWriter;
 import org.apache.hadoop.yarn.util.Times;
 import org.apache.hadoop.yarn.util.Times;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
+
+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.Mockito.doThrow;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 
 public class TestAggregatedLogFormat {
 public class TestAggregatedLogFormat {
 
 
@@ -84,8 +90,8 @@ public class TestAggregatedLogFormat {
     }
     }
   }
   }
 
 
-  @Before
-  @After
+  @BeforeEach
+  @AfterEach
   public void cleanupTestDir() throws Exception {
   public void cleanupTestDir() throws Exception {
     Path workDirPath = new Path(testWorkDir.getAbsolutePath());
     Path workDirPath = new Path(testWorkDir.getAbsolutePath());
     LOG.info("Cleaning test directory [" + workDirPath + "]");
     LOG.info("Cleaning test directory [" + workDirPath + "]");
@@ -97,7 +103,7 @@ public class TestAggregatedLogFormat {
   //appending to logs
   //appending to logs
 
 
   @Test
   @Test
-  public void testForCorruptedAggregatedLogs() throws Exception {
+  void testForCorruptedAggregatedLogs() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     File workDir = new File(testWorkDir, "testReadAcontainerLogs1");
     File workDir = new File(testWorkDir, "testReadAcontainerLogs1");
     Path remoteAppLogFile =
     Path remoteAppLogFile =
@@ -112,7 +118,7 @@ public class TestAggregatedLogFormat {
     long numChars = 950000;
     long numChars = 950000;
 
 
     writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile,
     writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile,
-       srcFileRoot, testContainerId);
+        srcFileRoot, testContainerId);
 
 
     LogReader logReader = new LogReader(conf, remoteAppLogFile);
     LogReader logReader = new LogReader(conf, remoteAppLogFile);
     LogKey rLogKey = new LogKey();
     LogKey rLogKey = new LogKey();
@@ -121,8 +127,8 @@ public class TestAggregatedLogFormat {
     try {
     try {
       LogReader.readAcontainerLogs(dis, writer);
       LogReader.readAcontainerLogs(dis, writer);
     } catch (Exception e) {
     } catch (Exception e) {
-      if(e.toString().contains("NumberFormatException")) {
-        Assert.fail("Aggregated logs are corrupted.");
+      if (e.toString().contains("NumberFormatException")) {
+        fail("Aggregated logs are corrupted.");
       }
       }
     }
     }
 
 
@@ -134,10 +140,10 @@ public class TestAggregatedLogFormat {
       // Trying to read a corrupted log file created above should cause
       // Trying to read a corrupted log file created above should cause
       // log reading to fail below with an IOException.
       // log reading to fail below with an IOException.
       logReader = new LogReader(conf, remoteAppLogFile);
       logReader = new LogReader(conf, remoteAppLogFile);
-      Assert.fail("Expect IOException from reading corrupt aggregated logs.");
+      fail("Expect IOException from reading corrupt aggregated logs.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       DataInputStream dIS = logReader.next(rLogKey);
       DataInputStream dIS = logReader.next(rLogKey);
-      Assert.assertNull("Input stream not available for reading", dIS);
+      assertNull(dIS, "Input stream not available for reading");
     }
     }
   }
   }
 
 
@@ -198,7 +204,7 @@ public class TestAggregatedLogFormat {
   }
   }
 
 
   @Test
   @Test
-  public void testReadAcontainerLogs1() throws Exception {
+  void testReadAcontainerLogs1() throws Exception {
     //Verify the output generated by readAContainerLogs(DataInputStream, Writer, logUploadedTime)
     //Verify the output generated by readAContainerLogs(DataInputStream, Writer, logUploadedTime)
     testReadAcontainerLog(true);
     testReadAcontainerLog(true);
 
 
@@ -250,12 +256,10 @@ public class TestAggregatedLogFormat {
 
 
       logWriter.append(logKey, spyLogValue);
       logWriter.append(logKey, spyLogValue);
     }
     }
-
     // make sure permission are correct on the file
     // make sure permission are correct on the file
-    FileStatus fsStatus =  fs.getFileStatus(remoteAppLogFile);
-    Assert.assertEquals("permissions on log aggregation file are wrong",  
-      FsPermission.createImmutable((short) 0640), fsStatus.getPermission()); 
-
+    FileStatus fsStatus = fs.getFileStatus(remoteAppLogFile);
+    assertEquals(FsPermission.createImmutable((short) 0640), fsStatus.getPermission(),
+        "permissions on log aggregation file are wrong");
     LogReader logReader = new LogReader(conf, remoteAppLogFile);
     LogReader logReader = new LogReader(conf, remoteAppLogFile);
     LogKey rLogKey = new LogKey();
     LogKey rLogKey = new LogKey();
     DataInputStream dis = logReader.next(rLogKey);
     DataInputStream dis = logReader.next(rLogKey);
@@ -283,24 +287,24 @@ public class TestAggregatedLogFormat {
         + numChars + ("\n").length() + ("End of LogType:stdout"
         + numChars + ("\n").length() + ("End of LogType:stdout"
             + System.lineSeparator() + System.lineSeparator()).length();
             + System.lineSeparator() + System.lineSeparator()).length();
 
 
-    Assert.assertTrue("LogType not matched", s.contains("LogType:stdout"));
-    Assert.assertTrue("log file:stderr should not be aggregated.", !s.contains("LogType:stderr"));
-    Assert.assertTrue("log file:logs should not be aggregated.", !s.contains("LogType:logs"));
-    Assert.assertTrue("LogLength not matched", s.contains("LogLength:" + numChars));
-    Assert.assertTrue("Log Contents not matched", s.contains("Log Contents"));
+    assertTrue(s.contains("LogType:stdout"), "LogType not matched");
+    assertTrue(!s.contains("LogType:stderr"), "log file:stderr should not be aggregated.");
+    assertTrue(!s.contains("LogType:logs"), "log file:logs should not be aggregated.");
+    assertTrue(s.contains("LogLength:" + numChars), "LogLength not matched");
+    assertTrue(s.contains("Log Contents"), "Log Contents not matched");
     
     
     StringBuilder sb = new StringBuilder();
     StringBuilder sb = new StringBuilder();
     for (int i = 0 ; i < numChars ; i++) {
     for (int i = 0 ; i < numChars ; i++) {
       sb.append(filler);
       sb.append(filler);
     }
     }
     String expectedContent = sb.toString();
     String expectedContent = sb.toString();
-    Assert.assertTrue("Log content incorrect", s.contains(expectedContent));
+    assertTrue(s.contains(expectedContent), "Log content incorrect");
     
     
-    Assert.assertEquals(expectedLength, s.length());
+    assertEquals(expectedLength, s.length());
   }
   }
 
 
   @Test
   @Test
-  public void testZeroLengthLog() throws IOException {
+  void testZeroLengthLog() throws IOException {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     File workDir = new File(testWorkDir, "testZeroLength");
     File workDir = new File(testWorkDir, "testZeroLength");
     Path remoteAppLogFile = new Path(workDir.getAbsolutePath(),
     Path remoteAppLogFile = new Path(workDir.getAbsolutePath(),
@@ -332,17 +336,18 @@ public class TestAggregatedLogFormat {
     Writer writer = new StringWriter();
     Writer writer = new StringWriter();
     LogReader.readAcontainerLogs(dis, writer);
     LogReader.readAcontainerLogs(dis, writer);
 
 
-    Assert.assertEquals("LogType:stdout\n" +
+    assertEquals("LogType:stdout\n" +
         "LogLength:0\n" +
         "LogLength:0\n" +
         "Log Contents:\n\n" +
         "Log Contents:\n\n" +
         "End of LogType:stdout\n\n", writer.toString());
         "End of LogType:stdout\n\n", writer.toString());
   }
   }
 
 
-  @Test(timeout=10000)
-  public void testContainerLogsFileAccess() throws IOException {
+  @Test
+  @Timeout(10000)
+  void testContainerLogsFileAccess() throws IOException {
     // This test will run only if NativeIO is enabled as SecureIOUtils 
     // This test will run only if NativeIO is enabled as SecureIOUtils 
     // require it to be enabled.
     // require it to be enabled.
-    Assume.assumeTrue(NativeIO.isAvailable());
+    Assumptions.assumeTrue(NativeIO.isAvailable());
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
     conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
         "kerberos");
         "kerberos");
@@ -415,28 +420,28 @@ public class TestAggregatedLogFormat {
     String stdoutFile1 =
     String stdoutFile1 =
         StringUtils.join(
         StringUtils.join(
             File.separator,
             File.separator,
-            Arrays.asList(new String[] {
+            Arrays.asList(new String[]{
                 workDir.getAbsolutePath(), "srcFiles",
                 workDir.getAbsolutePath(), "srcFiles",
                 testContainerId1.getApplicationAttemptId().getApplicationId()
                 testContainerId1.getApplicationAttemptId().getApplicationId()
-                    .toString(), testContainerId1.toString(), stderr }));
+                    .toString(), testContainerId1.toString(), stderr}));
 
 
     // The file: stdout is expected to be aggregated.
     // The file: stdout is expected to be aggregated.
     String stdoutFile2 =
     String stdoutFile2 =
         StringUtils.join(
         StringUtils.join(
             File.separator,
             File.separator,
-            Arrays.asList(new String[] {
+            Arrays.asList(new String[]{
                 workDir.getAbsolutePath(), "srcFiles",
                 workDir.getAbsolutePath(), "srcFiles",
                 testContainerId1.getApplicationAttemptId().getApplicationId()
                 testContainerId1.getApplicationAttemptId().getApplicationId()
-                    .toString(), testContainerId1.toString(), stdout }));
+                    .toString(), testContainerId1.toString(), stdout}));
     String message2 =
     String message2 =
         "Owner '" + expectedOwner + "' for path "
         "Owner '" + expectedOwner + "' for path "
             + stdoutFile2 + " did not match expected owner '"
             + stdoutFile2 + " did not match expected owner '"
             + ugi.getShortUserName() + "'";
             + ugi.getShortUserName() + "'";
-    
-    Assert.assertFalse(line.contains(message2));
-    Assert.assertFalse(line.contains(data + testContainerId1.toString()
+
+    assertFalse(line.contains(message2));
+    assertFalse(line.contains(data + testContainerId1.toString()
         + stderr));
         + stderr));
-    Assert.assertTrue(line.contains(data + testContainerId1.toString()
+    assertTrue(line.contains(data + testContainerId1.toString()
         + stdout));
         + stdout));
   }
   }
   
   

+ 20 - 20
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogsBlock.java

@@ -28,9 +28,11 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 
+import com.google.inject.Inject;
+import org.junit.jupiter.api.Test;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.FileUtil;
@@ -49,19 +51,17 @@ import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileCo
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.tfile.TFileAggregatedLogsBlock;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.tfile.TFileAggregatedLogsBlock;
-import org.apache.hadoop.yarn.webapp.YarnWebParams;
 import org.apache.hadoop.yarn.webapp.View.ViewContext;
 import org.apache.hadoop.yarn.webapp.View.ViewContext;
+import org.apache.hadoop.yarn.webapp.YarnWebParams;
 import org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest;
 import org.apache.hadoop.yarn.webapp.log.AggregatedLogsBlockForTest;
 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.HtmlBlockForTest;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlockForTest;
-import org.junit.Test;
-
-import static org.mockito.Mockito.*;
-
-import com.google.inject.Inject;
 
 
-import static org.junit.Assert.*;
+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.when;
 
 
 /**
 /**
  * Test AggregatedLogsBlock. AggregatedLogsBlock should check user, aggregate a
  * Test AggregatedLogsBlock. AggregatedLogsBlock should check user, aggregate a
@@ -73,7 +73,7 @@ public class TestAggregatedLogsBlock {
    * Bad user. User 'owner' is trying to read logs without access
    * Bad user. User 'owner' is trying to read logs without access
    */
    */
   @Test
   @Test
-  public void testAccessDenied() throws Exception {
+  void testAccessDenied() throws Exception {
 
 
     FileUtil.fullyDelete(new File("target/logs"));
     FileUtil.fullyDelete(new File("target/logs"));
     Configuration configuration = getConfiguration();
     Configuration configuration = getConfiguration();
@@ -89,7 +89,7 @@ public class TestAggregatedLogsBlock {
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     TFileAggregatedLogsBlockForTest aggregatedBlock
     TFileAggregatedLogsBlockForTest aggregatedBlock
         = getTFileAggregatedLogsBlockForTest(configuration, "owner",
         = getTFileAggregatedLogsBlockForTest(configuration, "owner",
-            "container_0_0001_01_000001", "localhost:1234");
+        "container_0_0001_01_000001", "localhost:1234");
     aggregatedBlock.render(block);
     aggregatedBlock.render(block);
 
 
     block.getWriter().flush();
     block.getWriter().flush();
@@ -100,7 +100,7 @@ public class TestAggregatedLogsBlock {
   }
   }
 
 
   @Test
   @Test
-  public void testBlockContainsPortNumForUnavailableAppLog() {
+  void testBlockContainsPortNumForUnavailableAppLog() {
     FileUtil.fullyDelete(new File("target/logs"));
     FileUtil.fullyDelete(new File("target/logs"));
     Configuration configuration = getConfiguration();
     Configuration configuration = getConfiguration();
 
 
@@ -125,7 +125,7 @@ public class TestAggregatedLogsBlock {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testBadLogs() throws Exception {
+  void testBadLogs() throws Exception {
 
 
     FileUtil.fullyDelete(new File("target/logs"));
     FileUtil.fullyDelete(new File("target/logs"));
     Configuration configuration = getConfiguration();
     Configuration configuration = getConfiguration();
@@ -146,8 +146,8 @@ public class TestAggregatedLogsBlock {
     String out = data.toString();
     String out = data.toString();
     assertTrue(out
     assertTrue(out
         .contains("Logs not available for entity. Aggregation may not be "
         .contains("Logs not available for entity. Aggregation may not be "
-        + "complete, Check back later or try to find the container logs "
-        + "in the local directory of nodemanager localhost:1234"));
+            + "complete, Check back later or try to find the container logs "
+            + "in the local directory of nodemanager localhost:1234"));
     assertTrue(out
     assertTrue(out
         .contains("Or see application log at http://localhost:8042"));
         .contains("Or see application log at http://localhost:8042"));
 
 
@@ -160,7 +160,7 @@ public class TestAggregatedLogsBlock {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testAggregatedLogsBlock() throws Exception {
+  void testAggregatedLogsBlock() throws Exception {
 
 
     FileUtil.fullyDelete(new File("target/logs"));
     FileUtil.fullyDelete(new File("target/logs"));
     Configuration configuration = getConfiguration();
     Configuration configuration = getConfiguration();
@@ -175,7 +175,7 @@ public class TestAggregatedLogsBlock {
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     TFileAggregatedLogsBlockForTest aggregatedBlock
     TFileAggregatedLogsBlockForTest aggregatedBlock
         = getTFileAggregatedLogsBlockForTest(configuration, "admin",
         = getTFileAggregatedLogsBlockForTest(configuration, "admin",
-            "container_0_0001_01_000001", "localhost:1234");
+        "container_0_0001_01_000001", "localhost:1234");
     aggregatedBlock.render(block);
     aggregatedBlock.render(block);
 
 
     block.getWriter().flush();
     block.getWriter().flush();
@@ -192,7 +192,7 @@ public class TestAggregatedLogsBlock {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testAggregatedLogsBlockHar() throws Exception {
+  void testAggregatedLogsBlockHar() throws Exception {
     FileUtil.fullyDelete(new File("target/logs"));
     FileUtil.fullyDelete(new File("target/logs"));
     Configuration configuration = getConfiguration();
     Configuration configuration = getConfiguration();
 
 
@@ -209,7 +209,7 @@ public class TestAggregatedLogsBlock {
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     TFileAggregatedLogsBlockForTest aggregatedBlock
     TFileAggregatedLogsBlockForTest aggregatedBlock
         = getTFileAggregatedLogsBlockForTest(configuration, "admin",
         = getTFileAggregatedLogsBlockForTest(configuration, "admin",
-            "container_1440536969523_0001_01_000001", "host1:1111");
+        "container_1440536969523_0001_01_000001", "host1:1111");
     aggregatedBlock.render(block);
     aggregatedBlock.render(block);
 
 
     block.getWriter().flush();
     block.getWriter().flush();
@@ -238,7 +238,7 @@ public class TestAggregatedLogsBlock {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testNoLogs() throws Exception {
+  void testNoLogs() throws Exception {
 
 
     FileUtil.fullyDelete(new File("target/logs"));
     FileUtil.fullyDelete(new File("target/logs"));
     Configuration configuration = getConfiguration();
     Configuration configuration = getConfiguration();
@@ -255,7 +255,7 @@ public class TestAggregatedLogsBlock {
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     HtmlBlock.Block block = new BlockForTest(html, printWriter, 10, false);
     TFileAggregatedLogsBlockForTest aggregatedBlock
     TFileAggregatedLogsBlockForTest aggregatedBlock
         = getTFileAggregatedLogsBlockForTest(configuration, "admin",
         = getTFileAggregatedLogsBlockForTest(configuration, "admin",
-            "container_0_0001_01_000001", "localhost:1234");
+        "container_0_0001_01_000001", "localhost:1234");
     aggregatedBlock.render(block);
     aggregatedBlock.render(block);
 
 
     block.getWriter().flush();
     block.getWriter().flush();

+ 3 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestContainerLogsUtils.java

@@ -17,8 +17,6 @@
  */
  */
 package org.apache.hadoop.yarn.logaggregation;
 package org.apache.hadoop.yarn.logaggregation;
 
 
-import static org.junit.Assert.assertTrue;
-
 import java.io.File;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.IOException;
@@ -27,6 +25,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
@@ -39,6 +38,8 @@ import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileCo
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * This class contains several utility functions for log aggregation tests.
  * This class contains several utility functions for log aggregation tests.
  */
  */

+ 27 - 24
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestLogAggregationMetaCollector.java

@@ -18,19 +18,6 @@
 
 
 package org.apache.hadoop.yarn.logaggregation;
 package org.apache.hadoop.yarn.logaggregation;
 
 
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.RemoteIterator;
-import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
-import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.hadoop.yarn.logaggregation.filecontroller.FakeLogAggregationFileController;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
 import java.io.IOException;
 import java.io.IOException;
 import java.time.Clock;
 import java.time.Clock;
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -42,7 +29,23 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.logaggregation.filecontroller.FakeLogAggregationFileController;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestLogAggregationMetaCollector {
 public class TestLogAggregationMetaCollector {
   private static final String TEST_NODE = "TEST_NODE_1";
   private static final String TEST_NODE = "TEST_NODE_1";
@@ -133,17 +136,17 @@ public class TestLogAggregationMetaCollector {
     }
     }
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     fileController = createFileController();
     fileController = createFileController();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
   }
   }
 
 
   @Test
   @Test
-  public void testAllNull() throws IOException {
+  void testAllNull() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     request.setAppId(null);
     request.setAppId(null);
@@ -165,7 +168,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testAllSet() throws IOException {
+  void testAllSet() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     Set<String> fileSizeExpressions = new HashSet<>();
     Set<String> fileSizeExpressions = new HashSet<>();
@@ -191,7 +194,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testSingleNodeRequest() throws IOException {
+  void testSingleNodeRequest() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     request.setAppId(null);
     request.setAppId(null);
@@ -214,7 +217,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testMultipleNodeRegexRequest() throws IOException {
+  void testMultipleNodeRegexRequest() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     request.setAppId(null);
     request.setAppId(null);
@@ -236,7 +239,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testMultipleFileRegex() throws IOException {
+  void testMultipleFileRegex() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     request.setAppId(null);
     request.setAppId(null);
@@ -260,7 +263,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testContainerIdExactMatch() throws IOException {
+  void testContainerIdExactMatch() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     request.setAppId(null);
     request.setAppId(null);
@@ -284,7 +287,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testMultipleFileBetweenSize() throws IOException {
+  void testMultipleFileBetweenSize() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     Set<String> fileSizeExpressions = new HashSet<>();
     Set<String> fileSizeExpressions = new HashSet<>();
@@ -311,7 +314,7 @@ public class TestLogAggregationMetaCollector {
   }
   }
 
 
   @Test
   @Test
-  public void testInvalidQueryStrings() throws IOException {
+  void testInvalidQueryStrings() throws IOException {
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
     ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder request =
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
         new ExtendedLogMetaRequest.ExtendedLogMetaRequestBuilder();
     Set<String> fileSizeExpressions = new HashSet<>();
     Set<String> fileSizeExpressions = new HashSet<>();

+ 5 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/FakeLogAggregationFileController.java

@@ -18,6 +18,11 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.filecontroller;
 package org.apache.hadoop.yarn.logaggregation.filecontroller;
 
 
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
 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.yarn.api.records.ApplicationAccessType;
 import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
@@ -28,11 +33,6 @@ import org.apache.hadoop.yarn.logaggregation.ContainerLogsRequest;
 import org.apache.hadoop.yarn.webapp.View;
 import org.apache.hadoop.yarn.webapp.View;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-
 public class FakeLogAggregationFileController
 public class FakeLogAggregationFileController
     extends LogAggregationFileController {
     extends LogAggregationFileController {
 
 

+ 16 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/TestLogAggregationFileController.java

@@ -18,6 +18,13 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.filecontroller;
 package org.apache.hadoop.yarn.logaggregation.filecontroller;
 
 
+import java.io.FileNotFoundException;
+import java.net.URI;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentMatcher;
+import org.mockito.Mockito;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
@@ -25,15 +32,9 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.ArgumentMatcher;
-import org.mockito.Mockito;
-
-import java.io.FileNotFoundException;
-import java.net.URI;
 
 
 import static org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController.TLDIR_PERMISSIONS;
 import static org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController.TLDIR_PERMISSIONS;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
@@ -49,19 +50,19 @@ import static org.mockito.Mockito.verify;
 public class TestLogAggregationFileController {
 public class TestLogAggregationFileController {
 
 
   @Test
   @Test
-  public void testRemoteDirCreationDefault() throws Exception {
+  void testRemoteDirCreationDefault() throws Exception {
     FileSystem fs = mock(FileSystem.class);
     FileSystem fs = mock(FileSystem.class);
     doReturn(new URI("")).when(fs).getUri();
     doReturn(new URI("")).when(fs).getUri();
     doThrow(FileNotFoundException.class).when(fs)
     doThrow(FileNotFoundException.class).when(fs)
-            .getFileStatus(any(Path.class));
+        .getFileStatus(any(Path.class));
 
 
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     LogAggregationFileController controller = mock(
     LogAggregationFileController controller = mock(
-            LogAggregationFileController.class, Mockito.CALLS_REAL_METHODS);
+        LogAggregationFileController.class, Mockito.CALLS_REAL_METHODS);
     doReturn(fs).when(controller).getFileSystem(any(Configuration.class));
     doReturn(fs).when(controller).getFileSystem(any(Configuration.class));
 
 
     UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
     UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
-        "yarn_user", new String[] {"yarn_group", "other_group"});
+        "yarn_user", new String[]{"yarn_group", "other_group"});
     UserGroupInformation.setLoginUser(ugi);
     UserGroupInformation.setLoginUser(ugi);
 
 
     controller.initialize(conf, "TFile");
     controller.initialize(conf, "TFile");
@@ -71,7 +72,7 @@ public class TestLogAggregationFileController {
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteDirCreationWithCustomGroup() throws Exception {
+  void testRemoteDirCreationWithCustomGroup() throws Exception {
     String testGroupName = "testGroup";
     String testGroupName = "testGroup";
 
 
     FileSystem fs = mock(FileSystem.class);
     FileSystem fs = mock(FileSystem.class);
@@ -86,7 +87,7 @@ public class TestLogAggregationFileController {
     doReturn(fs).when(controller).getFileSystem(any(Configuration.class));
     doReturn(fs).when(controller).getFileSystem(any(Configuration.class));
 
 
     UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
     UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
-        "yarn_user", new String[] {"yarn_group", "other_group"});
+        "yarn_user", new String[]{"yarn_group", "other_group"});
     UserGroupInformation.setLoginUser(ugi);
     UserGroupInformation.setLoginUser(ugi);
 
 
     controller.initialize(conf, "TFile");
     controller.initialize(conf, "TFile");
@@ -114,7 +115,7 @@ public class TestLogAggregationFileController {
   }
   }
 
 
   @Test
   @Test
-  public void testRemoteDirCreationWithCustomUser() throws Exception {
+  void testRemoteDirCreationWithCustomUser() throws Exception {
     FileSystem fs = mock(FileSystem.class);
     FileSystem fs = mock(FileSystem.class);
     doReturn(new URI("")).when(fs).getUri();
     doReturn(new URI("")).when(fs).getUri();
     doReturn(new FileStatus(128, false, 0, 64, System.currentTimeMillis(),
     doReturn(new FileStatus(128, false, 0, 64, System.currentTimeMillis(),
@@ -139,6 +140,6 @@ public class TestLogAggregationFileController {
     verify(fs).setPermission(argThat(new PathContainsString(".permission_check")),
     verify(fs).setPermission(argThat(new PathContainsString(".permission_check")),
         eq(new FsPermission(TLDIR_PERMISSIONS)));
         eq(new FsPermission(TLDIR_PERMISSIONS)));
     verify(fs).delete(argThat(new PathContainsString(".permission_check")), eq(false));
     verify(fs).delete(argThat(new PathContainsString(".permission_check")), eq(false));
-    Assert.assertTrue(controller.fsSupportsChmod);
+    assertTrue(controller.fsSupportsChmod);
   }
   }
 }
 }

+ 77 - 65
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/TestLogAggregationFileControllerFactory.java

@@ -18,6 +18,21 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.filecontroller;
 package org.apache.hadoop.yarn.logaggregation.filecontroller;
 
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
@@ -33,25 +48,14 @@ import org.apache.hadoop.yarn.logaggregation.filecontroller.ifile.LogAggregation
 import org.apache.hadoop.yarn.logaggregation.filecontroller.tfile.LogAggregationTFileController;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.tfile.LogAggregationTFileController;
 import org.apache.hadoop.yarn.webapp.View.ViewContext;
 import org.apache.hadoop.yarn.webapp.View.ViewContext;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
 
 
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS;
 import static org.apache.hadoop.yarn.conf.YarnConfiguration.LOG_AGGREGATION_FILE_FORMATS;
 import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.REMOTE_LOG_ROOT;
 import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.REMOTE_LOG_ROOT;
 import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.enableFileControllers;
 import static org.apache.hadoop.yarn.logaggregation.LogAggregationTestUtils.enableFileControllers;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Test LogAggregationFileControllerFactory.
  * Test LogAggregationFileControllerFactory.
@@ -79,7 +83,7 @@ public class TestLogAggregationFileControllerFactory extends Configured {
   private ApplicationId appId = ApplicationId.newInstance(
   private ApplicationId appId = ApplicationId.newInstance(
       System.currentTimeMillis(), 1);
       System.currentTimeMillis(), 1);
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
     conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
@@ -107,100 +111,106 @@ public class TestLogAggregationFileControllerFactory extends Configured {
                new FileWriter(new File(logPath.toString(), "testLog"))) {
                new FileWriter(new File(logPath.toString(), "testLog"))) {
         writer.write("test");
         writer.write("test");
       }
       }
-      assertTrue("The used LogAggregationFileController is not instance of "
-          + className.getSimpleName(), className.isInstance(
-              factory.getFileControllerForRead(appId, APP_OWNER)));
+      assertTrue(className.isInstance(factory.getFileControllerForRead(appId, APP_OWNER)),
+          "The used LogAggregationFileController is not instance of " + className.getSimpleName());
     } finally {
     } finally {
       fs.delete(logPath, true);
       fs.delete(logPath, true);
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testDefaultLogAggregationFileControllerFactory()
+  void testDefaultLogAggregationFileControllerFactory()
       throws IOException {
       throws IOException {
     LogAggregationFileControllerFactory factory =
     LogAggregationFileControllerFactory factory =
         new LogAggregationFileControllerFactory(getConf());
         new LogAggregationFileControllerFactory(getConf());
     List<LogAggregationFileController> list = factory
     List<LogAggregationFileController> list = factory
         .getConfiguredLogAggregationFileControllerList();
         .getConfiguredLogAggregationFileControllerList();
 
 
-    assertEquals("Only one LogAggregationFileController is expected!", 1,
-        list.size());
-    assertTrue("TFile format is expected to be the first " +
-        "LogAggregationFileController!", list.get(0) instanceof
-        LogAggregationTFileController);
-    assertTrue("TFile format is expected to be used for writing!",
-        factory.getFileControllerForWrite() instanceof
-            LogAggregationTFileController);
+    assertEquals(1,
+        list.size(),
+        "Only one LogAggregationFileController is expected!");
+    assertTrue(list.get(0) instanceof
+        LogAggregationTFileController, "TFile format is expected to be the first " +
+        "LogAggregationFileController!");
+    assertTrue(factory.getFileControllerForWrite() instanceof
+            LogAggregationTFileController,
+        "TFile format is expected to be used for writing!");
 
 
     verifyFileControllerInstance(factory, LogAggregationTFileController.class);
     verifyFileControllerInstance(factory, LogAggregationTFileController.class);
   }
   }
 
 
-  @Test(expected = Exception.class)
-  public void testLogAggregationFileControllerFactoryClassNotSet() {
-    Configuration conf = getConf();
-    conf.set(LOG_AGGREGATION_FILE_FORMATS, "TestLogAggregationFileController");
-    new LogAggregationFileControllerFactory(conf);
-    fail("TestLogAggregationFileController's class was not set, " +
-        "but the factory creation did not fail.");
+  @Test
+  void testLogAggregationFileControllerFactoryClassNotSet() {
+    assertThrows(Exception.class, () -> {
+      Configuration conf = getConf();
+      conf.set(LOG_AGGREGATION_FILE_FORMATS, "TestLogAggregationFileController");
+      new LogAggregationFileControllerFactory(conf);
+      fail("TestLogAggregationFileController's class was not set, " +
+          "but the factory creation did not fail.");
+    });
   }
   }
 
 
   @Test
   @Test
-  public void testLogAggregationFileControllerFactory() throws Exception {
+  void testLogAggregationFileControllerFactory() throws Exception {
     enableFileControllers(getConf(), ALL_FILE_CONTROLLERS, ALL_FILE_CONTROLLER_NAMES);
     enableFileControllers(getConf(), ALL_FILE_CONTROLLERS, ALL_FILE_CONTROLLER_NAMES);
     LogAggregationFileControllerFactory factory =
     LogAggregationFileControllerFactory factory =
         new LogAggregationFileControllerFactory(getConf());
         new LogAggregationFileControllerFactory(getConf());
     List<LogAggregationFileController> list =
     List<LogAggregationFileController> list =
         factory.getConfiguredLogAggregationFileControllerList();
         factory.getConfiguredLogAggregationFileControllerList();
 
 
-    assertEquals("The expected number of LogAggregationFileController " +
-        "is not 3!", 3, list.size());
-    assertTrue("Test format is expected to be the first " +
-        "LogAggregationFileController!", list.get(0) instanceof
-        TestLogAggregationFileController);
-    assertTrue("IFile format is expected to be the second " +
-        "LogAggregationFileController!", list.get(1) instanceof
-        LogAggregationIndexedFileController);
-    assertTrue("TFile format is expected to be the first " +
-        "LogAggregationFileController!", list.get(2) instanceof
-        LogAggregationTFileController);
-    assertTrue("Test format is expected to be used for writing!",
-        factory.getFileControllerForWrite() instanceof
-            TestLogAggregationFileController);
+    assertEquals(3, list.size(), "The expected number of LogAggregationFileController " +
+        "is not 3!");
+    assertTrue(list.get(0) instanceof
+        TestLogAggregationFileController, "Test format is expected to be the first " +
+        "LogAggregationFileController!");
+    assertTrue(list.get(1) instanceof
+        LogAggregationIndexedFileController, "IFile format is expected to be the second " +
+        "LogAggregationFileController!");
+    assertTrue(list.get(2) instanceof
+        LogAggregationTFileController, "TFile format is expected to be the first " +
+        "LogAggregationFileController!");
+    assertTrue(factory.getFileControllerForWrite() instanceof
+            TestLogAggregationFileController,
+        "Test format is expected to be used for writing!");
 
 
     verifyFileControllerInstance(factory,
     verifyFileControllerInstance(factory,
         TestLogAggregationFileController.class);
         TestLogAggregationFileController.class);
   }
   }
 
 
   @Test
   @Test
-  public void testClassConfUsed() {
+  void testClassConfUsed() {
     enableFileControllers(getConf(), Collections.singletonList(LogAggregationTFileController.class),
     enableFileControllers(getConf(), Collections.singletonList(LogAggregationTFileController.class),
         Collections.singletonList("TFile"));
         Collections.singletonList("TFile"));
     LogAggregationFileControllerFactory factory =
     LogAggregationFileControllerFactory factory =
         new LogAggregationFileControllerFactory(getConf());
         new LogAggregationFileControllerFactory(getConf());
     LogAggregationFileController fc = factory.getFileControllerForWrite();
     LogAggregationFileController fc = factory.getFileControllerForWrite();
 
 
-    assertEquals(WRONG_ROOT_LOG_DIR_MSG, "target/app-logs/TFile",
-        fc.getRemoteRootLogDir().toString());
-    assertEquals(WRONG_ROOT_LOG_DIR_SUFFIX_MSG, "TFile",
-        fc.getRemoteRootLogDirSuffix());
+    assertEquals("target/app-logs/TFile",
+        fc.getRemoteRootLogDir().toString(),
+        WRONG_ROOT_LOG_DIR_MSG);
+    assertEquals("TFile",
+        fc.getRemoteRootLogDirSuffix(),
+        WRONG_ROOT_LOG_DIR_SUFFIX_MSG);
   }
   }
 
 
   @Test
   @Test
-  public void testNodemanagerConfigurationIsUsed() {
+  void testNodemanagerConfigurationIsUsed() {
     Configuration conf = getConf();
     Configuration conf = getConf();
     conf.set(LOG_AGGREGATION_FILE_FORMATS, "TFile");
     conf.set(LOG_AGGREGATION_FILE_FORMATS, "TFile");
     LogAggregationFileControllerFactory factory =
     LogAggregationFileControllerFactory factory =
         new LogAggregationFileControllerFactory(conf);
         new LogAggregationFileControllerFactory(conf);
     LogAggregationFileController fc = factory.getFileControllerForWrite();
     LogAggregationFileController fc = factory.getFileControllerForWrite();
 
 
-    assertEquals(WRONG_ROOT_LOG_DIR_MSG, "target/app-logs/default",
-        fc.getRemoteRootLogDir().toString());
-    assertEquals(WRONG_ROOT_LOG_DIR_SUFFIX_MSG, "log-tfile",
-        fc.getRemoteRootLogDirSuffix());
+    assertEquals("target/app-logs/default",
+        fc.getRemoteRootLogDir().toString(),
+        WRONG_ROOT_LOG_DIR_MSG);
+    assertEquals("log-tfile",
+        fc.getRemoteRootLogDirSuffix(),
+        WRONG_ROOT_LOG_DIR_SUFFIX_MSG);
   }
   }
 
 
   @Test
   @Test
-  public void testDefaultConfUsed() {
+  void testDefaultConfUsed() {
     Configuration conf = getConf();
     Configuration conf = getConf();
     conf.unset(YarnConfiguration.NM_REMOTE_APP_LOG_DIR);
     conf.unset(YarnConfiguration.NM_REMOTE_APP_LOG_DIR);
     conf.unset(YarnConfiguration.NM_REMOTE_APP_LOG_DIR_SUFFIX);
     conf.unset(YarnConfiguration.NM_REMOTE_APP_LOG_DIR_SUFFIX);
@@ -210,10 +220,12 @@ public class TestLogAggregationFileControllerFactory extends Configured {
         new LogAggregationFileControllerFactory(getConf());
         new LogAggregationFileControllerFactory(getConf());
     LogAggregationFileController fc = factory.getFileControllerForWrite();
     LogAggregationFileController fc = factory.getFileControllerForWrite();
 
 
-    assertEquals(WRONG_ROOT_LOG_DIR_MSG, "/tmp/logs",
-        fc.getRemoteRootLogDir().toString());
-    assertEquals(WRONG_ROOT_LOG_DIR_SUFFIX_MSG, "logs-tfile",
-        fc.getRemoteRootLogDirSuffix());
+    assertEquals("/tmp/logs",
+        fc.getRemoteRootLogDir().toString(),
+        WRONG_ROOT_LOG_DIR_MSG);
+    assertEquals("logs-tfile",
+        fc.getRemoteRootLogDirSuffix(),
+        WRONG_ROOT_LOG_DIR_SUFFIX_MSG);
   }
   }
 
 
   private static class TestLogAggregationFileController
   private static class TestLogAggregationFileController

+ 51 - 47
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/TestLogAggregationIndexedFileController.java

@@ -32,6 +32,12 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.conf.Configured;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
@@ -48,27 +54,24 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogKey;
+import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogValue;
+import org.apache.hadoop.yarn.logaggregation.ContainerLogFileInfo;
 import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
 import org.apache.hadoop.yarn.logaggregation.ContainerLogMeta;
 import org.apache.hadoop.yarn.logaggregation.ContainerLogsRequest;
 import org.apache.hadoop.yarn.logaggregation.ContainerLogsRequest;
 import org.apache.hadoop.yarn.logaggregation.ExtendedLogMetaRequest;
 import org.apache.hadoop.yarn.logaggregation.ExtendedLogMetaRequest;
 import org.apache.hadoop.yarn.logaggregation.LogAggregationUtils;
 import org.apache.hadoop.yarn.logaggregation.LogAggregationUtils;
-import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogKey;
-import org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogValue;
-import org.apache.hadoop.yarn.logaggregation.ContainerLogFileInfo;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileController;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
 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.junit.After;
-import org.junit.Before;
-import org.junit.Test;
 
 
 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.Assert.assertNotNull;
+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.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;
 
 
@@ -104,7 +107,7 @@ public class TestLogAggregationIndexedFileController
     return conf;
     return conf;
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws IOException {
   public void setUp() throws IOException {
     setConf(getTestConf());
     setConf(getTestConf());
     appId = ApplicationId.newInstance(123456, 1);
     appId = ApplicationId.newInstance(123456, 1);
@@ -122,14 +125,15 @@ public class TestLogAggregationIndexedFileController
     System.setErr(sysErr);
     System.setErr(sysErr);
   }
   }
 
 
-  @After
+  @AfterEach
   public void teardown() throws Exception {
   public void teardown() throws Exception {
     fs.delete(rootLocalLogDirPath, true);
     fs.delete(rootLocalLogDirPath, true);
     fs.delete(new Path(remoteLogDir), true);
     fs.delete(new Path(remoteLogDir), true);
   }
   }
 
 
-  @Test(timeout = 15000)
-  public void testLogAggregationIndexFileFormat() throws Exception {
+  @Test
+  @Timeout(15000)
+  void testLogAggregationIndexFileFormat() throws Exception {
     if (fs.exists(rootLocalLogDirPath)) {
     if (fs.exists(rootLocalLogDirPath)) {
       fs.delete(rootLocalLogDirPath, true);
       fs.delete(rootLocalLogDirPath, true);
     }
     }
@@ -150,7 +154,7 @@ public class TestLogAggregationIndexedFileController
 
 
     LogKey key1 = new LogKey(containerId.toString());
     LogKey key1 = new LogKey(containerId.toString());
 
 
-    for(String logType : logTypes) {
+    for (String logType : logTypes) {
       File file = createAndWriteLocalLogFile(containerId, appLogsDir,
       File file = createAndWriteLocalLogFile(containerId, appLogsDir,
           logType);
           logType);
       files.add(file);
       files.add(file);
@@ -162,24 +166,23 @@ public class TestLogAggregationIndexedFileController
 
 
     final ControlledClock clock = new ControlledClock();
     final ControlledClock clock = new ControlledClock();
     clock.setTime(System.currentTimeMillis());
     clock.setTime(System.currentTimeMillis());
-    LogAggregationIndexedFileController fileFormat
-        = new LogAggregationIndexedFileController() {
-          private int rollOverCheck = 0;
-          @Override
-          public Clock getSystemClock() {
-            return clock;
-          }
-
-          @Override
-          public boolean isRollover(final FileContext fc,
-              final Path candidate) throws IOException {
-            rollOverCheck++;
-            if (rollOverCheck >= 3) {
-              return true;
-            }
-            return false;
-          }
-        };
+    LogAggregationIndexedFileController fileFormat = new LogAggregationIndexedFileController() {
+      private int rollOverCheck = 0;
+
+      @Override
+      public Clock getSystemClock() {
+        return clock;
+      }
+
+      @Override
+      public boolean isRollover(final FileContext fc, final Path candidate) throws IOException {
+        rollOverCheck++;
+        if (rollOverCheck >= 3) {
+          return true;
+        }
+        return false;
+      }
+    };
 
 
     fileFormat.initialize(getConf(), "Indexed");
     fileFormat.initialize(getConf(), "Indexed");
 
 
@@ -238,7 +241,7 @@ public class TestLogAggregationIndexedFileController
     factoryConf.set("yarn.log-aggregation.file-formats", "Indexed");
     factoryConf.set("yarn.log-aggregation.file-formats", "Indexed");
     factoryConf.set("yarn.log-aggregation.file-controller.Indexed.class",
     factoryConf.set("yarn.log-aggregation.file-controller.Indexed.class",
         "org.apache.hadoop.yarn.logaggregation.filecontroller.ifile"
         "org.apache.hadoop.yarn.logaggregation.filecontroller.ifile"
-        + ".LogAggregationIndexedFileController");
+            + ".LogAggregationIndexedFileController");
     LogAggregationFileControllerFactory factory =
     LogAggregationFileControllerFactory factory =
         new LogAggregationFileControllerFactory(factoryConf);
         new LogAggregationFileControllerFactory(factoryConf);
     LogAggregationFileController fileController = factory
     LogAggregationFileController fileController = factory
@@ -255,9 +258,9 @@ public class TestLogAggregationIndexedFileController
 
 
     // create a checksum file
     // create a checksum file
     Path checksumFile = new Path(fileFormat.getRemoteAppLogDir(
     Path checksumFile = new Path(fileFormat.getRemoteAppLogDir(
-        appId, USER_UGI.getShortUserName()),
+            appId, USER_UGI.getShortUserName()),
         LogAggregationUtils.getNodeString(nodeId)
         LogAggregationUtils.getNodeString(nodeId)
-        + LogAggregationIndexedFileController.CHECK_SUM_FILE_SUFFIX);
+            + LogAggregationIndexedFileController.CHECK_SUM_FILE_SUFFIX);
     FSDataOutputStream fInput = null;
     FSDataOutputStream fInput = null;
     try {
     try {
       String nodeName = logPath.getName() + "_" + clock.getTime();
       String nodeName = logPath.getName() + "_" + clock.getTime();
@@ -330,7 +333,7 @@ public class TestLogAggregationIndexedFileController
     fileFormat.postWrite(context);
     fileFormat.postWrite(context);
     fileFormat.closeWriter();
     fileFormat.closeWriter();
     meta = fileFormat.readAggregatedLogsMeta(
     meta = fileFormat.readAggregatedLogsMeta(
-            logRequest);
+        logRequest);
     assertThat(meta.size()).isEqualTo(2);
     assertThat(meta.size()).isEqualTo(2);
     for (ContainerLogMeta log : meta) {
     for (ContainerLogMeta log : meta) {
       assertEquals(containerId.toString(), log.getContainerId());
       assertEquals(containerId.toString(), log.getContainerId());
@@ -380,8 +383,9 @@ public class TestLogAggregationIndexedFileController
     sysOutStream.reset();
     sysOutStream.reset();
   }
   }
 
 
-  @Test(timeout = 15000)
-  public void testFetchApplictionLogsHar() throws Exception {
+  @Test
+  @Timeout(15000)
+  void testFetchApplictionLogsHar() throws Exception {
     List<String> newLogTypes = new ArrayList<>();
     List<String> newLogTypes = new ArrayList<>();
     newLogTypes.add("syslog");
     newLogTypes.add("syslog");
     newLogTypes.add("stdout");
     newLogTypes.add("stdout");
@@ -472,7 +476,7 @@ public class TestLogAggregationIndexedFileController
   }
   }
 
 
   @Test
   @Test
-  public void testGetRollOverLogMaxSize() {
+  void testGetRollOverLogMaxSize() {
     String fileControllerName = "testController";
     String fileControllerName = "testController";
     String remoteDirConf = String.format(
     String remoteDirConf = String.format(
         YarnConfiguration.LOG_AGGREGATION_REMOTE_APP_LOG_DIR_FMT,
         YarnConfiguration.LOG_AGGREGATION_REMOTE_APP_LOG_DIR_FMT,
@@ -500,7 +504,7 @@ public class TestLogAggregationIndexedFileController
   }
   }
 
 
   @Test
   @Test
-  public void testGetLogMetaFilesOfNode() throws Exception {
+  void testGetLogMetaFilesOfNode() throws Exception {
     if (fs.exists(rootLocalLogDirPath)) {
     if (fs.exists(rootLocalLogDirPath)) {
       fs.delete(rootLocalLogDirPath, true);
       fs.delete(rootLocalLogDirPath, true);
     }
     }
@@ -521,7 +525,7 @@ public class TestLogAggregationIndexedFileController
 
 
     LogKey key1 = new LogKey(containerId.toString());
     LogKey key1 = new LogKey(containerId.toString());
 
 
-    for(String logType : logTypes) {
+    for (String logType : logTypes) {
       File file = createAndWriteLocalLogFile(containerId, appLogsDir,
       File file = createAndWriteLocalLogFile(containerId, appLogsDir,
           logType);
           logType);
       files.add(file);
       files.add(file);
@@ -566,7 +570,7 @@ public class TestLogAggregationIndexedFileController
     final ControlledClock clock = new ControlledClock();
     final ControlledClock clock = new ControlledClock();
     clock.setTime(System.currentTimeMillis());
     clock.setTime(System.currentTimeMillis());
     Path checksumFile = new Path(fileFormat.getRemoteAppLogDir(
     Path checksumFile = new Path(fileFormat.getRemoteAppLogDir(
-        appId, USER_UGI.getShortUserName()),
+            appId, USER_UGI.getShortUserName()),
         LogAggregationUtils.getNodeString(nodeId)
         LogAggregationUtils.getNodeString(nodeId)
             + LogAggregationIndexedFileController.CHECK_SUM_FILE_SUFFIX);
             + LogAggregationIndexedFileController.CHECK_SUM_FILE_SUFFIX);
     FSDataOutputStream fInput = null;
     FSDataOutputStream fInput = null;
@@ -593,11 +597,11 @@ public class TestLogAggregationIndexedFileController
 
 
       if (node.getPath().getName().contains(
       if (node.getPath().getName().contains(
           LogAggregationIndexedFileController.CHECK_SUM_FILE_SUFFIX)) {
           LogAggregationIndexedFileController.CHECK_SUM_FILE_SUFFIX)) {
-        assertTrue("Checksum node files should not contain any logs",
-            metas.isEmpty());
+        assertTrue(metas.isEmpty(),
+            "Checksum node files should not contain any logs");
       } else {
       } else {
-        assertFalse("Non-checksum node files should contain log files",
-            metas.isEmpty());
+        assertFalse(metas.isEmpty(),
+            "Non-checksum node files should contain log files");
         assertEquals(4, metas.values().stream().findFirst().get().size());
         assertEquals(4, metas.values().stream().findFirst().get().size());
       }
       }
     }
     }

+ 3 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/AggregatedLogDeletionServiceForTest.java

@@ -18,14 +18,14 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.testutils;
 package org.apache.hadoop.yarn.logaggregation.testutils;
 
 
+import java.io.IOException;
+import java.util.List;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
 import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
 
 
-import java.io.IOException;
-import java.util.List;
-
 import static org.apache.hadoop.yarn.logaggregation.testutils.MockRMClientUtils.createMockRMClient;
 import static org.apache.hadoop.yarn.logaggregation.testutils.MockRMClientUtils.createMockRMClient;
 
 
 public class AggregatedLogDeletionServiceForTest extends AggregatedLogDeletionService {
 public class AggregatedLogDeletionServiceForTest extends AggregatedLogDeletionService {

+ 23 - 16
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/LogAggregationTestcase.java

@@ -18,6 +18,19 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.testutils;
 package org.apache.hadoop.yarn.logaggregation.testutils;
 
 
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
@@ -30,26 +43,20 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService.LogDeletionTask;
 import org.apache.hadoop.yarn.logaggregation.AggregatedLogDeletionService.LogDeletionTask;
 import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.AppDescriptor;
 import org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.AppDescriptor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
 
 
-import static org.apache.hadoop.yarn.logaggregation.testutils.FileStatusUtils.*;
+import static org.apache.hadoop.yarn.logaggregation.testutils.FileStatusUtils.createDirBucketDirLogPathWithFileStatus;
+import static org.apache.hadoop.yarn.logaggregation.testutils.FileStatusUtils.createDirLogPathWithFileStatus;
+import static org.apache.hadoop.yarn.logaggregation.testutils.FileStatusUtils.createFileLogPathWithFileStatus;
+import static org.apache.hadoop.yarn.logaggregation.testutils.FileStatusUtils.createPathWithFileStatusForAppId;
 import static org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.NO_TIMEOUT;
 import static org.apache.hadoop.yarn.logaggregation.testutils.LogAggregationTestcaseBuilder.NO_TIMEOUT;
 import static org.apache.hadoop.yarn.logaggregation.testutils.MockRMClientUtils.createMockRMClient;
 import static org.apache.hadoop.yarn.logaggregation.testutils.MockRMClientUtils.createMockRMClient;
-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.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 
 public class LogAggregationTestcase {
 public class LogAggregationTestcase {
   private static final Logger LOG = LoggerFactory.getLogger(LogAggregationTestcase.class);
   private static final Logger LOG = LoggerFactory.getLogger(LogAggregationTestcase.class);

+ 6 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/LogAggregationTestcaseBuilder.java

@@ -18,6 +18,12 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.testutils;
 package org.apache.hadoop.yarn.logaggregation.testutils;
 
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.compress.utils.Lists;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
@@ -27,12 +33,6 @@ import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.logaggregation.LogAggregationUtils;
 import org.apache.hadoop.yarn.logaggregation.LogAggregationUtils;
 
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import static org.apache.hadoop.yarn.logaggregation.TestAggregatedLogDeletionService.ALL_FILE_CONTROLLER_NAMES;
 import static org.apache.hadoop.yarn.logaggregation.TestAggregatedLogDeletionService.ALL_FILE_CONTROLLER_NAMES;
 
 
 public class LogAggregationTestcaseBuilder {
 public class LogAggregationTestcaseBuilder {

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/testutils/MockRMClientUtils.java

@@ -18,6 +18,8 @@
 
 
 package org.apache.hadoop.yarn.logaggregation.testutils;
 package org.apache.hadoop.yarn.logaggregation.testutils;
 
 
+import java.util.List;
+
 import org.apache.hadoop.test.MockitoUtil;
 import org.apache.hadoop.test.MockitoUtil;
 import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
 import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
 import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
 import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
@@ -26,8 +28,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 
 
-import java.util.List;
-
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.when;
 
 

+ 27 - 23
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/NodeLabelTestBase.java

@@ -25,19 +25,23 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.Set;
 
 
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
+
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
-import org.junit.Assert;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class NodeLabelTestBase {
 public class NodeLabelTestBase {
   public static void assertMapEquals(Map<NodeId, Set<String>> expected,
   public static void assertMapEquals(Map<NodeId, Set<String>> expected,
       ImmutableMap<NodeId, Set<String>> actual) {
       ImmutableMap<NodeId, Set<String>> actual) {
-    Assert.assertEquals(expected.size(), actual.size());
+    assertEquals(expected.size(), actual.size());
     for (NodeId k : expected.keySet()) {
     for (NodeId k : expected.keySet()) {
-      Assert.assertTrue(actual.containsKey(k));
+      assertTrue(actual.containsKey(k));
       assertCollectionEquals(expected.get(k), actual.get(k));
       assertCollectionEquals(expected.get(k), actual.get(k));
     }
     }
   }
   }
@@ -45,9 +49,9 @@ public class NodeLabelTestBase {
   public static void assertLabelInfoMapEquals(
   public static void assertLabelInfoMapEquals(
       Map<NodeId, Set<NodeLabel>> expected,
       Map<NodeId, Set<NodeLabel>> expected,
       ImmutableMap<NodeId, Set<NodeLabel>> actual) {
       ImmutableMap<NodeId, Set<NodeLabel>> actual) {
-    Assert.assertEquals(expected.size(), actual.size());
+    assertEquals(expected.size(), actual.size());
     for (NodeId k : expected.keySet()) {
     for (NodeId k : expected.keySet()) {
-      Assert.assertTrue(actual.containsKey(k));
+      assertTrue(actual.containsKey(k));
       assertNLCollectionEquals(expected.get(k), actual.get(k));
       assertNLCollectionEquals(expected.get(k), actual.get(k));
     }
     }
   }
   }
@@ -55,13 +59,13 @@ public class NodeLabelTestBase {
   public static void assertLabelsToNodesEquals(
   public static void assertLabelsToNodesEquals(
       Map<String, Set<NodeId>> expected,
       Map<String, Set<NodeId>> expected,
       ImmutableMap<String, Set<NodeId>> actual) {
       ImmutableMap<String, Set<NodeId>> actual) {
-    Assert.assertEquals(expected.size(), actual.size());
+    assertEquals(expected.size(), actual.size());
     for (String k : expected.keySet()) {
     for (String k : expected.keySet()) {
-      Assert.assertTrue(actual.containsKey(k));
+      assertTrue(actual.containsKey(k));
       Set<NodeId> expectedS1 = new HashSet<>(expected.get(k));
       Set<NodeId> expectedS1 = new HashSet<>(expected.get(k));
       Set<NodeId> actualS2 = new HashSet<>(actual.get(k));
       Set<NodeId> actualS2 = new HashSet<>(actual.get(k));
-      Assert.assertEquals(expectedS1, actualS2);
-      Assert.assertTrue(expectedS1.containsAll(actualS2));
+      assertEquals(expectedS1, actualS2);
+      assertTrue(expectedS1.containsAll(actualS2));
     }
     }
   }
   }
 
 
@@ -86,7 +90,7 @@ public class NodeLabelTestBase {
   public static void assertMapContains(Map<NodeId, Set<String>> expected,
   public static void assertMapContains(Map<NodeId, Set<String>> expected,
       ImmutableMap<NodeId, Set<String>> actual) {
       ImmutableMap<NodeId, Set<String>> actual) {
     for (NodeId k : actual.keySet()) {
     for (NodeId k : actual.keySet()) {
-      Assert.assertTrue(expected.containsKey(k));
+      assertTrue(expected.containsKey(k));
       assertCollectionEquals(expected.get(k), actual.get(k));
       assertCollectionEquals(expected.get(k), actual.get(k));
     }
     }
   }
   }
@@ -94,28 +98,28 @@ public class NodeLabelTestBase {
   public static void assertCollectionEquals(Collection<String> expected,
   public static void assertCollectionEquals(Collection<String> expected,
       Collection<String> actual) {
       Collection<String> actual) {
     if (expected == null) {
     if (expected == null) {
-      Assert.assertNull(actual);
+      assertNull(actual);
     } else {
     } else {
-      Assert.assertNotNull(actual);
+      assertNotNull(actual);
     }
     }
     Set<String> expectedSet = new HashSet<>(expected);
     Set<String> expectedSet = new HashSet<>(expected);
     Set<String> actualSet = new HashSet<>(actual);
     Set<String> actualSet = new HashSet<>(actual);
-    Assert.assertEquals(expectedSet, actualSet);
-    Assert.assertTrue(expectedSet.containsAll(actualSet));
+    assertEquals(expectedSet, actualSet);
+    assertTrue(expectedSet.containsAll(actualSet));
   }
   }
 
 
   public static void assertNLCollectionEquals(Collection<NodeLabel> expected,
   public static void assertNLCollectionEquals(Collection<NodeLabel> expected,
       Collection<NodeLabel> actual) {
       Collection<NodeLabel> actual) {
     if (expected == null) {
     if (expected == null) {
-      Assert.assertNull(actual);
+      assertNull(actual);
     } else {
     } else {
-      Assert.assertNotNull(actual);
+      assertNotNull(actual);
     }
     }
 
 
     Set<NodeLabel> expectedSet = new HashSet<>(expected);
     Set<NodeLabel> expectedSet = new HashSet<>(expected);
     Set<NodeLabel> actualSet = new HashSet<>(actual);
     Set<NodeLabel> actualSet = new HashSet<>(actual);
-    Assert.assertEquals(expectedSet, actualSet);
-    Assert.assertTrue(expectedSet.containsAll(actualSet));
+    assertEquals(expectedSet, actualSet);
+    assertTrue(expectedSet.containsAll(actualSet));
   }
   }
 
 
   @SuppressWarnings("unchecked")
   @SuppressWarnings("unchecked")
@@ -150,13 +154,13 @@ public class NodeLabelTestBase {
   public static void assertLabelsInfoToNodesEquals(
   public static void assertLabelsInfoToNodesEquals(
       Map<NodeLabel, Set<NodeId>> expected,
       Map<NodeLabel, Set<NodeId>> expected,
       ImmutableMap<NodeLabel, Set<NodeId>> actual) {
       ImmutableMap<NodeLabel, Set<NodeId>> actual) {
-    Assert.assertEquals(expected.size(), actual.size());
+    assertEquals(expected.size(), actual.size());
     for (NodeLabel k : expected.keySet()) {
     for (NodeLabel k : expected.keySet()) {
-      Assert.assertTrue(actual.containsKey(k));
+      assertTrue(actual.containsKey(k));
       Set<NodeId> expectedS1 = new HashSet<>(expected.get(k));
       Set<NodeId> expectedS1 = new HashSet<>(expected.get(k));
       Set<NodeId> actualS2 = new HashSet<>(actual.get(k));
       Set<NodeId> actualS2 = new HashSet<>(actual.get(k));
-      Assert.assertEquals(expectedS1, actualS2);
-      Assert.assertTrue(expectedS1.containsAll(actualS2));
+      assertEquals(expectedS1, actualS2);
+      assertTrue(expectedS1.containsAll(actualS2));
     }
     }
   }
   }
 }
 }

+ 154 - 132
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestCommonNodeLabelsManager.java

@@ -18,8 +18,6 @@
 
 
 package org.apache.hadoop.yarn.nodelabels;
 package org.apache.hadoop.yarn.nodelabels;
 
 
-import static org.junit.Assert.assertTrue;
-
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
@@ -27,24 +25,31 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 
 
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.util.Sets;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
-import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
 public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
   DummyCommonNodeLabelsManager mgr = null;
   DummyCommonNodeLabelsManager mgr = null;
 
 
-  @Before
+  @BeforeEach
   public void before() {
   public void before() {
     mgr = new DummyCommonNodeLabelsManager();
     mgr = new DummyCommonNodeLabelsManager();
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
@@ -53,13 +58,14 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
   }
   }
 
 
-  @After
+  @AfterEach
   public void after() {
   public void after() {
     mgr.stop();
     mgr.stop();
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testAddRemovelabel() throws Exception {
+  @Test
+  @Timeout(5000)
+  void testAddRemovelabel() throws Exception {
     // Add some label
     // Add some label
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("hello"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("hello"));
     verifyNodeLabelAdded(Sets.newHashSet("hello"), mgr.lastAddedlabels);
     verifyNodeLabelAdded(Sets.newHashSet("hello"), mgr.lastAddedlabels);
@@ -68,23 +74,23 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("hello1", "world1"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("hello1", "world1"));
     verifyNodeLabelAdded(Sets.newHashSet("hello1", "world1"), mgr.lastAddedlabels);
     verifyNodeLabelAdded(Sets.newHashSet("hello1", "world1"), mgr.lastAddedlabels);
 
 
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Sets.newHashSet("hello", "world", "hello1", "world1")));
         Sets.newHashSet("hello", "world", "hello1", "world1")));
     try {
     try {
       mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("hello1",
       mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("hello1",
           false)));
           false)));
-      Assert.fail("IOException not thrown on exclusivity change of labels");
+      fail("IOException not thrown on exclusivity change of labels");
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.assertTrue("IOException is expected when exclusivity is modified",
-          e instanceof IOException);
+      assertTrue(e instanceof IOException,
+          "IOException is expected when exclusivity is modified");
     }
     }
     try {
     try {
       mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("hello1",
       mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("hello1",
           true)));
           true)));
     } catch (Exception e) {
     } catch (Exception e) {
-      Assert.assertFalse(
-          "IOException not expected when no change in exclusivity",
-          e instanceof IOException);
+      assertFalse(
+          e instanceof IOException,
+          "IOException not expected when no change in exclusivity");
     }
     }
     // try to remove null, empty and non-existed label, should fail
     // try to remove null, empty and non-existed label, should fail
     for (String p : Arrays.asList(null, CommonNodeLabelsManager.NO_LABEL, "xx")) {
     for (String p : Arrays.asList(null, CommonNodeLabelsManager.NO_LABEL, "xx")) {
@@ -94,42 +100,45 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       } catch (IOException e) {
       } catch (IOException e) {
         caught = true;
         caught = true;
       }
       }
-      Assert.assertTrue("remove label should fail "
-          + "when label is null/empty/non-existed", caught);
+      assertTrue(caught, "remove label should fail "
+          + "when label is null/empty/non-existed");
     }
     }
 
 
     // Remove some label
     // Remove some label
     mgr.removeFromClusterNodeLabels(Arrays.asList("hello"));
     mgr.removeFromClusterNodeLabels(Arrays.asList("hello"));
     assertCollectionEquals(Sets.newHashSet("hello"), mgr.lastRemovedlabels);
     assertCollectionEquals(Sets.newHashSet("hello"), mgr.lastRemovedlabels);
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("world", "hello1", "world1")));
         Arrays.asList("world", "hello1", "world1")));
 
 
     mgr.removeFromClusterNodeLabels(Arrays
     mgr.removeFromClusterNodeLabels(Arrays
         .asList("hello1", "world1", "world"));
         .asList("hello1", "world1", "world"));
-    Assert.assertTrue(mgr.lastRemovedlabels.containsAll(Sets.newHashSet(
+    assertTrue(mgr.lastRemovedlabels.containsAll(Sets.newHashSet(
         "hello1", "world1", "world")));
         "hello1", "world1", "world")));
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().isEmpty());
+    assertTrue(mgr.getClusterNodeLabelNames().isEmpty());
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testAddlabelWithCase() throws Exception {
+  @Test
+  @Timeout(5000)
+  void testAddlabelWithCase() throws Exception {
     // Add some label, case will not ignore here
     // Add some label, case will not ignore here
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("HeLlO"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("HeLlO"));
     verifyNodeLabelAdded(Sets.newHashSet("HeLlO"), mgr.lastAddedlabels);
     verifyNodeLabelAdded(Sets.newHashSet("HeLlO"), mgr.lastAddedlabels);
-    Assert.assertFalse(mgr.getClusterNodeLabelNames().containsAll(
+    assertFalse(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("hello")));
         Arrays.asList("hello")));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testAddlabelWithExclusivity() throws Exception {
+  @Test
+  @Timeout(5000)
+  void testAddlabelWithExclusivity() throws Exception {
     // Add some label, case will not ignore here
     // Add some label, case will not ignore here
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("a", false), NodeLabel.newInstance("b", true)));
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("a", false), NodeLabel.newInstance("b", true)));
-    Assert.assertFalse(mgr.isExclusiveNodeLabel("a"));
-    Assert.assertTrue(mgr.isExclusiveNodeLabel("b"));
+    assertFalse(mgr.isExclusiveNodeLabel("a"));
+    assertTrue(mgr.isExclusiveNodeLabel("b"));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testAddInvalidlabel() throws IOException {
+  @Test
+  @Timeout(5000)
+  void testAddInvalidlabel() throws IOException {
     boolean caught = false;
     boolean caught = false;
     try {
     try {
       Set<String> set = new HashSet<String>();
       Set<String> set = new HashSet<String>();
@@ -138,7 +147,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("null label should not add to repo", caught);
+    assertTrue(caught, "null label should not add to repo");
 
 
     caught = false;
     caught = false;
     try {
     try {
@@ -147,7 +156,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       caught = true;
       caught = true;
     }
     }
 
 
-    Assert.assertTrue("empty label should not add to repo", caught);
+    assertTrue(caught, "empty label should not add to repo");
 
 
     caught = false;
     caught = false;
     try {
     try {
@@ -155,7 +164,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("invalid label character should not add to repo", caught);
+    assertTrue(caught, "invalid label character should not add to repo");
 
 
     caught = false;
     caught = false;
     try {
     try {
@@ -163,7 +172,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("too long label should not add to repo", caught);
+    assertTrue(caught, "too long label should not add to repo");
 
 
     caught = false;
     caught = false;
     try {
     try {
@@ -171,7 +180,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("label cannot start with \"-\"", caught);
+    assertTrue(caught, "label cannot start with \"-\"");
 
 
     caught = false;
     caught = false;
     try {
     try {
@@ -179,28 +188,29 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("label cannot start with \"_\"", caught);
-    
+    assertTrue(caught, "label cannot start with \"_\"");
+
     caught = false;
     caught = false;
     try {
     try {
       mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("a^aabbb"));
       mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("a^aabbb"));
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("label cannot contains other chars like ^[] ...", caught);
-    
+    assertTrue(caught, "label cannot contains other chars like ^[] ...");
+
     caught = false;
     caught = false;
     try {
     try {
       mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("aa[a]bbb"));
       mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("aa[a]bbb"));
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("label cannot contains other chars like ^[] ...", caught);
+    assertTrue(caught, "label cannot contains other chars like ^[] ...");
   }
   }
 
 
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Test(timeout = 5000)
-  public void testAddReplaceRemoveLabelsOnNodes() throws Exception {
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  @Test
+  @Timeout(5000)
+  void testAddReplaceRemoveLabelsOnNodes() throws Exception {
     // set a label on a node, but label doesn't exist
     // set a label on a node, but label doesn't exist
     boolean caught = false;
     boolean caught = false;
     try {
     try {
@@ -208,8 +218,8 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("trying to set a label to a node but "
-        + "label doesn't exist in repository should fail", caught);
+    assertTrue(caught, "trying to set a label to a node but "
+        + "label doesn't exist in repository should fail");
 
 
     // set a label on a node, but node is null or empty
     // set a label on a node, but node is null or empty
     try {
     try {
@@ -218,7 +228,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       caught = true;
       caught = true;
     }
     }
-    Assert.assertTrue("trying to add a empty node but succeeded", caught);
+    assertTrue(caught, "trying to add a empty node but succeeded");
 
 
     // set node->label one by one
     // set node->label one by one
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
@@ -263,15 +273,16 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     // remove labels on node
     // remove labels on node
     mgr.removeLabelsFromNode(ImmutableMap.of(toNodeId("n1"), toSet("p1"),
     mgr.removeLabelsFromNode(ImmutableMap.of(toNodeId("n1"), toSet("p1"),
         toNodeId("n2"), toSet("p3"), toNodeId("n3"), toSet("p3")));
         toNodeId("n2"), toSet("p3"), toNodeId("n3"), toSet("p3")));
-    Assert.assertEquals(0, mgr.getNodeLabels().size());
+    assertEquals(0, mgr.getNodeLabels().size());
     assertMapEquals(mgr.lastNodeToLabels, ImmutableMap.of(toNodeId("n1"),
     assertMapEquals(mgr.lastNodeToLabels, ImmutableMap.of(toNodeId("n1"),
         CommonNodeLabelsManager.EMPTY_STRING_SET, toNodeId("n2"),
         CommonNodeLabelsManager.EMPTY_STRING_SET, toNodeId("n2"),
         CommonNodeLabelsManager.EMPTY_STRING_SET, toNodeId("n3"),
         CommonNodeLabelsManager.EMPTY_STRING_SET, toNodeId("n3"),
         CommonNodeLabelsManager.EMPTY_STRING_SET));
         CommonNodeLabelsManager.EMPTY_STRING_SET));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testRemovelabelWithNodes() throws Exception {
+  @Test
+  @Timeout(5000)
+  void testRemovelabelWithNodes() throws Exception {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n2"), toSet("p2")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n2"), toSet("p2")));
@@ -283,21 +294,23 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertCollectionEquals(Arrays.asList("p1"), mgr.lastRemovedlabels);
     assertCollectionEquals(Arrays.asList("p1"), mgr.lastRemovedlabels);
 
 
     mgr.removeFromClusterNodeLabels(ImmutableSet.of("p2", "p3"));
     mgr.removeFromClusterNodeLabels(ImmutableSet.of("p2", "p3"));
-    Assert.assertTrue(mgr.getNodeLabels().isEmpty());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().isEmpty());
+    assertTrue(mgr.getNodeLabels().isEmpty());
+    assertTrue(mgr.getClusterNodeLabelNames().isEmpty());
     assertCollectionEquals(Arrays.asList("p2", "p3"), mgr.lastRemovedlabels);
     assertCollectionEquals(Arrays.asList("p2", "p3"), mgr.lastRemovedlabels);
   }
   }
-  
-  @Test(timeout = 5000) 
-  public void testTrimLabelsWhenAddRemoveNodeLabels() throws IOException {
+
+  @Test
+  @Timeout(5000)
+  void testTrimLabelsWhenAddRemoveNodeLabels() throws IOException {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(" p1"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(" p1"));
     assertCollectionEquals(toSet("p1"), mgr.getClusterNodeLabelNames());
     assertCollectionEquals(toSet("p1"), mgr.getClusterNodeLabelNames());
     mgr.removeFromClusterNodeLabels(toSet("p1 "));
     mgr.removeFromClusterNodeLabels(toSet("p1 "));
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().isEmpty());
+    assertTrue(mgr.getClusterNodeLabelNames().isEmpty());
   }
   }
-  
-  @Test(timeout = 5000) 
-  public void testTrimLabelsWhenModifyLabelsOnNodes() throws IOException {
+
+  @Test
+  @Timeout(5000)
+  void testTrimLabelsWhenModifyLabelsOnNodes() throws IOException {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(" p1", "p2"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet(" p1", "p2"));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1 ")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1 ")));
     assertMapEquals(
     assertMapEquals(
@@ -308,49 +321,51 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
         mgr.getNodeLabels(),
         mgr.getNodeLabels(),
         ImmutableMap.of(toNodeId("n1"), toSet("p2")));
         ImmutableMap.of(toNodeId("n1"), toSet("p2")));
     mgr.removeLabelsFromNode(ImmutableMap.of(toNodeId("n1"), toSet("  p2 ")));
     mgr.removeLabelsFromNode(ImmutableMap.of(toNodeId("n1"), toSet("  p2 ")));
-    Assert.assertTrue(mgr.getNodeLabels().isEmpty());
+    assertTrue(mgr.getNodeLabels().isEmpty());
   }
   }
-  
-  @Test(timeout = 5000)
-  public void testReplaceLabelsOnHostsShouldUpdateNodesBelongTo()
+
+  @Test
+  @Timeout(5000)
+  void testReplaceLabelsOnHostsShouldUpdateNodesBelongTo()
       throws IOException {
       throws IOException {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     assertMapEquals(
     assertMapEquals(
         mgr.getNodeLabels(),
         mgr.getNodeLabels(),
         ImmutableMap.of(toNodeId("n1"), toSet("p1")));
         ImmutableMap.of(toNodeId("n1"), toSet("p1")));
-    
+
     // Replace labels on n1:1 to P2
     // Replace labels on n1:1 to P2
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1:1"), toSet("p2"),
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1:1"), toSet("p2"),
         toNodeId("n1:2"), toSet("p2")));
         toNodeId("n1:2"), toSet("p2")));
     assertMapEquals(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n1"),
     assertMapEquals(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n1"),
         toSet("p1"), toNodeId("n1:1"), toSet("p2"), toNodeId("n1:2"),
         toSet("p1"), toNodeId("n1:1"), toSet("p2"), toNodeId("n1:2"),
         toSet("p2")));
         toSet("p2")));
-    
+
     // Replace labels on n1 to P1, both n1:1/n1 will be P1 now
     // Replace labels on n1 to P1, both n1:1/n1 will be P1 now
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     assertMapEquals(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n1"),
     assertMapEquals(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n1"),
         toSet("p1"), toNodeId("n1:1"), toSet("p1"), toNodeId("n1:2"),
         toSet("p1"), toNodeId("n1:1"), toSet("p1"), toNodeId("n1:2"),
         toSet("p1")));
         toSet("p1")));
-    
+
     // Set labels on n1:1 to P2 again to verify if add/remove works
     // Set labels on n1:1 to P2 again to verify if add/remove works
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1:1"), toSet("p2")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1:1"), toSet("p2")));
   }
   }
 
 
   private void assertNodeLabelsDisabledErrorMessage(IOException e) {
   private void assertNodeLabelsDisabledErrorMessage(IOException e) {
-    Assert.assertEquals(CommonNodeLabelsManager.NODE_LABELS_NOT_ENABLED_ERR,
+    assertEquals(CommonNodeLabelsManager.NODE_LABELS_NOT_ENABLED_ERR,
         e.getMessage());
         e.getMessage());
   }
   }
-  
-  @Test(timeout = 5000)
-  public void testNodeLabelsDisabled() throws IOException {
+
+  @Test
+  @Timeout(5000)
+  void testNodeLabelsDisabled() throws IOException {
     DummyCommonNodeLabelsManager mgr = new DummyCommonNodeLabelsManager();
     DummyCommonNodeLabelsManager mgr = new DummyCommonNodeLabelsManager();
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, false);
     conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, false);
     mgr.init(conf);
     mgr.init(conf);
     mgr.start();
     mgr.start();
     boolean caught = false;
     boolean caught = false;
-    
+
     // add labels
     // add labels
     try {
     try {
       mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x"));
       mgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x"));
@@ -359,9 +374,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       caught = true;
       caught = true;
     }
     }
     // check exception caught
     // check exception caught
-    Assert.assertTrue(caught);
+    assertTrue(caught);
     caught = false;
     caught = false;
-    
+
     // remove labels
     // remove labels
     try {
     try {
       mgr.removeFromClusterNodeLabels(ImmutableSet.of("x"));
       mgr.removeFromClusterNodeLabels(ImmutableSet.of("x"));
@@ -370,9 +385,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       caught = true;
       caught = true;
     }
     }
     // check exception caught
     // check exception caught
-    Assert.assertTrue(caught);
+    assertTrue(caught);
     caught = false;
     caught = false;
-    
+
     // add labels to node
     // add labels to node
     try {
     try {
       mgr.addLabelsToNode(ImmutableMap.of(NodeId.newInstance("host", 0),
       mgr.addLabelsToNode(ImmutableMap.of(NodeId.newInstance("host", 0),
@@ -382,9 +397,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       caught = true;
       caught = true;
     }
     }
     // check exception caught
     // check exception caught
-    Assert.assertTrue(caught);
+    assertTrue(caught);
     caught = false;
     caught = false;
-    
+
     // remove labels from node
     // remove labels from node
     try {
     try {
       mgr.removeLabelsFromNode(ImmutableMap.of(NodeId.newInstance("host", 0),
       mgr.removeLabelsFromNode(ImmutableMap.of(NodeId.newInstance("host", 0),
@@ -394,9 +409,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       caught = true;
       caught = true;
     }
     }
     // check exception caught
     // check exception caught
-    Assert.assertTrue(caught);
+    assertTrue(caught);
     caught = false;
     caught = false;
-    
+
     // replace labels on node
     // replace labels on node
     try {
     try {
       mgr.replaceLabelsOnNode(ImmutableMap.of(NodeId.newInstance("host", 0),
       mgr.replaceLabelsOnNode(ImmutableMap.of(NodeId.newInstance("host", 0),
@@ -406,14 +421,15 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
       caught = true;
       caught = true;
     }
     }
     // check exception caught
     // check exception caught
-    Assert.assertTrue(caught);
+    assertTrue(caught);
     caught = false;
     caught = false;
-    
+
     mgr.close();
     mgr.close();
-  }  
+  }
 
 
-  @Test(timeout = 5000)
-  public void testLabelsToNodes()
+  @Test
+  @Timeout(5000)
+  void testLabelsToNodes()
       throws IOException {
       throws IOException {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
@@ -421,7 +437,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes,
         labelsToNodes,
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n1"))));
+            "p1", toSet(toNodeId("n1"))));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
 
 
@@ -432,8 +448,8 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes,
         labelsToNodes,
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n1")),
-        "p2", toSet(toNodeId("n1:1"),toNodeId("n1:2"))));
+            "p1", toSet(toNodeId("n1")),
+            "p2", toSet(toNodeId("n1:1"), toNodeId("n1:2"))));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
 
 
@@ -443,7 +459,7 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes,
         labelsToNodes,
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n1"),toNodeId("n1:1"),toNodeId("n1:2"))));
+            "p1", toSet(toNodeId("n1"), toNodeId("n1:1"), toNodeId("n1:2"))));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
 
 
@@ -455,9 +471,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes,
         labelsToNodes,
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n1"),toNodeId("n1:2")),
-        "p2", toSet(toNodeId("n1:1")),
-        "p3", toSet(toNodeId("n2"))));
+            "p1", toSet(toNodeId("n1"), toNodeId("n1:2")),
+            "p2", toSet(toNodeId("n1:1")),
+            "p3", toSet(toNodeId("n2"))));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
 
 
@@ -467,20 +483,21 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes,
         labelsToNodes,
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n1"),toNodeId("n1:2")),
-        "p2", toSet(toNodeId("n1:1"))));
+            "p1", toSet(toNodeId("n1"), toNodeId("n1:2")),
+            "p2", toSet(toNodeId("n1:1"))));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
         labelsToNodes, transposeNodeToLabels(mgr.getNodeLabels()));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testLabelsToNodesForSelectedLabels()
+  @Test
+  @Timeout(5000)
+  void testLabelsToNodesForSelectedLabels()
       throws IOException {
       throws IOException {
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addLabelsToNode(
     mgr.addLabelsToNode(
         ImmutableMap.of(
         ImmutableMap.of(
-        toNodeId("n1:1"), toSet("p1"),
-        toNodeId("n1:2"), toSet("p2")));
+            toNodeId("n1:1"), toSet("p1"),
+            toNodeId("n1:2"), toSet("p2")));
     Set<String> setlabels =
     Set<String> setlabels =
         new HashSet<String>(Arrays.asList(new String[]{"p1"}));
         new HashSet<String>(Arrays.asList(new String[]{"p1"}));
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(setlabels),
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(setlabels),
@@ -493,14 +510,14 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         mgr.getLabelsToNodes(setlabels),
         mgr.getLabelsToNodes(setlabels),
         ImmutableMap.of(
         ImmutableMap.of(
-        "p3", toSet(toNodeId("n1"), toNodeId("n1:1"),toNodeId("n1:2"))));
+            "p3", toSet(toNodeId("n1"), toNodeId("n1:1"), toNodeId("n1:2"))));
 
 
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n2"), toSet("p2")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n2"), toSet("p2")));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         mgr.getLabelsToNodes(setlabels),
         mgr.getLabelsToNodes(setlabels),
         ImmutableMap.of(
         ImmutableMap.of(
-        "p2", toSet(toNodeId("n2")),
-        "p3", toSet(toNodeId("n1"), toNodeId("n1:1"),toNodeId("n1:2"))));
+            "p2", toSet(toNodeId("n2")),
+            "p3", toSet(toNodeId("n1"), toNodeId("n1:1"), toNodeId("n1:2"))));
 
 
     mgr.removeLabelsFromNode(ImmutableMap.of(toNodeId("n1"), toSet("p3")));
     mgr.removeLabelsFromNode(ImmutableMap.of(toNodeId("n1"), toSet("p3")));
     setlabels =
     setlabels =
@@ -508,29 +525,30 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         mgr.getLabelsToNodes(setlabels),
         mgr.getLabelsToNodes(setlabels),
         ImmutableMap.of(
         ImmutableMap.of(
-        "p2", toSet(toNodeId("n2"))));
+            "p2", toSet(toNodeId("n2"))));
 
 
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n3"), toSet("p1")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n3"), toSet("p1")));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         mgr.getLabelsToNodes(setlabels),
         mgr.getLabelsToNodes(setlabels),
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n3")),
-        "p2", toSet(toNodeId("n2"))));
+            "p1", toSet(toNodeId("n3")),
+            "p2", toSet(toNodeId("n2"))));
 
 
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n2:2"), toSet("p3")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n2:2"), toSet("p3")));
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         mgr.getLabelsToNodes(setlabels),
         mgr.getLabelsToNodes(setlabels),
         ImmutableMap.of(
         ImmutableMap.of(
-        "p1", toSet(toNodeId("n3")),
-        "p2", toSet(toNodeId("n2")),
-        "p3", toSet(toNodeId("n2:2"))));
+            "p1", toSet(toNodeId("n3")),
+            "p2", toSet(toNodeId("n2")),
+            "p3", toSet(toNodeId("n2:2"))));
     setlabels = new HashSet<String>(Arrays.asList(new String[]{"p1"}));
     setlabels = new HashSet<String>(Arrays.asList(new String[]{"p1"}));
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(setlabels),
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(setlabels),
         ImmutableMap.of("p1", toSet(toNodeId("n3"))));
         ImmutableMap.of("p1", toSet(toNodeId("n3"))));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testNoMoreThanOneLabelExistedInOneHost() throws IOException {
+  @Test
+  @Timeout(5000)
+  void testNoMoreThanOneLabelExistedInOneHost() throws IOException {
     boolean failed = false;
     boolean failed = false;
     // As in YARN-2694, we temporarily disable no more than one label existed in
     // As in YARN-2694, we temporarily disable no more than one label existed in
     // one host
     // one host
@@ -540,14 +558,14 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       failed = true;
       failed = true;
     }
     }
-    Assert.assertTrue("Should failed when set > 1 labels on a host", failed);
+    assertTrue(failed, "Should failed when set > 1 labels on a host");
 
 
     try {
     try {
       mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1", "p2")));
       mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1", "p2")));
     } catch (IOException e) {
     } catch (IOException e) {
       failed = true;
       failed = true;
     }
     }
-    Assert.assertTrue("Should failed when add > 1 labels on a host", failed);
+    assertTrue(failed, "Should failed when add > 1 labels on a host");
 
 
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     // add a same label to a node, #labels in this node is still 1, shouldn't
     // add a same label to a node, #labels in this node is still 1, shouldn't
@@ -558,20 +576,21 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     } catch (IOException e) {
     } catch (IOException e) {
       failed = true;
       failed = true;
     }
     }
-    Assert.assertTrue("Should failed when #labels > 1 on a host after add",
-        failed);
+    assertTrue(failed,
+        "Should failed when #labels > 1 on a host after add");
   }
   }
 
 
   private void verifyNodeLabelAdded(Set<String> expectedAddedLabelNames,
   private void verifyNodeLabelAdded(Set<String> expectedAddedLabelNames,
       Collection<NodeLabel> addedNodeLabels) {
       Collection<NodeLabel> addedNodeLabels) {
-    Assert.assertEquals(expectedAddedLabelNames.size(), addedNodeLabels.size());
+    assertEquals(expectedAddedLabelNames.size(), addedNodeLabels.size());
     for (NodeLabel label : addedNodeLabels) {
     for (NodeLabel label : addedNodeLabels) {
-      Assert.assertTrue(expectedAddedLabelNames.contains(label.getName()));
+      assertTrue(expectedAddedLabelNames.contains(label.getName()));
     }
     }
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testReplaceLabelsOnNodeInDistributedMode() throws Exception {
+  @Test
+  @Timeout(5000)
+  void testReplaceLabelsOnNodeInDistributedMode() throws Exception {
     //create new DummyCommonNodeLabelsManager than the one got from @before
     //create new DummyCommonNodeLabelsManager than the one got from @before
     mgr.stop();
     mgr.stop();
     mgr = new DummyCommonNodeLabelsManager();
     mgr = new DummyCommonNodeLabelsManager();
@@ -587,16 +606,17 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     Set<String> labelsByNode = mgr.getLabelsByNode(toNodeId("n1"));
     Set<String> labelsByNode = mgr.getLabelsByNode(toNodeId("n1"));
 
 
-    Assert.assertNull(
-        "Labels are not expected to be written to the NodeLabelStore",
-        mgr.lastNodeToLabels);
-    Assert.assertNotNull("Updated labels should be available from the Mgr",
-        labelsByNode);
-    Assert.assertTrue(labelsByNode.contains("p1"));
+    assertNull(
+        mgr.lastNodeToLabels,
+        "Labels are not expected to be written to the NodeLabelStore");
+    assertNotNull(labelsByNode,
+        "Updated labels should be available from the Mgr");
+    assertTrue(labelsByNode.contains("p1"));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testLabelsInfoToNodes() throws IOException {
+  @Test
+  @Timeout(5000)
+  void testLabelsInfoToNodes() throws IOException {
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", false),
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", false),
         NodeLabel.newInstance("p2", true), NodeLabel.newInstance("p3", true)));
         NodeLabel.newInstance("p2", true), NodeLabel.newInstance("p3", true)));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p1")));
@@ -605,8 +625,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
         NodeLabel.newInstance("p1", false), toSet(toNodeId("n1"))));
         NodeLabel.newInstance("p1", false), toSet(toNodeId("n1"))));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testGetNodeLabelsInfo() throws IOException {
+  @Test
+  @Timeout(5000)
+  void testGetNodeLabelsInfo() throws IOException {
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", false),
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", false),
         NodeLabel.newInstance("p2", true), NodeLabel.newInstance("p3", false)));
         NodeLabel.newInstance("p2", true), NodeLabel.newInstance("p3", false)));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p2")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1"), toSet("p2")));
@@ -617,8 +638,9 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
         toNodeId("n2"), toSet(NodeLabel.newInstance("p3", false))));
         toNodeId("n2"), toSet(NodeLabel.newInstance("p3", false))));
   }
   }
 
 
-  @Test(timeout = 5000)
-  public void testRemoveNodeLabelsInfo() throws IOException {
+  @Test
+  @Timeout(5000)
+  void testRemoveNodeLabelsInfo() throws IOException {
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", true)));
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", true)));
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p2", true)));
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p2", true)));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1:1"), toSet("p1")));
     mgr.addLabelsToNode(ImmutableMap.of(toNodeId("n1:1"), toSet("p1")));
@@ -628,10 +650,10 @@ public class TestCommonNodeLabelsManager extends NodeLabelTestBase {
     assertLabelsToNodesEquals(
     assertLabelsToNodesEquals(
         labelsToNodes,
         labelsToNodes,
         ImmutableMap.of(
         ImmutableMap.of(
-        "p2", toSet(toNodeId("n1:1"), toNodeId("n1:0"))));
+            "p2", toSet(toNodeId("n1:1"), toNodeId("n1:0"))));
 
 
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), new HashSet()));
     mgr.replaceLabelsOnNode(ImmutableMap.of(toNodeId("n1"), new HashSet()));
     Map<String, Set<NodeId>> labelsToNodes2 = mgr.getLabelsToNodes();
     Map<String, Set<NodeId>> labelsToNodes2 = mgr.getLabelsToNodes();
-    Assert.assertEquals(labelsToNodes2.get("p2"), null);
+    assertNull(labelsToNodes2.get("p2"));
   }
   }
 }
 }

+ 76 - 66
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java

@@ -24,23 +24,24 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Map;
 
 
+import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.Mockito;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.api.records.NodeLabel;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.event.InlineDispatcher;
 import org.apache.hadoop.yarn.event.InlineDispatcher;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.mockito.Mockito;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
-@RunWith(Parameterized.class)
 public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
 public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
   MockNodeLabelManager mgr = null;
   MockNodeLabelManager mgr = null;
   Configuration conf = null;
   Configuration conf = null;
@@ -57,26 +58,15 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     protected void startDispatcher() {
     protected void startDispatcher() {
       // do nothing
       // do nothing
     }
     }
-    
+
     @Override
     @Override
     protected void stopDispatcher() {
     protected void stopDispatcher() {
       // do nothing
       // do nothing
     }
     }
   }
   }
-  
-  public TestFileSystemNodeLabelsStore(String className) {
-    this.storeClassName = className;
-  }
-  
-  @Parameterized.Parameters
-  public static Collection<String[]> getParameters() {
-    return Arrays.asList(
-        new String[][] { { FileSystemNodeLabelsStore.class.getCanonicalName() },
-            { NonAppendableFSNodeLabelStore.class.getCanonicalName() } });
-  }
 
 
-  @Before
-  public void before() throws IOException {
+  public void initTestFileSystemNodeLabelsStore(String className) throws IOException {
+    this.storeClassName = className;
     mgr = new MockNodeLabelManager();
     mgr = new MockNodeLabelManager();
     conf = new Configuration();
     conf = new Configuration();
     conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);
     conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true);
@@ -91,7 +81,13 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
   }
   }
 
 
-  @After
+  public static Collection<String[]> getParameters() {
+    return Arrays.asList(
+        new String[][]{{FileSystemNodeLabelsStore.class.getCanonicalName()},
+            {NonAppendableFSNodeLabelStore.class.getCanonicalName()}});
+  }
+
+  @AfterEach
   public void after() throws IOException {
   public void after() throws IOException {
     if (mgr.store instanceof FileSystemNodeLabelsStore) {
     if (mgr.store instanceof FileSystemNodeLabelsStore) {
       FileSystemNodeLabelsStore fsStore =
       FileSystemNodeLabelsStore fsStore =
@@ -101,9 +97,12 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.stop();
     mgr.stop();
   }
   }
 
 
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Test(timeout = 10000)
-  public void testRecoverWithMirror() throws Exception {
+  @MethodSource("getParameters")
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  @ParameterizedTest
+  @Timeout(10000)
+  void testRecoverWithMirror(String className) throws Exception {
+    initTestFileSystemNodeLabelsStore(className);
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p5", "p6"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p5", "p6"));
@@ -131,15 +130,15 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
 
 
     // check variables
     // check variables
-    Assert.assertEquals(3, mgr.getClusterNodeLabelNames().size());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertEquals(3, mgr.getClusterNodeLabelNames().size());
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("p2", "p4", "p6")));
         Arrays.asList("p2", "p4", "p6")));
 
 
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
         toSet("p2"), toNodeId("n4"), toSet("p4"), toNodeId("n6"), toSet("p6"),
         toSet("p2"), toNodeId("n4"), toSet("p4"), toNodeId("n6"), toSet("p6"),
         toNodeId("n7"), toSet("p6")));
         toNodeId("n7"), toSet("p6")));
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
-            ImmutableMap.of(
+        ImmutableMap.of(
             "p6", toSet(toNodeId("n6"), toNodeId("n7")),
             "p6", toSet(toNodeId("n6"), toNodeId("n7")),
             "p4", toSet(toNodeId("n4")),
             "p4", toSet(toNodeId("n4")),
             "p2", toSet(toNodeId("n2"))));
             "p2", toSet(toNodeId("n2"))));
@@ -151,24 +150,27 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
 
 
     // check variables
     // check variables
-    Assert.assertEquals(3, mgr.getClusterNodeLabelNames().size());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertEquals(3, mgr.getClusterNodeLabelNames().size());
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("p2", "p4", "p6")));
         Arrays.asList("p2", "p4", "p6")));
 
 
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
         toSet("p2"), toNodeId("n4"), toSet("p4"), toNodeId("n6"), toSet("p6"),
         toSet("p2"), toNodeId("n4"), toSet("p4"), toNodeId("n6"), toSet("p6"),
         toNodeId("n7"), toSet("p6")));
         toNodeId("n7"), toSet("p6")));
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
-            ImmutableMap.of(
+        ImmutableMap.of(
             "p6", toSet(toNodeId("n6"), toNodeId("n7")),
             "p6", toSet(toNodeId("n6"), toNodeId("n7")),
             "p4", toSet(toNodeId("n4")),
             "p4", toSet(toNodeId("n4")),
             "p2", toSet(toNodeId("n2"))));
             "p2", toSet(toNodeId("n2"))));
     mgr.stop();
     mgr.stop();
   }
   }
 
 
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Test(timeout = 10000)
-  public void testRecoverWithDistributedNodeLabels() throws Exception {
+  @MethodSource("getParameters")
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  @ParameterizedTest
+  @Timeout(10000)
+  void testRecoverWithDistributedNodeLabels(String className) throws Exception {
+    initTestFileSystemNodeLabelsStore(className);
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p5", "p6"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p5", "p6"));
@@ -190,20 +192,23 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
 
 
     // check variables
     // check variables
-    Assert.assertEquals(3, mgr.getClusterNodeLabels().size());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertEquals(3, mgr.getClusterNodeLabels().size());
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("p2", "p4", "p6")));
         Arrays.asList("p2", "p4", "p6")));
 
 
-    Assert.assertTrue("During recovery in distributed node-labels setup, "
-        + "node to labels mapping should not be recovered ", mgr
-        .getNodeLabels().size() == 0);
+    assertTrue(mgr
+        .getNodeLabels().size() == 0, "During recovery in distributed node-labels setup, "
+        + "node to labels mapping should not be recovered ");
 
 
     mgr.stop();
     mgr.stop();
   }
   }
 
 
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Test(timeout = 10000)
-  public void testEditlogRecover() throws Exception {
+  @MethodSource("getParameters")
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  @ParameterizedTest
+  @Timeout(10000)
+  void testEditlogRecover(String className) throws Exception {
+    initTestFileSystemNodeLabelsStore(className);
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p1", "p2", "p3"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p4"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p5", "p6"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p5", "p6"));
@@ -231,24 +236,27 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
 
 
     // check variables
     // check variables
-    Assert.assertEquals(3, mgr.getClusterNodeLabelNames().size());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertEquals(3, mgr.getClusterNodeLabelNames().size());
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("p2", "p4", "p6")));
         Arrays.asList("p2", "p4", "p6")));
 
 
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
         toSet("p2"), toNodeId("n4"), toSet("p4"), toNodeId("n6"), toSet("p6"),
         toSet("p2"), toNodeId("n4"), toSet("p4"), toNodeId("n6"), toSet("p6"),
         toNodeId("n7"), toSet("p6")));
         toNodeId("n7"), toSet("p6")));
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
-            ImmutableMap.of(
+        ImmutableMap.of(
             "p6", toSet(toNodeId("n6"), toNodeId("n7")),
             "p6", toSet(toNodeId("n6"), toNodeId("n7")),
             "p4", toSet(toNodeId("n4")),
             "p4", toSet(toNodeId("n4")),
             "p2", toSet(toNodeId("n2"))));
             "p2", toSet(toNodeId("n2"))));
     mgr.stop();
     mgr.stop();
   }
   }
-  
-  @SuppressWarnings({ "unchecked", "rawtypes" })
-  @Test (timeout = 10000)
-  public void testSerilizationAfterRecovery() throws Exception {
+
+  @MethodSource("getParameters")
+  @SuppressWarnings({"unchecked", "rawtypes"})
+  @ParameterizedTest
+  @Timeout(10000)
+  void testSerilizationAfterRecovery(String className) throws Exception {
+    initTestFileSystemNodeLabelsStore(className);
     // Add to cluster node labels, p2/p6 are non-exclusive.
     // Add to cluster node labels, p2/p6 are non-exclusive.
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", true),
     mgr.addToCluserNodeLabels(Arrays.asList(NodeLabel.newInstance("p1", true),
         NodeLabel.newInstance("p2", false), NodeLabel.newInstance("p3", true),
         NodeLabel.newInstance("p2", false), NodeLabel.newInstance("p3", true),
@@ -289,8 +297,8 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
 
 
     // check variables
     // check variables
-    Assert.assertEquals(3, mgr.getClusterNodeLabelNames().size());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertEquals(3, mgr.getClusterNodeLabelNames().size());
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("p2", "p4", "p6")));
         Arrays.asList("p2", "p4", "p6")));
 
 
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
     assertMapContains(mgr.getNodeLabels(), ImmutableMap.of(toNodeId("n2"),
@@ -298,13 +306,13 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
         toNodeId("n7"), toSet("p6")));
         toNodeId("n7"), toSet("p6")));
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
     assertLabelsToNodesEquals(mgr.getLabelsToNodes(),
         ImmutableMap.of(
         ImmutableMap.of(
-        "p6", toSet(toNodeId("n6"), toNodeId("n7")),
-        "p4", toSet(toNodeId("n4")),
-        "p2", toSet(toNodeId("n2"))));
+            "p6", toSet(toNodeId("n6"), toNodeId("n7")),
+            "p4", toSet(toNodeId("n4")),
+            "p2", toSet(toNodeId("n2"))));
 
 
-    Assert.assertFalse(mgr.isExclusiveNodeLabel("p2"));
-    Assert.assertTrue(mgr.isExclusiveNodeLabel("p4"));
-    Assert.assertFalse(mgr.isExclusiveNodeLabel("p6"));
+    assertFalse(mgr.isExclusiveNodeLabel("p2"));
+    assertTrue(mgr.isExclusiveNodeLabel("p4"));
+    assertFalse(mgr.isExclusiveNodeLabel("p6"));
 
 
     /*
     /*
      * Add label p7,p8 then shutdown
      * Add label p7,p8 then shutdown
@@ -314,7 +322,7 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p7", "p8"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p7", "p8"));
     mgr.stop();
     mgr.stop();
-    
+
     /*
     /*
      * Restart, add label p9 and shutdown
      * Restart, add label p9 and shutdown
      */
      */
@@ -323,7 +331,7 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p9"));
     mgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("p9"));
     mgr.stop();
     mgr.stop();
-    
+
     /*
     /*
      * Recovery, and see if p9 added
      * Recovery, and see if p9 added
      */
      */
@@ -332,14 +340,16 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
     mgr.start();
     mgr.start();
 
 
     // check variables
     // check variables
-    Assert.assertEquals(6, mgr.getClusterNodeLabelNames().size());
-    Assert.assertTrue(mgr.getClusterNodeLabelNames().containsAll(
+    assertEquals(6, mgr.getClusterNodeLabelNames().size());
+    assertTrue(mgr.getClusterNodeLabelNames().containsAll(
         Arrays.asList("p2", "p4", "p6", "p7", "p8", "p9")));
         Arrays.asList("p2", "p4", "p6", "p7", "p8", "p9")));
     mgr.stop();
     mgr.stop();
   }
   }
 
 
-  @Test
-  public void testRootMkdirOnInitStore() throws Exception {
+  @MethodSource("getParameters")
+  @ParameterizedTest
+  void testRootMkdirOnInitStore(String className) throws Exception {
+    initTestFileSystemNodeLabelsStore(className);
     final FileSystem mockFs = Mockito.mock(FileSystem.class);
     final FileSystem mockFs = Mockito.mock(FileSystem.class);
     FileSystemNodeLabelsStore mockStore = new FileSystemNodeLabelsStore() {
     FileSystemNodeLabelsStore mockStore = new FileSystemNodeLabelsStore() {
       public void initFileSystem(Configuration config) throws IOException {
       public void initFileSystem(Configuration config) throws IOException {
@@ -355,7 +365,7 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
   }
   }
 
 
   private void verifyMkdirsCount(FileSystemNodeLabelsStore store,
   private void verifyMkdirsCount(FileSystemNodeLabelsStore store,
-                                 boolean existsRetVal, int expectedNumOfCalls)
+      boolean existsRetVal, int expectedNumOfCalls)
       throws Exception {
       throws Exception {
     Mockito.when(store.getFs().exists(Mockito.any(
     Mockito.when(store.getFs().exists(Mockito.any(
         Path.class))).thenReturn(existsRetVal);
         Path.class))).thenReturn(existsRetVal);

+ 21 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestNodeLabelUtil.java

@@ -17,13 +17,15 @@
  */
  */
 package org.apache.hadoop.yarn.nodelabels;
 package org.apache.hadoop.yarn.nodelabels;
 
 
-import static org.junit.Assert.fail;
-
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.api.records.NodeAttribute;
 import org.apache.hadoop.yarn.api.records.NodeAttribute;
 import org.apache.hadoop.yarn.api.records.NodeAttributeType;
 import org.apache.hadoop.yarn.api.records.NodeAttributeType;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Test class to verify node label util ops.
  * Test class to verify node label util ops.
@@ -31,7 +33,7 @@ import org.junit.Test;
 public class TestNodeLabelUtil {
 public class TestNodeLabelUtil {
 
 
   @Test
   @Test
-  public void testAttributeValueAddition() {
+  void testAttributeValueAddition() {
     String[] values =
     String[] values =
         new String[]{"1_8", "1.8", "ABZ", "ABZ", "az", "a-z", "a_z",
         new String[]{"1_8", "1.8", "ABZ", "ABZ", "az", "a-z", "a_z",
             "123456789"};
             "123456789"};
@@ -55,7 +57,7 @@ public class TestNodeLabelUtil {
   }
   }
 
 
   @Test
   @Test
-  public void testIsNodeAttributesEquals() {
+  void testIsNodeAttributesEquals() {
     NodeAttribute nodeAttributeCK1V1 = NodeAttribute
     NodeAttribute nodeAttributeCK1V1 = NodeAttribute
         .newInstance(NodeAttribute.PREFIX_CENTRALIZED, "K1",
         .newInstance(NodeAttribute.PREFIX_CENTRALIZED, "K1",
             NodeAttributeType.STRING, "V1");
             NodeAttributeType.STRING, "V1");
@@ -77,45 +79,45 @@ public class TestNodeLabelUtil {
     /*
     /*
      * equals if set size equals and items are all the same
      * equals if set size equals and items are all the same
      */
      */
-    Assert.assertTrue(NodeLabelUtil.isNodeAttributesEquals(null, null));
-    Assert.assertTrue(NodeLabelUtil
+    assertTrue(NodeLabelUtil.isNodeAttributesEquals(null, null));
+    assertTrue(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(), ImmutableSet.of()));
         .isNodeAttributesEquals(ImmutableSet.of(), ImmutableSet.of()));
-    Assert.assertTrue(NodeLabelUtil
+    assertTrue(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
             ImmutableSet.of(nodeAttributeCK1V1Copy)));
             ImmutableSet.of(nodeAttributeCK1V1Copy)));
-    Assert.assertTrue(NodeLabelUtil
+    assertTrue(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeDK1V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeDK1V1),
             ImmutableSet.of(nodeAttributeDK1V1Copy)));
             ImmutableSet.of(nodeAttributeDK1V1Copy)));
-    Assert.assertTrue(NodeLabelUtil.isNodeAttributesEquals(
+    assertTrue(NodeLabelUtil.isNodeAttributesEquals(
         ImmutableSet.of(nodeAttributeCK1V1, nodeAttributeDK1V1),
         ImmutableSet.of(nodeAttributeCK1V1, nodeAttributeDK1V1),
         ImmutableSet.of(nodeAttributeCK1V1Copy, nodeAttributeDK1V1Copy)));
         ImmutableSet.of(nodeAttributeCK1V1Copy, nodeAttributeDK1V1Copy)));
     /*
     /*
      * not equals if set size not equals or items are different
      * not equals if set size not equals or items are different
      */
      */
-    Assert.assertFalse(
+    assertFalse(
         NodeLabelUtil.isNodeAttributesEquals(null, ImmutableSet.of()));
         NodeLabelUtil.isNodeAttributesEquals(null, ImmutableSet.of()));
-    Assert.assertFalse(
+    assertFalse(
         NodeLabelUtil.isNodeAttributesEquals(ImmutableSet.of(), null));
         NodeLabelUtil.isNodeAttributesEquals(ImmutableSet.of(), null));
     // different attribute prefix
     // different attribute prefix
-    Assert.assertFalse(NodeLabelUtil
+    assertFalse(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
             ImmutableSet.of(nodeAttributeDK1V1)));
             ImmutableSet.of(nodeAttributeDK1V1)));
     // different attribute name
     // different attribute name
-    Assert.assertFalse(NodeLabelUtil
+    assertFalse(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeDK1V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeDK1V1),
             ImmutableSet.of(nodeAttributeDK2V1)));
             ImmutableSet.of(nodeAttributeDK2V1)));
     // different attribute value
     // different attribute value
-    Assert.assertFalse(NodeLabelUtil
+    assertFalse(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeDK2V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeDK2V1),
             ImmutableSet.of(nodeAttributeDK2V2)));
             ImmutableSet.of(nodeAttributeDK2V2)));
     // different set
     // different set
-    Assert.assertFalse(NodeLabelUtil
+    assertFalse(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
             ImmutableSet.of()));
             ImmutableSet.of()));
-    Assert.assertFalse(NodeLabelUtil
+    assertFalse(NodeLabelUtil
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
         .isNodeAttributesEquals(ImmutableSet.of(nodeAttributeCK1V1),
             ImmutableSet.of(nodeAttributeCK1V1, nodeAttributeDK1V1)));
             ImmutableSet.of(nodeAttributeCK1V1, nodeAttributeDK1V1)));
-    Assert.assertFalse(NodeLabelUtil.isNodeAttributesEquals(
+    assertFalse(NodeLabelUtil.isNodeAttributesEquals(
         ImmutableSet.of(nodeAttributeCK1V1, nodeAttributeDK1V1),
         ImmutableSet.of(nodeAttributeCK1V1, nodeAttributeDK1V1),
         ImmutableSet.of(nodeAttributeDK1V1)));
         ImmutableSet.of(nodeAttributeDK1V1)));
   }
   }

+ 6 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/resourcetypes/ResourceTypesTestHelper.java

@@ -16,17 +16,18 @@
 
 
 package org.apache.hadoop.yarn.resourcetypes;
 package org.apache.hadoop.yarn.resourcetypes;
 
 
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
 import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
 import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
+
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 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 java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
 /**
 /**
  * Contains helper methods to create Resource and ResourceInformation objects.
  * Contains helper methods to create Resource and ResourceInformation objects.
  * ResourceInformation can be created from a resource name
  * ResourceInformation can be created from a resource name

+ 14 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestDockerClientConfigHandler.java

@@ -16,6 +16,14 @@
  */
  */
 package org.apache.hadoop.yarn.security;
 package org.apache.hadoop.yarn.security;
 
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.nio.ByteBuffer;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
@@ -25,16 +33,9 @@ import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.TokenIdentifier;
 import org.apache.hadoop.security.token.TokenIdentifier;
 import org.apache.hadoop.yarn.util.DockerClientConfigHandler;
 import org.apache.hadoop.yarn.util.DockerClientConfigHandler;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.nio.ByteBuffer;
 
 
-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;
 
 
 /**
 /**
  * Test the functionality of the DockerClientConfigHandler.
  * Test the functionality of the DockerClientConfigHandler.
@@ -51,7 +52,7 @@ public class TestDockerClientConfigHandler {
   private File file;
   private File file;
   private Configuration conf = new Configuration();
   private Configuration conf = new Configuration();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     file = File.createTempFile("docker-client-config", "test");
     file = File.createTempFile("docker-client-config", "test");
     file.deleteOnExit();
     file.deleteOnExit();
@@ -61,7 +62,7 @@ public class TestDockerClientConfigHandler {
   }
   }
 
 
   @Test
   @Test
-  public void testReadCredentialsFromConfigFile() throws Exception {
+  void testReadCredentialsFromConfigFile() throws Exception {
     Credentials credentials =
     Credentials credentials =
         DockerClientConfigHandler.readCredentialsFromConfigFile(
         DockerClientConfigHandler.readCredentialsFromConfigFile(
             new Path(file.toURI()), conf, APPLICATION_ID);
             new Path(file.toURI()), conf, APPLICATION_ID);
@@ -85,7 +86,7 @@ public class TestDockerClientConfigHandler {
   }
   }
 
 
   @Test
   @Test
-  public void testGetCredentialsFromTokensByteBuffer() throws Exception {
+  void testGetCredentialsFromTokensByteBuffer() throws Exception {
     Credentials credentials =
     Credentials credentials =
         DockerClientConfigHandler.readCredentialsFromConfigFile(
         DockerClientConfigHandler.readCredentialsFromConfigFile(
             new Path(file.toURI()), conf, APPLICATION_ID);
             new Path(file.toURI()), conf, APPLICATION_ID);
@@ -110,7 +111,7 @@ public class TestDockerClientConfigHandler {
   }
   }
 
 
   @Test
   @Test
-  public void testWriteDockerCredentialsToPath() throws Exception {
+  void testWriteDockerCredentialsToPath() throws Exception {
     File outFile = File.createTempFile("docker-client-config", "out");
     File outFile = File.createTempFile("docker-client-config", "out");
     outFile.deleteOnExit();
     outFile.deleteOnExit();
     Credentials credentials =
     Credentials credentials =

+ 157 - 176
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java

@@ -21,6 +21,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.IOException;
 
 
+import org.junit.jupiter.api.Test;
+
 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.io.DataInputBuffer;
 import org.apache.hadoop.io.DataInputBuffer;
@@ -43,31 +45,33 @@ import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.server.api.ContainerType;
 import org.apache.hadoop.yarn.server.api.ContainerType;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 public class TestYARNTokenIdentifier {
 public class TestYARNTokenIdentifier {
 
 
   @Test
   @Test
-  public void testNMTokenIdentifier() throws IOException {
+  void testNMTokenIdentifier() throws IOException {
     testNMTokenIdentifier(false);
     testNMTokenIdentifier(false);
   }
   }
 
 
   @Test
   @Test
-  public void testNMTokenIdentifierOldFormat() throws IOException {
+  void testNMTokenIdentifierOldFormat() throws IOException {
     testNMTokenIdentifier(true);
     testNMTokenIdentifier(true);
   }
   }
 
 
   public void testNMTokenIdentifier(boolean oldFormat) throws IOException {
   public void testNMTokenIdentifier(boolean oldFormat) throws IOException {
-    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
-        ApplicationId.newInstance(1, 1), 1);
+    ApplicationAttemptId appAttemptId =
+        ApplicationAttemptId.newInstance(ApplicationId.newInstance(1, 1), 1);
     NodeId nodeId = NodeId.newInstance("host0", 0);
     NodeId nodeId = NodeId.newInstance("host0", 0);
     String applicationSubmitter = "usr0";
     String applicationSubmitter = "usr0";
     int masterKeyId = 1;
     int masterKeyId = 1;
-    
-    NMTokenIdentifier token = new NMTokenIdentifier(
-        appAttemptId, nodeId, applicationSubmitter, masterKeyId);
-    
+
+    NMTokenIdentifier token =
+        new NMTokenIdentifier(appAttemptId, nodeId, applicationSubmitter, masterKeyId);
+
     NMTokenIdentifier anotherToken = new NMTokenIdentifier();
     NMTokenIdentifier anotherToken = new NMTokenIdentifier();
 
 
     byte[] tokenContent;
     byte[] tokenContent;
@@ -79,36 +83,32 @@ public class TestYARNTokenIdentifier {
     DataInputBuffer dib = new DataInputBuffer();
     DataInputBuffer dib = new DataInputBuffer();
     dib.reset(tokenContent, tokenContent.length);
     dib.reset(tokenContent, tokenContent.length);
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
-    
+
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals("Token is not the same after serialization " +
-        "and deserialization.", token, anotherToken);
-    
+    assertEquals(token, anotherToken,
+        "Token is not the same after serialization " + "and deserialization.");
+
     // verify all properties are the same as original
     // verify all properties are the same as original
-    Assert.assertEquals(
-        "appAttemptId from proto is not the same with original token",
-        anotherToken.getApplicationAttemptId(), appAttemptId);
-    
-    Assert.assertEquals(
-        "NodeId from proto is not the same with original token",
-        anotherToken.getNodeId(), nodeId);
-    
-    Assert.assertEquals(
-        "applicationSubmitter from proto is not the same with original token",
-        anotherToken.getApplicationSubmitter(), applicationSubmitter);
-    
-    Assert.assertEquals(
-        "masterKeyId from proto is not the same with original token",
-        anotherToken.getKeyId(), masterKeyId);
+    assertEquals(anotherToken.getApplicationAttemptId(), appAttemptId,
+        "appAttemptId from proto is not the same with original token");
+
+    assertEquals(anotherToken.getNodeId(), nodeId,
+        "NodeId from proto is not the same with original token");
+
+    assertEquals(anotherToken.getApplicationSubmitter(), applicationSubmitter,
+        "applicationSubmitter from proto is not the same with original token");
+
+    assertEquals(anotherToken.getKeyId(), masterKeyId,
+        "masterKeyId from proto is not the same with original token");
   }
   }
 
 
   @Test
   @Test
-  public void testAMRMTokenIdentifier() throws IOException {
+  void testAMRMTokenIdentifier() throws IOException {
     testAMRMTokenIdentifier(false);
     testAMRMTokenIdentifier(false);
   }
   }
 
 
   @Test
   @Test
-  public void testAMRMTokenIdentifierOldFormat() throws IOException {
+  void testAMRMTokenIdentifierOldFormat() throws IOException {
     testAMRMTokenIdentifier(true);
     testAMRMTokenIdentifier(true);
   }
   }
 
 
@@ -130,55 +130,55 @@ public class TestYARNTokenIdentifier {
     DataInputBuffer dib = new DataInputBuffer();
     DataInputBuffer dib = new DataInputBuffer();
     dib.reset(tokenContent, tokenContent.length);
     dib.reset(tokenContent, tokenContent.length);
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
-        
+
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals("Token is not the same after serialization " +
-        "and deserialization.", token, anotherToken);
-        
-    Assert.assertEquals("ApplicationAttemptId from proto is not the same with original token",
-        anotherToken.getApplicationAttemptId(), appAttemptId);
-    
-    Assert.assertEquals("masterKeyId from proto is not the same with original token",
-        anotherToken.getKeyId(), masterKeyId);
+    assertEquals(token, anotherToken,
+        "Token is not the same after serialization " + "and deserialization.");
+
+    assertEquals(anotherToken.getApplicationAttemptId(), appAttemptId,
+        "ApplicationAttemptId from proto is not the same with original token");
+
+    assertEquals(anotherToken.getKeyId(), masterKeyId,
+        "masterKeyId from proto is not the same with original token");
   }
   }
-  
+
   @Test
   @Test
-  public void testClientToAMTokenIdentifier() throws IOException {
+  void testClientToAMTokenIdentifier() throws IOException {
     ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
     ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
         ApplicationId.newInstance(1, 1), 1);
         ApplicationId.newInstance(1, 1), 1);
-    
+
     String clientName = "user";
     String clientName = "user";
-  
+
     ClientToAMTokenIdentifier token = new ClientToAMTokenIdentifier(
     ClientToAMTokenIdentifier token = new ClientToAMTokenIdentifier(
         appAttemptId, clientName);
         appAttemptId, clientName);
-    
+
     ClientToAMTokenIdentifier anotherToken = new ClientToAMTokenIdentifier();
     ClientToAMTokenIdentifier anotherToken = new ClientToAMTokenIdentifier();
-    
+
     byte[] tokenContent = token.getBytes();
     byte[] tokenContent = token.getBytes();
     DataInputBuffer dib = new DataInputBuffer();
     DataInputBuffer dib = new DataInputBuffer();
     dib.reset(tokenContent, tokenContent.length);
     dib.reset(tokenContent, tokenContent.length);
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
-        
+
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals("Token is not the same after serialization " +
-        "and deserialization.", token, anotherToken);
-        
-    Assert.assertEquals("ApplicationAttemptId from proto is not the same with original token",
-        anotherToken.getApplicationAttemptID(), appAttemptId);
-    
-    Assert.assertEquals("clientName from proto is not the same with original token",
-        anotherToken.getClientName(), clientName);
+    assertEquals(token, anotherToken,
+        "Token is not the same after serialization " + "and deserialization.");
+
+    assertEquals(anotherToken.getApplicationAttemptID(), appAttemptId,
+        "ApplicationAttemptId from proto is not the same with original token");
+
+    assertEquals(anotherToken.getClientName(), clientName,
+        "clientName from proto is not the same with original token");
   }
   }
 
 
   @Test
   @Test
-  public void testContainerTokenIdentifierProtoMissingFields()
+  void testContainerTokenIdentifierProtoMissingFields()
       throws IOException {
       throws IOException {
     ContainerTokenIdentifierProto.Builder builder =
     ContainerTokenIdentifierProto.Builder builder =
         ContainerTokenIdentifierProto.newBuilder();
         ContainerTokenIdentifierProto.newBuilder();
     ContainerTokenIdentifierProto proto = builder.build();
     ContainerTokenIdentifierProto proto = builder.build();
-    Assert.assertFalse(proto.hasContainerType());
-    Assert.assertFalse(proto.hasExecutionType());
-    Assert.assertFalse(proto.hasNodeLabelExpression());
+    assertFalse(proto.hasContainerType());
+    assertFalse(proto.hasExecutionType());
+    assertFalse(proto.hasNodeLabelExpression());
 
 
     byte[] tokenData = proto.toByteArray();
     byte[] tokenData = proto.toByteArray();
     DataInputBuffer dib = new DataInputBuffer();
     DataInputBuffer dib = new DataInputBuffer();
@@ -186,21 +186,19 @@ public class TestYARNTokenIdentifier {
     ContainerTokenIdentifier tid = new ContainerTokenIdentifier();
     ContainerTokenIdentifier tid = new ContainerTokenIdentifier();
     tid.readFields(dib);
     tid.readFields(dib);
 
 
-    Assert.assertEquals("container type",
-        ContainerType.TASK, tid.getContainerType());
-    Assert.assertEquals("execution type",
-        ExecutionType.GUARANTEED, tid.getExecutionType());
-    Assert.assertEquals("node label expression",
-        CommonNodeLabelsManager.NO_LABEL, tid.getNodeLabelExpression());
+    assertEquals(ContainerType.TASK, tid.getContainerType(), "container type");
+    assertEquals(ExecutionType.GUARANTEED, tid.getExecutionType(), "execution type");
+    assertEquals(CommonNodeLabelsManager.NO_LABEL, tid.getNodeLabelExpression(),
+        "node label expression");
   }
   }
 
 
   @Test
   @Test
-  public void testContainerTokenIdentifier() throws IOException {
+  void testContainerTokenIdentifier() throws IOException {
     testContainerTokenIdentifier(false, false);
     testContainerTokenIdentifier(false, false);
   }
   }
 
 
   @Test
   @Test
-  public void testContainerTokenIdentifierOldFormat() throws IOException {
+  void testContainerTokenIdentifierOldFormat() throws IOException {
     testContainerTokenIdentifier(true, true);
     testContainerTokenIdentifier(true, true);
     testContainerTokenIdentifier(true, false);
     testContainerTokenIdentifier(true, false);
   }
   }
@@ -236,64 +234,55 @@ public class TestYARNTokenIdentifier {
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
     
     
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals("Token is not the same after serialization " +
-        "and deserialization.", token, anotherToken);
-    
-    Assert.assertEquals(
-        "ContainerID from proto is not the same with original token",
-        anotherToken.getContainerID(), containerID);
-    
-    Assert.assertEquals(
-        "Hostname from proto is not the same with original token",
-        anotherToken.getNmHostAddress(), hostName);
-    
-    Assert.assertEquals(
-        "ApplicationSubmitter from proto is not the same with original token",
-        anotherToken.getApplicationSubmitter(), appSubmitter);
-    
-    Assert.assertEquals(
-        "Resource from proto is not the same with original token",
-        anotherToken.getResource(), r);
-    
-    Assert.assertEquals(
-        "expiryTimeStamp from proto is not the same with original token",
-        anotherToken.getExpiryTimeStamp(), expiryTimeStamp);
-    
-    Assert.assertEquals(
-        "KeyId from proto is not the same with original token",
-        anotherToken.getMasterKeyId(), masterKeyId);
-    
-    Assert.assertEquals(
-        "RMIdentifier from proto is not the same with original token",
-        anotherToken.getRMIdentifier(), rmIdentifier);
-    
-    Assert.assertEquals(
-        "Priority from proto is not the same with original token",
-        anotherToken.getPriority(), priority);
-    
-    Assert.assertEquals(
-        "CreationTime from proto is not the same with original token",
-        anotherToken.getCreationTime(), creationTime);
+    assertEquals(token, anotherToken,
+        "Token is not the same after serialization " + "and deserialization.");
+
+    assertEquals(anotherToken.getContainerID(), containerID,
+        "ContainerID from proto is not the same with original token");
+
+    assertEquals(anotherToken.getNmHostAddress(), hostName,
+        "Hostname from proto is not the same with original token");
+
+    assertEquals(anotherToken.getApplicationSubmitter(), appSubmitter,
+        "ApplicationSubmitter from proto is not the same with original token");
+
+    assertEquals(anotherToken.getResource(), r,
+        "Resource from proto is not the same with original token");
+
+    assertEquals(anotherToken.getExpiryTimeStamp(), expiryTimeStamp,
+        "expiryTimeStamp from proto is not the same with original token");
+
+    assertEquals(anotherToken.getMasterKeyId(), masterKeyId,
+        "KeyId from proto is not the same with original token");
+
+    assertEquals(anotherToken.getRMIdentifier(), rmIdentifier,
+        "RMIdentifier from proto is not the same with original token");
+
+    assertEquals(anotherToken.getPriority(), priority,
+        "Priority from proto is not the same with original token");
+
+    assertEquals(anotherToken.getCreationTime(), creationTime,
+        "CreationTime from proto is not the same with original token");
     
     
-    Assert.assertNull(anotherToken.getLogAggregationContext());
+    assertNull(anotherToken.getLogAggregationContext());
 
 
-    Assert.assertEquals(CommonNodeLabelsManager.NO_LABEL,
+    assertEquals(CommonNodeLabelsManager.NO_LABEL,
         anotherToken.getNodeLabelExpression());
         anotherToken.getNodeLabelExpression());
 
 
-    Assert.assertEquals(ContainerType.TASK,
+    assertEquals(ContainerType.TASK,
         anotherToken.getContainerType());
         anotherToken.getContainerType());
 
 
-    Assert.assertEquals(ExecutionType.GUARANTEED,
+    assertEquals(ExecutionType.GUARANTEED,
         anotherToken.getExecutionType());
         anotherToken.getExecutionType());
   }
   }
 
 
   @Test
   @Test
-  public void testRMDelegationTokenIdentifier() throws IOException {
+  void testRMDelegationTokenIdentifier() throws IOException {
     testRMDelegationTokenIdentifier(false);
     testRMDelegationTokenIdentifier(false);
   }
   }
 
 
   @Test
   @Test
-  public void testRMDelegationTokenIdentifierOldFormat() throws IOException {
+  void testRMDelegationTokenIdentifierOldFormat() throws IOException {
     testRMDelegationTokenIdentifier(true);
     testRMDelegationTokenIdentifier(true);
   }
   }
 
 
@@ -333,30 +322,22 @@ public class TestYARNTokenIdentifier {
       dib.close();
       dib.close();
     }
     }
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals(
-        "Token is not the same after serialization and deserialization.",
-        originalToken, anotherToken);
-    Assert.assertEquals(
-        "owner from proto is not the same with original token",
-        owner, anotherToken.getOwner());
-    Assert.assertEquals(
-        "renewer from proto is not the same with original token",
-        renewer, anotherToken.getRenewer());
-    Assert.assertEquals(
-        "realUser from proto is not the same with original token",
-        realUser, anotherToken.getRealUser());
-    Assert.assertEquals(
-        "issueDate from proto is not the same with original token",
-        issueDate, anotherToken.getIssueDate());
-    Assert.assertEquals(
-        "maxDate from proto is not the same with original token",
-        maxDate, anotherToken.getMaxDate());
-    Assert.assertEquals(
-        "sequenceNumber from proto is not the same with original token",
-        sequenceNumber, anotherToken.getSequenceNumber());
-    Assert.assertEquals(
-        "masterKeyId from proto is not the same with original token",
-        masterKeyId, anotherToken.getMasterKeyId());
+    assertEquals(originalToken, anotherToken,
+        "Token is not the same after serialization and deserialization.");
+    assertEquals(owner, anotherToken.getOwner(),
+        "owner from proto is not the same with original token");
+    assertEquals(renewer, anotherToken.getRenewer(),
+        "renewer from proto is not the same with original token");
+    assertEquals(realUser, anotherToken.getRealUser(),
+        "realUser from proto is not the same with original token");
+    assertEquals(issueDate, anotherToken.getIssueDate(),
+        "issueDate from proto is not the same with original token");
+    assertEquals(maxDate, anotherToken.getMaxDate(),
+        "maxDate from proto is not the same with original token");
+    assertEquals(sequenceNumber, anotherToken.getSequenceNumber(),
+        "sequenceNumber from proto is not the same with original token");
+    assertEquals(masterKeyId, anotherToken.getMasterKeyId(),
+        "masterKeyId from proto is not the same with original token");
 
 
     // Test getProto
     // Test getProto
     YARNDelegationTokenIdentifierProto tokenProto = originalToken.getProto();
     YARNDelegationTokenIdentifierProto tokenProto = originalToken.getProto();
@@ -372,15 +353,15 @@ public class TestYARNTokenIdentifier {
     readToken.readFields(db);
     readToken.readFields(db);
 
 
     // Verify if read token equals with original token
     // Verify if read token equals with original token
-    Assert.assertEquals("Token from getProto is not the same after " +
-        "serialization and deserialization.", originalToken, readToken);
+    assertEquals(originalToken, readToken, "Token from getProto is not the same after " +
+        "serialization and deserialization.");
     db.close();
     db.close();
     out.close();
     out.close();
   }
   }
-  
+
   @Test
   @Test
-  public void testTimelineDelegationTokenIdentifier() throws IOException {
-    
+  void testTimelineDelegationTokenIdentifier() throws IOException {
+
     Text owner = new Text("user1");
     Text owner = new Text("user1");
     Text renewer = new Text("user2");
     Text renewer = new Text("user2");
     Text realUser = new Text("user3");
     Text realUser = new Text("user3");
@@ -388,50 +369,50 @@ public class TestYARNTokenIdentifier {
     long maxDate = 2;
     long maxDate = 2;
     int sequenceNumber = 3;
     int sequenceNumber = 3;
     int masterKeyId = 4;
     int masterKeyId = 4;
-    
-    TimelineDelegationTokenIdentifier token = 
+
+    TimelineDelegationTokenIdentifier token =
         new TimelineDelegationTokenIdentifier(owner, renewer, realUser);
         new TimelineDelegationTokenIdentifier(owner, renewer, realUser);
     token.setIssueDate(issueDate);
     token.setIssueDate(issueDate);
     token.setMaxDate(maxDate);
     token.setMaxDate(maxDate);
     token.setSequenceNumber(sequenceNumber);
     token.setSequenceNumber(sequenceNumber);
     token.setMasterKeyId(masterKeyId);
     token.setMasterKeyId(masterKeyId);
-    
-    TimelineDelegationTokenIdentifier anotherToken = 
+
+    TimelineDelegationTokenIdentifier anotherToken =
         new TimelineDelegationTokenIdentifier();
         new TimelineDelegationTokenIdentifier();
-    
+
     byte[] tokenContent = token.getBytes();
     byte[] tokenContent = token.getBytes();
     DataInputBuffer dib = new DataInputBuffer();
     DataInputBuffer dib = new DataInputBuffer();
     dib.reset(tokenContent, tokenContent.length);
     dib.reset(tokenContent, tokenContent.length);
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
-        
+
     // verify the whole record equals with original record
     // verify the whole record equals with original record
-    Assert.assertEquals("Token is not the same after serialization " +
-        "and deserialization.", token, anotherToken);
-    
-    Assert.assertEquals("owner from proto is not the same with original token",
-        anotherToken.getOwner(), owner);
-    
-    Assert.assertEquals("renewer from proto is not the same with original token",
-        anotherToken.getRenewer(), renewer);
-    
-    Assert.assertEquals("realUser from proto is not the same with original token",
-        anotherToken.getRealUser(), realUser);
-    
-    Assert.assertEquals("issueDate from proto is not the same with original token",
-        anotherToken.getIssueDate(), issueDate);
-    
-    Assert.assertEquals("maxDate from proto is not the same with original token",
-        anotherToken.getMaxDate(), maxDate);
-    
-    Assert.assertEquals("sequenceNumber from proto is not the same with original token",
-        anotherToken.getSequenceNumber(), sequenceNumber);
-    
-    Assert.assertEquals("masterKeyId from proto is not the same with original token",
-        anotherToken.getMasterKeyId(), masterKeyId);
+    assertEquals(token, anotherToken,
+        "Token is not the same after serialization " + "and deserialization.");
+
+    assertEquals(anotherToken.getOwner(), owner,
+        "owner from proto is not the same with original token");
+
+    assertEquals(anotherToken.getRenewer(), renewer,
+        "renewer from proto is not the same with original token");
+
+    assertEquals(anotherToken.getRealUser(), realUser,
+        "realUser from proto is not the same with original token");
+
+    assertEquals(anotherToken.getIssueDate(), issueDate,
+        "issueDate from proto is not the same with original token");
+
+    assertEquals(anotherToken.getMaxDate(), maxDate,
+        "maxDate from proto is not the same with original token");
+
+    assertEquals(anotherToken.getSequenceNumber(), sequenceNumber,
+        "sequenceNumber from proto is not the same with original token");
+
+    assertEquals(anotherToken.getMasterKeyId(), masterKeyId,
+        "masterKeyId from proto is not the same with original token");
   }
   }
 
 
   @Test
   @Test
-  public void testParseTimelineDelegationTokenIdentifierRenewer() throws IOException {
+  void testParseTimelineDelegationTokenIdentifierRenewer() throws IOException {
     // Server side when generation a timeline DT
     // Server side when generation a timeline DT
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTH_TO_LOCAL,
     conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTH_TO_LOCAL,
@@ -442,11 +423,11 @@ public class TestYARNTokenIdentifier {
     Text realUser = new Text("realUser");
     Text realUser = new Text("realUser");
     TimelineDelegationTokenIdentifier token =
     TimelineDelegationTokenIdentifier token =
         new TimelineDelegationTokenIdentifier(owner, renewer, realUser);
         new TimelineDelegationTokenIdentifier(owner, renewer, realUser);
-    Assert.assertEquals(new Text("yarn"), token.getRenewer());
+    assertEquals(new Text("yarn"), token.getRenewer());
   }
   }
 
 
   @Test
   @Test
-  public void testAMContainerTokenIdentifier() throws IOException {
+  void testAMContainerTokenIdentifier() throws IOException {
     ContainerId containerID = ContainerId.newContainerId(
     ContainerId containerID = ContainerId.newContainerId(
         ApplicationAttemptId.newInstance(ApplicationId.newInstance(
         ApplicationAttemptId.newInstance(ApplicationId.newInstance(
             1, 1), 1), 1);
             1, 1), 1), 1);
@@ -471,10 +452,10 @@ public class TestYARNTokenIdentifier {
     dib.reset(tokenContent, tokenContent.length);
     dib.reset(tokenContent, tokenContent.length);
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
 
 
-    Assert.assertEquals(ContainerType.APPLICATION_MASTER,
+    assertEquals(ContainerType.APPLICATION_MASTER,
         anotherToken.getContainerType());
         anotherToken.getContainerType());
 
 
-    Assert.assertEquals(ExecutionType.GUARANTEED,
+    assertEquals(ExecutionType.GUARANTEED,
         anotherToken.getExecutionType());
         anotherToken.getExecutionType());
 
 
     token =
     token =
@@ -490,10 +471,10 @@ public class TestYARNTokenIdentifier {
     dib.reset(tokenContent, tokenContent.length);
     dib.reset(tokenContent, tokenContent.length);
     anotherToken.readFields(dib);
     anotherToken.readFields(dib);
 
 
-    Assert.assertEquals(ContainerType.TASK,
+    assertEquals(ContainerType.TASK,
         anotherToken.getContainerType());
         anotherToken.getContainerType());
 
 
-    Assert.assertEquals(ExecutionType.OPPORTUNISTIC,
+    assertEquals(ExecutionType.OPPORTUNISTIC,
         anotherToken.getExecutionType());
         anotherToken.getExecutionType());
   }
   }
 
 

+ 37 - 36
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/server/security/TestApplicationACLsManager.java

@@ -17,18 +17,19 @@
  */
  */
 package org.apache.hadoop.yarn.server.security;
 package org.apache.hadoop.yarn.server.security;
 
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
 import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestApplicationACLsManager {
 public class TestApplicationACLsManager {
 
 
@@ -39,14 +40,14 @@ public class TestApplicationACLsManager {
   private static final String TESTUSER3 = "testuser3";
   private static final String TESTUSER3 = "testuser3";
 
 
   @Test
   @Test
-  public void testCheckAccess() {
+  void testCheckAccess() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE,
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE,
         true);
         true);
     conf.set(YarnConfiguration.YARN_ADMIN_ACL,
     conf.set(YarnConfiguration.YARN_ADMIN_ACL,
         ADMIN_USER);
         ADMIN_USER);
     ApplicationACLsManager aclManager = new ApplicationACLsManager(conf);
     ApplicationACLsManager aclManager = new ApplicationACLsManager(conf);
-    Map<ApplicationAccessType, String> aclMap = 
+    Map<ApplicationAccessType, String> aclMap =
         new HashMap<ApplicationAccessType, String>();
         new HashMap<ApplicationAccessType, String>();
     aclMap.put(ApplicationAccessType.VIEW_APP, TESTUSER1 + "," + TESTUSER3);
     aclMap.put(ApplicationAccessType.VIEW_APP, TESTUSER1 + "," + TESTUSER3);
     aclMap.put(ApplicationAccessType.MODIFY_APP, TESTUSER1);
     aclMap.put(ApplicationAccessType.MODIFY_APP, TESTUSER1);
@@ -56,46 +57,46 @@ public class TestApplicationACLsManager {
     //User in ACL, should be allowed access
     //User in ACL, should be allowed access
     UserGroupInformation testUser1 = UserGroupInformation
     UserGroupInformation testUser1 = UserGroupInformation
         .createRemoteUser(TESTUSER1);
         .createRemoteUser(TESTUSER1);
-    assertTrue(aclManager.checkAccess(testUser1, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(testUser1, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(testUser1, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(testUser1, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     //User NOT in ACL, should not be allowed access
     //User NOT in ACL, should not be allowed access
     UserGroupInformation testUser2 = UserGroupInformation
     UserGroupInformation testUser2 = UserGroupInformation
         .createRemoteUser(TESTUSER2);
         .createRemoteUser(TESTUSER2);
-    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.VIEW_APP, 
+    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.MODIFY_APP, 
+    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     //User has View access, but not modify access
     //User has View access, but not modify access
     UserGroupInformation testUser3 = UserGroupInformation
     UserGroupInformation testUser3 = UserGroupInformation
         .createRemoteUser(TESTUSER3);
         .createRemoteUser(TESTUSER3);
-    assertTrue(aclManager.checkAccess(testUser3, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(testUser3, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertFalse(aclManager.checkAccess(testUser3, ApplicationAccessType.MODIFY_APP, 
+    assertFalse(aclManager.checkAccess(testUser3, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     //Application Owner should have all access
     //Application Owner should have all access
     UserGroupInformation appOwner = UserGroupInformation
     UserGroupInformation appOwner = UserGroupInformation
         .createRemoteUser(APP_OWNER);
         .createRemoteUser(APP_OWNER);
-    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     //Admin should have all access
     //Admin should have all access
     UserGroupInformation adminUser = UserGroupInformation
     UserGroupInformation adminUser = UserGroupInformation
         .createRemoteUser(ADMIN_USER);
         .createRemoteUser(ADMIN_USER);
-    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
   }
   }
 
 
   @Test
   @Test
-  public void testCheckAccessWithNullACLS() {
+  void testCheckAccessWithNullACLS() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE,
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE,
         true);
         true);
@@ -108,30 +109,30 @@ public class TestApplicationACLsManager {
     //Application ACL is not added
     //Application ACL is not added
 
 
     //Application Owner should have all access even if Application ACL is not added
     //Application Owner should have all access even if Application ACL is not added
-    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     //Admin should have all access
     //Admin should have all access
     UserGroupInformation adminUser = UserGroupInformation
     UserGroupInformation adminUser = UserGroupInformation
         .createRemoteUser(ADMIN_USER);
         .createRemoteUser(ADMIN_USER);
-    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     // A regular user should Not have access
     // A regular user should Not have access
     UserGroupInformation testUser1 = UserGroupInformation
     UserGroupInformation testUser1 = UserGroupInformation
         .createRemoteUser(TESTUSER1);
         .createRemoteUser(TESTUSER1);
-    assertFalse(aclManager.checkAccess(testUser1, ApplicationAccessType.VIEW_APP, 
+    assertFalse(aclManager.checkAccess(testUser1, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertFalse(aclManager.checkAccess(testUser1, ApplicationAccessType.MODIFY_APP, 
+    assertFalse(aclManager.checkAccess(testUser1, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
   }
   }
-  
+
   @Test
   @Test
-  public void testCheckAccessWithPartialACLS() {
+  void testCheckAccessWithPartialACLS() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE,
     conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE,
         true);
         true);
@@ -141,40 +142,40 @@ public class TestApplicationACLsManager {
     UserGroupInformation appOwner = UserGroupInformation
     UserGroupInformation appOwner = UserGroupInformation
         .createRemoteUser(APP_OWNER);
         .createRemoteUser(APP_OWNER);
     // Add only the VIEW ACLS
     // Add only the VIEW ACLS
-    Map<ApplicationAccessType, String> aclMap = 
+    Map<ApplicationAccessType, String> aclMap =
         new HashMap<ApplicationAccessType, String>();
         new HashMap<ApplicationAccessType, String>();
-    aclMap.put(ApplicationAccessType.VIEW_APP, TESTUSER1 );
+    aclMap.put(ApplicationAccessType.VIEW_APP, TESTUSER1);
     ApplicationId appId = ApplicationId.newInstance(1, 1);
     ApplicationId appId = ApplicationId.newInstance(1, 1);
     aclManager.addApplication(appId, aclMap);
     aclManager.addApplication(appId, aclMap);
 
 
     //Application Owner should have all access even if Application ACL is not added
     //Application Owner should have all access even if Application ACL is not added
-    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(appOwner, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     //Admin should have all access
     //Admin should have all access
     UserGroupInformation adminUser = UserGroupInformation
     UserGroupInformation adminUser = UserGroupInformation
         .createRemoteUser(ADMIN_USER);
         .createRemoteUser(ADMIN_USER);
-    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.MODIFY_APP, 
+    assertTrue(aclManager.checkAccess(adminUser, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
 
 
     // testuser1 should  have view access only
     // testuser1 should  have view access only
     UserGroupInformation testUser1 = UserGroupInformation
     UserGroupInformation testUser1 = UserGroupInformation
         .createRemoteUser(TESTUSER1);
         .createRemoteUser(TESTUSER1);
-    assertTrue(aclManager.checkAccess(testUser1, ApplicationAccessType.VIEW_APP, 
+    assertTrue(aclManager.checkAccess(testUser1, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertFalse(aclManager.checkAccess(testUser1, ApplicationAccessType.MODIFY_APP, 
+    assertFalse(aclManager.checkAccess(testUser1, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    
+
     // A testuser2 should Not have access
     // A testuser2 should Not have access
     UserGroupInformation testUser2 = UserGroupInformation
     UserGroupInformation testUser2 = UserGroupInformation
         .createRemoteUser(TESTUSER2);
         .createRemoteUser(TESTUSER2);
-    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.VIEW_APP, 
+    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.VIEW_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
-    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.MODIFY_APP, 
+    assertFalse(aclManager.checkAccess(testUser2, ApplicationAccessType.MODIFY_APP,
         APP_OWNER, appId));
         APP_OWNER, appId));
   }
   }
 }
 }

+ 17 - 16
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestAdHocLogDumper.java

@@ -18,23 +18,24 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
+import java.io.File;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 
 
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 import org.apache.hadoop.util.Time;
 import org.apache.hadoop.util.Time;
 import org.apache.log4j.Appender;
 import org.apache.log4j.Appender;
 import org.apache.log4j.AppenderSkeleton;
 import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Priority;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.LogManager;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.io.File;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.log4j.Priority;
 
 
 import static org.apache.hadoop.util.GenericsUtil.isLog4jLogger;
 import static org.apache.hadoop.util.GenericsUtil.isLog4jLogger;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestAdHocLogDumper {
 public class TestAdHocLogDumper {
 
 
@@ -42,14 +43,14 @@ public class TestAdHocLogDumper {
       LoggerFactory.getLogger(TestAdHocLogDumper.class);
       LoggerFactory.getLogger(TestAdHocLogDumper.class);
 
 
   @Test
   @Test
-  public void testDumpingSchedulerLogs() throws Exception {
+  void testDumpingSchedulerLogs() throws Exception {
 
 
     Map<Appender, Priority> levels = new HashMap<>();
     Map<Appender, Priority> levels = new HashMap<>();
     String logFilename = "test.log";
     String logFilename = "test.log";
     Logger logger = LoggerFactory.getLogger(TestAdHocLogDumper.class);
     Logger logger = LoggerFactory.getLogger(TestAdHocLogDumper.class);
     if (isLog4jLogger(this.getClass())) {
     if (isLog4jLogger(this.getClass())) {
-      for (Enumeration appenders = LogManager.getRootLogger().
-          getAllAppenders(); appenders.hasMoreElements();) {
+      for (Enumeration appenders =
+           LogManager.getRootLogger().getAllAppenders(); appenders.hasMoreElements();) {
         Object obj = appenders.nextElement();
         Object obj = appenders.nextElement();
         if (obj instanceof AppenderSkeleton) {
         if (obj instanceof AppenderSkeleton) {
           AppenderSkeleton appender = (AppenderSkeleton) obj;
           AppenderSkeleton appender = (AppenderSkeleton) obj;
@@ -64,11 +65,11 @@ public class TestAdHocLogDumper {
     LOG.debug("test message 1");
     LOG.debug("test message 1");
     LOG.info("test message 2");
     LOG.info("test message 2");
     File logFile = new File(logFilename);
     File logFile = new File(logFilename);
-    Assert.assertTrue(logFile.exists());
+    assertTrue(logFile.exists());
     Thread.sleep(2000);
     Thread.sleep(2000);
     long lastWrite = logFile.lastModified();
     long lastWrite = logFile.lastModified();
-    Assert.assertTrue(lastWrite < Time.now());
-    Assert.assertTrue(logFile.length() != 0);
+    assertTrue(lastWrite < Time.now());
+    assertTrue(logFile.length() != 0);
 
 
     // make sure levels are set back to their original values
     // make sure levels are set back to their original values
     if (isLog4jLogger(this.getClass())) {
     if (isLog4jLogger(this.getClass())) {
@@ -77,12 +78,12 @@ public class TestAdHocLogDumper {
         Object obj = appenders.nextElement();
         Object obj = appenders.nextElement();
         if (obj instanceof AppenderSkeleton) {
         if (obj instanceof AppenderSkeleton) {
           AppenderSkeleton appender = (AppenderSkeleton) obj;
           AppenderSkeleton appender = (AppenderSkeleton) obj;
-          Assert.assertEquals(levels.get(appender), appender.getThreshold());
+          assertEquals(levels.get(appender), appender.getThreshold());
         }
         }
       }
       }
     }
     }
     boolean del = logFile.delete();
     boolean del = logFile.delete();
-    if(!del) {
+    if (!del) {
       LOG.info("Couldn't clean up after test");
       LOG.info("Couldn't clean up after test");
     }
     }
   }
   }

+ 14 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestApps.java

@@ -17,22 +17,23 @@
 */
 */
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.util.Shell;
-import org.junit.Test;
-
 import java.io.File;
 import java.io.File;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import org.junit.jupiter.api.Test;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.util.Shell;
+
 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.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestApps {
 public class TestApps {
   @Test
   @Test
-  public void testSetEnvFromInputString() {
+  void testSetEnvFromInputString() {
     Map<String, String> environment = new HashMap<String, String>();
     Map<String, String> environment = new HashMap<String, String>();
     environment.put("JAVA_HOME", "/path/jdk");
     environment.put("JAVA_HOME", "/path/jdk");
     String goodEnv = "a1=1,b_2=2,_c=3,d=4,e=,f_win=%JAVA_HOME%"
     String goodEnv = "a1=1,b_2=2,_c=3,d=4,e=,f_win=%JAVA_HOME%"
@@ -64,7 +65,7 @@ public class TestApps {
   }
   }
 
 
   @Test
   @Test
-  public void testSetEnvFromInputProperty() {
+  void testSetEnvFromInputProperty() {
     Configuration conf = new Configuration(false);
     Configuration conf = new Configuration(false);
     Map<String, String> env = new HashMap<>();
     Map<String, String> env = new HashMap<>();
     String propName = "mapreduce.map.env";
     String propName = "mapreduce.map.env";
@@ -91,7 +92,7 @@ public class TestApps {
   }
   }
 
 
   @Test
   @Test
-  public void testSetEnvFromInputPropertyDefault() {
+  void testSetEnvFromInputPropertyDefault() {
     Configuration conf = new Configuration(false);
     Configuration conf = new Configuration(false);
     Map<String, String> env = new HashMap<>();
     Map<String, String> env = new HashMap<>();
     String propName = "mapreduce.map.env";
     String propName = "mapreduce.map.env";
@@ -122,7 +123,7 @@ public class TestApps {
   }
   }
 
 
   @Test
   @Test
-  public void testSetEnvFromInputPropertyOverrideDefault() {
+  void testSetEnvFromInputPropertyOverrideDefault() {
     Configuration conf = new Configuration(false);
     Configuration conf = new Configuration(false);
     Map<String, String> env = new HashMap<>();
     Map<String, String> env = new HashMap<>();
 
 
@@ -152,7 +153,7 @@ public class TestApps {
   }
   }
 
 
   @Test
   @Test
-  public void testSetEnvFromInputPropertyCommas() {
+  void testSetEnvFromInputPropertyCommas() {
     Configuration conf = new Configuration(false);
     Configuration conf = new Configuration(false);
     Map<String, String> env = new HashMap<>();
     Map<String, String> env = new HashMap<>();
     String propName = "mapreduce.reduce.env";
     String propName = "mapreduce.reduce.env";
@@ -176,7 +177,7 @@ public class TestApps {
   }
   }
 
 
   @Test
   @Test
-  public void testSetEnvFromInputPropertyNull() {
+  void testSetEnvFromInputPropertyNull() {
     Configuration conf = new Configuration(false);
     Configuration conf = new Configuration(false);
     Map<String, String> env = new HashMap<>();
     Map<String, String> env = new HashMap<>();
     String propName = "mapreduce.map.env";
     String propName = "mapreduce.map.env";

+ 35 - 32
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestBoundedAppender.java

@@ -18,48 +18,49 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test class for {@link BoundedAppender}.
  * Test class for {@link BoundedAppender}.
  */
  */
 public class TestBoundedAppender {
 public class TestBoundedAppender {
-  @Rule
-  public ExpectedException expected = ExpectedException.none();
 
 
   @Test
   @Test
-  public void initWithZeroLimitThrowsException() {
-    expected.expect(IllegalArgumentException.class);
-    expected.expectMessage("limit should be positive");
+  void initWithZeroLimitThrowsException() {
+    Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
 
 
-    new BoundedAppender(0);
+      new BoundedAppender(0);
+    });
+    assertTrue(exception.getMessage().contains("limit should be positive"));
   }
   }
 
 
   @Test
   @Test
-  public void nullAppendedNullStringRead() {
+  void nullAppendedNullStringRead() {
     final BoundedAppender boundedAppender = new BoundedAppender(4);
     final BoundedAppender boundedAppender = new BoundedAppender(4);
     boundedAppender.append(null);
     boundedAppender.append(null);
 
 
-    assertEquals("null appended, \"null\" read", "null",
-        boundedAppender.toString());
+    assertEquals("null",
+        boundedAppender.toString(),
+        "null appended, \"null\" read");
   }
   }
 
 
   @Test
   @Test
-  public void appendBelowLimitOnceValueIsReadCorrectly() {
+  void appendBelowLimitOnceValueIsReadCorrectly() {
     final BoundedAppender boundedAppender = new BoundedAppender(2);
     final BoundedAppender boundedAppender = new BoundedAppender(2);
 
 
     boundedAppender.append("ab");
     boundedAppender.append("ab");
 
 
-    assertEquals("value appended is read correctly", "ab",
-        boundedAppender.toString());
+    assertEquals("ab",
+        boundedAppender.toString(),
+        "value appended is read correctly");
   }
   }
 
 
   @Test
   @Test
-  public void appendValuesBelowLimitAreReadCorrectlyInFifoOrder() {
+  void appendValuesBelowLimitAreReadCorrectlyInFifoOrder() {
     final BoundedAppender boundedAppender = new BoundedAppender(3);
     final BoundedAppender boundedAppender = new BoundedAppender(3);
 
 
     boundedAppender.append("ab");
     boundedAppender.append("ab");
@@ -67,13 +68,13 @@ public class TestBoundedAppender {
     boundedAppender.append("e");
     boundedAppender.append("e");
     boundedAppender.append("fg");
     boundedAppender.append("fg");
 
 
-    assertEquals("last values appended fitting limit are read correctly",
-        String.format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 7, "efg"),
-        boundedAppender.toString());
+    assertEquals(String.format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 7, "efg"),
+        boundedAppender.toString(),
+        "last values appended fitting limit are read correctly");
   }
   }
 
 
   @Test
   @Test
-  public void appendLastAboveLimitPreservesLastMessagePostfix() {
+  void appendLastAboveLimitPreservesLastMessagePostfix() {
     final BoundedAppender boundedAppender = new BoundedAppender(3);
     final BoundedAppender boundedAppender = new BoundedAppender(3);
 
 
     boundedAppender.append("ab");
     boundedAppender.append("ab");
@@ -81,35 +82,37 @@ public class TestBoundedAppender {
     boundedAppender.append("fghij");
     boundedAppender.append("fghij");
 
 
     assertEquals(
     assertEquals(
-        "last value appended above limit postfix is read correctly", String
+        String
             .format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 10, "hij"),
             .format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 10, "hij"),
-        boundedAppender.toString());
+        boundedAppender.toString(),
+        "last value appended above limit postfix is read correctly");
   }
   }
 
 
   @Test
   @Test
-  public void appendMiddleAboveLimitPreservesLastMessageAndMiddlePostfix() {
+  void appendMiddleAboveLimitPreservesLastMessageAndMiddlePostfix() {
     final BoundedAppender boundedAppender = new BoundedAppender(3);
     final BoundedAppender boundedAppender = new BoundedAppender(3);
 
 
     boundedAppender.append("ab");
     boundedAppender.append("ab");
     boundedAppender.append("cde");
     boundedAppender.append("cde");
 
 
-    assertEquals("last value appended above limit postfix is read correctly",
-        String.format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 5, "cde"),
-        boundedAppender.toString());
+    assertEquals(String.format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 5, "cde"),
+        boundedAppender.toString(),
+        "last value appended above limit postfix is read correctly");
 
 
     boundedAppender.append("fg");
     boundedAppender.append("fg");
 
 
     assertEquals(
     assertEquals(
-        "middle value appended above limit postfix and last value are "
-            + "read correctly",
         String.format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 7, "efg"),
         String.format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 7, "efg"),
-        boundedAppender.toString());
+        boundedAppender.toString(),
+        "middle value appended above limit postfix and last value are "
+            + "read correctly");
 
 
     boundedAppender.append("hijkl");
     boundedAppender.append("hijkl");
 
 
     assertEquals(
     assertEquals(
-        "last value appended above limit postfix is read correctly", String
+        String
             .format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 12, "jkl"),
             .format(BoundedAppender.TRUNCATED_MESSAGES_TEMPLATE, 3, 12, "jkl"),
-        boundedAppender.toString());
+        boundedAppender.toString(),
+        "last value appended above limit postfix is read correctly");
   }
   }
 }
 }

+ 36 - 28
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestConverterUtils.java

@@ -17,23 +17,25 @@
 */
 */
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
 import java.net.URISyntaxException;
 import java.net.URISyntaxException;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.yarn.api.TestContainerId;
 import org.apache.hadoop.yarn.api.TestContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerId;
-import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeId;
-import org.junit.Test;
+import org.apache.hadoop.yarn.api.records.URL;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 public class TestConverterUtils {
 public class TestConverterUtils {
-  
+
   @Test
   @Test
-  public void testConvertUrlWithNoPort() throws URISyntaxException {
+  void testConvertUrlWithNoPort() throws URISyntaxException {
     Path expectedPath = new Path("hdfs://foo.com");
     Path expectedPath = new Path("hdfs://foo.com");
     URL url = URL.fromPath(expectedPath);
     URL url = URL.fromPath(expectedPath);
     Path actualPath = url.toPath();
     Path actualPath = url.toPath();
@@ -41,15 +43,15 @@ public class TestConverterUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testConvertUrlWithUserinfo() throws URISyntaxException {
+  void testConvertUrlWithUserinfo() throws URISyntaxException {
     Path expectedPath = new Path("foo://username:password@example.com:8042");
     Path expectedPath = new Path("foo://username:password@example.com:8042");
     URL url = URL.fromPath(expectedPath);
     URL url = URL.fromPath(expectedPath);
     Path actualPath = url.toPath();
     Path actualPath = url.toPath();
     assertEquals(expectedPath, actualPath);
     assertEquals(expectedPath, actualPath);
   }
   }
-  
+
   @Test
   @Test
-  public void testContainerId() throws URISyntaxException {
+  void testContainerId() throws URISyntaxException {
     ContainerId id = TestContainerId.newContainerId(0, 0, 0, 0);
     ContainerId id = TestContainerId.newContainerId(0, 0, 0, 0);
     String cid = id.toString();
     String cid = id.toString();
     assertEquals("container_0_0000_00_000000", cid);
     assertEquals("container_0_0000_00_000000", cid);
@@ -58,7 +60,7 @@ public class TestConverterUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testContainerIdWithEpoch() throws URISyntaxException {
+  void testContainerIdWithEpoch() throws URISyntaxException {
     ContainerId id = TestContainerId.newContainerId(0, 0, 0, 25645811);
     ContainerId id = TestContainerId.newContainerId(0, 0, 0, 25645811);
     String cid = id.toString();
     String cid = id.toString();
     assertEquals("container_0_0000_00_25645811", cid);
     assertEquals("container_0_0000_00_25645811", cid);
@@ -85,38 +87,44 @@ public class TestConverterUtils {
 
 
   @Test
   @Test
   @SuppressWarnings("deprecation")
   @SuppressWarnings("deprecation")
-  public void testContainerIdNull() throws URISyntaxException {
-    assertNull(ConverterUtils.toString((ContainerId)null));
-  }  
-  
+  void testContainerIdNull() throws URISyntaxException {
+    assertNull(ConverterUtils.toString((ContainerId) null));
+  }
+
   @Test
   @Test
-  public void testNodeIdWithDefaultPort() throws URISyntaxException {
+  void testNodeIdWithDefaultPort() throws URISyntaxException {
     NodeId nid;
     NodeId nid;
-    
+
     nid = ConverterUtils.toNodeIdWithDefaultPort("node:10");
     nid = ConverterUtils.toNodeIdWithDefaultPort("node:10");
     assertThat(nid.getPort()).isEqualTo(10);
     assertThat(nid.getPort()).isEqualTo(10);
     assertThat(nid.getHost()).isEqualTo("node");
     assertThat(nid.getHost()).isEqualTo("node");
-    
+
     nid = ConverterUtils.toNodeIdWithDefaultPort("node");
     nid = ConverterUtils.toNodeIdWithDefaultPort("node");
     assertThat(nid.getPort()).isEqualTo(0);
     assertThat(nid.getPort()).isEqualTo(0);
     assertThat(nid.getHost()).isEqualTo("node");
     assertThat(nid.getHost()).isEqualTo("node");
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   @SuppressWarnings("deprecation")
   @SuppressWarnings("deprecation")
-  public void testInvalidContainerId() {
-    ContainerId.fromString("container_e20_1423221031460_0003_01");
+  void testInvalidContainerId() {
+    assertThrows(IllegalArgumentException.class, () -> {
+      ContainerId.fromString("container_e20_1423221031460_0003_01");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   @SuppressWarnings("deprecation")
   @SuppressWarnings("deprecation")
-  public void testInvalidAppattemptId() {
-    ConverterUtils.toApplicationAttemptId("appattempt_1423221031460");
+  void testInvalidAppattemptId() {
+    assertThrows(IllegalArgumentException.class, () -> {
+      ConverterUtils.toApplicationAttemptId("appattempt_1423221031460");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   @SuppressWarnings("deprecation")
   @SuppressWarnings("deprecation")
-  public void testApplicationId() {
-    ConverterUtils.toApplicationId("application_1423221031460");
+  void testApplicationId() {
+    assertThrows(IllegalArgumentException.class, () -> {
+      ConverterUtils.toApplicationId("application_1423221031460");
+    });
   }
   }
 }
 }

+ 139 - 129
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java

@@ -18,13 +18,6 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import static org.apache.hadoop.fs.CreateFlag.CREATE;
-import static org.apache.hadoop.fs.CreateFlag.OVERWRITE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
 import java.io.File;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.IOException;
@@ -52,14 +45,17 @@ import java.util.zip.GZIPOutputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 import java.util.zip.ZipOutputStream;
 
 
-import org.apache.hadoop.util.concurrent.HadoopExecutors;
-import org.apache.hadoop.yarn.api.records.URL;
-import org.junit.Assert;
+import org.apache.hadoop.thirdparty.com.google.common.cache.CacheBuilder;
+import org.apache.hadoop.thirdparty.com.google.common.cache.CacheLoader;
+import org.apache.hadoop.thirdparty.com.google.common.cache.LoadingCache;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
 import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
@@ -70,17 +66,21 @@ import org.apache.hadoop.fs.LocalDirAllocator;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.util.concurrent.HadoopExecutors;
 import org.apache.hadoop.yarn.api.records.LocalResource;
 import org.apache.hadoop.yarn.api.records.LocalResource;
 import org.apache.hadoop.yarn.api.records.LocalResourceType;
 import org.apache.hadoop.yarn.api.records.LocalResourceType;
 import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
 import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
+import org.apache.hadoop.yarn.api.records.URL;
 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.junit.AfterClass;
-import org.junit.Test;
 
 
-import org.apache.hadoop.thirdparty.com.google.common.cache.CacheBuilder;
-import org.apache.hadoop.thirdparty.com.google.common.cache.CacheLoader;
-import org.apache.hadoop.thirdparty.com.google.common.cache.LoadingCache;
+import static org.apache.hadoop.fs.CreateFlag.CREATE;
+import static org.apache.hadoop.fs.CreateFlag.OVERWRITE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 
 /**
 /**
  * Unit test for the FSDownload class.
  * Unit test for the FSDownload class.
@@ -96,7 +96,7 @@ public class TestFSDownload {
   };
   };
   private Configuration conf = new Configuration();
   private Configuration conf = new Configuration();
 
 
-  @AfterClass
+  @AfterAll
   public static void deleteTestDir() throws IOException {
   public static void deleteTestDir() throws IOException {
     FileContext fs = FileContext.getLocalFSFileContext();
     FileContext fs = FileContext.getLocalFSFileContext();
     fs.delete(new Path("target", TestFSDownload.class.getSimpleName()), true);
     fs.delete(new Path("target", TestFSDownload.class.getSimpleName()), true);
@@ -270,16 +270,17 @@ public class TestFSDownload {
     return ret;
     return ret;
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDownloadBadPublic() throws IOException, URISyntaxException,
+  @Test
+  @Timeout(10000)
+  void testDownloadBadPublic() throws IOException, URISyntaxException,
       InterruptedException {
       InterruptedException {
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
     FileContext files = FileContext.getLocalFSFileContext(conf);
     FileContext files = FileContext.getLocalFSFileContext(conf);
     final Path basedir = files.makeQualified(new Path("target",
     final Path basedir = files.makeQualified(new Path("target",
-      TestFSDownload.class.getSimpleName()));
+        TestFSDownload.class.getSimpleName()));
     files.mkdir(basedir, null, true);
     files.mkdir(basedir, null, true);
     conf.setStrings(TestFSDownload.class.getName(), basedir.toString());
     conf.setStrings(TestFSDownload.class.getName(), basedir.toString());
-    
+
     Map<LocalResource, LocalResourceVisibility> rsrcVis =
     Map<LocalResource, LocalResourceVisibility> rsrcVis =
         new HashMap<LocalResource, LocalResourceVisibility>();
         new HashMap<LocalResource, LocalResourceVisibility>();
 
 
@@ -288,11 +289,11 @@ public class TestFSDownload {
     rand.setSeed(sharedSeed);
     rand.setSeed(sharedSeed);
     System.out.println("SEED: " + sharedSeed);
     System.out.println("SEED: " + sharedSeed);
 
 
-    Map<LocalResource,Future<Path>> pending =
-      new HashMap<LocalResource,Future<Path>>();
+    Map<LocalResource, Future<Path>> pending =
+        new HashMap<LocalResource, Future<Path>>();
     ExecutorService exec = HadoopExecutors.newSingleThreadExecutor();
     ExecutorService exec = HadoopExecutors.newSingleThreadExecutor();
     LocalDirAllocator dirs =
     LocalDirAllocator dirs =
-      new LocalDirAllocator(TestFSDownload.class.getName());
+        new LocalDirAllocator(TestFSDownload.class.getName());
     int size = 512;
     int size = 512;
     LocalResourceVisibility vis = LocalResourceVisibility.PUBLIC;
     LocalResourceVisibility vis = LocalResourceVisibility.PUBLIC;
     Path path = new Path(basedir, "test-file");
     Path path = new Path(basedir, "test-file");
@@ -300,32 +301,33 @@ public class TestFSDownload {
     rsrcVis.put(rsrc, vis);
     rsrcVis.put(rsrc, vis);
     Path destPath = dirs.getLocalPathForWrite(
     Path destPath = dirs.getLocalPathForWrite(
         basedir.toString(), size, conf);
         basedir.toString(), size, conf);
-    destPath = new Path (destPath,
-      Long.toString(uniqueNumberGenerator.incrementAndGet()));
+    destPath = new Path(destPath,
+        Long.toString(uniqueNumberGenerator.incrementAndGet()));
     FSDownload fsd =
     FSDownload fsd =
-      new FSDownload(files, UserGroupInformation.getCurrentUser(), conf,
-          destPath, rsrc);
+        new FSDownload(files, UserGroupInformation.getCurrentUser(), conf,
+            destPath, rsrc);
     pending.put(rsrc, exec.submit(fsd));
     pending.put(rsrc, exec.submit(fsd));
     exec.shutdown();
     exec.shutdown();
-    while (!exec.awaitTermination(1000, TimeUnit.MILLISECONDS));
-    Assert.assertTrue(pending.get(rsrc).isDone());
+    while (!exec.awaitTermination(1000, TimeUnit.MILLISECONDS)) ;
+    assertTrue(pending.get(rsrc).isDone());
 
 
     try {
     try {
-      for (Map.Entry<LocalResource,Future<Path>> p : pending.entrySet()) {
+      for (Map.Entry<LocalResource, Future<Path>> p : pending.entrySet()) {
         p.getValue().get();
         p.getValue().get();
-        Assert.fail("We localized a file that is not public.");
+        fail("We localized a file that is not public.");
       }
       }
     } catch (ExecutionException e) {
     } catch (ExecutionException e) {
-      Assert.assertTrue(e.getCause() instanceof IOException);
+      assertTrue(e.getCause() instanceof IOException);
     }
     }
   }
   }
 
 
-  @Test (timeout=60000)
-  public void testDownloadPublicWithStatCache() throws IOException,
+  @Test
+  @Timeout(60000)
+  void testDownloadPublicWithStatCache() throws IOException,
       URISyntaxException, InterruptedException, ExecutionException {
       URISyntaxException, InterruptedException, ExecutionException {
     FileContext files = FileContext.getLocalFSFileContext(conf);
     FileContext files = FileContext.getLocalFSFileContext(conf);
     Path basedir = files.makeQualified(new Path("target",
     Path basedir = files.makeQualified(new Path("target",
-      TestFSDownload.class.getSimpleName()));
+        TestFSDownload.class.getSimpleName()));
 
 
     // if test directory doesn't have ancestor permission, skip this test
     // if test directory doesn't have ancestor permission, skip this test
     FileSystem f = basedir.getFileSystem(conf);
     FileSystem f = basedir.getFileSystem(conf);
@@ -336,28 +338,28 @@ public class TestFSDownload {
 
 
     int size = 512;
     int size = 512;
 
 
-    final ConcurrentMap<Path,AtomicInteger> counts =
-        new ConcurrentHashMap<Path,AtomicInteger>();
-    final CacheLoader<Path,Future<FileStatus>> loader =
+    final ConcurrentMap<Path, AtomicInteger> counts =
+        new ConcurrentHashMap<Path, AtomicInteger>();
+    final CacheLoader<Path, Future<FileStatus>> loader =
         FSDownload.createStatusCacheLoader(conf);
         FSDownload.createStatusCacheLoader(conf);
-    final LoadingCache<Path,Future<FileStatus>> statCache =
-        CacheBuilder.newBuilder().build(new CacheLoader<Path,Future<FileStatus>>() {
-      public Future<FileStatus> load(Path path) throws Exception {
-        // increment the count
-        AtomicInteger count = counts.get(path);
-        if (count == null) {
-          count = new AtomicInteger(0);
-          AtomicInteger existing = counts.putIfAbsent(path, count);
-          if (existing != null) {
-            count = existing;
-          }
-        }
-        count.incrementAndGet();
+    final LoadingCache<Path, Future<FileStatus>> statCache =
+        CacheBuilder.newBuilder().build(new CacheLoader<Path, Future<FileStatus>>() {
+          public Future<FileStatus> load(Path path) throws Exception {
+            // increment the count
+            AtomicInteger count = counts.get(path);
+            if (count == null) {
+              count = new AtomicInteger(0);
+              AtomicInteger existing = counts.putIfAbsent(path, count);
+              if (existing != null) {
+                count = existing;
+              }
+            }
+            count.incrementAndGet();
 
 
-        // use the default loader
-        return loader.load(path);
-      }
-    });
+            // use the default loader
+            return loader.load(path);
+          }
+        });
 
 
     // test FSDownload.isPublic() concurrently
     // test FSDownload.isPublic() concurrently
     final int fileCount = 3;
     final int fileCount = 3;
@@ -382,11 +384,11 @@ public class TestFSDownload {
     try {
     try {
       List<Future<Boolean>> futures = exec.invokeAll(tasks);
       List<Future<Boolean>> futures = exec.invokeAll(tasks);
       // files should be public
       // files should be public
-      for (Future<Boolean> future: futures) {
+      for (Future<Boolean> future : futures) {
         assertTrue(future.get());
         assertTrue(future.get());
       }
       }
       // for each path exactly one file status call should be made
       // for each path exactly one file status call should be made
-      for (AtomicInteger count: counts.values()) {
+      for (AtomicInteger count : counts.values()) {
         assertSame(count.get(), 1);
         assertSame(count.get(), 1);
       }
       }
     } finally {
     } finally {
@@ -394,16 +396,17 @@ public class TestFSDownload {
     }
     }
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDownload() throws IOException, URISyntaxException,
+  @Test
+  @Timeout(10000)
+  void testDownload() throws IOException, URISyntaxException,
       InterruptedException {
       InterruptedException {
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
     FileContext files = FileContext.getLocalFSFileContext(conf);
     FileContext files = FileContext.getLocalFSFileContext(conf);
     final Path basedir = files.makeQualified(new Path("target",
     final Path basedir = files.makeQualified(new Path("target",
-      TestFSDownload.class.getSimpleName()));
+        TestFSDownload.class.getSimpleName()));
     files.mkdir(basedir, null, true);
     files.mkdir(basedir, null, true);
     conf.setStrings(TestFSDownload.class.getName(), basedir.toString());
     conf.setStrings(TestFSDownload.class.getName(), basedir.toString());
-    
+
     Map<LocalResource, LocalResourceVisibility> rsrcVis =
     Map<LocalResource, LocalResourceVisibility> rsrcVis =
         new HashMap<LocalResource, LocalResourceVisibility>();
         new HashMap<LocalResource, LocalResourceVisibility>();
 
 
@@ -412,16 +415,16 @@ public class TestFSDownload {
     rand.setSeed(sharedSeed);
     rand.setSeed(sharedSeed);
     System.out.println("SEED: " + sharedSeed);
     System.out.println("SEED: " + sharedSeed);
 
 
-    Map<LocalResource,Future<Path>> pending =
-      new HashMap<LocalResource,Future<Path>>();
+    Map<LocalResource, Future<Path>> pending =
+        new HashMap<LocalResource, Future<Path>>();
     ExecutorService exec = HadoopExecutors.newSingleThreadExecutor();
     ExecutorService exec = HadoopExecutors.newSingleThreadExecutor();
     LocalDirAllocator dirs =
     LocalDirAllocator dirs =
-      new LocalDirAllocator(TestFSDownload.class.getName());
+        new LocalDirAllocator(TestFSDownload.class.getName());
     int[] sizes = new int[10];
     int[] sizes = new int[10];
     for (int i = 0; i < 10; ++i) {
     for (int i = 0; i < 10; ++i) {
       sizes[i] = rand.nextInt(512) + 512;
       sizes[i] = rand.nextInt(512) + 512;
       LocalResourceVisibility vis = LocalResourceVisibility.PRIVATE;
       LocalResourceVisibility vis = LocalResourceVisibility.PRIVATE;
-      if (i%2 == 1) {
+      if (i % 2 == 1) {
         vis = LocalResourceVisibility.APPLICATION;
         vis = LocalResourceVisibility.APPLICATION;
       }
       }
       Path p = new Path(basedir, "" + i);
       Path p = new Path(basedir, "" + i);
@@ -429,7 +432,7 @@ public class TestFSDownload {
       rsrcVis.put(rsrc, vis);
       rsrcVis.put(rsrc, vis);
       Path destPath = dirs.getLocalPathForWrite(
       Path destPath = dirs.getLocalPathForWrite(
           basedir.toString(), sizes[i], conf);
           basedir.toString(), sizes[i], conf);
-      destPath = new Path (destPath,
+      destPath = new Path(destPath,
           Long.toString(uniqueNumberGenerator.incrementAndGet()));
           Long.toString(uniqueNumberGenerator.incrementAndGet()));
       FSDownload fsd =
       FSDownload fsd =
           new FSDownload(files, UserGroupInformation.getCurrentUser(), conf,
           new FSDownload(files, UserGroupInformation.getCurrentUser(), conf,
@@ -438,29 +441,29 @@ public class TestFSDownload {
     }
     }
 
 
     exec.shutdown();
     exec.shutdown();
-    while (!exec.awaitTermination(1000, TimeUnit.MILLISECONDS));
-    for (Future<Path> path: pending.values()) {
-      Assert.assertTrue(path.isDone());
+    while (!exec.awaitTermination(1000, TimeUnit.MILLISECONDS)) ;
+    for (Future<Path> path : pending.values()) {
+      assertTrue(path.isDone());
     }
     }
 
 
     try {
     try {
-      for (Map.Entry<LocalResource,Future<Path>> p : pending.entrySet()) {
+      for (Map.Entry<LocalResource, Future<Path>> p : pending.entrySet()) {
         Path localized = p.getValue().get();
         Path localized = p.getValue().get();
         assertEquals(sizes[Integer.parseInt(localized.getName())], p.getKey()
         assertEquals(sizes[Integer.parseInt(localized.getName())], p.getKey()
             .getSize());
             .getSize());
 
 
         FileStatus status = files.getFileStatus(localized.getParent());
         FileStatus status = files.getFileStatus(localized.getParent());
         FsPermission perm = status.getPermission();
         FsPermission perm = status.getPermission();
-        assertEquals("Cache directory permissions are incorrect",
-            new FsPermission((short)0755), perm);
+        assertEquals(new FsPermission((short) 0755), perm,
+            "Cache directory permissions are incorrect");
 
 
         status = files.getFileStatus(localized);
         status = files.getFileStatus(localized);
         perm = status.getPermission();
         perm = status.getPermission();
-        System.out.println("File permission " + perm + 
+        System.out.println("File permission " + perm +
             " for rsrc vis " + p.getKey().getVisibility().name());
             " for rsrc vis " + p.getKey().getVisibility().name());
         assert(rsrcVis.containsKey(p.getKey()));
         assert(rsrcVis.containsKey(p.getKey()));
-        Assert.assertTrue("Private file should be 500",
-            perm.toShort() == FSDownload.PRIVATE_FILE_PERMS.toShort());
+        assertTrue(perm.toShort() == FSDownload.PRIVATE_FILE_PERMS.toShort(),
+            "Private file should be 500");
       }
       }
     } catch (ExecutionException e) {
     } catch (ExecutionException e) {
       throw new IOException("Failed exec", e);
       throw new IOException("Failed exec", e);
@@ -524,15 +527,14 @@ public class TestFSDownload {
           FileStatus[] childFiles = files.getDefaultFileSystem().listStatus(
           FileStatus[] childFiles = files.getDefaultFileSystem().listStatus(
               filestatus.getPath());
               filestatus.getPath());
           for (FileStatus childfile : childFiles) {
           for (FileStatus childfile : childFiles) {
-            if(strFileName.endsWith(".ZIP") &&
-               childfile.getPath().getName().equals(strFileName) &&
-               !childfile.isDirectory()) {
-               Assert.fail("Failure...After unzip, there should have been a" +
-                 " directory formed with zip file name but found a file. "
-                 + childfile.getPath());
+            if (strFileName.endsWith(".ZIP") && childfile.getPath().getName().equals(strFileName)
+                && !childfile.isDirectory()) {
+              fail("Failure...After unzip, there should have been a"
+                  + " directory formed with zip file name but found a file. "
+                  + childfile.getPath());
             }
             }
             if (childfile.getPath().getName().startsWith("tmp")) {
             if (childfile.getPath().getName().startsWith("tmp")) {
-              Assert.fail("Tmp File should not have been there "
+              fail("Tmp File should not have been there "
                   + childfile.getPath());
                   + childfile.getPath());
             }
             }
           }
           }
@@ -543,20 +545,23 @@ public class TestFSDownload {
     }
     }
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDownloadArchive() throws IOException, URISyntaxException,
+  @Test
+  @Timeout(10000)
+  void testDownloadArchive() throws IOException, URISyntaxException,
       InterruptedException {
       InterruptedException {
     downloadWithFileType(TEST_FILE_TYPE.TAR);
     downloadWithFileType(TEST_FILE_TYPE.TAR);
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDownloadPatternJar() throws IOException, URISyntaxException,
+  @Test
+  @Timeout(10000)
+  void testDownloadPatternJar() throws IOException, URISyntaxException,
       InterruptedException {
       InterruptedException {
     downloadWithFileType(TEST_FILE_TYPE.JAR);
     downloadWithFileType(TEST_FILE_TYPE.JAR);
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDownloadArchiveZip() throws IOException, URISyntaxException,
+  @Test
+  @Timeout(10000)
+  void testDownloadArchiveZip() throws IOException, URISyntaxException,
       InterruptedException {
       InterruptedException {
     downloadWithFileType(TEST_FILE_TYPE.ZIP);
     downloadWithFileType(TEST_FILE_TYPE.ZIP);
   }
   }
@@ -564,8 +569,9 @@ public class TestFSDownload {
   /*
   /*
    * To test fix for YARN-3029
    * To test fix for YARN-3029
    */
    */
-  @Test (timeout=10000)
-  public void testDownloadArchiveZipWithTurkishLocale() throws IOException,
+  @Test
+  @Timeout(10000)
+  void testDownloadArchiveZipWithTurkishLocale() throws IOException,
       URISyntaxException, InterruptedException {
       URISyntaxException, InterruptedException {
     Locale defaultLocale = Locale.getDefault();
     Locale defaultLocale = Locale.getDefault();
     // Set to Turkish
     // Set to Turkish
@@ -576,8 +582,9 @@ public class TestFSDownload {
     Locale.setDefault(defaultLocale);
     Locale.setDefault(defaultLocale);
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDownloadArchiveTgz() throws IOException, URISyntaxException,
+  @Test
+  @Timeout(10000)
+  void testDownloadArchiveTgz() throws IOException, URISyntaxException,
       InterruptedException {
       InterruptedException {
     downloadWithFileType(TEST_FILE_TYPE.TGZ);
     downloadWithFileType(TEST_FILE_TYPE.TGZ);
   }
   }
@@ -588,11 +595,11 @@ public class TestFSDownload {
     FileStatus status = files.getFileStatus(p);
     FileStatus status = files.getFileStatus(p);
     if (status.isDirectory()) {
     if (status.isDirectory()) {
       if (vis == LocalResourceVisibility.PUBLIC) {
       if (vis == LocalResourceVisibility.PUBLIC) {
-        Assert.assertTrue(status.getPermission().toShort() ==
+        assertTrue(status.getPermission().toShort() ==
           FSDownload.PUBLIC_DIR_PERMS.toShort());
           FSDownload.PUBLIC_DIR_PERMS.toShort());
       }
       }
       else {
       else {
-        Assert.assertTrue(status.getPermission().toShort() ==
+        assertTrue(status.getPermission().toShort() ==
           FSDownload.PRIVATE_DIR_PERMS.toShort());
           FSDownload.PRIVATE_DIR_PERMS.toShort());
       }
       }
       if (!status.isSymlink()) {
       if (!status.isSymlink()) {
@@ -604,40 +611,41 @@ public class TestFSDownload {
     }
     }
     else {
     else {
       if (vis == LocalResourceVisibility.PUBLIC) {
       if (vis == LocalResourceVisibility.PUBLIC) {
-        Assert.assertTrue(status.getPermission().toShort() ==
+        assertTrue(status.getPermission().toShort() ==
           FSDownload.PUBLIC_FILE_PERMS.toShort());
           FSDownload.PUBLIC_FILE_PERMS.toShort());
       }
       }
       else {
       else {
-        Assert.assertTrue(status.getPermission().toShort() ==
+        assertTrue(status.getPermission().toShort() ==
           FSDownload.PRIVATE_FILE_PERMS.toShort());
           FSDownload.PRIVATE_FILE_PERMS.toShort());
       }
       }
     }      
     }      
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testDirDownload() throws IOException, InterruptedException {
+  @Test
+  @Timeout(10000)
+  void testDirDownload() throws IOException, InterruptedException {
     FileContext files = FileContext.getLocalFSFileContext(conf);
     FileContext files = FileContext.getLocalFSFileContext(conf);
     final Path basedir = files.makeQualified(new Path("target",
     final Path basedir = files.makeQualified(new Path("target",
-      TestFSDownload.class.getSimpleName()));
+        TestFSDownload.class.getSimpleName()));
     files.mkdir(basedir, null, true);
     files.mkdir(basedir, null, true);
     conf.setStrings(TestFSDownload.class.getName(), basedir.toString());
     conf.setStrings(TestFSDownload.class.getName(), basedir.toString());
-    
+
     Map<LocalResource, LocalResourceVisibility> rsrcVis =
     Map<LocalResource, LocalResourceVisibility> rsrcVis =
         new HashMap<LocalResource, LocalResourceVisibility>();
         new HashMap<LocalResource, LocalResourceVisibility>();
-  
+
     Random rand = new Random();
     Random rand = new Random();
     long sharedSeed = rand.nextLong();
     long sharedSeed = rand.nextLong();
     rand.setSeed(sharedSeed);
     rand.setSeed(sharedSeed);
     System.out.println("SEED: " + sharedSeed);
     System.out.println("SEED: " + sharedSeed);
 
 
-    Map<LocalResource,Future<Path>> pending =
-      new HashMap<LocalResource,Future<Path>>();
+    Map<LocalResource, Future<Path>> pending =
+        new HashMap<LocalResource, Future<Path>>();
     ExecutorService exec = HadoopExecutors.newSingleThreadExecutor();
     ExecutorService exec = HadoopExecutors.newSingleThreadExecutor();
     LocalDirAllocator dirs =
     LocalDirAllocator dirs =
-      new LocalDirAllocator(TestFSDownload.class.getName());
+        new LocalDirAllocator(TestFSDownload.class.getName());
     for (int i = 0; i < 5; ++i) {
     for (int i = 0; i < 5; ++i) {
       LocalResourceVisibility vis = LocalResourceVisibility.PRIVATE;
       LocalResourceVisibility vis = LocalResourceVisibility.PRIVATE;
-      if (i%2 == 1) {
+      if (i % 2 == 1) {
         vis = LocalResourceVisibility.APPLICATION;
         vis = LocalResourceVisibility.APPLICATION;
       }
       }
 
 
@@ -646,7 +654,7 @@ public class TestFSDownload {
       rsrcVis.put(rsrc, vis);
       rsrcVis.put(rsrc, vis);
       Path destPath = dirs.getLocalPathForWrite(
       Path destPath = dirs.getLocalPathForWrite(
           basedir.toString(), conf);
           basedir.toString(), conf);
-      destPath = new Path (destPath,
+      destPath = new Path(destPath,
           Long.toString(uniqueNumberGenerator.incrementAndGet()));
           Long.toString(uniqueNumberGenerator.incrementAndGet()));
       FSDownload fsd =
       FSDownload fsd =
           new FSDownload(files, UserGroupInformation.getCurrentUser(), conf,
           new FSDownload(files, UserGroupInformation.getCurrentUser(), conf,
@@ -655,21 +663,21 @@ public class TestFSDownload {
     }
     }
 
 
     exec.shutdown();
     exec.shutdown();
-    while (!exec.awaitTermination(1000, TimeUnit.MILLISECONDS));
-    for (Future<Path> path: pending.values()) {
-      Assert.assertTrue(path.isDone());
+    while (!exec.awaitTermination(1000, TimeUnit.MILLISECONDS)) ;
+    for (Future<Path> path : pending.values()) {
+      assertTrue(path.isDone());
     }
     }
 
 
     try {
     try {
-      
-      for (Map.Entry<LocalResource,Future<Path>> p : pending.entrySet()) {
+
+      for (Map.Entry<LocalResource, Future<Path>> p : pending.entrySet()) {
         Path localized = p.getValue().get();
         Path localized = p.getValue().get();
         FileStatus status = files.getFileStatus(localized);
         FileStatus status = files.getFileStatus(localized);
 
 
         System.out.println("Testing path " + localized);
         System.out.println("Testing path " + localized);
         assert(status.isDirectory());
         assert(status.isDirectory());
         assert(rsrcVis.containsKey(p.getKey()));
         assert(rsrcVis.containsKey(p.getKey()));
-        
+
         verifyPermsRecursively(localized.getFileSystem(conf),
         verifyPermsRecursively(localized.getFileSystem(conf),
             files, localized, rsrcVis.get(p.getKey()));
             files, localized, rsrcVis.get(p.getKey()));
       }
       }
@@ -678,8 +686,9 @@ public class TestFSDownload {
     }
     }
   }
   }
 
 
-  @Test (timeout=10000)
-  public void testUniqueDestinationPath() throws Exception {
+  @Test
+  @Timeout(10000)
+  void testUniqueDestinationPath() throws Exception {
     FileContext files = FileContext.getLocalFSFileContext(conf);
     FileContext files = FileContext.getLocalFSFileContext(conf);
     final Path basedir = files.makeQualified(new Path("target",
     final Path basedir = files.makeQualified(new Path("target",
         TestFSDownload.class.getSimpleName()));
         TestFSDownload.class.getSimpleName()));
@@ -704,12 +713,12 @@ public class TestFSDownload {
             destPath, rsrc);
             destPath, rsrc);
     Future<Path> rPath = singleThreadedExec.submit(fsd);
     Future<Path> rPath = singleThreadedExec.submit(fsd);
     singleThreadedExec.shutdown();
     singleThreadedExec.shutdown();
-    while (!singleThreadedExec.awaitTermination(1000, TimeUnit.MILLISECONDS));
-    Assert.assertTrue(rPath.isDone());
+    while (!singleThreadedExec.awaitTermination(1000, TimeUnit.MILLISECONDS)) ;
+    assertTrue(rPath.isDone());
     // Now FSDownload will not create a random directory to localize the
     // Now FSDownload will not create a random directory to localize the
     // resource. Therefore the final localizedPath for the resource should be
     // resource. Therefore the final localizedPath for the resource should be
     // destination directory (passed as an argument) + file name.
     // destination directory (passed as an argument) + file name.
-    Assert.assertEquals(destPath, rPath.get().getParent());
+    assertEquals(destPath, rPath.get().getParent());
   }
   }
 
 
   /**
   /**
@@ -717,8 +726,9 @@ public class TestFSDownload {
    * from modification to the local resource's timestamp on the source FS just
    * from modification to the local resource's timestamp on the source FS just
    * before the download of this local resource has started.
    * before the download of this local resource has started.
    */
    */
-  @Test(timeout=10000)
-  public void testResourceTimestampChangeDuringDownload()
+  @Test
+  @Timeout(10000)
+  void testResourceTimestampChangeDuringDownload()
       throws IOException, InterruptedException {
       throws IOException, InterruptedException {
     conf = new Configuration();
     conf = new Configuration();
     FileContext files = FileContext.getLocalFSFileContext(conf);
     FileContext files = FileContext.getLocalFSFileContext(conf);
@@ -759,7 +769,7 @@ public class TestFSDownload {
       FileSystem sourceFs = sourceFsPath.getFileSystem(conf);
       FileSystem sourceFs = sourceFsPath.getFileSystem(conf);
       sourceFs.setTimes(sourceFsPath, modifiedFSTimestamp, modifiedFSTimestamp);
       sourceFs.setTimes(sourceFsPath, modifiedFSTimestamp, modifiedFSTimestamp);
     } catch (URISyntaxException use) {
     } catch (URISyntaxException use) {
-      Assert.fail("No exception expected.");
+      fail("No exception expected.");
     }
     }
 
 
     // Execute the FSDownload operation.
     // Execute the FSDownload operation.
@@ -770,19 +780,19 @@ public class TestFSDownload {
     exec.shutdown();
     exec.shutdown();
 
 
     exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
     exec.awaitTermination(1000, TimeUnit.MILLISECONDS);
-    Assert.assertTrue(pending.get(localResource).isDone());
+    assertTrue(pending.get(localResource).isDone());
 
 
     try {
     try {
       for (Map.Entry<LocalResource, Future<Path>> p : pending.entrySet()) {
       for (Map.Entry<LocalResource, Future<Path>> p : pending.entrySet()) {
         p.getValue().get();
         p.getValue().get();
       }
       }
-      Assert.fail("Exception expected from timestamp update during download");
+      fail("Exception expected from timestamp update during download");
     } catch (ExecutionException ee) {
     } catch (ExecutionException ee) {
-      Assert.assertTrue(ee.getCause() instanceof IOException);
-      Assert.assertTrue("Exception contains original timestamp",
-          ee.getMessage().contains(Times.formatISO8601(origLRTimestamp)));
-      Assert.assertTrue("Exception contains modified timestamp",
-          ee.getMessage().contains(Times.formatISO8601(modifiedFSTimestamp)));
+      assertTrue(ee.getCause() instanceof IOException);
+      assertTrue(ee.getMessage().contains(Times.formatISO8601(origLRTimestamp)),
+          "Exception contains original timestamp");
+      assertTrue(ee.getMessage().contains(Times.formatISO8601(modifiedFSTimestamp)),
+          "Exception contains modified timestamp");
     }
     }
   }
   }
 }
 }

+ 11 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestLRUCacheHashMap.java

@@ -19,9 +19,12 @@ package org.apache.hadoop.yarn.util;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test class to validate the correctness of the {@code LRUCacheHashMap}.
  * Test class to validate the correctness of the {@code LRUCacheHashMap}.
@@ -34,7 +37,7 @@ public class TestLRUCacheHashMap {
    * expected.
    * expected.
    */
    */
   @Test
   @Test
-  public void testLRUCache()
+  void testLRUCache()
       throws YarnException, IOException, InterruptedException {
       throws YarnException, IOException, InterruptedException {
 
 
     int mapSize = 5;
     int mapSize = 5;
@@ -48,11 +51,11 @@ public class TestLRUCacheHashMap {
     map.put("4", 4);
     map.put("4", 4);
     map.put("5", 5);
     map.put("5", 5);
 
 
-    Assert.assertEquals(mapSize, map.size());
+    assertEquals(mapSize, map.size());
 
 
     // Check if all the elements in the map are from 1 to 5
     // Check if all the elements in the map are from 1 to 5
     for (int i = 1; i < mapSize; i++) {
     for (int i = 1; i < mapSize; i++) {
-      Assert.assertTrue(map.containsKey(Integer.toString(i)));
+      assertTrue(map.containsKey(Integer.toString(i)));
     }
     }
 
 
     map.put("6", 6);
     map.put("6", 6);
@@ -60,14 +63,14 @@ public class TestLRUCacheHashMap {
     map.put("7", 7);
     map.put("7", 7);
     map.put("8", 8);
     map.put("8", 8);
 
 
-    Assert.assertEquals(mapSize, map.size());
+    assertEquals(mapSize, map.size());
 
 
     // Check if all the elements in the map are from 5 to 8 and the 3
     // Check if all the elements in the map are from 5 to 8 and the 3
     for (int i = 5; i < mapSize; i++) {
     for (int i = 5; i < mapSize; i++) {
-      Assert.assertTrue(map.containsKey(Integer.toString(i)));
+      assertTrue(map.containsKey(Integer.toString(i)));
     }
     }
 
 
-    Assert.assertTrue(map.containsKey("3"));
+    assertTrue(map.containsKey("3"));
 
 
   }
   }
 
 

+ 95 - 100
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestLog4jWarningErrorMetricsAppender.java

@@ -18,20 +18,22 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Marker;
 import org.slf4j.Marker;
 import org.slf4j.MarkerFactory;
 import org.slf4j.MarkerFactory;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Level;
-import org.apache.hadoop.util.Time;
-import org.junit.Assert;
-import org.junit.Test;
 
 
+import org.apache.hadoop.util.Time;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
 
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestLog4jWarningErrorMetricsAppender {
 public class TestLog4jWarningErrorMetricsAppender {
 
 
@@ -81,186 +83,179 @@ public class TestLog4jWarningErrorMetricsAppender {
   }
   }
 
 
   @Test
   @Test
-  public void testPurge() throws Exception {
+  void testPurge() throws Exception {
     setupAppender(2, 1, 1);
     setupAppender(2, 1, 1);
     logMessages(Level.ERROR, "test message 1", 1);
     logMessages(Level.ERROR, "test message 1", 1);
     cutoff.clear();
     cutoff.clear();
     cutoff.add(0L);
     cutoff.add(0L);
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).get(0)
-      .size());
+    assertEquals(1, appender.getErrorCounts(cutoff).size());
+    assertEquals(1, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).get(0)
+        .size());
     Thread.sleep(3000);
     Thread.sleep(3000);
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(0, appender.getErrorMessagesAndCounts(cutoff).get(0)
-      .size());
+    assertEquals(1, appender.getErrorCounts(cutoff).size());
+    assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(0, appender.getErrorMessagesAndCounts(cutoff).get(0)
+        .size());
 
 
     setupAppender(2, 1000, 2);
     setupAppender(2, 1000, 2);
 
 
     logMessages(Level.ERROR, "test message 1", 3);
     logMessages(Level.ERROR, "test message 1", 3);
     logMessages(Level.ERROR, "test message 2", 2);
     logMessages(Level.ERROR, "test message 2", 2);
 
 
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(5, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).get(0)
-      .size());
+    assertEquals(1, appender.getErrorCounts(cutoff).size());
+    assertEquals(5, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).get(0)
+        .size());
     logMessages(Level.ERROR, "test message 3", 3);
     logMessages(Level.ERROR, "test message 3", 3);
     Thread.sleep(2000);
     Thread.sleep(2000);
-    Assert.assertEquals(8, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).get(0)
-      .size());
+    assertEquals(8, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).get(0)
+        .size());
   }
   }
 
 
   @Test
   @Test
-  public void testErrorCounts() throws Exception {
+  void testErrorCounts() throws Exception {
     cutoff.clear();
     cutoff.clear();
     setupAppender(100, 100, 100);
     setupAppender(100, 100, 100);
     cutoff.add(0L);
     cutoff.add(0L);
     logMessages(Level.ERROR, "test message 1", 2);
     logMessages(Level.ERROR, "test message 1", 2);
     logMessages(Level.ERROR, "test message 2", 3);
     logMessages(Level.ERROR, "test message 2", 3);
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getWarningCounts(cutoff).size());
-    Assert.assertEquals(5, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert
-      .assertEquals(0, appender.getWarningCounts(cutoff).get(0).longValue());
+    assertEquals(1, appender.getErrorCounts(cutoff).size());
+    assertEquals(1, appender.getWarningCounts(cutoff).size());
+    assertEquals(5, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(0, appender.getWarningCounts(cutoff).get(0).longValue());
     Thread.sleep(1000);
     Thread.sleep(1000);
     cutoff.add(Time.now() / 1000);
     cutoff.add(Time.now() / 1000);
     logMessages(Level.ERROR, "test message 3", 2);
     logMessages(Level.ERROR, "test message 3", 2);
-    Assert.assertEquals(2, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(2, appender.getWarningCounts(cutoff).size());
-    Assert.assertEquals(7, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(2, appender.getErrorCounts(cutoff).get(1).longValue());
-    Assert
-      .assertEquals(0, appender.getWarningCounts(cutoff).get(0).longValue());
-    Assert
-      .assertEquals(0, appender.getWarningCounts(cutoff).get(1).longValue());
+    assertEquals(2, appender.getErrorCounts(cutoff).size());
+    assertEquals(2, appender.getWarningCounts(cutoff).size());
+    assertEquals(7, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(2, appender.getErrorCounts(cutoff).get(1).longValue());
+    assertEquals(0, appender.getWarningCounts(cutoff).get(0).longValue());
+    assertEquals(0, appender.getWarningCounts(cutoff).get(1).longValue());
   }
   }
 
 
   @Test
   @Test
-  public void testWarningCounts() throws Exception {
+  void testWarningCounts() throws Exception {
     cutoff.clear();
     cutoff.clear();
     setupAppender(100, 100, 100);
     setupAppender(100, 100, 100);
     cutoff.add(0L);
     cutoff.add(0L);
     logMessages(Level.WARN, "test message 1", 2);
     logMessages(Level.WARN, "test message 1", 2);
     logMessages(Level.WARN, "test message 2", 3);
     logMessages(Level.WARN, "test message 2", 3);
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getWarningCounts(cutoff).size());
-    Assert.assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert
-      .assertEquals(5, appender.getWarningCounts(cutoff).get(0).longValue());
+    assertEquals(1, appender.getErrorCounts(cutoff).size());
+    assertEquals(1, appender.getWarningCounts(cutoff).size());
+    assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(5, appender.getWarningCounts(cutoff).get(0).longValue());
     Thread.sleep(1000);
     Thread.sleep(1000);
     cutoff.add(Time.now() / 1000);
     cutoff.add(Time.now() / 1000);
     logMessages(Level.WARN, "test message 3", 2);
     logMessages(Level.WARN, "test message 3", 2);
-    Assert.assertEquals(2, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(2, appender.getWarningCounts(cutoff).size());
-    Assert.assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(0, appender.getErrorCounts(cutoff).get(1).longValue());
-    Assert
-      .assertEquals(7, appender.getWarningCounts(cutoff).get(0).longValue());
-    Assert
-      .assertEquals(2, appender.getWarningCounts(cutoff).get(1).longValue());
+    assertEquals(2, appender.getErrorCounts(cutoff).size());
+    assertEquals(2, appender.getWarningCounts(cutoff).size());
+    assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(0, appender.getErrorCounts(cutoff).get(1).longValue());
+    assertEquals(7, appender.getWarningCounts(cutoff).get(0).longValue());
+    assertEquals(2, appender.getWarningCounts(cutoff).get(1).longValue());
   }
   }
 
 
   @Test
   @Test
-  public void testWarningMessages() throws Exception {
+  void testWarningMessages() throws Exception {
     cutoff.clear();
     cutoff.clear();
     setupAppender(100, 100, 100);
     setupAppender(100, 100, 100);
     cutoff.add(0L);
     cutoff.add(0L);
     logMessages(Level.WARN, "test message 1", 2);
     logMessages(Level.WARN, "test message 1", 2);
     logMessages(Level.WARN, "test message 2", 3);
     logMessages(Level.WARN, "test message 2", 3);
-    Assert.assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getWarningMessagesAndCounts(cutoff).size());
+    assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).size());
+    assertEquals(1, appender.getWarningMessagesAndCounts(cutoff).size());
     Map<String, Log4jWarningErrorMetricsAppender.Element> errorsMap =
     Map<String, Log4jWarningErrorMetricsAppender.Element> errorsMap =
         appender.getErrorMessagesAndCounts(cutoff).get(0);
         appender.getErrorMessagesAndCounts(cutoff).get(0);
     Map<String, Log4jWarningErrorMetricsAppender.Element> warningsMap =
     Map<String, Log4jWarningErrorMetricsAppender.Element> warningsMap =
         appender.getWarningMessagesAndCounts(cutoff).get(0);
         appender.getWarningMessagesAndCounts(cutoff).get(0);
-    Assert.assertEquals(0, errorsMap.size());
-    Assert.assertEquals(2, warningsMap.size());
-    Assert.assertTrue(warningsMap.containsKey("test message 1"));
-    Assert.assertTrue(warningsMap.containsKey("test message 2"));
+    assertEquals(0, errorsMap.size());
+    assertEquals(2, warningsMap.size());
+    assertTrue(warningsMap.containsKey("test message 1"));
+    assertTrue(warningsMap.containsKey("test message 2"));
     Log4jWarningErrorMetricsAppender.Element msg1Info = warningsMap.get("test message 1");
     Log4jWarningErrorMetricsAppender.Element msg1Info = warningsMap.get("test message 1");
     Log4jWarningErrorMetricsAppender.Element msg2Info = warningsMap.get("test message 2");
     Log4jWarningErrorMetricsAppender.Element msg2Info = warningsMap.get("test message 2");
-    Assert.assertEquals(2, msg1Info.count.intValue());
-    Assert.assertEquals(3, msg2Info.count.intValue());
+    assertEquals(2, msg1Info.count.intValue());
+    assertEquals(3, msg2Info.count.intValue());
     Thread.sleep(1000);
     Thread.sleep(1000);
     cutoff.add(Time.now() / 1000);
     cutoff.add(Time.now() / 1000);
     logMessages(Level.WARN, "test message 3", 2);
     logMessages(Level.WARN, "test message 3", 2);
-    Assert.assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).size());
-    Assert.assertEquals(2, appender.getWarningMessagesAndCounts(cutoff).size());
+    assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).size());
+    assertEquals(2, appender.getWarningMessagesAndCounts(cutoff).size());
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(0);
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(0);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(0);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(0);
-    Assert.assertEquals(0, errorsMap.size());
-    Assert.assertEquals(3, warningsMap.size());
-    Assert.assertTrue(warningsMap.containsKey("test message 3"));
+    assertEquals(0, errorsMap.size());
+    assertEquals(3, warningsMap.size());
+    assertTrue(warningsMap.containsKey("test message 3"));
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(1);
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(1);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(1);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(1);
-    Assert.assertEquals(0, errorsMap.size());
-    Assert.assertEquals(1, warningsMap.size());
-    Assert.assertTrue(warningsMap.containsKey("test message 3"));
+    assertEquals(0, errorsMap.size());
+    assertEquals(1, warningsMap.size());
+    assertTrue(warningsMap.containsKey("test message 3"));
     Log4jWarningErrorMetricsAppender.Element msg3Info = warningsMap.get("test message 3");
     Log4jWarningErrorMetricsAppender.Element msg3Info = warningsMap.get("test message 3");
-    Assert.assertEquals(2, msg3Info.count.intValue());
+    assertEquals(2, msg3Info.count.intValue());
   }
   }
 
 
   @Test
   @Test
-  public void testErrorMessages() throws Exception {
+  void testErrorMessages() throws Exception {
     cutoff.clear();
     cutoff.clear();
     setupAppender(100, 100, 100);
     setupAppender(100, 100, 100);
     cutoff.add(0L);
     cutoff.add(0L);
     logMessages(Level.ERROR, "test message 1", 2);
     logMessages(Level.ERROR, "test message 1", 2);
     logMessages(Level.ERROR, "test message 2", 3);
     logMessages(Level.ERROR, "test message 2", 3);
-    Assert.assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getWarningMessagesAndCounts(cutoff).size());
+    assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).size());
+    assertEquals(1, appender.getWarningMessagesAndCounts(cutoff).size());
     Map<String, Log4jWarningErrorMetricsAppender.Element> errorsMap =
     Map<String, Log4jWarningErrorMetricsAppender.Element> errorsMap =
         appender.getErrorMessagesAndCounts(cutoff).get(0);
         appender.getErrorMessagesAndCounts(cutoff).get(0);
     Map<String, Log4jWarningErrorMetricsAppender.Element> warningsMap =
     Map<String, Log4jWarningErrorMetricsAppender.Element> warningsMap =
         appender.getWarningMessagesAndCounts(cutoff).get(0);
         appender.getWarningMessagesAndCounts(cutoff).get(0);
-    Assert.assertEquals(2, errorsMap.size());
-    Assert.assertEquals(0, warningsMap.size());
-    Assert.assertTrue(errorsMap.containsKey("test message 1"));
-    Assert.assertTrue(errorsMap.containsKey("test message 2"));
+    assertEquals(2, errorsMap.size());
+    assertEquals(0, warningsMap.size());
+    assertTrue(errorsMap.containsKey("test message 1"));
+    assertTrue(errorsMap.containsKey("test message 2"));
     Log4jWarningErrorMetricsAppender.Element msg1Info = errorsMap.get("test message 1");
     Log4jWarningErrorMetricsAppender.Element msg1Info = errorsMap.get("test message 1");
     Log4jWarningErrorMetricsAppender.Element msg2Info = errorsMap.get("test message 2");
     Log4jWarningErrorMetricsAppender.Element msg2Info = errorsMap.get("test message 2");
-    Assert.assertEquals(2, msg1Info.count.intValue());
-    Assert.assertEquals(3, msg2Info.count.intValue());
+    assertEquals(2, msg1Info.count.intValue());
+    assertEquals(3, msg2Info.count.intValue());
     Thread.sleep(1000);
     Thread.sleep(1000);
     cutoff.add(Time.now() / 1000);
     cutoff.add(Time.now() / 1000);
     logMessages(Level.ERROR, "test message 3", 2);
     logMessages(Level.ERROR, "test message 3", 2);
-    Assert.assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).size());
-    Assert.assertEquals(2, appender.getWarningMessagesAndCounts(cutoff).size());
+    assertEquals(2, appender.getErrorMessagesAndCounts(cutoff).size());
+    assertEquals(2, appender.getWarningMessagesAndCounts(cutoff).size());
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(0);
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(0);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(0);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(0);
-    Assert.assertEquals(3, errorsMap.size());
-    Assert.assertEquals(0, warningsMap.size());
-    Assert.assertTrue(errorsMap.containsKey("test message 3"));
+    assertEquals(3, errorsMap.size());
+    assertEquals(0, warningsMap.size());
+    assertTrue(errorsMap.containsKey("test message 3"));
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(1);
     errorsMap = appender.getErrorMessagesAndCounts(cutoff).get(1);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(1);
     warningsMap = appender.getWarningMessagesAndCounts(cutoff).get(1);
-    Assert.assertEquals(1, errorsMap.size());
-    Assert.assertEquals(0, warningsMap.size());
-    Assert.assertTrue(errorsMap.containsKey("test message 3"));
+    assertEquals(1, errorsMap.size());
+    assertEquals(0, warningsMap.size());
+    assertTrue(errorsMap.containsKey("test message 3"));
     Log4jWarningErrorMetricsAppender.Element msg3Info = errorsMap.get("test message 3");
     Log4jWarningErrorMetricsAppender.Element msg3Info = errorsMap.get("test message 3");
-    Assert.assertEquals(2, msg3Info.count.intValue());
+    assertEquals(2, msg3Info.count.intValue());
   }
   }
 
 
   @Test
   @Test
-  public void testInfoDebugTrace() {
+  void testInfoDebugTrace() {
     cutoff.clear();
     cutoff.clear();
     setupAppender(100, 100, 100);
     setupAppender(100, 100, 100);
     cutoff.add(0L);
     cutoff.add(0L);
     logMessages(Level.INFO, "test message 1", 2);
     logMessages(Level.INFO, "test message 1", 2);
     logMessages(Level.DEBUG, "test message 2", 2);
     logMessages(Level.DEBUG, "test message 2", 2);
     logMessages(Level.TRACE, "test message 3", 2);
     logMessages(Level.TRACE, "test message 3", 2);
-    Assert.assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getWarningMessagesAndCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getErrorCounts(cutoff).size());
-    Assert.assertEquals(1, appender.getWarningCounts(cutoff).size());
-    Assert.assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
-    Assert
-      .assertEquals(0, appender.getWarningCounts(cutoff).get(0).longValue());
-    Assert.assertEquals(0, appender.getErrorMessagesAndCounts(cutoff).get(0)
-      .size());
-    Assert.assertEquals(0, appender.getWarningMessagesAndCounts(cutoff).get(0)
-      .size());
+    assertEquals(1, appender.getErrorMessagesAndCounts(cutoff).size());
+    assertEquals(1, appender.getWarningMessagesAndCounts(cutoff).size());
+    assertEquals(1, appender.getErrorCounts(cutoff).size());
+    assertEquals(1, appender.getWarningCounts(cutoff).size());
+    assertEquals(0, appender.getErrorCounts(cutoff).get(0).longValue());
+    assertEquals(0, appender.getWarningCounts(cutoff).get(0).longValue());
+    assertEquals(0, appender.getErrorMessagesAndCounts(cutoff).get(0)
+        .size());
+    assertEquals(0, appender.getWarningMessagesAndCounts(cutoff).get(0)
+        .size());
   }
   }
 
 
 }
 }

+ 130 - 133
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java

@@ -18,11 +18,6 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import static org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.KB_TO_BYTES;
-import static org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree.UNAVAILABLE;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-
 import java.io.BufferedReader;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.File;
@@ -37,9 +32,13 @@ import java.util.Vector;
 import java.util.regex.Matcher;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
-import org.apache.commons.io.FileUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
+import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.FileUtil;
@@ -52,19 +51,23 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.MemInfo;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.MemInfo;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessSmapMemoryInfo;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessSmapMemoryInfo;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessTreeSmapMemInfo;
 import org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessTreeSmapMemInfo;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+
+import static org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.KB_TO_BYTES;
+import static org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree.UNAVAILABLE;
+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.junit.jupiter.api.Assumptions.assumeTrue;
 
 
 /**
 /**
  * A JUnit test to test ProcfsBasedProcessTree.
  * A JUnit test to test ProcfsBasedProcessTree.
  */
  */
 public class TestProcfsBasedProcessTree {
 public class TestProcfsBasedProcessTree {
 
 
-  private static final Logger LOG = LoggerFactory
-      .getLogger(TestProcfsBasedProcessTree.class);
-  protected static File TEST_ROOT_DIR = new File("target",
-    TestProcfsBasedProcessTree.class.getName() + "-localDir");
+  private static final Logger LOG = LoggerFactory.getLogger(TestProcfsBasedProcessTree.class);
+  protected static File TEST_ROOT_DIR =
+      new File("target", TestProcfsBasedProcessTree.class.getName() + "-localDir");
 
 
   private ShellCommandExecutor shexec = null;
   private ShellCommandExecutor shexec = null;
   private String pidFile, lowestDescendant, lostDescendant;
   private String pidFile, lowestDescendant, lostDescendant;
@@ -111,21 +114,22 @@ public class TestProcfsBasedProcessTree {
     return getPidFromPidFile(pidFile);
     return getPidFromPidFile(pidFile);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     assumeTrue(Shell.LINUX);
     assumeTrue(Shell.LINUX);
     FileContext.getLocalFSFileContext().delete(
     FileContext.getLocalFSFileContext().delete(
       new Path(TEST_ROOT_DIR.getAbsolutePath()), true);
       new Path(TEST_ROOT_DIR.getAbsolutePath()), true);
   }
   }
 
 
-  @Test(timeout = 30000)
-  public void testProcessTree() throws Exception {
+  @Test
+  @Timeout(30000)
+  void testProcessTree() throws Exception {
     try {
     try {
-      Assert.assertTrue(ProcfsBasedProcessTree.isAvailable());
+      assertTrue(ProcfsBasedProcessTree.isAvailable());
     } catch (Exception e) {
     } catch (Exception e) {
       LOG.info(StringUtils.stringifyException(e));
       LOG.info(StringUtils.stringifyException(e));
-      Assert.assertTrue("ProcfsBaseProcessTree should be available on Linux",
-        false);
+      assertTrue(false,
+          "ProcfsBaseProcessTree should be available on Linux");
       return;
       return;
     }
     }
     // create shell script
     // create shell script
@@ -156,7 +160,7 @@ public class TestProcfsBasedProcessTree {
         + "(sleep 300&\n"
         + "(sleep 300&\n"
         + "echo $! > " + lostDescendant + ")\n"
         + "echo $! > " + lostDescendant + ")\n"
         + " while true\n do\n" + "  sleep 5\n" + " done\n" + "fi",
         + " while true\n do\n" + "  sleep 5\n" + " done\n" + "fi",
-            StandardCharsets.UTF_8);
+        StandardCharsets.UTF_8);
 
 
     Thread t = new RogueTaskThread();
     Thread t = new RogueTaskThread();
     t.start();
     t.start();
@@ -182,8 +186,8 @@ public class TestProcfsBasedProcessTree {
     // Verify the orphaned pid is In process tree
     // Verify the orphaned pid is In process tree
     String lostpid = getPidFromPidFile(lostDescendant);
     String lostpid = getPidFromPidFile(lostDescendant);
     LOG.info("Orphaned pid: " + lostpid);
     LOG.info("Orphaned pid: " + lostpid);
-    Assert.assertTrue("Child process owned by init escaped process tree.",
-       p.contains(lostpid));
+    assertTrue(p.contains(lostpid),
+        "Child process owned by init escaped process tree.");
 
 
     // Get the process-tree dump
     // Get the process-tree dump
     String processTreeDump = p.getProcessTreeDump();
     String processTreeDump = p.getProcessTreeDump();
@@ -208,18 +212,18 @@ public class TestProcfsBasedProcessTree {
     }
     }
 
 
     LOG.info("Process-tree dump follows: \n" + processTreeDump);
     LOG.info("Process-tree dump follows: \n" + processTreeDump);
-    Assert.assertTrue("Process-tree dump doesn't start with a proper header",
-      processTreeDump.startsWith("\t|- PID PPID PGRPID SESSID CMD_NAME "
-          + "USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) "
-          + "RSSMEM_USAGE(PAGES) FULL_CMD_LINE\n"));
+    assertTrue(processTreeDump.startsWith("\t|- PID PPID PGRPID SESSID CMD_NAME "
+            + "USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) "
+            + "RSSMEM_USAGE(PAGES) FULL_CMD_LINE\n"),
+        "Process-tree dump doesn't start with a proper header");
     for (int i = N; i >= 0; i--) {
     for (int i = N; i >= 0; i--) {
       String cmdLineDump =
       String cmdLineDump =
           "\\|- [0-9]+ [0-9]+ [0-9]+ [0-9]+ \\(sh\\)"
           "\\|- [0-9]+ [0-9]+ [0-9]+ [0-9]+ \\(sh\\)"
               + " [0-9]+ [0-9]+ [0-9]+ [0-9]+ sh " + shellScript + " " + i;
               + " [0-9]+ [0-9]+ [0-9]+ [0-9]+ sh " + shellScript + " " + i;
       Pattern pat = Pattern.compile(cmdLineDump);
       Pattern pat = Pattern.compile(cmdLineDump);
       Matcher mat = pat.matcher(processTreeDump);
       Matcher mat = pat.matcher(processTreeDump);
-      Assert.assertTrue("Process-tree dump doesn't contain the cmdLineDump of "
-          + i + "th process!", mat.find());
+      assertTrue(mat.find(), "Process-tree dump doesn't contain the cmdLineDump of "
+          + i + "th process!");
     }
     }
 
 
     // Not able to join thread sometimes when forking with large N.
     // Not able to join thread sometimes when forking with large N.
@@ -232,12 +236,12 @@ public class TestProcfsBasedProcessTree {
 
 
     // ProcessTree is gone now. Any further calls should be sane.
     // ProcessTree is gone now. Any further calls should be sane.
     p.updateProcessTree();
     p.updateProcessTree();
-    Assert.assertFalse("ProcessTree must have been gone", isAlive(pid));
-    Assert.assertTrue(
-      "vmem for the gone-process is " + p.getVirtualMemorySize()
-          + " . It should be UNAVAILABLE(-1).",
-          p.getVirtualMemorySize() == UNAVAILABLE);
-    Assert.assertEquals("[ ]", p.toString());
+    assertFalse(isAlive(pid), "ProcessTree must have been gone");
+    assertTrue(
+        p.getVirtualMemorySize() == UNAVAILABLE,
+        "vmem for the gone-process is " + p.getVirtualMemorySize()
+            + " . It should be UNAVAILABLE(-1).");
+    assertEquals("[ ]", p.toString());
   }
   }
 
 
   protected ProcfsBasedProcessTree createProcessTree(String pid) {
   protected ProcfsBasedProcessTree createProcessTree(String pid) {
@@ -395,11 +399,12 @@ public class TestProcfsBasedProcessTree {
    *           if there was a problem setting up the fake procfs directories or
    *           if there was a problem setting up the fake procfs directories or
    *           files.
    *           files.
    */
    */
-  @Test(timeout = 30000)
-  public void testCpuAndMemoryForProcessTree() throws IOException {
+  @Test
+  @Timeout(30000)
+  void testCpuAndMemoryForProcessTree() throws IOException {
 
 
     // test processes
     // test processes
-    String[] pids = { "100", "200", "300", "400" };
+    String[] pids = {"100", "200", "300", "400"};
     ControlledClock testClock = new ControlledClock();
     ControlledClock testClock = new ControlledClock();
     testClock.setTime(0);
     testClock.setTime(0);
     // create the fake procfs root directory.
     // create the fake procfs root directory.
@@ -442,34 +447,35 @@ public class TestProcfsBasedProcessTree {
       processTree.updateProcessTree();
       processTree.updateProcessTree();
 
 
       // verify virtual memory
       // verify virtual memory
-      Assert.assertEquals("Virtual memory does not match", 600000L,
-        processTree.getVirtualMemorySize());
+      assertEquals(600000L, processTree.getVirtualMemorySize(), "Virtual memory does not match");
 
 
       // verify rss memory
       // verify rss memory
       long cumuRssMem =
       long cumuRssMem =
           ProcfsBasedProcessTree.PAGE_SIZE > 0
           ProcfsBasedProcessTree.PAGE_SIZE > 0
-              ? 600L * ProcfsBasedProcessTree.PAGE_SIZE : 
-                  ResourceCalculatorProcessTree.UNAVAILABLE;
-      Assert.assertEquals("rss memory does not match", cumuRssMem,
-        processTree.getRssMemorySize());
+              ? 600L * ProcfsBasedProcessTree.PAGE_SIZE :
+              ResourceCalculatorProcessTree.UNAVAILABLE;
+      assertEquals(cumuRssMem,
+          processTree.getRssMemorySize(),
+          "rss memory does not match");
 
 
       // verify cumulative cpu time
       // verify cumulative cpu time
       long cumuCpuTime =
       long cumuCpuTime =
           ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0
           ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0
               ? 7200L * ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS : 0L;
               ? 7200L * ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS : 0L;
-      Assert.assertEquals("Cumulative cpu time does not match", cumuCpuTime,
-        processTree.getCumulativeCpuTime());
+      assertEquals(cumuCpuTime,
+          processTree.getCumulativeCpuTime(),
+          "Cumulative cpu time does not match");
 
 
       // verify CPU usage
       // verify CPU usage
-      Assert.assertEquals("Percent CPU time should be set to -1 initially",
-          -1.0, processTree.getCpuUsagePercent(),
-          0.01);
+      assertEquals(-1.0, processTree.getCpuUsagePercent(),
+          0.01,
+          "Percent CPU time should be set to -1 initially");
 
 
       // Check by enabling smaps
       // Check by enabling smaps
       setSmapsInProceTree(processTree, true);
       setSmapsInProceTree(processTree, true);
       // anon (exclude r-xs,r--s)
       // anon (exclude r-xs,r--s)
-      Assert.assertEquals("rss memory does not match",
-          (20 * KB_TO_BYTES * 3), processTree.getRssMemorySize());
+      assertEquals((20 * KB_TO_BYTES * 3), processTree.getRssMemorySize(),
+          "rss memory does not match");
 
 
       // test the cpu time again to see if it cumulates
       // test the cpu time again to see if it cumulates
       procInfos[0] =
       procInfos[0] =
@@ -490,8 +496,9 @@ public class TestProcfsBasedProcessTree {
       cumuCpuTime =
       cumuCpuTime =
           ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0
           ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0
               ? 9400L * ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS : 0L;
               ? 9400L * ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS : 0L;
-      Assert.assertEquals("Cumulative cpu time does not match", cumuCpuTime,
-        processTree.getCumulativeCpuTime());
+      assertEquals(cumuCpuTime,
+          processTree.getCumulativeCpuTime(),
+          "Cumulative cpu time does not match");
 
 
       double expectedCpuUsagePercent =
       double expectedCpuUsagePercent =
           (ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0) ?
           (ProcfsBasedProcessTree.JIFFY_LENGTH_IN_MILLIS > 0) ?
@@ -500,11 +507,12 @@ public class TestProcfsBasedProcessTree {
       // expectedCpuUsagePercent is given by (94000L - 72000) * 100/
       // expectedCpuUsagePercent is given by (94000L - 72000) * 100/
       //    200000;
       //    200000;
       // which in this case is 11. Lets verify that first
       // which in this case is 11. Lets verify that first
-      Assert.assertEquals(11, expectedCpuUsagePercent, 0.001);
-      Assert.assertEquals("Percent CPU time is not correct expected " +
-              expectedCpuUsagePercent, expectedCpuUsagePercent,
+      assertEquals(11, expectedCpuUsagePercent, 0.001);
+      assertEquals(expectedCpuUsagePercent,
           processTree.getCpuUsagePercent(),
           processTree.getCpuUsagePercent(),
-          0.01);
+          0.01,
+          "Percent CPU time is not correct expected " +
+              expectedCpuUsagePercent);
     } finally {
     } finally {
       FileUtil.fullyDelete(procfsRootDir);
       FileUtil.fullyDelete(procfsRootDir);
     }
     }
@@ -529,8 +537,9 @@ public class TestProcfsBasedProcessTree {
    *           if there was a problem setting up the fake procfs directories or
    *           if there was a problem setting up the fake procfs directories or
    *           files.
    *           files.
    */
    */
-  @Test(timeout = 30000)
-  public void testMemForOlderProcesses() throws IOException {
+  @Test
+  @Timeout(30000)
+  void testMemForOlderProcesses() throws IOException {
     testMemForOlderProcesses(false);
     testMemForOlderProcesses(false);
     testMemForOlderProcesses(true);
     testMemForOlderProcesses(true);
   }
   }
@@ -576,8 +585,7 @@ public class TestProcfsBasedProcessTree {
       setSmapsInProceTree(processTree, smapEnabled);
       setSmapsInProceTree(processTree, smapEnabled);
 
 
       // verify virtual memory
       // verify virtual memory
-      Assert.assertEquals("Virtual memory does not match", 700000L,
-        processTree.getVirtualMemorySize());
+      assertEquals(700000L, processTree.getVirtualMemorySize(), "Virtual memory does not match");
 
 
       // write one more process as child of 100.
       // write one more process as child of 100.
       String[] newPids = { "500" };
       String[] newPids = { "500" };
@@ -594,36 +602,31 @@ public class TestProcfsBasedProcessTree {
 
 
       // check memory includes the new process.
       // check memory includes the new process.
       processTree.updateProcessTree();
       processTree.updateProcessTree();
-      Assert.assertEquals("vmem does not include new process",
-        1200000L, processTree.getVirtualMemorySize());
+      assertEquals(1200000L, processTree.getVirtualMemorySize(),
+          "vmem does not include new process");
       if (!smapEnabled) {
       if (!smapEnabled) {
-        long cumuRssMem =
-            ProcfsBasedProcessTree.PAGE_SIZE > 0
-                ? 1200L * ProcfsBasedProcessTree.PAGE_SIZE : 
-                    ResourceCalculatorProcessTree.UNAVAILABLE;
-        Assert.assertEquals("rssmem does not include new process",
-          cumuRssMem, processTree.getRssMemorySize());
+        long cumuRssMem = ProcfsBasedProcessTree.PAGE_SIZE > 0 ?
+            1200L * ProcfsBasedProcessTree.PAGE_SIZE :
+            ResourceCalculatorProcessTree.UNAVAILABLE;
+        assertEquals(cumuRssMem, processTree.getRssMemorySize(),
+            "rssmem does not include new process");
       } else {
       } else {
-        Assert.assertEquals("rssmem does not include new process",
-            20 * KB_TO_BYTES * 4, processTree.getRssMemorySize());
+        assertEquals(20 * KB_TO_BYTES * 4, processTree.getRssMemorySize(),
+            "rssmem does not include new process");
       }
       }
 
 
       // however processes older than 1 iteration will retain the older value
       // however processes older than 1 iteration will retain the older value
-      Assert.assertEquals(
-        "vmem shouldn't have included new process", 700000L,
-        processTree.getVirtualMemorySize(1));
+      assertEquals(700000L, processTree.getVirtualMemorySize(1),
+          "vmem shouldn't have included new process");
       if (!smapEnabled) {
       if (!smapEnabled) {
-        long cumuRssMem =
-            ProcfsBasedProcessTree.PAGE_SIZE > 0
-                ? 700L * ProcfsBasedProcessTree.PAGE_SIZE : 
-                    ResourceCalculatorProcessTree.UNAVAILABLE;
-        Assert.assertEquals(
-          "rssmem shouldn't have included new process", cumuRssMem,
-          processTree.getRssMemorySize(1));
+        long cumuRssMem = ProcfsBasedProcessTree.PAGE_SIZE > 0 ?
+            700L * ProcfsBasedProcessTree.PAGE_SIZE :
+            ResourceCalculatorProcessTree.UNAVAILABLE;
+        assertEquals(cumuRssMem, processTree.getRssMemorySize(1),
+            "rssmem shouldn't have included new process");
       } else {
       } else {
-        Assert.assertEquals(
-          "rssmem shouldn't have included new process",
-            20 * KB_TO_BYTES * 3, processTree.getRssMemorySize(1));
+        assertEquals(20 * KB_TO_BYTES * 3, processTree.getRssMemorySize(1),
+            "rssmem shouldn't have included new process");
       }
       }
 
 
       // one more process
       // one more process
@@ -643,49 +646,41 @@ public class TestProcfsBasedProcessTree {
       processTree.updateProcessTree();
       processTree.updateProcessTree();
 
 
       // processes older than 2 iterations should be same as before.
       // processes older than 2 iterations should be same as before.
-      Assert.assertEquals(
-        "vmem shouldn't have included new processes", 700000L,
-        processTree.getVirtualMemorySize(2));
+      assertEquals(700000L, processTree.getVirtualMemorySize(2),
+          "vmem shouldn't have included new processes");
       if (!smapEnabled) {
       if (!smapEnabled) {
         long cumuRssMem =
         long cumuRssMem =
             ProcfsBasedProcessTree.PAGE_SIZE > 0
             ProcfsBasedProcessTree.PAGE_SIZE > 0
                 ? 700L * ProcfsBasedProcessTree.PAGE_SIZE : 
                 ? 700L * ProcfsBasedProcessTree.PAGE_SIZE : 
                     ResourceCalculatorProcessTree.UNAVAILABLE;
                     ResourceCalculatorProcessTree.UNAVAILABLE;
-        Assert.assertEquals(
-          "rssmem shouldn't have included new processes",
-          cumuRssMem, processTree.getRssMemorySize(2));
+        assertEquals(cumuRssMem, processTree.getRssMemorySize(2),
+            "rssmem shouldn't have included new processes");
       } else {
       } else {
-        Assert.assertEquals(
-          "rssmem shouldn't have included new processes",
-            20 * KB_TO_BYTES * 3, processTree.getRssMemorySize(2));
+        assertEquals(20 * KB_TO_BYTES * 3, processTree.getRssMemorySize(2),
+            "rssmem shouldn't have included new processes");
       }
       }
 
 
       // processes older than 1 iteration should not include new process,
       // processes older than 1 iteration should not include new process,
       // but include process 500
       // but include process 500
-      Assert.assertEquals(
-        "vmem shouldn't have included new processes", 1200000L,
-        processTree.getVirtualMemorySize(1));
+      assertEquals(1200000L, processTree.getVirtualMemorySize(1),
+          "vmem shouldn't have included new processes");
       if (!smapEnabled) {
       if (!smapEnabled) {
         long cumuRssMem =
         long cumuRssMem =
             ProcfsBasedProcessTree.PAGE_SIZE > 0
             ProcfsBasedProcessTree.PAGE_SIZE > 0
                 ? 1200L * ProcfsBasedProcessTree.PAGE_SIZE : 
                 ? 1200L * ProcfsBasedProcessTree.PAGE_SIZE : 
                     ResourceCalculatorProcessTree.UNAVAILABLE;
                     ResourceCalculatorProcessTree.UNAVAILABLE;
-        Assert.assertEquals(
-          "rssmem shouldn't have included new processes",
-          cumuRssMem, processTree.getRssMemorySize(1));
+        assertEquals(cumuRssMem, processTree.getRssMemorySize(1),
+            "rssmem shouldn't have included new processes");
       } else {
       } else {
-        Assert.assertEquals(
-          "rssmem shouldn't have included new processes",
-            20 * KB_TO_BYTES * 4, processTree.getRssMemorySize(1));
+        assertEquals(20 * KB_TO_BYTES * 4, processTree.getRssMemorySize(1),
+            "rssmem shouldn't have included new processes");
       }
       }
 
 
       // no processes older than 3 iterations
       // no processes older than 3 iterations
-      Assert.assertEquals(
-          "Getting non-zero vmem for processes older than 3 iterations",
-          0, processTree.getVirtualMemorySize(3));
-      Assert.assertEquals(
-          "Getting non-zero rssmem for processes older than 3 iterations",
-          0, processTree.getRssMemorySize(3));
+      assertEquals(0, processTree.getVirtualMemorySize(3),
+          "Getting non-zero vmem for processes older than 3 iterations");
+      assertEquals(0, processTree.getRssMemorySize(3),
+          "Getting non-zero rssmem for processes older than 3 iterations");
     } finally {
     } finally {
       FileUtil.fullyDelete(procfsRootDir);
       FileUtil.fullyDelete(procfsRootDir);
     }
     }
@@ -700,8 +695,9 @@ public class TestProcfsBasedProcessTree {
    *           if there was a problem setting up the fake procfs directories or
    *           if there was a problem setting up the fake procfs directories or
    *           files.
    *           files.
    */
    */
-  @Test(timeout = 30000)
-  public void testDestroyProcessTree() throws IOException {
+  @Test
+  @Timeout(30000)
+  void testDestroyProcessTree() throws IOException {
     // test process
     // test process
     String pid = "100";
     String pid = "100";
     // create the fake procfs root directory.
     // create the fake procfs root directory.
@@ -715,8 +711,8 @@ public class TestProcfsBasedProcessTree {
           SystemClock.getInstance());
           SystemClock.getInstance());
 
 
       // Let us not create stat file for pid 100.
       // Let us not create stat file for pid 100.
-      Assert.assertTrue(ProcfsBasedProcessTree.checkPidPgrpidForMatch(pid,
-        procfsRootDir.getAbsolutePath()));
+      assertTrue(ProcfsBasedProcessTree.checkPidPgrpidForMatch(pid,
+          procfsRootDir.getAbsolutePath()));
     } finally {
     } finally {
       FileUtil.fullyDelete(procfsRootDir);
       FileUtil.fullyDelete(procfsRootDir);
     }
     }
@@ -727,10 +723,11 @@ public class TestProcfsBasedProcessTree {
    *
    *
    * @throws IOException
    * @throws IOException
    */
    */
-  @Test(timeout = 30000)
-  public void testProcessTreeDump() throws IOException {
+  @Test
+  @Timeout(30000)
+  void testProcessTreeDump() throws IOException {
 
 
-    String[] pids = { "100", "200", "300", "400", "500", "600" };
+    String[] pids = {"100", "200", "300", "400", "500", "600"};
 
 
     File procfsRootDir = new File(TEST_ROOT_DIR, "proc");
     File procfsRootDir = new File(TEST_ROOT_DIR, "proc");
 
 
@@ -790,29 +787,29 @@ public class TestProcfsBasedProcessTree {
       String processTreeDump = processTree.getProcessTreeDump();
       String processTreeDump = processTree.getProcessTreeDump();
 
 
       LOG.info("Process-tree dump follows: \n" + processTreeDump);
       LOG.info("Process-tree dump follows: \n" + processTreeDump);
-      Assert.assertTrue("Process-tree dump doesn't start with a proper header",
-        processTreeDump.startsWith("\t|- PID PPID PGRPID SESSID CMD_NAME "
-            + "USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) "
-            + "RSSMEM_USAGE(PAGES) FULL_CMD_LINE\n"));
+      assertTrue(processTreeDump.startsWith("\t|- PID PPID PGRPID SESSID CMD_NAME "
+              + "USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) "
+              + "RSSMEM_USAGE(PAGES) FULL_CMD_LINE\n"),
+          "Process-tree dump doesn't start with a proper header");
       for (int i = 0; i < 5; i++) {
       for (int i = 0; i < 5; i++) {
         ProcessStatInfo p = procInfos[i];
         ProcessStatInfo p = procInfos[i];
-        Assert.assertTrue(
-          "Process-tree dump doesn't contain the cmdLineDump of process "
-              + p.pid,
-          processTreeDump.contains("\t|- " + p.pid + " " + p.ppid + " "
-              + p.pgrpId + " " + p.session + " (" + p.name + ") " + p.utime
-              + " " + p.stime + " " + p.vmem + " " + p.rssmemPage + " "
-              + cmdLines[i]));
+        assertTrue(
+            processTreeDump.contains("\t|- " + p.pid + " " + p.ppid + " "
+                + p.pgrpId + " " + p.session + " (" + p.name + ") " + p.utime
+                + " " + p.stime + " " + p.vmem + " " + p.rssmemPage + " "
+                + cmdLines[i]),
+            "Process-tree dump doesn't contain the cmdLineDump of process "
+                + p.pid);
       }
       }
 
 
       // 600 should not be in the dump
       // 600 should not be in the dump
       ProcessStatInfo p = procInfos[5];
       ProcessStatInfo p = procInfos[5];
-      Assert.assertFalse(
-        "Process-tree dump shouldn't contain the cmdLineDump of process "
-            + p.pid,
-        processTreeDump.contains("\t|- " + p.pid + " " + p.ppid + " "
-            + p.pgrpId + " " + p.session + " (" + p.name + ") " + p.utime + " "
-            + p.stime + " " + p.vmem + " " + cmdLines[5]));
+      assertFalse(
+          processTreeDump.contains("\t|- " + p.pid + " " + p.ppid + " "
+              + p.pgrpId + " " + p.session + " (" + p.name + ") " + p.utime + " "
+              + p.stime + " " + p.vmem + " " + cmdLines[5]),
+          "Process-tree dump shouldn't contain the cmdLineDump of process "
+              + p.pid);
     } finally {
     } finally {
       FileUtil.fullyDelete(procfsRootDir);
       FileUtil.fullyDelete(procfsRootDir);
     }
     }
@@ -887,11 +884,11 @@ public class TestProcfsBasedProcessTree {
   public static void setupProcfsRootDir(File procfsRootDir) throws IOException {
   public static void setupProcfsRootDir(File procfsRootDir) throws IOException {
     // cleanup any existing process root dir.
     // cleanup any existing process root dir.
     if (procfsRootDir.exists()) {
     if (procfsRootDir.exists()) {
-      Assert.assertTrue(FileUtil.fullyDelete(procfsRootDir));
+      assertTrue(FileUtil.fullyDelete(procfsRootDir));
     }
     }
 
 
     // create afresh
     // create afresh
-    Assert.assertTrue(procfsRootDir.mkdirs());
+    assertTrue(procfsRootDir.mkdirs());
   }
   }
 
 
   /**
   /**

+ 20 - 18
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestRackResolver.java

@@ -24,16 +24,19 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 
 
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
+
 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.net.DNSToSwitchMapping;
 import org.apache.hadoop.net.DNSToSwitchMapping;
 import org.apache.hadoop.net.NetworkTopology;
 import org.apache.hadoop.net.NetworkTopology;
 import org.apache.hadoop.net.Node;
 import org.apache.hadoop.net.Node;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestRackResolver {
 public class TestRackResolver {
 
 
@@ -41,7 +44,7 @@ public class TestRackResolver {
       LoggerFactory.getLogger(TestRackResolver.class);
       LoggerFactory.getLogger(TestRackResolver.class);
   private static final String invalidHost = "invalidHost";
   private static final String invalidHost = "invalidHost";
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     RackResolver.reset();
     RackResolver.reset();
   }
   }
@@ -54,8 +57,7 @@ public class TestRackResolver {
     @Override
     @Override
     public List<String> resolve(List<String> hostList) {
     public List<String> resolve(List<String> hostList) {
       // Only one host at a time
       // Only one host at a time
-      Assert.assertTrue("hostList size is " + hostList.size(),
-        hostList.size() <= 1);
+      assertTrue(hostList.size() <= 1, "hostList size is " + hostList.size());
       List<String> returnList = new ArrayList<String>();
       List<String> returnList = new ArrayList<String>();
       if (hostList.isEmpty()) {
       if (hostList.isEmpty()) {
         return returnList;
         return returnList;
@@ -74,7 +76,7 @@ public class TestRackResolver {
       }
       }
       // I should not be reached again as RackResolver is supposed to do
       // I should not be reached again as RackResolver is supposed to do
       // caching.
       // caching.
-      Assert.assertTrue(numHost1 <= 1);
+      assertTrue(numHost1 <= 1);
       return returnList;
       return returnList;
     }
     }
 
 
@@ -112,7 +114,7 @@ public class TestRackResolver {
         // I should not be reached again as RackResolver is supposed to do
         // I should not be reached again as RackResolver is supposed to do
         // caching.
         // caching.
       }
       }
-      Assert.assertEquals(returnList.size(), hostList.size());
+      assertEquals(returnList.size(), hostList.size());
       return returnList;
       return returnList;
     }
     }
 
 
@@ -127,11 +129,11 @@ public class TestRackResolver {
   }
   }
 
 
   @Test
   @Test
-  public void testCaching() {
+  void testCaching() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.setClass(
     conf.setClass(
-      CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
-      MyResolver.class, DNSToSwitchMapping.class);
+        CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
+        MyResolver.class, DNSToSwitchMapping.class);
     RackResolver.init(conf);
     RackResolver.init(conf);
     try {
     try {
       InetAddress iaddr = InetAddress.getByName("host1");
       InetAddress iaddr = InetAddress.getByName("host1");
@@ -140,15 +142,15 @@ public class TestRackResolver {
       // Ignore if not found
       // Ignore if not found
     }
     }
     Node node = RackResolver.resolve("host1");
     Node node = RackResolver.resolve("host1");
-    Assert.assertEquals("/rack1", node.getNetworkLocation());
+    assertEquals("/rack1", node.getNetworkLocation());
     node = RackResolver.resolve("host1");
     node = RackResolver.resolve("host1");
-    Assert.assertEquals("/rack1", node.getNetworkLocation());
+    assertEquals("/rack1", node.getNetworkLocation());
     node = RackResolver.resolve(invalidHost);
     node = RackResolver.resolve(invalidHost);
-    Assert.assertEquals(NetworkTopology.DEFAULT_RACK, node.getNetworkLocation());
+    assertEquals(NetworkTopology.DEFAULT_RACK, node.getNetworkLocation());
   }
   }
 
 
   @Test
   @Test
-  public void testMultipleHosts() {
+  void testMultipleHosts() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.setClass(
     conf.setClass(
         CommonConfigurationKeysPublic
         CommonConfigurationKeysPublic
@@ -158,9 +160,9 @@ public class TestRackResolver {
     RackResolver.init(conf);
     RackResolver.init(conf);
     List<Node> nodes = RackResolver.resolve(
     List<Node> nodes = RackResolver.resolve(
         Arrays.asList("host1", invalidHost, "host2"));
         Arrays.asList("host1", invalidHost, "host2"));
-    Assert.assertEquals("/rack1", nodes.get(0).getNetworkLocation());
-    Assert.assertEquals(NetworkTopology.DEFAULT_RACK,
+    assertEquals("/rack1", nodes.get(0).getNetworkLocation());
+    assertEquals(NetworkTopology.DEFAULT_RACK,
         nodes.get(1).getNetworkLocation());
         nodes.get(1).getNetworkLocation());
-    Assert.assertEquals("/rack2", nodes.get(2).getNetworkLocation());
+    assertEquals("/rack2", nodes.get(2).getNetworkLocation());
   }
   }
 }
 }

+ 6 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestRackResolverScriptBasedMapping.java

@@ -18,17 +18,19 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
+import org.junit.jupiter.api.Test;
+
 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.net.DNSToSwitchMapping;
 import org.apache.hadoop.net.DNSToSwitchMapping;
 import org.apache.hadoop.net.ScriptBasedMapping;
 import org.apache.hadoop.net.ScriptBasedMapping;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestRackResolverScriptBasedMapping {
 public class TestRackResolverScriptBasedMapping {
 
 
   @Test
   @Test
-  public void testScriptName() {
+  void testScriptName() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf
     conf
         .setClass(
         .setClass(
@@ -38,7 +40,7 @@ public class TestRackResolverScriptBasedMapping {
     conf.set(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY,
     conf.set(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_FILE_NAME_KEY,
         "testScript");
         "testScript");
     RackResolver.init(conf);
     RackResolver.init(conf);
-    Assert.assertEquals(RackResolver.getDnsToSwitchMapping().toString(),
+    assertEquals(RackResolver.getDnsToSwitchMapping().toString(),
         "script-based mapping with script testScript");
         "script-based mapping with script testScript");
   }
   }
 }
 }

+ 9 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestResourceCalculatorProcessTree.java

@@ -17,11 +17,14 @@
  */
  */
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.hamcrest.core.IsInstanceOf.*;
-import static org.hamcrest.core.IsSame.*;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.hamcrest.core.IsSame.sameInstance;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 /**
 /**
  * A JUnit test to test {@link ResourceCalculatorPlugin}
  * A JUnit test to test {@link ResourceCalculatorPlugin}
@@ -73,7 +76,7 @@ public class TestResourceCalculatorProcessTree {
   }
   }
 
 
   @Test
   @Test
-  public void testCreateInstance() {
+  void testCreateInstance() {
     ResourceCalculatorProcessTree tree;
     ResourceCalculatorProcessTree tree;
     tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, new Configuration());
     tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, new Configuration());
     assertNotNull(tree);
     assertNotNull(tree);
@@ -81,7 +84,7 @@ public class TestResourceCalculatorProcessTree {
   }
   }
 
 
   @Test
   @Test
-  public void testCreatedInstanceConfigured() {
+  void testCreatedInstanceConfigured() {
     ResourceCalculatorProcessTree tree;
     ResourceCalculatorProcessTree tree;
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, conf);
     tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, conf);

+ 13 - 12
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestTimelineServiceHelper.java

@@ -17,34 +17,35 @@
  */
  */
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeMap;
 
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 public class TestTimelineServiceHelper {
 public class TestTimelineServiceHelper {
 
 
   @Test
   @Test
-  public void testMapCastToHashMap() {
+  void testMapCastToHashMap() {
 
 
     // Test null map be casted to null
     // Test null map be casted to null
     Map<String, String> nullMap = null;
     Map<String, String> nullMap = null;
-    Assert.assertNull(TimelineServiceHelper.mapCastToHashMap(nullMap));
+    assertNull(TimelineServiceHelper.mapCastToHashMap(nullMap));
 
 
     // Test empty hashmap be casted to a empty hashmap
     // Test empty hashmap be casted to a empty hashmap
     Map<String, String> emptyHashMap = new HashMap<String, String>();
     Map<String, String> emptyHashMap = new HashMap<String, String>();
-    Assert.assertEquals(
+    assertEquals(
         TimelineServiceHelper.mapCastToHashMap(emptyHashMap).size(), 0);
         TimelineServiceHelper.mapCastToHashMap(emptyHashMap).size(), 0);
 
 
     // Test empty non-hashmap be casted to a empty hashmap
     // Test empty non-hashmap be casted to a empty hashmap
     Map<String, String> emptyTreeMap = new TreeMap<String, String>();
     Map<String, String> emptyTreeMap = new TreeMap<String, String>();
-    Assert.assertEquals(
+    assertEquals(
         TimelineServiceHelper.mapCastToHashMap(emptyTreeMap).size(), 0);
         TimelineServiceHelper.mapCastToHashMap(emptyTreeMap).size(), 0);
 
 
     // Test non-empty hashmap be casted to hashmap correctly
     // Test non-empty hashmap be casted to hashmap correctly
@@ -52,7 +53,7 @@ public class TestTimelineServiceHelper {
     String key = "KEY";
     String key = "KEY";
     String value = "VALUE";
     String value = "VALUE";
     firstHashMap.put(key, value);
     firstHashMap.put(key, value);
-    Assert.assertEquals(
+    assertEquals(
         TimelineServiceHelper.mapCastToHashMap(firstHashMap), firstHashMap);
         TimelineServiceHelper.mapCastToHashMap(firstHashMap), firstHashMap);
 
 
     // Test non-empty non-hashmap is casted correctly.
     // Test non-empty non-hashmap is casted correctly.
@@ -60,7 +61,7 @@ public class TestTimelineServiceHelper {
     firstTreeMap.put(key, value);
     firstTreeMap.put(key, value);
     HashMap<String, String> alternateHashMap =
     HashMap<String, String> alternateHashMap =
         TimelineServiceHelper.mapCastToHashMap(firstTreeMap);
         TimelineServiceHelper.mapCastToHashMap(firstTreeMap);
-    Assert.assertEquals(firstTreeMap.size(), alternateHashMap.size());
+    assertEquals(firstTreeMap.size(), alternateHashMap.size());
     assertThat(alternateHashMap.get(key)).isEqualTo(value);
     assertThat(alternateHashMap.get(key)).isEqualTo(value);
 
 
     // Test complicated hashmap be casted correctly
     // Test complicated hashmap be casted correctly
@@ -69,7 +70,7 @@ public class TestTimelineServiceHelper {
     Set<String> hashSet = new HashSet<String>();
     Set<String> hashSet = new HashSet<String>();
     hashSet.add(value);
     hashSet.add(value);
     complicatedHashMap.put(key, hashSet);
     complicatedHashMap.put(key, hashSet);
-    Assert.assertEquals(
+    assertEquals(
         TimelineServiceHelper.mapCastToHashMap(complicatedHashMap),
         TimelineServiceHelper.mapCastToHashMap(complicatedHashMap),
         complicatedHashMap);
         complicatedHashMap);
 
 
@@ -77,7 +78,7 @@ public class TestTimelineServiceHelper {
     Map<String, Set<String>> complicatedTreeMap =
     Map<String, Set<String>> complicatedTreeMap =
         new TreeMap<String, Set<String>>();
         new TreeMap<String, Set<String>>();
     complicatedTreeMap.put(key, hashSet);
     complicatedTreeMap.put(key, hashSet);
-    Assert.assertEquals(
+    assertEquals(
         TimelineServiceHelper.mapCastToHashMap(complicatedTreeMap).get(key),
         TimelineServiceHelper.mapCastToHashMap(complicatedTreeMap).get(key),
         hashSet);
         hashSet);
   }
   }

+ 19 - 19
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestTimes.java

@@ -18,64 +18,64 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
-import org.junit.Assert;
-import org.junit.Test;
-
 import java.io.IOException;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
 
 
+import org.junit.jupiter.api.Test;
+
 import static org.apache.hadoop.yarn.util.Times.ISO8601_DATE_FORMAT;
 import static org.apache.hadoop.yarn.util.Times.ISO8601_DATE_FORMAT;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestTimes {
 public class TestTimes {
 
 
   @Test
   @Test
-  public void testNegativeStartTimes() {
+  void testNegativeStartTimes() {
     long elapsed = Times.elapsed(-5, 10, true);
     long elapsed = Times.elapsed(-5, 10, true);
-    Assert.assertEquals("Elapsed time is not 0", 0, elapsed);
+    assertEquals(0, elapsed, "Elapsed time is not 0");
     elapsed = Times.elapsed(-5, 10, false);
     elapsed = Times.elapsed(-5, 10, false);
-    Assert.assertEquals("Elapsed time is not -1", -1, elapsed);
+    assertEquals(-1, elapsed, "Elapsed time is not -1");
   }
   }
 
 
   @Test
   @Test
-  public void testNegativeFinishTimes() {
+  void testNegativeFinishTimes() {
     long elapsed = Times.elapsed(5, -10, false);
     long elapsed = Times.elapsed(5, -10, false);
-    Assert.assertEquals("Elapsed time is not -1", -1, elapsed);
+    assertEquals(-1, elapsed, "Elapsed time is not -1");
   }
   }
 
 
   @Test
   @Test
-  public void testNegativeStartandFinishTimes() {
+  void testNegativeStartandFinishTimes() {
     long elapsed = Times.elapsed(-5, -10, false);
     long elapsed = Times.elapsed(-5, -10, false);
-    Assert.assertEquals("Elapsed time is not -1", -1, elapsed);
+    assertEquals(-1, elapsed, "Elapsed time is not -1");
   }
   }
 
 
   @Test
   @Test
-  public void testPositiveStartandFinishTimes() {
+  void testPositiveStartandFinishTimes() {
     long elapsed = Times.elapsed(5, 10, true);
     long elapsed = Times.elapsed(5, 10, true);
-    Assert.assertEquals("Elapsed time is not 5", 5, elapsed);
+    assertEquals(5, elapsed, "Elapsed time is not 5");
     elapsed = Times.elapsed(5, 10, false);
     elapsed = Times.elapsed(5, 10, false);
-    Assert.assertEquals("Elapsed time is not 5", 5, elapsed);
+    assertEquals(5, elapsed, "Elapsed time is not 5");
   }
   }
 
 
   @Test
   @Test
-  public void testFinishTimesAheadOfStartTimes() {
+  void testFinishTimesAheadOfStartTimes() {
     long elapsed = Times.elapsed(10, 5, true);
     long elapsed = Times.elapsed(10, 5, true);
-    Assert.assertEquals("Elapsed time is not -1", -1, elapsed);
+    assertEquals(-1, elapsed, "Elapsed time is not -1");
     elapsed = Times.elapsed(10, 5, false);
     elapsed = Times.elapsed(10, 5, false);
-    Assert.assertEquals("Elapsed time is not -1", -1, elapsed);
+    assertEquals(-1, elapsed, "Elapsed time is not -1");
     // use Long.MAX_VALUE to ensure started time is after the current one
     // use Long.MAX_VALUE to ensure started time is after the current one
     elapsed = Times.elapsed(Long.MAX_VALUE, 0, true);
     elapsed = Times.elapsed(Long.MAX_VALUE, 0, true);
-    Assert.assertEquals("Elapsed time is not -1", -1, elapsed);
+    assertEquals(-1, elapsed, "Elapsed time is not -1");
   }
   }
 
 
   @Test
   @Test
-  public void validateISO() throws IOException {
+  void validateISO() throws IOException {
     SimpleDateFormat isoFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT);
     SimpleDateFormat isoFormat = new SimpleDateFormat(ISO8601_DATE_FORMAT);
     for (int i = 0; i < 1000; i++) {
     for (int i = 0; i < 1000; i++) {
       long now = System.currentTimeMillis();
       long now = System.currentTimeMillis();
       String instant =  Times.formatISO8601(now);
       String instant =  Times.formatISO8601(now);
       String date = isoFormat.format(new Date(now));
       String date = isoFormat.format(new Date(now));
-      Assert.assertEquals(date, instant);
+      assertEquals(date, instant);
     }
     }
   }
   }
 }
 }

+ 11 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestWindowsBasedProcessTree.java

@@ -18,13 +18,14 @@
 
 
 package org.apache.hadoop.yarn.util;
 package org.apache.hadoop.yarn.util;
 
 
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
-import org.junit.Assert;
-import org.junit.Test;
 
 
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestWindowsBasedProcessTree {
 public class TestWindowsBasedProcessTree {
   private static final Logger LOG = LoggerFactory
   private static final Logger LOG = LoggerFactory
@@ -42,12 +43,13 @@ public class TestWindowsBasedProcessTree {
     }
     }
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(30000)
   @SuppressWarnings("deprecation")
   @SuppressWarnings("deprecation")
-  public void tree() {
+  void tree() {
     assumeWindows();
     assumeWindows();
-    assertTrue("WindowsBasedProcessTree should be available on Windows", 
-               WindowsBasedProcessTree.isAvailable());
+    assertTrue(WindowsBasedProcessTree.isAvailable(),
+        "WindowsBasedProcessTree should be available on Windows");
     ControlledClock testClock = new ControlledClock();
     ControlledClock testClock = new ControlledClock();
     long elapsedTimeBetweenUpdatesMsec = 0;
     long elapsedTimeBetweenUpdatesMsec = 0;
     testClock.setTime(elapsedTimeBetweenUpdatesMsec);
     testClock.setTime(elapsedTimeBetweenUpdatesMsec);
@@ -72,8 +74,7 @@ public class TestWindowsBasedProcessTree {
     assertTrue(pTree.getRssMemorySize(1) == 2048);
     assertTrue(pTree.getRssMemorySize(1) == 2048);
     assertTrue(pTree.getCumulativeCpuTime() == 3000);
     assertTrue(pTree.getCumulativeCpuTime() == 3000);
     assertTrue(pTree.getCpuUsagePercent() == 200);
     assertTrue(pTree.getCpuUsagePercent() == 200);
-    Assert.assertEquals("Percent CPU time is not correct",
-        pTree.getCpuUsagePercent(), 200, 0.01);
+    assertEquals(pTree.getCpuUsagePercent(), 200, 0.01, "Percent CPU time is not correct");
 
 
     pTree.infoStr = "3524,1024,1024,1500\r\n2844,1024,1024,1500\r\n";
     pTree.infoStr = "3524,1024,1024,1500\r\n2844,1024,1024,1500\r\n";
     elapsedTimeBetweenUpdatesMsec = 2000;
     elapsedTimeBetweenUpdatesMsec = 2000;
@@ -84,7 +85,6 @@ public class TestWindowsBasedProcessTree {
     assertTrue(pTree.getRssMemorySize() == 2048);
     assertTrue(pTree.getRssMemorySize() == 2048);
     assertTrue(pTree.getRssMemorySize(2) == 2048);
     assertTrue(pTree.getRssMemorySize(2) == 2048);
     assertTrue(pTree.getCumulativeCpuTime() == 4000);
     assertTrue(pTree.getCumulativeCpuTime() == 4000);
-    Assert.assertEquals("Percent CPU time is not correct",
-        pTree.getCpuUsagePercent(), 0, 0.01);
+    assertEquals(pTree.getCpuUsagePercent(), 0, 0.01, "Percent CPU time is not correct");
   }
   }
 }
 }

+ 16 - 17
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestYarnVersionInfo.java

@@ -20,39 +20,38 @@ package org.apache.hadoop.yarn.util;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * A JUnit test to test {@link YarnVersionInfo}
  * A JUnit test to test {@link YarnVersionInfo}
  */
  */
 public class TestYarnVersionInfo {
 public class TestYarnVersionInfo {
-  
+
   /**
   /**
    * Test the yarn version info routines.
    * Test the yarn version info routines.
    * @throws IOException
    * @throws IOException
    */
    */
   @Test
   @Test
-  public void versionInfoGenerated() throws IOException {
+  void versionInfoGenerated() throws IOException {
 
 
     // can't easily know what the correct values are going to be so just
     // can't easily know what the correct values are going to be so just
     // make sure they aren't Unknown
     // make sure they aren't Unknown
-    assertNotEquals("getVersion returned Unknown",
-        "Unknown", YarnVersionInfo.getVersion());
-    assertNotEquals("getUser returned Unknown",
-        "Unknown", YarnVersionInfo.getUser());
-    assertNotEquals("getSrcChecksum returned Unknown",
-        "Unknown", YarnVersionInfo.getSrcChecksum());
+    assertNotEquals("Unknown", YarnVersionInfo.getVersion(), "getVersion returned Unknown");
+    assertNotEquals("Unknown", YarnVersionInfo.getUser(), "getUser returned Unknown");
+    assertNotEquals("Unknown", YarnVersionInfo.getSrcChecksum(), "getSrcChecksum returned Unknown");
 
 
     // these could be Unknown if the VersionInfo generated from code not in svn or git
     // these could be Unknown if the VersionInfo generated from code not in svn or git
     // so just check that they return something
     // so just check that they return something
-    assertNotNull("getUrl returned null", YarnVersionInfo.getUrl());
-    assertNotNull("getRevision returned null", YarnVersionInfo.getRevision());
-    assertNotNull("getBranch returned null", YarnVersionInfo.getBranch());
+    assertNotNull(YarnVersionInfo.getUrl(), "getUrl returned null");
+    assertNotNull(YarnVersionInfo.getRevision(), "getRevision returned null");
+    assertNotNull(YarnVersionInfo.getBranch(), "getBranch returned null");
 
 
-    assertTrue("getBuildVersion check doesn't contain: source checksum",
-               YarnVersionInfo.getBuildVersion().contains("source checksum"));
+    assertTrue(YarnVersionInfo.getBuildVersion().contains("source checksum"),
+        "getBuildVersion check doesn't contain: source checksum");
 
 
   }
   }
 }
 }

+ 8 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/CustomResourceTypesConfigurationProvider.java

@@ -16,14 +16,6 @@
 
 
 package org.apache.hadoop.yarn.util.resource;
 package org.apache.hadoop.yarn.util.resource;
 
 
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.util.Lists;
-import org.apache.hadoop.yarn.LocalConfigurationProvider;
-import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
-import org.apache.hadoop.yarn.api.records.ResourceInformation;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
@@ -33,6 +25,14 @@ import java.util.Map;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.IntStream;
 
 
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.util.Lists;
+import org.apache.hadoop.yarn.LocalConfigurationProvider;
+import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
+import org.apache.hadoop.yarn.api.records.ResourceInformation;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toList;
 
 
 /**
 /**

+ 90 - 67
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceCalculator.java

@@ -22,32 +22,32 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
 
 
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
 import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableSet;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
-@RunWith(Parameterized.class)
 public class TestResourceCalculator {
 public class TestResourceCalculator {
   private static final String EXTRA_RESOURCE_NAME = "test";
   private static final String EXTRA_RESOURCE_NAME = "test";
 
 
-  private final ResourceCalculator resourceCalculator;
+  private ResourceCalculator resourceCalculator;
 
 
-  @Parameterized.Parameters(name = "{0}")
   public static Collection<Object[]> getParameters() {
   public static Collection<Object[]> getParameters() {
-    return Arrays.asList(new Object[][] {
-        { "DefaultResourceCalculator", new DefaultResourceCalculator() },
-        { "DominantResourceCalculator", new DominantResourceCalculator() } });
+    return Arrays.asList(new Object[][]{
+        {"DefaultResourceCalculator", new DefaultResourceCalculator()},
+        {"DominantResourceCalculator", new DominantResourceCalculator()}});
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setupNoExtraResource() {
   public void setupNoExtraResource() {
     // This has to run before each test because we don't know when
     // This has to run before each test because we don't know when
     // setupExtraResource() might be called
     // setupExtraResource() might be called
@@ -61,34 +61,38 @@ public class TestResourceCalculator {
     ResourceUtils.resetResourceTypes(conf);
     ResourceUtils.resetResourceTypes(conf);
   }
   }
 
 
-  public TestResourceCalculator(String name, ResourceCalculator rs) {
+  public void initTestResourceCalculator(String name, ResourceCalculator rs) {
     this.resourceCalculator = rs;
     this.resourceCalculator = rs;
   }
   }
-  
-  @Test(timeout = 10000)
-  public void testFitsIn() {
+
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  @Timeout(10000)
+  void testFitsIn(String name, ResourceCalculator rs) {
+
+    initTestResourceCalculator(name, rs);
 
 
     if (resourceCalculator instanceof DefaultResourceCalculator) {
     if (resourceCalculator instanceof DefaultResourceCalculator) {
-      Assert.assertTrue(resourceCalculator.fitsIn(
+      assertTrue(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(2, 1)));
           Resource.newInstance(1, 2), Resource.newInstance(2, 1)));
-      Assert.assertTrue(resourceCalculator.fitsIn(
+      assertTrue(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(2, 2)));
           Resource.newInstance(1, 2), Resource.newInstance(2, 2)));
-      Assert.assertTrue(resourceCalculator.fitsIn(
+      assertTrue(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(1, 2)));
           Resource.newInstance(1, 2), Resource.newInstance(1, 2)));
-      Assert.assertTrue(resourceCalculator.fitsIn(
+      assertTrue(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(1, 1)));
           Resource.newInstance(1, 2), Resource.newInstance(1, 1)));
-      Assert.assertFalse(resourceCalculator.fitsIn(
+      assertFalse(resourceCalculator.fitsIn(
           Resource.newInstance(2, 1), Resource.newInstance(1, 2)));
           Resource.newInstance(2, 1), Resource.newInstance(1, 2)));
     } else if (resourceCalculator instanceof DominantResourceCalculator) {
     } else if (resourceCalculator instanceof DominantResourceCalculator) {
-      Assert.assertFalse(resourceCalculator.fitsIn(
+      assertFalse(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(2, 1)));
           Resource.newInstance(1, 2), Resource.newInstance(2, 1)));
-      Assert.assertTrue(resourceCalculator.fitsIn(
+      assertTrue(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(2, 2)));
           Resource.newInstance(1, 2), Resource.newInstance(2, 2)));
-      Assert.assertTrue(resourceCalculator.fitsIn(
+      assertTrue(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(1, 2)));
           Resource.newInstance(1, 2), Resource.newInstance(1, 2)));
-      Assert.assertFalse(resourceCalculator.fitsIn(
+      assertFalse(resourceCalculator.fitsIn(
           Resource.newInstance(1, 2), Resource.newInstance(1, 1)));
           Resource.newInstance(1, 2), Resource.newInstance(1, 1)));
-      Assert.assertFalse(resourceCalculator.fitsIn(
+      assertFalse(resourceCalculator.fitsIn(
           Resource.newInstance(2, 1), Resource.newInstance(1, 2)));
           Resource.newInstance(2, 1), Resource.newInstance(1, 2)));
     }
     }
   }
   }
@@ -121,22 +125,22 @@ public class TestResourceCalculator {
       int expected) {
       int expected) {
     int actual = resourceCalculator.compare(cluster, res1, res2);
     int actual = resourceCalculator.compare(cluster, res1, res2);
 
 
-    assertEquals(String.format("Resource comparison did not give the expected "
-        + "result for %s v/s %s", res1.toString(), res2.toString()),
-        expected, actual);
+    assertEquals(expected, actual, String.format("Resource comparison did not give the expected "
+        + "result for %s v/s %s", res1.toString(), res2.toString()));
 
 
     if (expected != 0) {
     if (expected != 0) {
       // Try again with args in the opposite order and the negative of the
       // Try again with args in the opposite order and the negative of the
       // expected result.
       // expected result.
       actual = resourceCalculator.compare(cluster, res2, res1);
       actual = resourceCalculator.compare(cluster, res2, res1);
-      assertEquals(String.format("Resource comparison did not give the "
-          + "expected result for %s v/s %s", res2.toString(), res1.toString()),
-          expected * -1, actual);
+      assertEquals(expected * -1, actual, String.format("Resource comparison did not give the "
+          + "expected result for %s v/s %s", res2.toString(), res1.toString()));
     }
     }
   }
   }
 
 
-  @Test
-  public void testCompareWithOnlyMandatory() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testCompareWithOnlyMandatory(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     // This test is necessary because there are optimizations that are only
     // This test is necessary because there are optimizations that are only
     // triggered when only the mandatory resources are configured.
     // triggered when only the mandatory resources are configured.
 
 
@@ -173,8 +177,10 @@ public class TestResourceCalculator {
     assertComparison(cluster, newResource(3, 1), newResource(3, 0), 1);
     assertComparison(cluster, newResource(3, 1), newResource(3, 0), 1);
   }
   }
 
 
-  @Test
-  public void testCompare() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testCompare(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     // Test with 3 resources
     // Test with 3 resources
     setupExtraResource();
     setupExtraResource();
 
 
@@ -209,7 +215,7 @@ public class TestResourceCalculator {
   /**
   /**
    * Verify compare when one or all the resource are zero.
    * Verify compare when one or all the resource are zero.
    */
    */
-  private void testCompareDominantZeroValueResource(){
+  private void testCompareDominantZeroValueResource() {
     Resource cluster = newResource(4L, 4, 0);
     Resource cluster = newResource(4L, 4, 0);
     assertComparison(cluster, newResource(2, 1, 1), newResource(1, 1, 2), 1);
     assertComparison(cluster, newResource(2, 1, 1), newResource(1, 1, 2), 1);
     assertComparison(cluster, newResource(2, 2, 1), newResource(1, 2, 2), 1);
     assertComparison(cluster, newResource(2, 2, 1), newResource(1, 2, 2), 1);
@@ -261,8 +267,11 @@ public class TestResourceCalculator {
     assertComparison(cluster, newResource(3, 1, 1), newResource(3, 0, 0), 1);
     assertComparison(cluster, newResource(3, 1, 1), newResource(3, 0, 0), 1);
   }
   }
 
 
-  @Test(timeout = 10000)
-  public void testCompareWithEmptyCluster() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  @Timeout(10000)
+  void testCompareWithEmptyCluster(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     Resource clusterResource = Resource.newInstance(0, 0);
     Resource clusterResource = Resource.newInstance(0, 0);
 
 
     // For lhs == rhs
     // For lhs == rhs
@@ -316,35 +325,39 @@ public class TestResourceCalculator {
       boolean greaterThan, boolean greaterThanOrEqual, Resource max,
       boolean greaterThan, boolean greaterThanOrEqual, Resource max,
       Resource min) {
       Resource min) {
 
 
-    assertEquals("Less Than operation is wrongly calculated.", lessThan,
-        Resources.lessThan(resourceCalculator, clusterResource, lhs, rhs));
+    assertEquals(lessThan,
+        Resources.lessThan(resourceCalculator, clusterResource, lhs, rhs),
+        "Less Than operation is wrongly calculated.");
 
 
     assertEquals(
     assertEquals(
-        "Less Than Or Equal To operation is wrongly calculated.",
         lessThanOrEqual, Resources.lessThanOrEqual(resourceCalculator,
         lessThanOrEqual, Resources.lessThanOrEqual(resourceCalculator,
-            clusterResource, lhs, rhs));
+            clusterResource, lhs, rhs), "Less Than Or Equal To operation is wrongly calculated.");
 
 
-    assertEquals("Greater Than operation is wrongly calculated.",
-        greaterThan,
-        Resources.greaterThan(resourceCalculator, clusterResource, lhs, rhs));
+    assertEquals(greaterThan,
+        Resources.greaterThan(resourceCalculator, clusterResource, lhs, rhs),
+        "Greater Than operation is wrongly calculated.");
 
 
-    assertEquals(
-        "Greater Than Or Equal To operation is wrongly calculated.",
-        greaterThanOrEqual, Resources.greaterThanOrEqual(resourceCalculator,
-            clusterResource, lhs, rhs));
+    assertEquals(greaterThanOrEqual,
+        Resources.greaterThanOrEqual(resourceCalculator, clusterResource, lhs, rhs),
+        "Greater Than Or Equal To operation is wrongly calculated.");
 
 
-    assertEquals("Max(value) Operation wrongly calculated.", max,
-        Resources.max(resourceCalculator, clusterResource, lhs, rhs));
+    assertEquals(max,
+        Resources.max(resourceCalculator, clusterResource, lhs, rhs),
+        "Max(value) Operation wrongly calculated.");
 
 
-    assertEquals("Min(value) operation is wrongly calculated.", min,
-        Resources.min(resourceCalculator, clusterResource, lhs, rhs));
+    assertEquals(min,
+        Resources.min(resourceCalculator, clusterResource, lhs, rhs),
+        "Min(value) operation is wrongly calculated.");
   }
   }
 
 
   /**
   /**
    * Test resource normalization.
    * Test resource normalization.
    */
    */
-  @Test(timeout = 10000)
-  public void testNormalize() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  @Timeout(10000)
+  void testNormalize(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     // requested resources value cannot be an arbitrary number.
     // requested resources value cannot be an arbitrary number.
     Resource ask = Resource.newInstance(1111, 2);
     Resource ask = Resource.newInstance(1111, 2);
     Resource min = Resource.newInstance(1024, 1);
     Resource min = Resource.newInstance(1024, 1);
@@ -420,22 +433,28 @@ public class TestResourceCalculator {
     }
     }
   }
   }
 
 
-  @Test
-  public void testDivisionByZeroRatioDenominatorIsZero() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testDivisionByZeroRatioDenominatorIsZero(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     float ratio = resourceCalculator.ratio(newResource(1, 1), newResource(0,
     float ratio = resourceCalculator.ratio(newResource(1, 1), newResource(0,
         0));
         0));
     assertEquals(Float.POSITIVE_INFINITY, ratio, 0.00001);
     assertEquals(Float.POSITIVE_INFINITY, ratio, 0.00001);
   }
   }
 
 
-  @Test
-  public void testDivisionByZeroRatioNumeratorAndDenominatorIsZero() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testDivisionByZeroRatioNumeratorAndDenominatorIsZero(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     float ratio = resourceCalculator.ratio(newResource(0, 0), newResource(0,
     float ratio = resourceCalculator.ratio(newResource(0, 0), newResource(0,
         0));
         0));
     assertEquals(0.0, ratio, 0.00001);
     assertEquals(0.0, ratio, 0.00001);
   }
   }
 
 
-  @Test
-  public void testFitsInDiagnosticsCollector() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testFitsInDiagnosticsCollector(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     if (resourceCalculator instanceof DefaultResourceCalculator) {
     if (resourceCalculator instanceof DefaultResourceCalculator) {
       // required-resource = (0, 0)
       // required-resource = (0, 0)
       assertEquals(ImmutableSet.of(),
       assertEquals(ImmutableSet.of(),
@@ -551,8 +570,10 @@ public class TestResourceCalculator {
     }
     }
   }
   }
 
 
-  @Test
-  public void testRatioWithNoExtraResource() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testRatioWithNoExtraResource(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     //setup
     //setup
     Resource resource1 = newResource(1, 1);
     Resource resource1 = newResource(1, 1);
     Resource resource2 = newResource(2, 1);
     Resource resource2 = newResource(2, 1);
@@ -570,8 +591,10 @@ public class TestResourceCalculator {
     }
     }
   }
   }
 
 
-  @Test
-  public void testRatioWithExtraResource() {
+  @MethodSource("getParameters")
+  @ParameterizedTest(name = "{0}")
+  void testRatioWithExtraResource(String name, ResourceCalculator rs) {
+    initTestResourceCalculator(name, rs);
     //setup
     //setup
     setupExtraResource();
     setupExtraResource();
     Resource resource1 = newResource(1, 1, 2);
     Resource resource1 = newResource(1, 1, 2);

+ 119 - 120
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResourceUtils.java

@@ -18,25 +18,6 @@
 
 
 package org.apache.hadoop.yarn.util.resource;
 package org.apache.hadoop.yarn.util.resource;
 
 
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
-import org.apache.hadoop.yarn.api.records.Resource;
-import org.apache.hadoop.yarn.api.records.ResourceInformation;
-import org.apache.hadoop.yarn.api.records.ResourceTypeInfo;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URL;
@@ -48,6 +29,27 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 
 
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
+import org.apache.hadoop.yarn.api.records.Resource;
+import org.apache.hadoop.yarn.api.records.ResourceInformation;
+import org.apache.hadoop.yarn.api.records.ResourceTypeInfo;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 /**
 /**
  * Test class to verify all resource utility methods.
  * Test class to verify all resource utility methods.
  */
  */
@@ -70,15 +72,12 @@ public class TestResourceUtils {
     }
     }
   }
   }
 
 
-  @Rule
-  public ExpectedException expexted = ExpectedException.none();
-
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     ResourceUtils.resetResourceTypes();
     ResourceUtils.resetResourceTypes();
   }
   }
 
 
-  @After
+  @AfterEach
   public void teardown() {
   public void teardown() {
     if (nodeResourcesFile != null && nodeResourcesFile.exists()) {
     if (nodeResourcesFile != null && nodeResourcesFile.exists()) {
       nodeResourcesFile.delete();
       nodeResourcesFile.delete();
@@ -137,29 +136,28 @@ public class TestResourceUtils {
   private void testMemoryAndVcores(Map<String, ResourceInformation> res) {
   private void testMemoryAndVcores(Map<String, ResourceInformation> res) {
     String memory = ResourceInformation.MEMORY_MB.getName();
     String memory = ResourceInformation.MEMORY_MB.getName();
     String vcores = ResourceInformation.VCORES.getName();
     String vcores = ResourceInformation.VCORES.getName();
-    Assert.assertTrue("Resource 'memory' missing", res.containsKey(memory));
-    Assert.assertEquals("'memory' units incorrect",
-        ResourceInformation.MEMORY_MB.getUnits(), res.get(memory).getUnits());
-    Assert.assertEquals("'memory' types incorrect",
-        ResourceInformation.MEMORY_MB.getResourceType(),
-        res.get(memory).getResourceType());
-    Assert.assertTrue("Resource 'vcores' missing", res.containsKey(vcores));
-    Assert.assertEquals("'vcores' units incorrect",
-        ResourceInformation.VCORES.getUnits(), res.get(vcores).getUnits());
-    Assert.assertEquals("'vcores' type incorrect",
-        ResourceInformation.VCORES.getResourceType(),
-        res.get(vcores).getResourceType());
+    assertTrue(res.containsKey(memory), "Resource 'memory' missing");
+    assertEquals(ResourceInformation.MEMORY_MB.getUnits(), res.get(memory).getUnits(),
+        "'memory' units incorrect");
+    assertEquals(ResourceInformation.MEMORY_MB.getResourceType(), res.get(memory).getResourceType(),
+        "'memory' types incorrect");
+    assertTrue(res.containsKey(vcores), "Resource 'vcores' missing");
+    assertEquals(ResourceInformation.VCORES.getUnits(), res.get(vcores).getUnits(),
+        "'vcores' units incorrect");
+    assertEquals(ResourceInformation.VCORES.getResourceType(),
+        res.get(vcores).getResourceType(),
+        "'vcores' type incorrect");
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceTypes() {
+  void testGetResourceTypes() {
     Map<String, ResourceInformation> res = ResourceUtils.getResourceTypes();
     Map<String, ResourceInformation> res = ResourceUtils.getResourceTypes();
-    Assert.assertEquals(2, res.size());
+    assertEquals(2, res.size());
     testMemoryAndVcores(res);
     testMemoryAndVcores(res);
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceTypesConfigs() throws Exception {
+  void testGetResourceTypesConfigs() throws Exception {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
 
 
     ResourceFileInformation testFile1 =
     ResourceFileInformation testFile1 =
@@ -183,19 +181,19 @@ public class TestResourceUtils {
       ResourceUtils.resetResourceTypes();
       ResourceUtils.resetResourceTypes();
       res = setupResourceTypesInternal(conf, testInformation.filename);
       res = setupResourceTypesInternal(conf, testInformation.filename);
       testMemoryAndVcores(res);
       testMemoryAndVcores(res);
-      Assert.assertEquals(testInformation.resourceCount, res.size());
+      assertEquals(testInformation.resourceCount, res.size());
       for (Map.Entry<String, String> entry :
       for (Map.Entry<String, String> entry :
           testInformation.resourceNameUnitsMap.entrySet()) {
           testInformation.resourceNameUnitsMap.entrySet()) {
         String resourceName = entry.getKey();
         String resourceName = entry.getKey();
-        Assert.assertTrue("Missing key " + resourceName,
-            res.containsKey(resourceName));
-        Assert.assertEquals(entry.getValue(), res.get(resourceName).getUnits());
+        assertTrue(res.containsKey(resourceName),
+            "Missing key " + resourceName);
+        assertEquals(entry.getValue(), res.get(resourceName).getUnits());
       }
       }
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testGetRequestedResourcesFromConfig() {
+  void testGetRequestedResourcesFromConfig() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
 
 
     //these resource type configurations should be recognised
     //these resource type configurations should be recognised
@@ -229,14 +227,14 @@ public class TestResourceUtils {
     Set<String> expectedSet =
     Set<String> expectedSet =
         new HashSet<>(Arrays.asList(expectedKeys));
         new HashSet<>(Arrays.asList(expectedKeys));
 
 
-    Assert.assertEquals(properList.size(), expectedKeys.length);
+    assertEquals(properList.size(), expectedKeys.length);
     properList.forEach(
     properList.forEach(
-        item -> Assert.assertTrue(expectedSet.contains(item.getName())));
+        item -> assertTrue(expectedSet.contains(item.getName())));
 
 
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceTypesConfigErrors() throws IOException {
+  void testGetResourceTypesConfigErrors() throws IOException {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
 
 
     String[] resourceFiles = {"resource-types-error-1.xml",
     String[] resourceFiles = {"resource-types-error-1.xml",
@@ -246,7 +244,7 @@ public class TestResourceUtils {
       ResourceUtils.resetResourceTypes();
       ResourceUtils.resetResourceTypes();
       try {
       try {
         setupResourceTypesInternal(conf, resourceFile);
         setupResourceTypesInternal(conf, resourceFile);
-        Assert.fail("Expected error with file " + resourceFile);
+        fail("Expected error with file " + resourceFile);
       } catch (YarnRuntimeException | IllegalArgumentException e) {
       } catch (YarnRuntimeException | IllegalArgumentException e) {
         //Test passed
         //Test passed
       }
       }
@@ -254,7 +252,7 @@ public class TestResourceUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testInitializeResourcesMap() {
+  void testInitializeResourcesMap() {
     String[] empty = {"", ""};
     String[] empty = {"", ""};
     String[] res1 = {"resource1", "m"};
     String[] res1 = {"resource1", "m"};
     String[] res2 = {"resource2", "G"};
     String[] res2 = {"resource2", "G"};
@@ -291,31 +289,30 @@ public class TestResourceUtils {
         len = 4;
         len = 4;
       }
       }
 
 
-      Assert.assertEquals(len, ret.size());
+      assertEquals(len, ret.size());
       for (String[] resources : test) {
       for (String[] resources : test) {
         if (resources[0].length() == 0) {
         if (resources[0].length() == 0) {
           continue;
           continue;
         }
         }
-        Assert.assertTrue(ret.containsKey(resources[0]));
+        assertTrue(ret.containsKey(resources[0]));
         ResourceInformation resInfo = ret.get(resources[0]);
         ResourceInformation resInfo = ret.get(resources[0]);
-        Assert.assertEquals(resources[1], resInfo.getUnits());
-        Assert.assertEquals(ResourceTypes.COUNTABLE, resInfo.getResourceType());
+        assertEquals(resources[1], resInfo.getUnits());
+        assertEquals(ResourceTypes.COUNTABLE, resInfo.getResourceType());
       }
       }
       // we must always have memory and vcores with their fixed units
       // we must always have memory and vcores with their fixed units
-      Assert.assertTrue(ret.containsKey("memory-mb"));
+      assertTrue(ret.containsKey("memory-mb"));
       ResourceInformation memInfo = ret.get("memory-mb");
       ResourceInformation memInfo = ret.get("memory-mb");
-      Assert.assertEquals("Mi", memInfo.getUnits());
-      Assert.assertEquals(ResourceTypes.COUNTABLE, memInfo.getResourceType());
-      Assert.assertTrue(ret.containsKey("vcores"));
+      assertEquals("Mi", memInfo.getUnits());
+      assertEquals(ResourceTypes.COUNTABLE, memInfo.getResourceType());
+      assertTrue(ret.containsKey("vcores"));
       ResourceInformation vcoresInfo = ret.get("vcores");
       ResourceInformation vcoresInfo = ret.get("vcores");
-      Assert.assertEquals("", vcoresInfo.getUnits());
-      Assert
-          .assertEquals(ResourceTypes.COUNTABLE, vcoresInfo.getResourceType());
+      assertEquals("", vcoresInfo.getUnits());
+      assertEquals(ResourceTypes.COUNTABLE, vcoresInfo.getResourceType());
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testInitializeResourcesMapErrors() {
+  void testInitializeResourcesMapErrors() {
     String[] mem1 = {"memory-mb", ""};
     String[] mem1 = {"memory-mb", ""};
     String[] vcores1 = {"vcores", "M"};
     String[] vcores1 = {"vcores", "M"};
 
 
@@ -346,7 +343,7 @@ public class TestResourceUtils {
       }
       }
       try {
       try {
         ResourceUtils.initializeResourcesMap(conf);
         ResourceUtils.initializeResourcesMap(conf);
-        Assert.fail("resource map initialization should fail");
+        fail("resource map initialization should fail");
       } catch (Exception e) {
       } catch (Exception e) {
         //Test passed
         //Test passed
       }
       }
@@ -354,7 +351,7 @@ public class TestResourceUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceInformation() throws Exception {
+  void testGetResourceInformation() throws Exception {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     Map<String, Resource> testRun = new HashMap<>();
     Map<String, Resource> testRun = new HashMap<>();
     setupResourceTypesInternal(conf, "resource-types-4.xml");
     setupResourceTypesInternal(conf, "resource-types-4.xml");
@@ -372,16 +369,16 @@ public class TestResourceUtils {
       ResourceUtils.resetNodeResources();
       ResourceUtils.resetNodeResources();
       Map<String, ResourceInformation> actual = setupNodeResources(conf,
       Map<String, ResourceInformation> actual = setupNodeResources(conf,
           resourceFile);
           resourceFile);
-      Assert.assertEquals(actual.size(),
+      assertEquals(actual.size(),
           entry.getValue().getResources().length);
           entry.getValue().getResources().length);
       for (ResourceInformation resInfo : entry.getValue().getResources()) {
       for (ResourceInformation resInfo : entry.getValue().getResources()) {
-        Assert.assertEquals(resInfo, actual.get(resInfo.getName()));
+        assertEquals(resInfo, actual.get(resInfo.getName()));
       }
       }
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testGetNodeResourcesConfigErrors() throws Exception {
+  void testGetNodeResourcesConfigErrors() throws Exception {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     setupResourceTypesInternal(conf, "resource-types-4.xml");
     setupResourceTypesInternal(conf, "resource-types-4.xml");
     String[] invalidNodeResFiles = {"node-resources-error-1.xml"};
     String[] invalidNodeResFiles = {"node-resources-error-1.xml"};
@@ -390,7 +387,7 @@ public class TestResourceUtils {
       ResourceUtils.resetNodeResources();
       ResourceUtils.resetNodeResources();
       try {
       try {
         setupNodeResources(conf, resourceFile);
         setupNodeResources(conf, resourceFile);
-        Assert.fail("Expected error with file " + resourceFile);
+        fail("Expected error with file " + resourceFile);
       } catch (YarnRuntimeException e) {
       } catch (YarnRuntimeException e) {
         //Test passed
         //Test passed
       }
       }
@@ -398,26 +395,28 @@ public class TestResourceUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testGetNodeResourcesRedefineFpgaErrors() throws Exception {
-    Configuration conf = new YarnConfiguration();
-    expexted.expect(YarnRuntimeException.class);
-    expexted.expectMessage("Defined mandatory resource type=yarn.io/fpga");
-    setupResourceTypesInternal(conf,
-        "resource-types-error-redefine-fpga-unit.xml");
+  void testGetNodeResourcesRedefineFpgaErrors() throws Exception {
+    Throwable exception = assertThrows(YarnRuntimeException.class, () -> {
+      Configuration conf = new YarnConfiguration();
+      setupResourceTypesInternal(conf,
+          "resource-types-error-redefine-fpga-unit.xml");
+    });
+    assertTrue(exception.getMessage().contains("Defined mandatory resource type=yarn.io/fpga"));
   }
   }
 
 
   @Test
   @Test
-  public void testGetNodeResourcesRedefineGpuErrors() throws Exception {
-    Configuration conf = new YarnConfiguration();
-    expexted.expect(YarnRuntimeException.class);
-    expexted.expectMessage("Defined mandatory resource type=yarn.io/gpu");
-    setupResourceTypesInternal(conf,
-        "resource-types-error-redefine-gpu-unit.xml");
+  void testGetNodeResourcesRedefineGpuErrors() throws Exception {
+    Throwable exception = assertThrows(YarnRuntimeException.class, () -> {
+      Configuration conf = new YarnConfiguration();
+      setupResourceTypesInternal(conf,
+          "resource-types-error-redefine-gpu-unit.xml");
+    });
+    assertTrue(exception.getMessage().contains("Defined mandatory resource type=yarn.io/gpu"));
   }
   }
 
 
   @Test
   @Test
-  public void testResourceNameFormatValidation() {
-    String[] validNames = new String[] {
+  void testResourceNameFormatValidation() {
+    String[] validNames = new String[]{
         "yarn.io/gpu",
         "yarn.io/gpu",
         "gpu",
         "gpu",
         "g_1_2",
         "g_1_2",
@@ -427,7 +426,7 @@ public class TestResourceUtils {
         "a....b",
         "a....b",
     };
     };
 
 
-    String[] invalidNames = new String[] {
+    String[] invalidNames = new String[]{
         "asd/resource/-name",
         "asd/resource/-name",
         "prefix/-resource_1",
         "prefix/-resource_1",
         "prefix/0123resource",
         "prefix/0123resource",
@@ -443,7 +442,7 @@ public class TestResourceUtils {
     for (String invalidName : invalidNames) {
     for (String invalidName : invalidNames) {
       try {
       try {
         ResourceUtils.validateNameOfResourceNameAndThrowException(invalidName);
         ResourceUtils.validateNameOfResourceNameAndThrowException(invalidName);
-        Assert.fail("Expected to fail name check, the name=" + invalidName
+        fail("Expected to fail name check, the name=" + invalidName
             + " is illegal.");
             + " is illegal.");
       } catch (YarnRuntimeException e) {
       } catch (YarnRuntimeException e) {
         // Expected
         // Expected
@@ -452,7 +451,7 @@ public class TestResourceUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testGetResourceInformationWithDiffUnits() throws Exception {
+  void testGetResourceInformationWithDiffUnits() throws Exception {
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     Map<String, Resource> testRun = new HashMap<>();
     Map<String, Resource> testRun = new HashMap<>();
     setupResourceTypesInternal(conf, "resource-types-4.xml");
     setupResourceTypesInternal(conf, "resource-types-4.xml");
@@ -476,82 +475,82 @@ public class TestResourceUtils {
       ResourceUtils.resetNodeResources();
       ResourceUtils.resetNodeResources();
       Map<String, ResourceInformation> actual = setupNodeResources(conf,
       Map<String, ResourceInformation> actual = setupNodeResources(conf,
           resourceFile);
           resourceFile);
-      Assert.assertEquals(actual.size(),
+      assertEquals(actual.size(),
           entry.getValue().getResources().length);
           entry.getValue().getResources().length);
       for (ResourceInformation resInfo : entry.getValue().getResources()) {
       for (ResourceInformation resInfo : entry.getValue().getResources()) {
-        Assert.assertEquals(resInfo, actual.get(resInfo.getName()));
+        assertEquals(resInfo, actual.get(resInfo.getName()));
       }
       }
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testResourceUnitParsing() throws Exception {
+  void testResourceUnitParsing() throws Exception {
     Resource res = ResourceUtils.createResourceFromString("memory=20g,vcores=3",
     Resource res = ResourceUtils.createResourceFromString("memory=20g,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20 * 1024, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20 * 1024, 3), res);
 
 
     res = ResourceUtils.createResourceFromString("memory=20G,vcores=3",
     res = ResourceUtils.createResourceFromString("memory=20G,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20 * 1024, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20 * 1024, 3), res);
 
 
     res = ResourceUtils.createResourceFromString("memory=20M,vcores=3",
     res = ResourceUtils.createResourceFromString("memory=20M,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20, 3), res);
 
 
     res = ResourceUtils.createResourceFromString("memory=20m,vcores=3",
     res = ResourceUtils.createResourceFromString("memory=20m,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20, 3), res);
 
 
     res = ResourceUtils.createResourceFromString("memory-mb=20,vcores=3",
     res = ResourceUtils.createResourceFromString("memory-mb=20,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20, 3), res);
 
 
     res = ResourceUtils.createResourceFromString("memory-mb=20m,vcores=3",
     res = ResourceUtils.createResourceFromString("memory-mb=20m,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20, 3), res);
 
 
     res = ResourceUtils.createResourceFromString("memory-mb=20G,vcores=3",
     res = ResourceUtils.createResourceFromString("memory-mb=20G,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(20 * 1024, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(20 * 1024, 3), res);
 
 
     // W/o unit for memory means bits, and 20 bits will be rounded to 0
     // W/o unit for memory means bits, and 20 bits will be rounded to 0
     res = ResourceUtils.createResourceFromString("memory=20,vcores=3",
     res = ResourceUtils.createResourceFromString("memory=20,vcores=3",
-            ResourceUtils.getResourcesTypeInfo());
-    Assert.assertEquals(Resources.createResource(0, 3), res);
+        ResourceUtils.getResourcesTypeInfo());
+    assertEquals(Resources.createResource(0, 3), res);
 
 
     // Test multiple resources
     // Test multiple resources
     List<ResourceTypeInfo> resTypes = new ArrayList<>(
     List<ResourceTypeInfo> resTypes = new ArrayList<>(
-            ResourceUtils.getResourcesTypeInfo());
+        ResourceUtils.getResourcesTypeInfo());
     resTypes.add(ResourceTypeInfo.newInstance(ResourceInformation.GPU_URI, ""));
     resTypes.add(ResourceTypeInfo.newInstance(ResourceInformation.GPU_URI, ""));
     ResourceUtils.reinitializeResources(resTypes);
     ResourceUtils.reinitializeResources(resTypes);
     res = ResourceUtils.createResourceFromString("memory=2G,vcores=3,gpu=0",
     res = ResourceUtils.createResourceFromString("memory=2G,vcores=3,gpu=0",
-            resTypes);
-    Assert.assertEquals(2 * 1024, res.getMemorySize());
-    Assert.assertEquals(0, res.getResourceValue(ResourceInformation.GPU_URI));
+        resTypes);
+    assertEquals(2 * 1024, res.getMemorySize());
+    assertEquals(0, res.getResourceValue(ResourceInformation.GPU_URI));
 
 
     res = ResourceUtils.createResourceFromString("memory=2G,vcores=3,gpu=3",
     res = ResourceUtils.createResourceFromString("memory=2G,vcores=3,gpu=3",
-            resTypes);
-    Assert.assertEquals(2 * 1024, res.getMemorySize());
-    Assert.assertEquals(3, res.getResourceValue(ResourceInformation.GPU_URI));
+        resTypes);
+    assertEquals(2 * 1024, res.getMemorySize());
+    assertEquals(3, res.getResourceValue(ResourceInformation.GPU_URI));
 
 
     res = ResourceUtils.createResourceFromString("memory=2G,vcores=3",
     res = ResourceUtils.createResourceFromString("memory=2G,vcores=3",
-            resTypes);
-    Assert.assertEquals(2 * 1024, res.getMemorySize());
-    Assert.assertEquals(0, res.getResourceValue(ResourceInformation.GPU_URI));
+        resTypes);
+    assertEquals(2 * 1024, res.getMemorySize());
+    assertEquals(0, res.getResourceValue(ResourceInformation.GPU_URI));
 
 
     res = ResourceUtils.createResourceFromString(
     res = ResourceUtils.createResourceFromString(
-            "memory=2G,vcores=3,yarn.io/gpu=0", resTypes);
-    Assert.assertEquals(2 * 1024, res.getMemorySize());
-    Assert.assertEquals(0, res.getResourceValue(ResourceInformation.GPU_URI));
+        "memory=2G,vcores=3,yarn.io/gpu=0", resTypes);
+    assertEquals(2 * 1024, res.getMemorySize());
+    assertEquals(0, res.getResourceValue(ResourceInformation.GPU_URI));
 
 
     res = ResourceUtils.createResourceFromString(
     res = ResourceUtils.createResourceFromString(
-            "memory=2G,vcores=3,yarn.io/gpu=3", resTypes);
-    Assert.assertEquals(2 * 1024, res.getMemorySize());
-    Assert.assertEquals(3, res.getResourceValue(ResourceInformation.GPU_URI));
+        "memory=2G,vcores=3,yarn.io/gpu=3", resTypes);
+    assertEquals(2 * 1024, res.getMemorySize());
+    assertEquals(3, res.getResourceValue(ResourceInformation.GPU_URI));
   }
   }
 
 
   @Test
   @Test
-  public void testMultipleOpsForResourcesWithTags() throws Exception {
+  void testMultipleOpsForResourcesWithTags() throws Exception {
 
 
     Configuration conf = new YarnConfiguration();
     Configuration conf = new YarnConfiguration();
     setupResourceTypes(conf, "resource-types-6.xml");
     setupResourceTypes(conf, "resource-types-6.xml");

+ 86 - 67
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/resource/TestResources.java

@@ -18,28 +18,30 @@
 
 
 package org.apache.hadoop.yarn.util.resource;
 package org.apache.hadoop.yarn.util.resource;
 
 
+import java.io.File;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.api.records.ResourceInformation;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
 
 
-import static org.apache.hadoop.yarn.util.resource.Resources.componentwiseMin;
-import static org.apache.hadoop.yarn.util.resource.Resources.componentwiseMax;
 import static org.apache.hadoop.yarn.util.resource.Resources.add;
 import static org.apache.hadoop.yarn.util.resource.Resources.add;
-import static org.apache.hadoop.yarn.util.resource.Resources.multiplyAndRoundUp;
-import static org.apache.hadoop.yarn.util.resource.Resources.subtract;
+import static org.apache.hadoop.yarn.util.resource.Resources.componentwiseMax;
+import static org.apache.hadoop.yarn.util.resource.Resources.componentwiseMin;
+import static org.apache.hadoop.yarn.util.resource.Resources.fitsIn;
 import static org.apache.hadoop.yarn.util.resource.Resources.multiply;
 import static org.apache.hadoop.yarn.util.resource.Resources.multiply;
 import static org.apache.hadoop.yarn.util.resource.Resources.multiplyAndAddTo;
 import static org.apache.hadoop.yarn.util.resource.Resources.multiplyAndAddTo;
 import static org.apache.hadoop.yarn.util.resource.Resources.multiplyAndRoundDown;
 import static org.apache.hadoop.yarn.util.resource.Resources.multiplyAndRoundDown;
-import static org.apache.hadoop.yarn.util.resource.Resources.fitsIn;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.apache.hadoop.yarn.util.resource.Resources.multiplyAndRoundUp;
+import static org.apache.hadoop.yarn.util.resource.Resources.subtract;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestResources {
 public class TestResources {
   private static final String INVALID_RESOURCE_MSG = "Invalid resource value";
   private static final String INVALID_RESOURCE_MSG = "Invalid resource value";
@@ -75,12 +77,12 @@ public class TestResources {
     }
     }
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
     setupExtraResourceType();
     setupExtraResourceType();
   }
   }
 
 
-  @After
+  @AfterEach
   public void teardown() {
   public void teardown() {
     deleteResourceTypesFile();
     deleteResourceTypesFile();
   }
   }
@@ -96,8 +98,9 @@ public class TestResources {
     return ret;
     return ret;
   }
   }
 
 
-  @Test(timeout = 10000)
-  public void testCompareToWithUnboundedResource() {
+  @Test
+  @Timeout(10000)
+  void testCompareToWithUnboundedResource() {
     unsetExtraResourceType();
     unsetExtraResourceType();
     Resource unboundedClone = Resources.clone(ExtendedResources.unbounded());
     Resource unboundedClone = Resources.clone(ExtendedResources.unbounded());
     assertTrue(unboundedClone
     assertTrue(unboundedClone
@@ -107,8 +110,9 @@ public class TestResources {
         unboundedClone.compareTo(createResource(0, Integer.MAX_VALUE)) > 0);
         unboundedClone.compareTo(createResource(0, Integer.MAX_VALUE)) > 0);
   }
   }
 
 
-  @Test(timeout = 10000)
-  public void testCompareToWithNoneResource() {
+  @Test
+  @Timeout(10000)
+  void testCompareToWithNoneResource() {
     assertTrue(Resources.none().compareTo(createResource(0, 0)) == 0);
     assertTrue(Resources.none().compareTo(createResource(0, 0)) == 0);
     assertTrue(Resources.none().compareTo(createResource(1, 0)) < 0);
     assertTrue(Resources.none().compareTo(createResource(1, 0)) < 0);
     assertTrue(Resources.none().compareTo(createResource(0, 1)) < 0);
     assertTrue(Resources.none().compareTo(createResource(0, 1)) < 0);
@@ -118,8 +122,9 @@ public class TestResources {
     assertTrue(Resources.none().compareTo(createResource(0, 0, 1)) < 0);
     assertTrue(Resources.none().compareTo(createResource(0, 0, 1)) < 0);
   }
   }
 
 
-  @Test(timeout = 1000)
-  public void testFitsIn() {
+  @Test
+  @Timeout(1000)
+  void testFitsIn() {
     assertTrue(fitsIn(createResource(1, 1), createResource(2, 2)));
     assertTrue(fitsIn(createResource(1, 1), createResource(2, 2)));
     assertTrue(fitsIn(createResource(2, 2), createResource(2, 2)));
     assertTrue(fitsIn(createResource(2, 2), createResource(2, 2)));
     assertFalse(fitsIn(createResource(2, 2), createResource(1, 1)));
     assertFalse(fitsIn(createResource(2, 2), createResource(1, 1)));
@@ -130,8 +135,9 @@ public class TestResources {
     assertTrue(fitsIn(createResource(1, 1, 1), createResource(2, 2, 2)));
     assertTrue(fitsIn(createResource(1, 1, 1), createResource(2, 2, 2)));
   }
   }
 
 
-  @Test(timeout = 1000)
-  public void testComponentwiseMin() {
+  @Test
+  @Timeout(1000)
+  void testComponentwiseMin() {
     assertEquals(createResource(1, 1),
     assertEquals(createResource(1, 1),
         componentwiseMin(createResource(1, 1), createResource(2, 2)));
         componentwiseMin(createResource(1, 1), createResource(2, 2)));
     assertEquals(createResource(1, 1),
     assertEquals(createResource(1, 1),
@@ -147,7 +153,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testComponentwiseMax() {
+  void testComponentwiseMax() {
     assertEquals(createResource(2, 2),
     assertEquals(createResource(2, 2),
         componentwiseMax(createResource(1, 1), createResource(2, 2)));
         componentwiseMax(createResource(1, 1), createResource(2, 2)));
     assertEquals(createResource(2, 2),
     assertEquals(createResource(2, 2),
@@ -165,7 +171,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testAdd() {
+  void testAdd() {
     assertEquals(createResource(2, 3),
     assertEquals(createResource(2, 3),
         add(createResource(1, 1), createResource(1, 2)));
         add(createResource(1, 1), createResource(1, 2)));
     assertEquals(createResource(3, 2),
     assertEquals(createResource(3, 2),
@@ -177,7 +183,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testSubtract() {
+  void testSubtract() {
     assertEquals(createResource(1, 0),
     assertEquals(createResource(1, 0),
         subtract(createResource(2, 1), createResource(1, 1)));
         subtract(createResource(2, 1), createResource(1, 1)));
     assertEquals(createResource(0, 1),
     assertEquals(createResource(0, 1),
@@ -189,7 +195,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testClone() {
+  void testClone() {
     assertEquals(createResource(1, 1), Resources.clone(createResource(1, 1)));
     assertEquals(createResource(1, 1), Resources.clone(createResource(1, 1)));
     assertEquals(createResource(1, 1, 0),
     assertEquals(createResource(1, 1, 0),
         Resources.clone(createResource(1, 1)));
         Resources.clone(createResource(1, 1)));
@@ -200,7 +206,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testMultiply() {
+  void testMultiply() {
     assertEquals(createResource(4, 2), multiply(createResource(2, 1), 2));
     assertEquals(createResource(4, 2), multiply(createResource(2, 1), 2));
     assertEquals(createResource(4, 2, 0), multiply(createResource(2, 1), 2));
     assertEquals(createResource(4, 2, 0), multiply(createResource(2, 1), 2));
     assertEquals(createResource(2, 4), multiply(createResource(1, 2), 2));
     assertEquals(createResource(2, 4), multiply(createResource(1, 2), 2));
@@ -209,61 +215,74 @@ public class TestResources {
     assertEquals(createResource(4, 4, 6), multiply(createResource(2, 2, 3), 2));
     assertEquals(createResource(4, 4, 6), multiply(createResource(2, 2, 3), 2));
   }
   }
 
 
-  @Test(timeout=10000)
-  public void testMultiplyRoundUp() {
+  @Test
+  @Timeout(10000)
+  void testMultiplyRoundUp() {
     final double by = 0.5;
     final double by = 0.5;
     final String memoryErrorMsg = "Invalid memory size.";
     final String memoryErrorMsg = "Invalid memory size.";
     final String vcoreErrorMsg = "Invalid virtual core number.";
     final String vcoreErrorMsg = "Invalid virtual core number.";
     Resource resource = Resources.createResource(1, 1);
     Resource resource = Resources.createResource(1, 1);
     Resource result = Resources.multiplyAndRoundUp(resource, by);
     Resource result = Resources.multiplyAndRoundUp(resource, by);
-    assertEquals(memoryErrorMsg, result.getMemorySize(), 1);
-    assertEquals(vcoreErrorMsg, result.getVirtualCores(), 1);
+    assertEquals(result.getMemorySize(), 1, memoryErrorMsg);
+    assertEquals(result.getVirtualCores(), 1, vcoreErrorMsg);
 
 
     resource = Resources.createResource(2, 2);
     resource = Resources.createResource(2, 2);
     result = Resources.multiplyAndRoundUp(resource, by);
     result = Resources.multiplyAndRoundUp(resource, by);
-    assertEquals(memoryErrorMsg, result.getMemorySize(), 1);
-    assertEquals(vcoreErrorMsg, result.getVirtualCores(), 1);
+    assertEquals(result.getMemorySize(), 1, memoryErrorMsg);
+    assertEquals(result.getVirtualCores(), 1, vcoreErrorMsg);
 
 
     resource = Resources.createResource(0, 0);
     resource = Resources.createResource(0, 0);
     result = Resources.multiplyAndRoundUp(resource, by);
     result = Resources.multiplyAndRoundUp(resource, by);
-    assertEquals(memoryErrorMsg, result.getMemorySize(), 0);
-    assertEquals(vcoreErrorMsg, result.getVirtualCores(), 0);
+    assertEquals(result.getMemorySize(), 0, memoryErrorMsg);
+    assertEquals(result.getVirtualCores(), 0, vcoreErrorMsg);
   }
   }
 
 
   @Test
   @Test
-  public void testMultiplyAndRoundUpCustomResources() {
-    assertEquals(INVALID_RESOURCE_MSG, createResource(5, 2, 8),
-        multiplyAndRoundUp(createResource(3, 1, 5), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(5, 2, 0),
-        multiplyAndRoundUp(createResource(3, 1, 0), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(5, 5, 0),
-        multiplyAndRoundUp(createResource(3, 3, 0), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(8, 3, 13),
-        multiplyAndRoundUp(createResource(3, 1, 5), 2.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(8, 3, 0),
-        multiplyAndRoundUp(createResource(3, 1, 0), 2.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(8, 8, 0),
-        multiplyAndRoundUp(createResource(3, 3, 0), 2.5));
+  void testMultiplyAndRoundUpCustomResources() {
+    assertEquals(createResource(5, 2, 8),
+        multiplyAndRoundUp(createResource(3, 1, 5), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(5, 2, 0),
+        multiplyAndRoundUp(createResource(3, 1, 0), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(5, 5, 0),
+        multiplyAndRoundUp(createResource(3, 3, 0), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(8, 3, 13),
+        multiplyAndRoundUp(createResource(3, 1, 5), 2.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(8, 3, 0),
+        multiplyAndRoundUp(createResource(3, 1, 0), 2.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(8, 8, 0),
+        multiplyAndRoundUp(createResource(3, 3, 0), 2.5),
+        INVALID_RESOURCE_MSG);
   }
   }
 
 
   @Test
   @Test
-  public void testMultiplyAndRoundDown() {
-    assertEquals(INVALID_RESOURCE_MSG, createResource(4, 1),
-        multiplyAndRoundDown(createResource(3, 1), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(4, 1, 0),
-        multiplyAndRoundDown(createResource(3, 1), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(1, 4),
-        multiplyAndRoundDown(createResource(1, 3), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(1, 4, 0),
-        multiplyAndRoundDown(createResource(1, 3), 1.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(7, 7, 0),
-        multiplyAndRoundDown(createResource(3, 3, 0), 2.5));
-    assertEquals(INVALID_RESOURCE_MSG, createResource(2, 2, 7),
-        multiplyAndRoundDown(createResource(1, 1, 3), 2.5));
+  void testMultiplyAndRoundDown() {
+    assertEquals(createResource(4, 1),
+        multiplyAndRoundDown(createResource(3, 1), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(4, 1, 0),
+        multiplyAndRoundDown(createResource(3, 1), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(1, 4),
+        multiplyAndRoundDown(createResource(1, 3), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(1, 4, 0),
+        multiplyAndRoundDown(createResource(1, 3), 1.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(7, 7, 0),
+        multiplyAndRoundDown(createResource(3, 3, 0), 2.5),
+        INVALID_RESOURCE_MSG);
+    assertEquals(createResource(2, 2, 7),
+        multiplyAndRoundDown(createResource(1, 1, 3), 2.5),
+        INVALID_RESOURCE_MSG);
   }
   }
 
 
   @Test
   @Test
-  public void testMultiplyAndAddTo() throws Exception {
+  void testMultiplyAndAddTo() throws Exception {
     unsetExtraResourceType();
     unsetExtraResourceType();
     setupExtraResourceType();
     setupExtraResourceType();
     assertEquals(createResource(6, 4),
     assertEquals(createResource(6, 4),
@@ -283,7 +302,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testCreateResourceWithSameLongValue() throws Exception {
+  void testCreateResourceWithSameLongValue() throws Exception {
     unsetExtraResourceType();
     unsetExtraResourceType();
     setupExtraResourceType();
     setupExtraResourceType();
 
 
@@ -294,7 +313,7 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testCreateResourceWithSameIntValue() throws Exception {
+  void testCreateResourceWithSameIntValue() throws Exception {
     unsetExtraResourceType();
     unsetExtraResourceType();
     setupExtraResourceType();
     setupExtraResourceType();
 
 
@@ -305,14 +324,14 @@ public class TestResources {
   }
   }
 
 
   @Test
   @Test
-  public void testCreateSimpleResourceWithSameLongValue() {
+  void testCreateSimpleResourceWithSameLongValue() {
     Resource res = ResourceUtils.createResourceWithSameValue(11L);
     Resource res = ResourceUtils.createResourceWithSameValue(11L);
     assertEquals(11L, res.getMemorySize());
     assertEquals(11L, res.getMemorySize());
     assertEquals(11, res.getVirtualCores());
     assertEquals(11, res.getVirtualCores());
   }
   }
 
 
   @Test
   @Test
-  public void testCreateSimpleResourceWithSameIntValue() {
+  void testCreateSimpleResourceWithSameIntValue() {
     Resource res = ResourceUtils.createResourceWithSameValue(11);
     Resource res = ResourceUtils.createResourceWithSameValue(11);
     assertEquals(11, res.getMemorySize());
     assertEquals(11, res.getMemorySize());
     assertEquals(11, res.getVirtualCores());
     assertEquals(11, res.getVirtualCores());

+ 10 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/timeline/TestShortenedFlowName.java

@@ -17,11 +17,13 @@
  */
  */
 package org.apache.hadoop.yarn.util.timeline;
 package org.apache.hadoop.yarn.util.timeline;
 
 
+import java.util.UUID;
+
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
 
 
-import java.util.UUID;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * Test case for limiting flow name size.
  * Test case for limiting flow name size.
@@ -31,22 +33,22 @@ public class TestShortenedFlowName {
   private static final String TEST_FLOW_NAME = "TestFlowName";
   private static final String TEST_FLOW_NAME = "TestFlowName";
 
 
   @Test
   @Test
-  public void testRemovingUUID() {
+  void testRemovingUUID() {
     String flowName = TEST_FLOW_NAME + "-" + UUID.randomUUID();
     String flowName = TEST_FLOW_NAME + "-" + UUID.randomUUID();
     flowName = TimelineUtils.removeUUID(flowName);
     flowName = TimelineUtils.removeUUID(flowName);
-    Assert.assertEquals(TEST_FLOW_NAME, flowName);
+    assertEquals(TEST_FLOW_NAME, flowName);
   }
   }
 
 
   @Test
   @Test
-  public void testShortenedFlowName() {
+  void testShortenedFlowName() {
     YarnConfiguration conf = new YarnConfiguration();
     YarnConfiguration conf = new YarnConfiguration();
     String flowName = TEST_FLOW_NAME + UUID.randomUUID();
     String flowName = TEST_FLOW_NAME + UUID.randomUUID();
     conf.setInt(YarnConfiguration.FLOW_NAME_MAX_SIZE, 8);
     conf.setInt(YarnConfiguration.FLOW_NAME_MAX_SIZE, 8);
     String shortenedFlowName = TimelineUtils.shortenFlowName(flowName, conf);
     String shortenedFlowName = TimelineUtils.shortenFlowName(flowName, conf);
-    Assert.assertEquals("TestFlow", shortenedFlowName);
+    assertEquals("TestFlow", shortenedFlowName);
     conf.setInt(YarnConfiguration.FLOW_NAME_MAX_SIZE,
     conf.setInt(YarnConfiguration.FLOW_NAME_MAX_SIZE,
         YarnConfiguration.FLOW_NAME_DEFAULT_MAX_SIZE);
         YarnConfiguration.FLOW_NAME_DEFAULT_MAX_SIZE);
     shortenedFlowName = TimelineUtils.shortenFlowName(flowName, conf);
     shortenedFlowName = TimelineUtils.shortenFlowName(flowName, conf);
-    Assert.assertEquals(TEST_FLOW_NAME, shortenedFlowName);
+    assertEquals(TEST_FLOW_NAME, shortenedFlowName);
   }
   }
 }
 }

+ 2 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java

@@ -21,11 +21,11 @@ package org.apache.hadoop.yarn.webapp;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Random;
 import java.util.Random;
 
 
-import org.apache.hadoop.net.ServerSocketUtil;
-
 import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 
 
+import org.apache.hadoop.net.ServerSocketUtil;
+
 public abstract class JerseyTestBase extends JerseyTest {
 public abstract class JerseyTestBase extends JerseyTest {
   public JerseyTestBase(WebAppDescriptor appDescriptor) {
   public JerseyTestBase(WebAppDescriptor appDescriptor) {
     super(appDescriptor);
     super(appDescriptor);

+ 2 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestJAXBContextResolver.java

@@ -21,17 +21,16 @@ package org.apache.hadoop.yarn.webapp;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Set;
-
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Provider;
 import javax.ws.rs.ext.Provider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBContext;
 
 
-import org.apache.hadoop.yarn.webapp.MyTestWebService.MyInfo;
-
 import com.google.inject.Singleton;
 import com.google.inject.Singleton;
 import com.sun.jersey.api.json.JSONConfiguration;
 import com.sun.jersey.api.json.JSONConfiguration;
 import com.sun.jersey.api.json.JSONJAXBContext;
 import com.sun.jersey.api.json.JSONJAXBContext;
 
 
+import org.apache.hadoop.yarn.webapp.MyTestWebService.MyInfo;
+
 @Singleton
 @Singleton
 @Provider
 @Provider
 public class MyTestJAXBContextResolver implements ContextResolver<JAXBContext> {
 public class MyTestJAXBContextResolver implements ContextResolver<JAXBContext> {

+ 1 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java

@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
 
 import com.google.inject.Singleton;
 import com.google.inject.Singleton;
+
 import org.apache.hadoop.http.JettyUtils;
 import org.apache.hadoop.http.JettyUtils;
 
 
 @Singleton
 @Singleton

+ 39 - 27
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/TestParseRoute.java

@@ -20,64 +20,76 @@ package org.apache.hadoop.yarn.webapp;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 
 
-import org.apache.hadoop.yarn.webapp.WebApp;
-import org.apache.hadoop.yarn.webapp.WebAppException;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 public class TestParseRoute {
 public class TestParseRoute {
 
 
-  @Test public void testNormalAction() {
+  @Test
+  void testNormalAction() {
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a1", ":a2"),
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a1", ":a2"),
-                 WebApp.parseRoute("/foo/action/:a1/:a2"));
+        WebApp.parseRoute("/foo/action/:a1/:a2"));
   }
   }
 
 
-  @Test public void testDefaultController() {
+  @Test
+  void testDefaultController() {
     assertEquals(Arrays.asList("/", "default", "index"),
     assertEquals(Arrays.asList("/", "default", "index"),
-                 WebApp.parseRoute("/"));
+        WebApp.parseRoute("/"));
   }
   }
 
 
-  @Test public void testDefaultAction() {
+  @Test
+  void testDefaultAction() {
     assertEquals(Arrays.asList("/foo", "foo", "index"),
     assertEquals(Arrays.asList("/foo", "foo", "index"),
-                 WebApp.parseRoute("/foo"));
+        WebApp.parseRoute("/foo"));
     assertEquals(Arrays.asList("/foo", "foo", "index"),
     assertEquals(Arrays.asList("/foo", "foo", "index"),
-                 WebApp.parseRoute("/foo/"));
+        WebApp.parseRoute("/foo/"));
   }
   }
 
 
-  @Test public void testMissingAction() {
+  @Test
+  void testMissingAction() {
     assertEquals(Arrays.asList("/foo", "foo", "index", ":a1"),
     assertEquals(Arrays.asList("/foo", "foo", "index", ":a1"),
-                 WebApp.parseRoute("/foo/:a1"));
+        WebApp.parseRoute("/foo/:a1"));
   }
   }
 
 
-  @Test public void testDefaultCapture() {
+  @Test
+  void testDefaultCapture() {
     assertEquals(Arrays.asList("/", "default", "index", ":a"),
     assertEquals(Arrays.asList("/", "default", "index", ":a"),
-                 WebApp.parseRoute("/:a"));
+        WebApp.parseRoute("/:a"));
   }
   }
 
 
-  @Test public void testPartialCapture1() {
+  @Test
+  void testPartialCapture1() {
     assertEquals(Arrays.asList("/foo/action/bar", "foo", "action", "bar", ":a"),
     assertEquals(Arrays.asList("/foo/action/bar", "foo", "action", "bar", ":a"),
-                 WebApp.parseRoute("/foo/action/bar/:a"));
+        WebApp.parseRoute("/foo/action/bar/:a"));
   }
   }
 
 
-  @Test public void testPartialCapture2() {
+  @Test
+  void testPartialCapture2() {
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a1", "bar",
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a1", "bar",
-                               ":a2", ":a3"),
-                 WebApp.parseRoute("/foo/action/:a1/bar/:a2/:a3"));
+            ":a2", ":a3"),
+        WebApp.parseRoute("/foo/action/:a1/bar/:a2/:a3"));
   }
   }
 
 
-  @Test public void testLeadingPaddings() {
+  @Test
+  void testLeadingPaddings() {
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a"),
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a"),
-                 WebApp.parseRoute(" /foo/action/ :a"));
+        WebApp.parseRoute(" /foo/action/ :a"));
   }
   }
 
 
-  @Test public void testTrailingPaddings() {
+  @Test
+  void testTrailingPaddings() {
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a"),
     assertEquals(Arrays.asList("/foo/action", "foo", "action", ":a"),
-                 WebApp.parseRoute("/foo/action//:a / "));
+        WebApp.parseRoute("/foo/action//:a / "));
     assertEquals(Arrays.asList("/foo/action", "foo", "action"),
     assertEquals(Arrays.asList("/foo/action", "foo", "action"),
-                 WebApp.parseRoute("/foo/action / "));
+        WebApp.parseRoute("/foo/action / "));
   }
   }
 
 
-  @Test(expected=WebAppException.class) public void testMissingLeadingSlash() {
-    WebApp.parseRoute("foo/bar");
+  @Test
+  void testMissingLeadingSlash() {
+    assertThrows(WebAppException.class, () -> {
+      WebApp.parseRoute("foo/bar");
+    });
   }
   }
 }
 }

+ 10 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/TestSubViews.java

@@ -18,15 +18,18 @@
 
 
 package org.apache.hadoop.yarn.webapp;
 package org.apache.hadoop.yarn.webapp;
 
 
-import org.apache.hadoop.yarn.webapp.test.WebAppTests;
-import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
-import org.apache.hadoop.yarn.webapp.view.HtmlPage;
 import java.io.PrintWriter;
 import java.io.PrintWriter;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+
 import com.google.inject.Injector;
 import com.google.inject.Injector;
+import org.junit.jupiter.api.Test;
+
+import org.apache.hadoop.yarn.webapp.test.WebAppTests;
+import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
+import org.apache.hadoop.yarn.webapp.view.HtmlPage;
 
 
-import org.junit.Test;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 
 
 public class TestSubViews {
 public class TestSubViews {
 
 
@@ -61,7 +64,8 @@ public class TestSubViews {
     }
     }
   }
   }
 
 
-  @Test public void testSubView() throws Exception {
+  @Test
+  void testSubView() throws Exception {
     Injector injector = WebAppTests.createMockInjector(this);
     Injector injector = WebAppTests.createMockInjector(this);
     injector.getInstance(MainView.class).render();
     injector.getInstance(MainView.class).render();
 
 

+ 83 - 68
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/TestWebApp.java

@@ -18,22 +18,16 @@
 
 
 package org.apache.hadoop.yarn.webapp;
 package org.apache.hadoop.yarn.webapp;
 
 
-import static org.apache.hadoop.yarn.util.StringHelper.join;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_TABLE;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
-import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
 import java.io.InputStream;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.net.URLEncoder;
 
 
+import com.google.inject.Inject;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.net.ServerSocketUtil;
 import org.apache.hadoop.net.ServerSocketUtil;
@@ -42,11 +36,18 @@ import org.apache.hadoop.yarn.webapp.view.HtmlPage;
 import org.apache.hadoop.yarn.webapp.view.JQueryUI;
 import org.apache.hadoop.yarn.webapp.view.JQueryUI;
 import org.apache.hadoop.yarn.webapp.view.RobotsTextPage;
 import org.apache.hadoop.yarn.webapp.view.RobotsTextPage;
 import org.apache.hadoop.yarn.webapp.view.TextPage;
 import org.apache.hadoop.yarn.webapp.view.TextPage;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
-import com.google.inject.Inject;
+import static org.apache.hadoop.yarn.util.StringHelper.join;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_TABLE;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestWebApp {
 public class TestWebApp {
   static final Logger LOG = LoggerFactory.getLogger(TestWebApp.class);
   static final Logger LOG = LoggerFactory.getLogger(TestWebApp.class);
@@ -150,12 +151,14 @@ public class TestWebApp {
 
 
   String echo(String s) { return s; }
   String echo(String s) { return s; }
 
 
-  @Test public void testCreate() {
+  @Test
+  void testCreate() {
     WebApp app = WebApps.$for(this).start();
     WebApp app = WebApps.$for(this).start();
     app.stop();
     app.stop();
   }
   }
 
 
-  @Test public void testCreateWithPort() {
+  @Test
+  void testCreateWithPort() {
     // see if the ephemeral port is updated
     // see if the ephemeral port is updated
     WebApp app = WebApps.$for(this).at(0).start();
     WebApp app = WebApps.$for(this).at(0).start();
     int port = app.getListenerAddress().getPort();
     int port = app.getListenerAddress().getPort();
@@ -167,72 +170,80 @@ public class TestWebApp {
     app.stop();
     app.stop();
   }
   }
 
 
-  @Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class)
-  public void testCreateWithBindAddressNonZeroPort() {
-    WebApp app = WebApps.$for(this).at("0.0.0.0:50000").start();
-    int port = app.getListenerAddress().getPort();
-    assertEquals(50000, port);
-    // start another WebApp with same NonZero port
-    WebApp app2 = WebApps.$for(this).at("0.0.0.0:50000").start();
-    // An exception occurs (findPort disabled)
-    app.stop();
-    app2.stop();
+  @Test
+  void testCreateWithBindAddressNonZeroPort() {
+    assertThrows(org.apache.hadoop.yarn.webapp.WebAppException.class, () -> {
+      WebApp app = WebApps.$for(this).at("0.0.0.0:50000").start();
+      int port = app.getListenerAddress().getPort();
+      assertEquals(50000, port);
+      // start another WebApp with same NonZero port
+      WebApp app2 = WebApps.$for(this).at("0.0.0.0:50000").start();
+      // An exception occurs (findPort disabled)
+      app.stop();
+      app2.stop();
+    });
   }
   }
 
 
-  @Test(expected=org.apache.hadoop.yarn.webapp.WebAppException.class)
-  public void testCreateWithNonZeroPort() {
-    WebApp app = WebApps.$for(this).at(50000).start();
-    int port = app.getListenerAddress().getPort();
-    assertEquals(50000, port);
-    // start another WebApp with same NonZero port
-    WebApp app2 = WebApps.$for(this).at(50000).start();
-    // An exception occurs (findPort disabled)
-    app.stop();
-    app2.stop();
+  @Test
+  void testCreateWithNonZeroPort() {
+    assertThrows(org.apache.hadoop.yarn.webapp.WebAppException.class, () -> {
+      WebApp app = WebApps.$for(this).at(50000).start();
+      int port = app.getListenerAddress().getPort();
+      assertEquals(50000, port);
+      // start another WebApp with same NonZero port
+      WebApp app2 = WebApps.$for(this).at(50000).start();
+      // An exception occurs (findPort disabled)
+      app.stop();
+      app2.stop();
+    });
   }
   }
 
 
-  @Test public void testServePaths() {
+  @Test
+  void testServePaths() {
     WebApp app = WebApps.$for("test", this).start();
     WebApp app = WebApps.$for("test", this).start();
     assertEquals("/test", app.getRedirectPath());
     assertEquals("/test", app.getRedirectPath());
-    String[] expectedPaths = { "/test", "/test/*" };
+    String[] expectedPaths = {"/test", "/test/*"};
     String[] pathSpecs = app.getServePathSpecs();
     String[] pathSpecs = app.getServePathSpecs();
-     
+
     assertEquals(2, pathSpecs.length);
     assertEquals(2, pathSpecs.length);
-    for(int i = 0; i < expectedPaths.length; i++) {
+    for (int i = 0; i < expectedPaths.length; i++) {
       assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i]));
       assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i]));
     }
     }
     app.stop();
     app.stop();
   }
   }
 
 
-  @Test public void testServePathsNoName() {
+  @Test
+  void testServePathsNoName() {
     WebApp app = WebApps.$for("", this).start();
     WebApp app = WebApps.$for("", this).start();
     assertEquals("/", app.getRedirectPath());
     assertEquals("/", app.getRedirectPath());
-    String[] expectedPaths = { "/*" };
+    String[] expectedPaths = {"/*"};
     String[] pathSpecs = app.getServePathSpecs();
     String[] pathSpecs = app.getServePathSpecs();
-     
+
     assertEquals(1, pathSpecs.length);
     assertEquals(1, pathSpecs.length);
-    for(int i = 0; i < expectedPaths.length; i++) {
+    for (int i = 0; i < expectedPaths.length; i++) {
       assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i]));
       assertTrue(ArrayUtils.contains(pathSpecs, expectedPaths[i]));
     }
     }
     app.stop();
     app.stop();
   }
   }
 
 
-  @Test public void testDefaultRoutes() throws Exception {
+  @Test
+  void testDefaultRoutes() throws Exception {
     WebApp app = WebApps.$for("test", this).start();
     WebApp app = WebApps.$for("test", this).start();
     String baseUrl = baseUrl(app);
     String baseUrl = baseUrl(app);
     try {
     try {
-      assertEquals("foo", getContent(baseUrl +"test/foo").trim());
-      assertEquals("foo", getContent(baseUrl +"test/foo/index").trim());
-      assertEquals("bar", getContent(baseUrl +"test/foo/bar").trim());
-      assertEquals("default", getContent(baseUrl +"test").trim());
-      assertEquals("default", getContent(baseUrl +"test/").trim());
+      assertEquals("foo", getContent(baseUrl + "test/foo").trim());
+      assertEquals("foo", getContent(baseUrl + "test/foo/index").trim());
+      assertEquals("bar", getContent(baseUrl + "test/foo/bar").trim());
+      assertEquals("default", getContent(baseUrl + "test").trim());
+      assertEquals("default", getContent(baseUrl + "test/").trim());
       assertEquals("default", getContent(baseUrl).trim());
       assertEquals("default", getContent(baseUrl).trim());
     } finally {
     } finally {
       app.stop();
       app.stop();
     }
     }
   }
   }
 
 
-  @Test public void testCustomRoutes() throws Exception {
+  @Test
+  void testCustomRoutes() throws Exception {
     WebApp app =
     WebApp app =
         WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
         WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
           @Override
           @Override
@@ -249,21 +260,22 @@ public class TestWebApp {
     String baseUrl = baseUrl(app);
     String baseUrl = baseUrl(app);
     try {
     try {
       assertEquals("foo", getContent(baseUrl).trim());
       assertEquals("foo", getContent(baseUrl).trim());
-      assertEquals("foo", getContent(baseUrl +"test").trim());
-      assertEquals("foo1", getContent(baseUrl +"test/1").trim());
-      assertEquals("bar", getContent(baseUrl +"test/bar/foo").trim());
-      assertEquals("default", getContent(baseUrl +"test/foo/bar").trim());
-      assertEquals("default1", getContent(baseUrl +"test/foo/1").trim());
-      assertEquals("default2", getContent(baseUrl +"test/foo/bar/2").trim());
-      assertEquals(404, getResponseCode(baseUrl +"test/goo"));
-      assertEquals(200, getResponseCode(baseUrl +"ws/v1/test"));
-      assertTrue(getContent(baseUrl +"ws/v1/test").contains("myInfo"));
+      assertEquals("foo", getContent(baseUrl + "test").trim());
+      assertEquals("foo1", getContent(baseUrl + "test/1").trim());
+      assertEquals("bar", getContent(baseUrl + "test/bar/foo").trim());
+      assertEquals("default", getContent(baseUrl + "test/foo/bar").trim());
+      assertEquals("default1", getContent(baseUrl + "test/foo/1").trim());
+      assertEquals("default2", getContent(baseUrl + "test/foo/bar/2").trim());
+      assertEquals(404, getResponseCode(baseUrl + "test/goo"));
+      assertEquals(200, getResponseCode(baseUrl + "ws/v1/test"));
+      assertTrue(getContent(baseUrl + "ws/v1/test").contains("myInfo"));
     } finally {
     } finally {
       app.stop();
       app.stop();
     }
     }
   }
   }
 
 
-  @Test public void testEncodedUrl() throws Exception {
+  @Test
+  void testEncodedUrl() throws Exception {
     WebApp app =
     WebApp app =
         WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
         WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
           @Override
           @Override
@@ -292,7 +304,8 @@ public class TestWebApp {
     }
     }
   }
   }
 
 
-  @Test public void testRobotsText() throws Exception {
+  @Test
+  void testRobotsText() throws Exception {
     WebApp app =
     WebApp app =
         WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
         WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
           @Override
           @Override
@@ -319,18 +332,20 @@ public class TestWebApp {
 
 
   // This is to test the GuiceFilter should only be applied to webAppContext,
   // This is to test the GuiceFilter should only be applied to webAppContext,
   // not to logContext;
   // not to logContext;
-  @Test public void testYARNWebAppContext() throws Exception {
+  @Test
+  void testYARNWebAppContext() throws Exception {
     // setting up the log context
     // setting up the log context
     System.setProperty("hadoop.log.dir", "/Not/Existing/dir");
     System.setProperty("hadoop.log.dir", "/Not/Existing/dir");
     WebApp app = WebApps.$for("test", this).start(new WebApp() {
     WebApp app = WebApps.$for("test", this).start(new WebApp() {
-      @Override public void setup() {
+      @Override
+      public void setup() {
         route("/", FooController.class);
         route("/", FooController.class);
       }
       }
     });
     });
     String baseUrl = baseUrl(app);
     String baseUrl = baseUrl(app);
     try {
     try {
       // Not able to access a non-existing dir, should not redirect to foo.
       // Not able to access a non-existing dir, should not redirect to foo.
-      assertEquals(404, getResponseCode(baseUrl +"logs"));
+      assertEquals(404, getResponseCode(baseUrl + "logs"));
       // should be able to redirect to foo.
       // should be able to redirect to foo.
       assertEquals("foo", getContent(baseUrl).trim());
       assertEquals("foo", getContent(baseUrl).trim());
     } finally {
     } finally {
@@ -345,7 +360,7 @@ public class TestWebApp {
   }
   }
 
 
   @Test
   @Test
-  public void testPortRanges() throws Exception {
+  void testPortRanges() throws Exception {
     WebApp app = WebApps.$for("test", this).start();
     WebApp app = WebApps.$for("test", this).start();
     String baseUrl = baseUrl(app);
     String baseUrl = baseUrl(app);
     WebApp app1 = null;
     WebApp app1 = null;
@@ -355,7 +370,7 @@ public class TestWebApp {
     WebApp app5 = null;
     WebApp app5 = null;
     try {
     try {
       int port =  ServerSocketUtil.waitForPort(48000, 60);
       int port =  ServerSocketUtil.waitForPort(48000, 60);
-      assertEquals("foo", getContent(baseUrl +"test/foo").trim());
+      assertEquals("foo", getContent(baseUrl + "test/foo").trim());
       app1 = WebApps.$for("test", this).at(port).start();
       app1 = WebApps.$for("test", this).at(port).start();
       assertEquals(port, app1.getListenerAddress().getPort());
       assertEquals(port, app1.getListenerAddress().getPort());
       app2 = WebApps.$for("test", this).at("0.0.0.0", port, true).start();
       app2 = WebApps.$for("test", this).at("0.0.0.0", port, true).start();

+ 9 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/WebServicesTestUtils.java

@@ -18,9 +18,6 @@
 
 
 package org.apache.hadoop.yarn.webapp;
 package org.apache.hadoop.yarn.webapp;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import javax.ws.rs.core.Response.StatusType;
 import javax.ws.rs.core.Response.StatusType;
@@ -30,6 +27,9 @@ import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.NodeList;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 public class WebServicesTestUtils {
 public class WebServicesTestUtils {
   public static long getXmlLong(Element element, String name) {
   public static long getXmlLong(Element element, String name) {
     String val = getXmlString(element, name);
     String val = getXmlString(element, name);
@@ -122,20 +122,18 @@ public class WebServicesTestUtils {
 
 
   public static void checkStringMatch(String print, String expected, String got) {
   public static void checkStringMatch(String print, String expected, String got) {
     assertTrue(
     assertTrue(
-        print + " doesn't match, got: " + got + " expected: " + expected,
-        got.matches(expected));
+        got.matches(expected),
+        print + " doesn't match, got: " + got + " expected: " + expected);
   }
   }
 
 
   public static void checkStringContains(String print, String expected, String got) {
   public static void checkStringContains(String print, String expected, String got) {
     assertTrue(
     assertTrue(
-        print + " doesn't contain expected string, got: " + got + " expected: " + expected,
-        got.contains(expected));
+        got.contains(expected),
+        print + " doesn't contain expected string, got: " + got + " expected: " + expected);
   }
   }
 
 
   public static void checkStringEqual(String print, String expected, String got) {
   public static void checkStringEqual(String print, String expected, String got) {
-    assertTrue(
-        print + " is not equal, got: " + got + " expected: " + expected,
-        got.equals(expected));
+    assertEquals(got, expected);
   }
   }
 
 
   public static void assertResponseStatusCode(StatusType expected,
   public static void assertResponseStatusCode(StatusType expected,
@@ -145,6 +143,6 @@ public class WebServicesTestUtils {
 
 
   public static void assertResponseStatusCode(String errmsg,
   public static void assertResponseStatusCode(String errmsg,
       StatusType expected, StatusType actual) {
       StatusType expected, StatusType actual) {
-    assertEquals(errmsg, expected.getStatusCode(), actual.getStatusCode());
+    assertEquals(expected.getStatusCode(), actual.getStatusCode(), errmsg);
   }
   }
 }
 }

+ 26 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/hamlet2/TestHamlet.java

@@ -17,19 +17,27 @@
  */
  */
 package org.apache.hadoop.yarn.webapp.hamlet2;
 package org.apache.hadoop.yarn.webapp.hamlet2;
 
 
-import java.util.EnumSet;
 import java.io.PrintWriter;
 import java.io.PrintWriter;
-import org.junit.Test;
+import java.util.EnumSet;
+
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.webapp.SubView;
 import org.apache.hadoop.yarn.webapp.SubView;
 
 
-import static org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.*;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
+import static org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.LinkType;
+import static org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.Media;
+import static org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.TABLE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 
 
 public class TestHamlet {
 public class TestHamlet {
 
 
-  @Test public void testHamlet() {
+  @Test
+  void testHamlet() {
     Hamlet h = newHamlet().
     Hamlet h = newHamlet().
         title("test").
         title("test").
         h1("heading 1").
         h1("heading 1").
@@ -69,7 +77,8 @@ public class TestHamlet {
     verify(out, never()).print("</p>");
     verify(out, never()).print("</p>");
   }
   }
 
 
-  @Test public void testTable() {
+  @Test
+  void testTable() {
     Hamlet h = newHamlet().
     Hamlet h = newHamlet().
         title("test table").
         title("test table").
         link("style.css");
         link("style.css");
@@ -90,7 +99,8 @@ public class TestHamlet {
     verify(out, atLeast(1)).print("</tr>");
     verify(out, atLeast(1)).print("</tr>");
   }
   }
 
 
-  @Test public void testEnumAttrs() {
+  @Test
+  void testEnumAttrs() {
     Hamlet h = newHamlet().
     Hamlet h = newHamlet().
         meta_http("Content-type", "text/html; charset=utf-8").
         meta_http("Content-type", "text/html; charset=utf-8").
         title("test enum attrs").
         title("test enum attrs").
@@ -109,7 +119,8 @@ public class TestHamlet {
     verify(out).print(" rel=\"start index\"");
     verify(out).print(" rel=\"start index\"");
   }
   }
 
 
-  @Test public void testScriptStyle() {
+  @Test
+  void testScriptStyle() {
     Hamlet h = newHamlet().
     Hamlet h = newHamlet().
         script("a.js").script("b.js").
         script("a.js").script("b.js").
         style("h1 { font-size: 1.2em }");
         style("h1 { font-size: 1.2em }");
@@ -121,7 +132,8 @@ public class TestHamlet {
     verify(out).print(" type=\"text/css\"");
     verify(out).print(" type=\"text/css\"");
   }
   }
 
 
-  @Test public void testPreformatted() {
+  @Test
+  void testPreformatted() {
     Hamlet h = newHamlet().
     Hamlet h = newHamlet().
         div().
         div().
         i("inline before pre").
         i("inline before pre").
@@ -144,7 +156,8 @@ public class TestHamlet {
     @Override public void renderPartial() {}
     @Override public void renderPartial() {}
   }
   }
 
 
-  @Test public void testSubViews() {
+  @Test
+  void testSubViews() {
     Hamlet h = newHamlet().
     Hamlet h = newHamlet().
         title("test sub-views").
         title("test sub-views").
         div("#view1").__(TestView1.class).__().
         div("#view1").__(TestView1.class).__().
@@ -153,8 +166,8 @@ public class TestHamlet {
     PrintWriter out = h.getWriter();
     PrintWriter out = h.getWriter();
     out.flush();
     out.flush();
     assertEquals(0, h.nestLevel);
     assertEquals(0, h.nestLevel);
-    verify(out).print("["+ TestView1.class.getName() +"]");
-    verify(out).print("["+ TestView2.class.getName() +"]");
+    verify(out).print("[" + TestView1.class.getName() + "]");
+    verify(out).print("[" + TestView2.class.getName() + "]");
   }
   }
 
 
   static Hamlet newHamlet() {
   static Hamlet newHamlet() {

+ 21 - 8
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/hamlet2/TestHamletImpl.java

@@ -18,19 +18,29 @@
 package org.apache.hadoop.yarn.webapp.hamlet2;
 package org.apache.hadoop.yarn.webapp.hamlet2;
 
 
 import java.io.PrintWriter;
 import java.io.PrintWriter;
-import org.junit.Test;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
+import org.junit.jupiter.api.Test;
 
 
-import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.*;
+import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.CoreAttrs;
+import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.H1;
+import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.LINK;
+import org.apache.hadoop.yarn.webapp.hamlet2.HamletSpec.SCRIPT;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 
 
 public class TestHamletImpl {
 public class TestHamletImpl {
   /**
   /**
    * Test the generic implementation methods
    * Test the generic implementation methods
    * @see TestHamlet for Hamlet syntax
    * @see TestHamlet for Hamlet syntax
    */
    */
-  @Test public void testGeneric() {
+  @Test
+  void testGeneric() {
     PrintWriter out = spy(new PrintWriter(System.out));
     PrintWriter out = spy(new PrintWriter(System.out));
     HamletImpl hi = new HamletImpl(out, 0, false);
     HamletImpl hi = new HamletImpl(out, 0, false);
     hi.
     hi.
@@ -66,7 +76,8 @@ public class TestHamletImpl {
     verify(out, never()).print("</sub4>");
     verify(out, never()).print("</sub4>");
   }
   }
 
 
-  @Test public void testSetSelector() {
+  @Test
+  void testSetSelector() {
     CoreAttrs e = mock(CoreAttrs.class);
     CoreAttrs e = mock(CoreAttrs.class);
     HamletImpl.setSelector(e, "#id.class");
     HamletImpl.setSelector(e, "#id.class");
 
 
@@ -81,7 +92,8 @@ public class TestHamletImpl {
     verify(t).__("heading");
     verify(t).__("heading");
   }
   }
 
 
-  @Test public void testSetLinkHref() {
+  @Test
+  void testSetLinkHref() {
     LINK link = mock(LINK.class);
     LINK link = mock(LINK.class);
     HamletImpl.setLinkHref(link, "uri");
     HamletImpl.setLinkHref(link, "uri");
     HamletImpl.setLinkHref(link, "style.css");
     HamletImpl.setLinkHref(link, "style.css");
@@ -93,7 +105,8 @@ public class TestHamletImpl {
     verifyNoMoreInteractions(link);
     verifyNoMoreInteractions(link);
   }
   }
 
 
-  @Test public void testSetScriptSrc() {
+  @Test
+  void testSetScriptSrc() {
     SCRIPT script = mock(SCRIPT.class);
     SCRIPT script = mock(SCRIPT.class);
     HamletImpl.setScriptSrc(script, "uri");
     HamletImpl.setScriptSrc(script, "uri");
     HamletImpl.setScriptSrc(script, "script.js");
     HamletImpl.setScriptSrc(script, "script.js");

+ 21 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/hamlet2/TestParseSelector.java

@@ -17,41 +17,51 @@
  */
  */
 package org.apache.hadoop.yarn.webapp.hamlet2;
 package org.apache.hadoop.yarn.webapp.hamlet2;
 
 
-import org.junit.Test;
-
-import static org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.webapp.WebAppException;
 import org.apache.hadoop.yarn.webapp.WebAppException;
 
 
+import static org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl.S_CLASS;
+import static org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl.S_ID;
+import static org.apache.hadoop.yarn.webapp.hamlet2.HamletImpl.parseSelector;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 public class TestParseSelector {
 public class TestParseSelector {
 
 
-  @Test public void testNormal() {
+  @Test
+  void testNormal() {
     String[] res = parseSelector("#id.class");
     String[] res = parseSelector("#id.class");
     assertEquals("id", res[S_ID]);
     assertEquals("id", res[S_ID]);
     assertEquals("class", res[S_CLASS]);
     assertEquals("class", res[S_CLASS]);
   }
   }
 
 
-  @Test public void testMultiClass() {
+  @Test
+  void testMultiClass() {
     String[] res = parseSelector("#id.class1.class2");
     String[] res = parseSelector("#id.class1.class2");
     assertEquals("id", res[S_ID]);
     assertEquals("id", res[S_ID]);
     assertEquals("class1 class2", res[S_CLASS]);
     assertEquals("class1 class2", res[S_CLASS]);
   }
   }
 
 
-  @Test public void testMissingId() {
+  @Test
+  void testMissingId() {
     String[] res = parseSelector(".class");
     String[] res = parseSelector(".class");
     assertNull(res[S_ID]);
     assertNull(res[S_ID]);
     assertEquals("class", res[S_CLASS]);
     assertEquals("class", res[S_CLASS]);
   }
   }
 
 
-  @Test public void testMissingClass() {
+  @Test
+  void testMissingClass() {
     String[] res = parseSelector("#id");
     String[] res = parseSelector("#id");
     assertEquals("id", res[S_ID]);
     assertEquals("id", res[S_ID]);
     assertNull(res[S_CLASS]);
     assertNull(res[S_CLASS]);
   }
   }
 
 
-  @Test(expected=WebAppException.class) public void testMissingAll() {
-    parseSelector("");
+  @Test
+  void testMissingAll() {
+    assertThrows(WebAppException.class, () -> {
+      parseSelector("");
+    });
   }
   }
 }
 }

+ 0 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/log/AggregatedLogsBlockForTest.java

@@ -20,7 +20,6 @@ package org.apache.hadoop.yarn.webapp.log;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;

+ 25 - 18
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/test/TestWebAppTests.java

@@ -18,23 +18,26 @@
 
 
 package org.apache.hadoop.yarn.webapp.test;
 package org.apache.hadoop.yarn.webapp.test;
 
 
-import com.google.inject.AbstractModule;
-import com.google.inject.Injector;
-import com.google.inject.servlet.RequestScoped;
 import java.io.PrintWriter;
 import java.io.PrintWriter;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
 
 
-import org.slf4j.LoggerFactory;
+import com.google.inject.AbstractModule;
+import com.google.inject.Injector;
+import com.google.inject.servlet.RequestScoped;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.mockito.Mockito.verify;
 
 
 public class TestWebAppTests {
 public class TestWebAppTests {
   static final Logger LOG = LoggerFactory.getLogger(TestWebAppTests.class);
   static final Logger LOG = LoggerFactory.getLogger(TestWebAppTests.class);
 
 
-  @Test public void testInstances() throws Exception {
+  @Test
+  void testInstances() throws Exception {
     Injector injector = WebAppTests.createMockInjector(this);
     Injector injector = WebAppTests.createMockInjector(this);
     HttpServletRequest req = injector.getInstance(HttpServletRequest.class);
     HttpServletRequest req = injector.getInstance(HttpServletRequest.class);
     HttpServletResponse res = injector.getInstance(HttpServletResponse.class);
     HttpServletResponse res = injector.getInstance(HttpServletResponse.class);
@@ -61,24 +64,27 @@ public class TestWebAppTests {
   static class FooBar extends Bar {
   static class FooBar extends Bar {
   }
   }
 
 
-  @Test public void testCreateInjector() throws Exception {
+  @Test
+  void testCreateInjector() throws Exception {
     Bar bar = new Bar();
     Bar bar = new Bar();
     Injector injector = WebAppTests.createMockInjector(Foo.class, bar);
     Injector injector = WebAppTests.createMockInjector(Foo.class, bar);
     logInstances(injector.getInstance(HttpServletRequest.class),
     logInstances(injector.getInstance(HttpServletRequest.class),
-                 injector.getInstance(HttpServletResponse.class),
-                 injector.getInstance(HttpServletResponse.class).getWriter());
+        injector.getInstance(HttpServletResponse.class),
+        injector.getInstance(HttpServletResponse.class).getWriter());
     assertSame(bar, injector.getInstance(Foo.class));
     assertSame(bar, injector.getInstance(Foo.class));
   }
   }
 
 
-  @Test public void testCreateInjector2() {
+  @Test
+  void testCreateInjector2() {
     final FooBar foobar = new FooBar();
     final FooBar foobar = new FooBar();
     Bar bar = new Bar();
     Bar bar = new Bar();
     Injector injector = WebAppTests.createMockInjector(Foo.class, bar,
     Injector injector = WebAppTests.createMockInjector(Foo.class, bar,
         new AbstractModule() {
         new AbstractModule() {
-      @Override protected void configure() {
-        bind(Bar.class).toInstance(foobar);
-      }
-    });
+          @Override
+          protected void configure() {
+            bind(Bar.class).toInstance(foobar);
+          }
+        });
     assertNotSame(bar, injector.getInstance(Bar.class));
     assertNotSame(bar, injector.getInstance(Bar.class));
     assertSame(foobar, injector.getInstance(Bar.class));
     assertSame(foobar, injector.getInstance(Bar.class));
   }
   }
@@ -87,11 +93,12 @@ public class TestWebAppTests {
   static class ScopeTest {
   static class ScopeTest {
   }
   }
 
 
-  @Test public void testRequestScope() {
+  @Test
+  void testRequestScope() {
     Injector injector = WebAppTests.createMockInjector(this);
     Injector injector = WebAppTests.createMockInjector(this);
 
 
     assertSame(injector.getInstance(ScopeTest.class),
     assertSame(injector.getInstance(ScopeTest.class),
-               injector.getInstance(ScopeTest.class));
+        injector.getInstance(ScopeTest.class));
   }
   }
 
 
   private void logInstances(HttpServletRequest req, HttpServletResponse res,
   private void logInstances(HttpServletRequest req, HttpServletResponse res,

+ 14 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/test/WebAppTests.java

@@ -18,30 +18,29 @@
 
 
 package org.apache.hadoop.yarn.webapp.test;
 package org.apache.hadoop.yarn.webapp.test;
 
 
-import org.apache.hadoop.yarn.webapp.Controller;
-import org.apache.hadoop.yarn.webapp.SubView;
-import org.apache.hadoop.yarn.webapp.View;
-import org.apache.hadoop.yarn.webapp.WebAppException;
-
+import java.io.IOException;
+import java.io.PrintWriter;
 import java.lang.reflect.Method;
 import java.lang.reflect.Method;
 import java.util.Map;
 import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 
-import com.google.inject.Module;
-import com.google.inject.Scopes;
-import com.google.inject.servlet.RequestScoped;
 import com.google.inject.AbstractModule;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Injector;
+import com.google.inject.Module;
 import com.google.inject.Provides;
 import com.google.inject.Provides;
+import com.google.inject.Scopes;
+import com.google.inject.servlet.RequestScoped;
 
 
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
+import org.apache.hadoop.yarn.webapp.Controller;
+import org.apache.hadoop.yarn.webapp.SubView;
+import org.apache.hadoop.yarn.webapp.View;
+import org.apache.hadoop.yarn.webapp.WebAppException;
 
 
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 
 public class WebAppTests {
 public class WebAppTests {
 
 

+ 34 - 31
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java

@@ -18,14 +18,18 @@
 
 
 package org.apache.hadoop.yarn.webapp.util;
 package org.apache.hadoop.yarn.webapp.util;
 
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.UnknownHostException;
 import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+
 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.http.HttpServer2;
 import org.apache.hadoop.http.HttpServer2;
@@ -35,13 +39,10 @@ import org.apache.hadoop.security.alias.CredentialProvider;
 import org.apache.hadoop.security.alias.CredentialProviderFactory;
 import org.apache.hadoop.security.alias.CredentialProviderFactory;
 import org.apache.hadoop.security.alias.JavaKeyStoreProvider;
 import org.apache.hadoop.security.alias.JavaKeyStoreProvider;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mockito;
 
 
-import javax.servlet.http.HttpServletRequest;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 public class TestWebAppUtils {
 public class TestWebAppUtils {
   private static final String RM1_NODE_ID = "rm1";
   private static final String RM1_NODE_ID = "rm1";
@@ -53,7 +54,7 @@ public class TestWebAppUtils {
   private static final String anyIpAddress = "1.2.3.4";
   private static final String anyIpAddress = "1.2.3.4";
   private static Map<String, String> savedStaticResolution = new HashMap<>();
   private static Map<String, String> savedStaticResolution = new HashMap<>();
 
 
-  @BeforeClass
+  @BeforeAll
   public static void initializeDummyHostnameResolution() throws Exception {
   public static void initializeDummyHostnameResolution() throws Exception {
     String previousIpAddress;
     String previousIpAddress;
     for (String hostName : dummyHostNames) {
     for (String hostName : dummyHostNames) {
@@ -64,7 +65,7 @@ public class TestWebAppUtils {
     }
     }
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void restoreDummyHostnameResolution() throws Exception {
   public static void restoreDummyHostnameResolution() throws Exception {
     for (Map.Entry<String, String> hostnameToIpEntry : savedStaticResolution.entrySet()) {
     for (Map.Entry<String, String> hostnameToIpEntry : savedStaticResolution.entrySet()) {
       NetUtils.addStaticResolution(hostnameToIpEntry.getKey(), hostnameToIpEntry.getValue());
       NetUtils.addStaticResolution(hostnameToIpEntry.getKey(), hostnameToIpEntry.getValue());
@@ -72,7 +73,7 @@ public class TestWebAppUtils {
   }
   }
 
 
   @Test
   @Test
-  public void TestRMWebAppURLRemoteAndLocal() throws UnknownHostException {
+  void TestRMWebAppURLRemoteAndLocal() throws UnknownHostException {
     Configuration configuration = new Configuration();
     Configuration configuration = new Configuration();
     final String rmAddress = "host1:8088";
     final String rmAddress = "host1:8088";
     configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS, rmAddress);
     configuration.set(YarnConfiguration.RM_WEBAPP_ADDRESS, rmAddress);
@@ -84,30 +85,32 @@ public class TestWebAppUtils {
     configuration.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID);
     configuration.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID);
 
 
     String rmRemoteUrl = WebAppUtils.getResolvedRemoteRMWebAppURLWithoutScheme(configuration);
     String rmRemoteUrl = WebAppUtils.getResolvedRemoteRMWebAppURLWithoutScheme(configuration);
-    Assert.assertEquals("ResolvedRemoteRMWebAppUrl should resolve to the first HA RM address", rm1Address, rmRemoteUrl);
+    assertEquals(rm1Address, rmRemoteUrl,
+        "ResolvedRemoteRMWebAppUrl should resolve to the first HA RM address");
 
 
     String rmLocalUrl = WebAppUtils.getResolvedRMWebAppURLWithoutScheme(configuration);
     String rmLocalUrl = WebAppUtils.getResolvedRMWebAppURLWithoutScheme(configuration);
-    Assert.assertEquals("ResolvedRMWebAppUrl should resolve to the default RM webapp address", rmAddress, rmLocalUrl);
+    assertEquals(rmAddress, rmLocalUrl,
+        "ResolvedRMWebAppUrl should resolve to the default RM webapp address");
   }
   }
 
 
   @Test
   @Test
-  public void testGetPassword() throws Exception {
+  void testGetPassword() throws Exception {
     Configuration conf = provisionCredentialsForSSL();
     Configuration conf = provisionCredentialsForSSL();
 
 
     // use WebAppUtils as would be used by loadSslConfiguration
     // use WebAppUtils as would be used by loadSslConfiguration
-    Assert.assertEquals("keypass",
+    assertEquals("keypass",
         WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_KEY_PASSWORD_KEY));
         WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_KEY_PASSWORD_KEY));
-    Assert.assertEquals("storepass",
+    assertEquals("storepass",
         WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_KEYSTORE_PASSWORD_KEY));
         WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_KEYSTORE_PASSWORD_KEY));
-    Assert.assertEquals("trustpass",
+    assertEquals("trustpass",
         WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_TRUSTSTORE_PASSWORD_KEY));
         WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_TRUSTSTORE_PASSWORD_KEY));
 
 
     // let's make sure that a password that doesn't exist returns null
     // let's make sure that a password that doesn't exist returns null
-    Assert.assertEquals(null, WebAppUtils.getPassword(conf,"invalid-alias"));
+    assertNull(WebAppUtils.getPassword(conf, "invalid-alias"));
   }
   }
 
 
   @Test
   @Test
-  public void testLoadSslConfiguration() throws Exception {
+  void testLoadSslConfiguration() throws Exception {
     Configuration conf = provisionCredentialsForSSL();
     Configuration conf = provisionCredentialsForSSL();
     TestBuilder builder = (TestBuilder) new TestBuilder();
     TestBuilder builder = (TestBuilder) new TestBuilder();
 
 
@@ -116,12 +119,12 @@ public class TestWebAppUtils {
 
 
     String keypass = "keypass";
     String keypass = "keypass";
     String storepass = "storepass";
     String storepass = "storepass";
-    String trustpass = "trustpass";    
+    String trustpass = "trustpass";
 
 
     // make sure we get the right passwords in the builder
     // make sure we get the right passwords in the builder
-    assertEquals(keypass, ((TestBuilder)builder).keypass);
-    assertEquals(storepass, ((TestBuilder)builder).keystorePassword);
-    assertEquals(trustpass, ((TestBuilder)builder).truststorePassword);
+    assertEquals(keypass, ((TestBuilder) builder).keypass);
+    assertEquals(storepass, ((TestBuilder) builder).keystorePassword);
+    assertEquals(trustpass, ((TestBuilder) builder).truststorePassword);
   }
   }
 
 
   protected Configuration provisionCredentialsForSSL() throws IOException,
   protected Configuration provisionCredentialsForSSL() throws IOException,
@@ -145,11 +148,11 @@ public class TestWebAppUtils {
     char[] trustpass = {'t', 'r', 'u', 's', 't', 'p', 'a', 's', 's'};
     char[] trustpass = {'t', 'r', 'u', 's', 't', 'p', 'a', 's', 's'};
 
 
     // ensure that we get nulls when the key isn't there
     // ensure that we get nulls when the key isn't there
-    assertEquals(null, provider.getCredentialEntry(
+    assertNull(provider.getCredentialEntry(
         WebAppUtils.WEB_APP_KEY_PASSWORD_KEY));
         WebAppUtils.WEB_APP_KEY_PASSWORD_KEY));
-    assertEquals(null, provider.getCredentialEntry(
+    assertNull(provider.getCredentialEntry(
         WebAppUtils.WEB_APP_KEYSTORE_PASSWORD_KEY));
         WebAppUtils.WEB_APP_KEYSTORE_PASSWORD_KEY));
-    assertEquals(null, provider.getCredentialEntry(
+    assertNull(provider.getCredentialEntry(
         WebAppUtils.WEB_APP_TRUSTSTORE_PASSWORD_KEY));
         WebAppUtils.WEB_APP_TRUSTSTORE_PASSWORD_KEY));
 
 
     // create new aliases
     // create new aliases
@@ -180,7 +183,7 @@ public class TestWebAppUtils {
   }
   }
 
 
   @Test
   @Test
-  public void testAppendQueryParams() throws Exception {
+  void testAppendQueryParams() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     String targetUri = "/test/path";
     String targetUri = "/test/path";
     Mockito.when(request.getCharacterEncoding()).thenReturn(null);
     Mockito.when(request.getCharacterEncoding()).thenReturn(null);
@@ -194,12 +197,12 @@ public class TestWebAppUtils {
     for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
     for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
       Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
       Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
       String uri = WebAppUtils.appendQueryParams(request, targetUri);
       String uri = WebAppUtils.appendQueryParams(request, targetUri);
-      Assert.assertEquals(entry.getValue(), uri);
+      assertEquals(entry.getValue(), uri);
     }
     }
   }
   }
 
 
   @Test
   @Test
-  public void testGetHtmlEscapedURIWithQueryString() throws Exception {
+  void testGetHtmlEscapedURIWithQueryString() throws Exception {
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     String targetUri = "/test/path";
     String targetUri = "/test/path";
     Mockito.when(request.getCharacterEncoding()).thenReturn(null);
     Mockito.when(request.getCharacterEncoding()).thenReturn(null);
@@ -214,7 +217,7 @@ public class TestWebAppUtils {
     for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
     for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
       Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
       Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
       String uri = WebAppUtils.getHtmlEscapedURIWithQueryString(request);
       String uri = WebAppUtils.getHtmlEscapedURIWithQueryString(request);
-      Assert.assertEquals(entry.getValue(), uri);
+      assertEquals(entry.getValue(), uri);
     }
     }
   }
   }
 
 

+ 9 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebServiceClient.java

@@ -22,6 +22,8 @@ import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URI;
 import java.net.URL;
 import java.net.URL;
 
 
+import org.junit.jupiter.api.Test;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.http.HttpServer2;
 import org.apache.hadoop.http.HttpServer2;
@@ -29,8 +31,9 @@ import org.apache.hadoop.http.TestHttpServer.EchoServlet;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 public class TestWebServiceClient {
 public class TestWebServiceClient {
 
 
@@ -43,17 +46,17 @@ public class TestWebServiceClient {
   static final String SERVLET_PATH_ECHO = "/" + SERVLET_NAME_ECHO;
   static final String SERVLET_PATH_ECHO = "/" + SERVLET_NAME_ECHO;
 
 
   @Test
   @Test
-  public void testGetWebServiceClient() throws Exception {
+  void testGetWebServiceClient() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, "HTTPS_ONLY");
     conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, "HTTPS_ONLY");
     WebServiceClient.initialize(conf);
     WebServiceClient.initialize(conf);
     WebServiceClient client = WebServiceClient.getWebServiceClient();
     WebServiceClient client = WebServiceClient.getWebServiceClient();
-    Assert.assertNotNull(client.getSSLFactory());
+    assertNotNull(client.getSSLFactory());
     WebServiceClient.destroy();
     WebServiceClient.destroy();
   }
   }
 
 
   @Test
   @Test
-  public void testCreateClient() throws Exception {
+  void testCreateClient() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, "HTTPS_ONLY");
     conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, "HTTPS_ONLY");
     File base = new File(BASEDIR);
     File base = new File(BASEDIR);
@@ -91,7 +94,7 @@ public class TestWebServiceClient {
     WebServiceClient client = WebServiceClient.getWebServiceClient();
     WebServiceClient client = WebServiceClient.getWebServiceClient();
     HttpURLConnection conn = client.getHttpURLConnectionFactory()
     HttpURLConnection conn = client.getHttpURLConnectionFactory()
         .getHttpURLConnection(u);
         .getHttpURLConnection(u);
-    Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
+    assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
     WebServiceClient.destroy();
     WebServiceClient.destroy();
     server.stop();
     server.stop();
     FileUtil.fullyDelete(new File(BASEDIR));
     FileUtil.fullyDelete(new File(BASEDIR));

+ 11 - 11
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/view/TestCommonViews.java

@@ -19,36 +19,36 @@
 package org.apache.hadoop.yarn.webapp.view;
 package org.apache.hadoop.yarn.webapp.view;
 
 
 import com.google.inject.Injector;
 import com.google.inject.Injector;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.yarn.webapp.ResponseInfo;
 import org.apache.hadoop.yarn.webapp.ResponseInfo;
 import org.apache.hadoop.yarn.webapp.test.WebAppTests;
 import org.apache.hadoop.yarn.webapp.test.WebAppTests;
-import org.apache.hadoop.yarn.webapp.view.ErrorPage;
-import org.apache.hadoop.yarn.webapp.view.FooterBlock;
-import org.apache.hadoop.yarn.webapp.view.HeaderBlock;
-import org.apache.hadoop.yarn.webapp.view.JQueryUI;
-
-import org.junit.Test;
 
 
 public class TestCommonViews {
 public class TestCommonViews {
 
 
-  @Test public void testErrorPage() {
+  @Test
+  void testErrorPage() {
     Injector injector = WebAppTests.testPage(ErrorPage.class);
     Injector injector = WebAppTests.testPage(ErrorPage.class);
 
 
   }
   }
 
 
-  @Test public void testHeaderBlock() {
+  @Test
+  void testHeaderBlock() {
     WebAppTests.testBlock(HeaderBlock.class);
     WebAppTests.testBlock(HeaderBlock.class);
   }
   }
 
 
-  @Test public void testFooterBlock() {
+  @Test
+  void testFooterBlock() {
     WebAppTests.testBlock(FooterBlock.class);
     WebAppTests.testBlock(FooterBlock.class);
   }
   }
 
 
-  @Test public void testJQueryUI() {
+  @Test
+  void testJQueryUI() {
     WebAppTests.testBlock(JQueryUI.class);
     WebAppTests.testBlock(JQueryUI.class);
   }
   }
 
 
-  @Test public void testInfoBlock() {
+  @Test
+  void testInfoBlock() {
     Injector injector = WebAppTests.createMockInjector(this);
     Injector injector = WebAppTests.createMockInjector(this);
     ResponseInfo info = injector.getInstance(ResponseInfo.class);
     ResponseInfo info = injector.getInstance(ResponseInfo.class);
   }
   }

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.