Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@
<type>test-jar</type>
<scope>test</scope>
</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>
<groupId>org.apache.hadoop</groupId>
Expand Down Expand Up @@ -257,12 +272,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@
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;
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.
*/
public class TestHBaseTimelineStorageUtils {

private String hbaseConfigPath = "target/hbase-site.xml";

@Before
@BeforeEach
public void setup() throws IOException {
// Input Hbase Configuration
Configuration hbaseConf = new Configuration();
Expand All @@ -60,25 +62,27 @@ public void setup() throws IOException {
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();
Expand All @@ -95,8 +99,8 @@ public void testWithHbaseConfAtHdfsFileSystem() throws IOException {
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();
Expand Down