From 12853268e1fcf91a7ef665bdd04cb9a4d21b1d9b Mon Sep 17 00:00:00 2001 From: zhangduo Date: Wed, 2 Mar 2016 09:37:07 +0800 Subject: [PATCH] HBASE-15365 Do not write to '/tmp' in TestHBaseConfiguration Conflicts: hbase-common/src/test/java/org/apache/hadoop/hbase/TestHBaseConfiguration.java --- .../hadoop/hbase/TestHBaseConfiguration.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) 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 f8b60fd9889..2a8d1a29b06 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,28 +20,36 @@ 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.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(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; @@ -98,22 +106,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)); } } @@ -197,7 +202,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);