@Test
  public void testConnectionSchemaAPIs() throws Exception {
    /**
     * get/set Schema are new in JDK7 and not available in java.sql.Connection in JDK6. Hence the
     * test uses HiveConnection object to call these methods so that test will run with older JDKs
     */
    HiveConnection hiveConn = (HiveConnection) conDefault;
    assertEquals(defaultDbName, hiveConn.getSchema());
    Statement stmt = conDefault.createStatement();

    stmt.execute("USE " + testDbName);
    assertEquals(testDbName, hiveConn.getSchema());

    stmt.execute("USE " + defaultDbName);
    assertEquals(defaultDbName, hiveConn.getSchema());

    hiveConn.setSchema(defaultDbName);
    assertEquals(defaultDbName, hiveConn.getSchema());
    hiveConn.setSchema(defaultDbName);
    assertEquals(defaultDbName, hiveConn.getSchema());

    assertTrue(hiveConn.getCatalog().isEmpty());
    hiveConn.setCatalog("foo");
    assertTrue(hiveConn.getCatalog().isEmpty());
  }
verify that the current db is the one expected. first create table as <db>.tab and then
describe that table to check if <db> is the current database
@param expectedDbName
@param hs2Conn
@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java