@Test
  public void testMetaDataGetColumns() throws SQLException {
    Map<String[], Integer> tests = new HashMap<String[], Integer>();
    tests.put(new String[] { "testjdbcdrivertbl", null }, 2);
    tests.put(new String[] { "%jdbcdrivertbl", null }, 2);
    tests.put(new String[] { "%jdbcdrivertbl%", "under\\_col" }, 1);
    tests.put(new String[] { "%jdbcdrivertbl%", "under\\_co_" }, 1);
    tests.put(new String[] { "%jdbcdrivertbl%", "under_col" }, 1);
    tests.put(new String[] { "%jdbcdrivertbl%", "und%" }, 1);
    tests.put(new String[] { "%jdbcdrivertbl%", "%" }, 2);
    tests.put(new String[] { "%jdbcdrivertbl%", "_%" }, 2);

    for (String[] checkPattern : tests.keySet()) {
      ResultSet rs =
          con.getMetaData().getColumns(null, testDbName, checkPattern[0], checkPattern[1]);

      // validate the metadata for the getColumns result set
      ResultSetMetaData rsmd = rs.getMetaData();
      assertEquals("TABLE_CAT", rsmd.getColumnName(1));

      int cnt = 0;
      while (rs.next()) {
        String columnname = rs.getString("COLUMN_NAME");
        int ordinalPos = rs.getInt("ORDINAL_POSITION");
        switch (cnt) {
        case 0:
          assertEquals("Wrong column name found", "under_col", columnname);
          assertEquals("Wrong ordinal position found", ordinalPos, 1);
          break;
        case 1:
          assertEquals("Wrong column name found", "value", columnname);
          assertEquals("Wrong ordinal position found", ordinalPos, 2);
          break;
        default:
          break;
        }
        cnt++;
      }
      rs.close();
      assertEquals("Found less columns then we test for.", tests.get(checkPattern).intValue(), cnt);
    }
  }
Test if Connection.getMetaData().getTableTypes() returns expected
 tabletypes
@param tabletypes expected table types
@throws SQLException
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java