You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2016/03/02 04:25:10 UTC

hbase git commit: HBASE-15365 Do not write to '/tmp' in TestHBaseConfiguration

Repository: hbase
Updated Branches:
  refs/heads/master bab8d1527 -> 69e442efe


HBASE-15365 Do not write to '/tmp' in TestHBaseConfiguration


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/69e442ef
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/69e442ef
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/69e442ef

Branch: refs/heads/master
Commit: 69e442efe4c3e612d5dee6a7f4b0a408395202d3
Parents: bab8d15
Author: zhangduo <zh...@apache.org>
Authored: Wed Mar 2 09:37:07 2016 +0800
Committer: zhangduo <zh...@apache.org>
Committed: Wed Mar 2 11:05:36 2016 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/TestHBaseConfiguration.java    | 32 +++++++++++---------
 1 file changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/69e442ef/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
index 6c14ef9..3cec72e 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java
@@ -20,29 +20,37 @@ package org.apache.hadoop.hbase;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
 
-import com.google.common.collect.ImmutableMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.testclassification.MiscTests;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.apache.hadoop.hbase.zookeeper.ZKConfig;
+import org.junit.AfterClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.google.common.collect.ImmutableMap;
+
 @Category({MiscTests.class, SmallTests.class})
 public class TestHBaseConfiguration {
 
   private static final Log LOG = LogFactory.getLog(TestHBaseConfiguration.class);
 
+  private static HBaseCommonTestingUtility UTIL = new HBaseCommonTestingUtility();
+
+  @AfterClass
+  public static void tearDown() throws IOException {
+    UTIL.cleanupTestDir();
+  }
+
   @Test
   public void testGetIntDeprecated() {
     int VAL = 1, VAL2 = 2;
@@ -99,22 +107,19 @@ public class TestHBaseConfiguration {
   @Test
   public void testGetPassword() throws Exception {
     Configuration conf = HBaseConfiguration.create();
-    conf.set(ReflectiveCredentialProviderClient.CREDENTIAL_PROVIDER_PATH,
-        "jceks://file/tmp/foo.jks");
-    ReflectiveCredentialProviderClient client =
-        new ReflectiveCredentialProviderClient();
+    conf.set(ReflectiveCredentialProviderClient.CREDENTIAL_PROVIDER_PATH, "jceks://file"
+        + new File(UTIL.getDataTestDir().toUri().getPath(), "foo.jks").getCanonicalPath());
+    ReflectiveCredentialProviderClient client = new ReflectiveCredentialProviderClient();
     if (client.isHadoopCredentialProviderAvailable()) {
-      char[] keyPass = {'k', 'e', 'y', 'p', 'a', 's', 's'};
-      char[] storePass = {'s', 't', 'o', 'r', 'e', 'p', 'a', 's', 's'};
+      char[] keyPass = { 'k', 'e', 'y', 'p', 'a', 's', 's' };
+      char[] storePass = { 's', 't', 'o', 'r', 'e', 'p', 'a', 's', 's' };
       client.createEntry(conf, "ssl.keypass.alias", keyPass);
       client.createEntry(conf, "ssl.storepass.alias", storePass);
 
-      String keypass = HBaseConfiguration.getPassword(
-          conf, "ssl.keypass.alias", null);
+      String keypass = HBaseConfiguration.getPassword(conf, "ssl.keypass.alias", null);
       assertEquals(keypass, new String(keyPass));
 
-      String storepass = HBaseConfiguration.getPassword(
-          conf, "ssl.storepass.alias", null);
+      String storepass = HBaseConfiguration.getPassword(conf, "ssl.storepass.alias", null);
       assertEquals(storepass, new String(storePass));
     }
   }
@@ -198,7 +203,6 @@ public class TestHBaseConfiguration {
         getProvidersMethod = loadMethod(hadoopCredProviderFactoryClz,
             HADOOP_CRED_PROVIDER_FACTORY_GET_PROVIDERS_METHOD_NAME,
             Configuration.class);
-
         // Load Hadoop CredentialProvider
         Class<?> hadoopCredProviderClz = null;
         hadoopCredProviderClz = Class.forName(HADOOP_CRED_PROVIDER_CLASS_NAME);