From fd0415c44ac27e3f5011fe10ed5e3d9a9e37d78e Mon Sep 17 00:00:00 2001 From: Ashutosh Gupta Date: Sun, 25 Sep 2022 15:26:06 +0100 Subject: [PATCH] YARN-11270. Upgrade JUnit from 4 to 5 in hadoop-yarn-server-timelineservice-hbase-client (#4773) Co-authored-by: Ashutosh Gupta Signed-off-by: Akira Ajisaka --- .../pom.xml | 21 +++++++++---- .../common/TestHBaseTimelineStorageUtils.java | 30 +++++++++++-------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/pom.xml index 0bedcfcb27f..6c0a635bc83 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/pom.xml @@ -126,6 +126,21 @@ test-jar test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.platform + junit-platform-launcher + test + org.apache.hadoop @@ -257,12 +272,6 @@ - - - junit - junit - test - diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/TestHBaseTimelineStorageUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/TestHBaseTimelineStorageUtils.java index 46bb8aed9e5..f65e9eac7a4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/TestHBaseTimelineStorageUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/hadoop-yarn-server-timelineservice-hbase-client/src/test/java/org/apache/hadoop/yarn/server/timelineservice/storage/common/TestHBaseTimelineStorageUtils.java @@ -24,9 +24,8 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.File; @@ -34,6 +33,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + /** * Unit tests for HBaseTimelineStorageUtils static methos. */ @@ -41,7 +43,7 @@ public class TestHBaseTimelineStorageUtils { private String hbaseConfigPath = "target/hbase-site.xml"; - @Before + @BeforeEach public void setup() throws IOException { // Input Hbase Configuration Configuration hbaseConf = new Configuration(); @@ -60,25 +62,27 @@ public class TestHBaseTimelineStorageUtils { os.close(); } - @Test(expected=NullPointerException.class) - public void testGetTimelineServiceHBaseConfNullArgument() throws Exception { - HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(null); + @Test + void testGetTimelineServiceHBaseConfNullArgument() throws Exception { + assertThrows(NullPointerException.class, () -> { + HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(null); + }); } @Test - public void testWithHbaseConfAtLocalFileSystem() throws IOException { + void testWithHbaseConfAtLocalFileSystem() throws IOException { // Verifying With Hbase Conf from Local FileSystem Configuration conf = new Configuration(); conf.set(YarnConfiguration.TIMELINE_SERVICE_HBASE_CONFIGURATION_FILE, hbaseConfigPath); Configuration hbaseConfFromLocal = HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(conf); - Assert.assertEquals("Failed to read hbase config from Local FileSystem", - "test", hbaseConfFromLocal.get("input")); + assertEquals("test", hbaseConfFromLocal.get("input"), + "Failed to read hbase config from Local FileSystem"); } @Test - public void testWithHbaseConfAtHdfsFileSystem() throws IOException { + void testWithHbaseConfAtHdfsFileSystem() throws IOException { MiniDFSCluster hdfsCluster = null; try { HdfsConfiguration hdfsConfig = new HdfsConfiguration(); @@ -95,8 +99,8 @@ public class TestHBaseTimelineStorageUtils { path.toString()); Configuration hbaseConfFromHdfs = HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(conf); - Assert.assertEquals("Failed to read hbase config from Hdfs FileSystem", - "test", hbaseConfFromHdfs.get("input")); + assertEquals("test", hbaseConfFromHdfs.get("input"), + "Failed to read hbase config from Hdfs FileSystem"); } finally { if (hdfsCluster != null) { hdfsCluster.shutdown();