YARN-11270. Upgrade JUnit from 4 to 5 in hadoop-yarn-server-timelineservice-hbase-client (#4773)

Co-authored-by: Ashutosh Gupta <ashugpt@amazon.com>
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
Ashutosh Gupta 2022-09-25 15:26:06 +01:00 committed by GitHub
parent 747fb92107
commit fd0415c44a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 19 deletions

View File

@ -126,6 +126,21 @@
<type>test-jar</type> <type>test-jar</type>
<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.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.hadoop</groupId> <groupId>org.apache.hadoop</groupId>
@ -257,12 +272,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -24,9 +24,8 @@
import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.junit.Assert; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.Test;
import org.junit.Test;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -34,6 +33,9 @@
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; 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. * Unit tests for HBaseTimelineStorageUtils static methos.
*/ */
@ -41,7 +43,7 @@ public class TestHBaseTimelineStorageUtils {
private String hbaseConfigPath = "target/hbase-site.xml"; private String hbaseConfigPath = "target/hbase-site.xml";
@Before @BeforeEach
public void setup() throws IOException { public void setup() throws IOException {
// Input Hbase Configuration // Input Hbase Configuration
Configuration hbaseConf = new Configuration(); Configuration hbaseConf = new Configuration();
@ -60,25 +62,27 @@ public void setup() throws IOException {
os.close(); os.close();
} }
@Test(expected=NullPointerException.class) @Test
public void testGetTimelineServiceHBaseConfNullArgument() throws Exception { void testGetTimelineServiceHBaseConfNullArgument() throws Exception {
assertThrows(NullPointerException.class, () -> {
HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(null); HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(null);
});
} }
@Test @Test
public void testWithHbaseConfAtLocalFileSystem() throws IOException { void testWithHbaseConfAtLocalFileSystem() throws IOException {
// Verifying With Hbase Conf from Local FileSystem // Verifying With Hbase Conf from Local FileSystem
Configuration conf = new Configuration(); Configuration conf = new Configuration();
conf.set(YarnConfiguration.TIMELINE_SERVICE_HBASE_CONFIGURATION_FILE, conf.set(YarnConfiguration.TIMELINE_SERVICE_HBASE_CONFIGURATION_FILE,
hbaseConfigPath); hbaseConfigPath);
Configuration hbaseConfFromLocal = Configuration hbaseConfFromLocal =
HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(conf); HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(conf);
Assert.assertEquals("Failed to read hbase config from Local FileSystem", assertEquals("test", hbaseConfFromLocal.get("input"),
"test", hbaseConfFromLocal.get("input")); "Failed to read hbase config from Local FileSystem");
} }
@Test @Test
public void testWithHbaseConfAtHdfsFileSystem() throws IOException { void testWithHbaseConfAtHdfsFileSystem() throws IOException {
MiniDFSCluster hdfsCluster = null; MiniDFSCluster hdfsCluster = null;
try { try {
HdfsConfiguration hdfsConfig = new HdfsConfiguration(); HdfsConfiguration hdfsConfig = new HdfsConfiguration();
@ -95,8 +99,8 @@ public void testWithHbaseConfAtHdfsFileSystem() throws IOException {
path.toString()); path.toString());
Configuration hbaseConfFromHdfs = Configuration hbaseConfFromHdfs =
HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(conf); HBaseTimelineStorageUtils.getTimelineServiceHBaseConf(conf);
Assert.assertEquals("Failed to read hbase config from Hdfs FileSystem", assertEquals("test", hbaseConfFromHdfs.get("input"),
"test", hbaseConfFromHdfs.get("input")); "Failed to read hbase config from Hdfs FileSystem");
} finally { } finally {
if (hdfsCluster != null) { if (hdfsCluster != null) {
hdfsCluster.shutdown(); hdfsCluster.shutdown();