You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2014/04/19 06:45:15 UTC
svn commit: r1588607 - in
/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc:
TestJdbcDriver2.java TestJdbcWithMiniHS2.java
Author: hashutosh
Date: Sat Apr 19 04:45:15 2014
New Revision: 1588607
URL: http://svn.apache.org/r1588607
Log:
HIVE-5870 : Move TestJDBCDriver2.testNewConnectionConfiguration to TestJDBCWithMiniHS2 (Szehon Ho via Ashutosh Chauhan)
Modified:
hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java
Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1588607&r1=1588606&r2=1588607&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java Sat Apr 19 04:45:15 2014
@@ -343,59 +343,6 @@ public class TestJdbcDriver2 {
rs.close();
}
- /**
- * This method tests whether while creating a new connection,
- * the config variables specified in the JDBC URI are properly set for the connection.
- * This is a test for HiveConnection#configureConnection.
- * @throws Exception
- */
- @Test
- public void testNewConnectionConfiguration() throws Exception {
- // Start HiveServer2 with default conf
- HiveServer2 hiveServer2 = new HiveServer2();
- hiveServer2.init(new HiveConf());
- hiveServer2.start();
- Thread.sleep(3000);
-
- // Set some conf parameters
- String hiveConf = "hive.cli.print.header=true;hive.server2.async.exec.shutdown.timeout=20;" +
- "hive.server2.async.exec.threads=30;hive.server2.thrift.http.max.worker.threads=15";
- // Set some conf vars
- String hiveVar = "stab=salesTable;icol=customerID";
- String jdbcUri = "jdbc:hive2://localhost:10000/default" +
- "?" + hiveConf +
- "#" + hiveVar;
-
- // Open a new connection with these conf & vars
- Connection con1 = DriverManager.getConnection(jdbcUri);
-
- // Execute "set" command and retrieve values for the conf & vars specified above
- // Assert values retrieved
- Statement stmt = con1.createStatement();
-
- // Verify that the property has been properly set while creating the connection above
- verifyConfProperty(stmt, "hive.cli.print.header", "true");
- verifyConfProperty(stmt, "hive.server2.async.exec.shutdown.timeout", "20");
- verifyConfProperty(stmt, "hive.server2.async.exec.threads", "30");
- verifyConfProperty(stmt, "hive.server2.thrift.http.max.worker.threads", "15");
- verifyConfProperty(stmt, "stab", "salesTable");
- verifyConfProperty(stmt, "icol", "customerID");
- con1.close();
-
- if(hiveServer2 != null) {
- hiveServer2.stop();
- }
- }
-
- private void verifyConfProperty(Statement stmt, String property, String expectedValue)
- throws Exception {
- ResultSet res = stmt.executeQuery("set " + property);
- while(res.next()) {
- String resultValues[] = res.getString(1).split("=");
- assertEquals(resultValues[1], expectedValue);
- }
- }
-
@Test
public void testDataTypes2() throws Exception {
Statement stmt = con.createStatement();
Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java?rev=1588607&r1=1588606&r2=1588607&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java Sat Apr 19 04:45:15 2014
@@ -246,4 +246,50 @@ import org.junit.Test;
stmt.execute("DROP TABLE IF EXISTS " + expectedDbName + "." + verifyTab);
stmt.close();
}
+
+ /**
+ * This method tests whether while creating a new connection, the config
+ * variables specified in the JDBC URI are properly set for the connection.
+ * This is a test for HiveConnection#configureConnection.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testNewConnectionConfiguration() throws Exception {
+
+ // Set some conf parameters
+ String hiveConf = "hive.cli.print.header=true;hive.server2.async.exec.shutdown.timeout=20;"
+ + "hive.server2.async.exec.threads=30;hive.server2.thrift.http.max.worker.threads=15";
+ // Set some conf vars
+ String hiveVar = "stab=salesTable;icol=customerID";
+ String jdbcUri = miniHS2.getJdbcURL() + "?" + hiveConf + "#" + hiveVar;
+
+ // Open a new connection with these conf & vars
+ Connection con1 = DriverManager.getConnection(jdbcUri);
+
+ // Execute "set" command and retrieve values for the conf & vars specified
+ // above
+ // Assert values retrieved
+ Statement stmt = con1.createStatement();
+
+ // Verify that the property has been properly set while creating the
+ // connection above
+ verifyConfProperty(stmt, "hive.cli.print.header", "true");
+ verifyConfProperty(stmt, "hive.server2.async.exec.shutdown.timeout", "20");
+ verifyConfProperty(stmt, "hive.server2.async.exec.threads", "30");
+ verifyConfProperty(stmt, "hive.server2.thrift.http.max.worker.threads",
+ "15");
+ verifyConfProperty(stmt, "stab", "salesTable");
+ verifyConfProperty(stmt, "icol", "customerID");
+ con1.close();
+ }
+
+ private void verifyConfProperty(Statement stmt, String property,
+ String expectedValue) throws Exception {
+ ResultSet res = stmt.executeQuery("set " + property);
+ while (res.next()) {
+ String resultValues[] = res.getString(1).split("=");
+ assertEquals(resultValues[1], expectedValue);
+ }
+ }
}