You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2017/02/09 23:50:59 UTC
hive git commit: HIVE-15550 : fix arglist logging in schematool - add
missing test file
Repository: hive
Updated Branches:
refs/heads/master 1f1e91aa0 -> b799bde78
HIVE-15550 : fix arglist logging in schematool - add missing test file
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b799bde7
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b799bde7
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b799bde7
Branch: refs/heads/master
Commit: b799bde78919bdd8803b248d6aff57009767e1df
Parents: 1f1e91a
Author: Anishek Agarwal <an...@gmail.com>
Authored: Thu Feb 9 15:50:45 2017 -0800
Committer: Thejas M Nair <th...@hortonworks.com>
Committed: Thu Feb 9 15:50:56 2017 -0800
----------------------------------------------------------------------
.../apache/hive/beeline/TestHiveSchemaTool.java | 73 ++++++++++++++++++++
1 file changed, 73 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/b799bde7/beeline/src/test/org/apache/hive/beeline/TestHiveSchemaTool.java
----------------------------------------------------------------------
diff --git a/beeline/src/test/org/apache/hive/beeline/TestHiveSchemaTool.java b/beeline/src/test/org/apache/hive/beeline/TestHiveSchemaTool.java
new file mode 100644
index 0000000..8d386da
--- /dev/null
+++ b/beeline/src/test/org/apache/hive/beeline/TestHiveSchemaTool.java
@@ -0,0 +1,73 @@
+package org.apache.hive.beeline;
+
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.same;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.verifyStatic;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore("javax.management.*")
+@PrepareForTest({ HiveSchemaHelper.class, HiveSchemaTool.CommandBuilder.class })
+public class TestHiveSchemaTool {
+
+ String scriptFile = System.getProperty("java.io.tmpdir") + File.separator + "someScript.sql";
+ @Mock
+ private HiveConf hiveConf;
+ private HiveSchemaTool.CommandBuilder builder;
+ private String pasword = "reallySimplePassword";
+
+ @Before
+ public void setup() throws IOException {
+ mockStatic(HiveSchemaHelper.class);
+ when(HiveSchemaHelper
+ .getValidConfVar(eq(HiveConf.ConfVars.METASTORECONNECTURLKEY), same(hiveConf)))
+ .thenReturn("someURL");
+ when(HiveSchemaHelper
+ .getValidConfVar(eq(HiveConf.ConfVars.METASTORE_CONNECTION_DRIVER), same(hiveConf)))
+ .thenReturn("someDriver");
+
+ File file = new File(scriptFile);
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+ builder = new HiveSchemaTool.CommandBuilder(hiveConf, "testUser", pasword, scriptFile);
+ }
+
+ @After
+ public void globalAssert() throws IOException {
+ verifyStatic();
+ HiveSchemaHelper.getValidConfVar(eq(HiveConf.ConfVars.METASTORECONNECTURLKEY), same(hiveConf));
+ HiveSchemaHelper
+ .getValidConfVar(eq(HiveConf.ConfVars.METASTORE_CONNECTION_DRIVER), same(hiveConf));
+
+ new File(scriptFile).delete();
+ }
+
+ @Test
+ public void shouldReturnStrippedPassword() throws IOException {
+ assertFalse(builder.buildToLog().contains(pasword));
+ }
+
+ @Test
+ public void shouldReturnActualPassword() throws IOException {
+ String[] strings = builder.buildToRun();
+ assertTrue(Arrays.asList(strings).contains(pasword));
+ }
+}
\ No newline at end of file