diff --git a/src/main/java/com/profiler/common/util/PropertyUtils.java b/src/main/java/com/profiler/common/util/PropertyUtils.java index 255baf8b9..c4f906a92 100644 --- a/src/main/java/com/profiler/common/util/PropertyUtils.java +++ b/src/main/java/com/profiler/common/util/PropertyUtils.java @@ -1,25 +1,24 @@ package com.profiler.common.util; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class PropertyUtils { - public static Properties readProperties(String propertyName) { + public static Properties readProperties(String propertyName) throws IOException { return readProperties(propertyName, PropertyUtils.class.getClassLoader()); } - public static Properties readProperties(String propertyName, ClassLoader cl) { + public static Properties readProperties(String propertyName, ClassLoader cl) throws IOException { Properties properties = new Properties(); InputStream stream = cl.getResourceAsStream(propertyName); if (stream == null) { - throw new RuntimeException(propertyName + " not found."); + throw new FileNotFoundException(propertyName + " not found."); } try { properties.load(stream); - } catch (IOException e) { - throw new RuntimeException(propertyName + " load fail. Cause:" + e.getMessage(), e); } finally { try { stream.close(); diff --git a/src/test/java/com/profiler/common/hbase/HBaseClientTest.java b/src/test/java/com/profiler/common/hbase/HBaseClientTest.java index bcfc75e84..fda0f37e9 100644 --- a/src/test/java/com/profiler/common/hbase/HBaseClientTest.java +++ b/src/test/java/com/profiler/common/hbase/HBaseClientTest.java @@ -1,10 +1,8 @@ package com.profiler.common.hbase; -import java.util.*; - +import com.profiler.common.hbase.HBaseQuery.HbaseColumn; import com.profiler.common.util.PropertyUtils; import junit.framework.Assert; - import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.client.Put; @@ -13,7 +11,8 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import com.profiler.common.hbase.HBaseQuery.HbaseColumn; +import java.io.IOException; +import java.util.*; public class HBaseClientTest { @@ -22,7 +21,7 @@ public class HBaseClientTest { private static HBaseClient client; @BeforeClass - public static void init() { + public static void init() throws IOException { Properties properties = PropertyUtils.readProperties("test-hbase.properties"); client = new HBaseClient(properties); if (client.isTableExists(TABLE_NAME)) {