@After
  public void tearDown() throws Exception {
    try {
      client.dropTable(DB_NAME, TABLE_NAME);
      client.dropDatabase(DB_NAME);
      try {
        if (d != null) {
          d.close();
          d.destroy();
          d = null;
        }
      } finally {
        TestTxnDbUtil.cleanDb(hiveConf);
        FileUtils.deleteDirectory(new File(getTestDataDir()));
      }

      client.close();
    } catch (Throwable e) {
      System.err.println("Unable to close metastore");
      System.err.println(StringUtils.stringifyException(e));
      throw new Exception(e);
    }
  }
Integration tests for the HiveMetaTool program.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/tools/metatool/TestHiveMetaTool.java