@Test
  public void testTableDatabase() throws Exception {
    String dbName = "testDb";
    String tblName_1 = "testTbl_1";
    String tblName_2 = "testTbl_2";

    try {
      silentDropDatabase(dbName);

      String extWarehouse =  MetastoreConf.getVar(conf, ConfVars.WAREHOUSE_EXTERNAL);
      LOG.info("external warehouse set to:" + extWarehouse);
      if (extWarehouse == null || extWarehouse.trim().isEmpty()) {
        extWarehouse = "/tmp/external";
      }
      String dbLocation =
          extWarehouse + "/_testDB_table_database_";
      String mgdLocation =
          MetastoreConf.getVar(conf, ConfVars.WAREHOUSE) + "/_testDB_table_database_";
      new DatabaseBuilder()
          .setName(dbName)
          .setLocation(dbLocation)
          .setManagedLocation(mgdLocation)
          .create(client, conf);
      Database db = client.getDatabase(dbName);

      Table tbl = new TableBuilder()
          .setDbName(dbName)
          .setTableName(tblName_1)
          .setType(TableType.EXTERNAL_TABLE.name())
          .addCol("name", ColumnType.STRING_TYPE_NAME)
          .addCol("income", ColumnType.INT_TYPE_NAME)
          .addTableParam("EXTERNAL", "TRUE")
          .create(client, conf);

      tbl = client.getTable(dbName, tblName_1);

      Path path = new Path(tbl.getSd().getLocation());
      System.err.println("Table's location " + path + ", Database's location " + db.getLocationUri());
      assertEquals("Table type is expected to be EXTERNAL", TableType.EXTERNAL_TABLE.name(), tbl.getTableType());
      assertEquals("Table location is not a subset of the database location",
          db.getLocationUri(), path.getParent().toString());

    } catch (Exception e) {
      System.err.println(StringUtils.stringifyException(e));
      System.err.println("testTableDatabase() failed.");
      throw e;
    } finally {
      silentDropDatabase(dbName);
    }
  }
tests create table and partition and tries to drop the table without
droppping the partition
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java