diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHiveServer2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHiveServer2.java index da51a55..b231137 100644 --- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHiveServer2.java +++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/miniHS2/TestHiveServer2.java @@ -20,7 +20,6 @@ import static org.junit.Assert.assertFalse; -import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -58,18 +57,28 @@ public void tearDown() throws Exception { miniHS2.stop(); } + /** + * Open a new session and run a test query + * @throws Exception + */ @Test public void testConnection() throws Exception { - String tabName = "testTab1"; + String tabName = "TestHiveServer2TestConnection"; CLIServiceClient serviceClient = miniHS2.getServiceClient(); SessionHandle sessHandle = serviceClient.openSession("foo", "bar"); - serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS tab", confOverlay); serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tabName + " (id INT)", confOverlay); OperationHandle opHandle = serviceClient.executeStatement(sessHandle, "SHOW TABLES", confOverlay); RowSet rowSet = serviceClient.fetchResults(opHandle); assertFalse(rowSet.numRows() == 0); + serviceClient.executeStatement(sessHandle, "DROP TABLE " + tabName, confOverlay); + serviceClient.closeSession(sessHandle); } + + /** + * Open a new session and execute a set command + * @throws Exception + */ @Test public void testGetVariableValue() throws Exception { CLIServiceClient serviceClient = miniHS2.getServiceClient(); @@ -77,6 +86,7 @@ public void testGetVariableValue() throws Exception { OperationHandle opHandle = serviceClient.executeStatement(sessHandle, "set system:os.name", confOverlay); RowSet rowSet = serviceClient.fetchResults(opHandle); Assert.assertEquals(1, rowSet.numRows()); + serviceClient.closeSession(sessHandle); } }