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

This commit is contained in:
zhangduo 2016-03-02 09:37:07 +08:00
parent bab8d1527b
commit 69e442efe4
1 changed files with 18 additions and 14 deletions

View File

@ -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);