@Before
  public void setUp() throws Exception {
    // Get new client
    client = metaStore.getClient();

    // Clean up the database
    client.dropDatabase(OTHER_DATABASE, true, true, true);
    // Drop every table in the default database
    for(String tableName : client.getAllTables(DEFAULT_DATABASE)) {
      client.dropTable(DEFAULT_DATABASE, tableName, true, true, true);
    }

    // Clean up trash
    metaStore.cleanWarehouseDirs();

    testTables[0] =
        new TableBuilder()
            .setTableName("test_table")
            .addCol("test_col", "int")
            .create(client, metaStore.getConf());

    testTables[1] =
        new TableBuilder()
            .setTableName("test_view")
            .addCol("test_col", "int")
            .setType("VIRTUAL_VIEW")
            .create(client, metaStore.getConf());

    testTables[2] =
        new TableBuilder()
            .setTableName("test_table_to_find_1")
            .addCol("test_col", "int")
            .create(client, metaStore.getConf());

    testTables[3] =
        new TableBuilder()
            .setTableName("test_partitioned_table")
            .addCol("test_col1", "int")
            .addCol("test_col2", "int")
            .addPartCol("test_part_col", "int")
            .create(client, metaStore.getConf());

    testTables[4] =
        new TableBuilder()
            .setTableName("external_table_for_test")
            .addCol("test_col", "int")
            .setLocation(metaStore.getExternalWarehouseRoot() + "/external/table_dir")
            .addTableParam("EXTERNAL", "TRUE")
            .setType("EXTERNAL_TABLE")
            .create(client, metaStore.getConf());


    new DatabaseBuilder().setName(OTHER_DATABASE).create(client, metaStore.getConf());

    testTables[5] =
        new TableBuilder()
            .setDbName(OTHER_DATABASE)
            .setTableName("test_table")
            .addCol("test_col", "int")
            .create(client, metaStore.getConf());

    // Create partitions for the partitioned table
    for(int i=0; i < 2; i++) {
      new PartitionBuilder()
              .inTable(testTables[3])
              .addValue("a" + i)
              .addToTable(client, metaStore.getConf());
    }
    // Add an external partition too
    new PartitionBuilder()
        .inTable(testTables[3])
        .addValue("a2")
        .setLocation(metaStore.getWarehouseRoot() + "/external/a2")
        .addToTable(client, metaStore.getConf());

    // Add data files to the partitioned table
    List<Partition> partitions =
        client.listPartitions(testTables[3].getDbName(), testTables[3].getTableName(), (short)-1);
    for(Partition partition : partitions) {
      Path dataFile = new Path(partition.getSd().getLocation() + "/dataFile");
      metaStore.createFile(dataFile, "100");
    }

    // Reload tables from the MetaStore, and create data files
    for(int i=0; i < testTables.length; i++) {
      testTables[i] = client.getTable(testTables[i].getDbName(), testTables[i].getTableName());
      if (testTables[i].getPartitionKeys().isEmpty()) {
        if (testTables[i].getSd().getLocation() != null) {
          Path dataFile = new Path(testTables[i].getSd().getLocation() + "/dataFile");
          metaStore.createFile(dataFile, "100");
        }
      }
    }
    partitionedTable = testTables[3];
    externalTable = testTables[4];
  }
Test class for IMetaStoreClient API. Testing the Table related functions for metadata
manipulation, like creating, dropping and altering tables.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java