@BeforeClass
  public static void setup() throws Exception {
    mDfs = new MiniDFSCluster.Builder(new Configuration()).numDataNodes(1).format(true).build();
    conf = new Configuration();
    conf.set("fs.defaultFS", "hdfs://" + mDfs.getNameNode().getHostAndPort());
    String warehouseLocation = "hdfs://" + mDfs.getNameNode().getHostAndPort()
        + MetastoreConf.ConfVars.WAREHOUSE.getDefaultVal();
    conf.set(MetastoreConf.ConfVars.WAREHOUSE.getVarname(), warehouseLocation);
    conf.set(MetastoreConf.ConfVars.AUTO_CREATE_ALL.getVarname(), "true");
    conf.set(MetastoreConf.ConfVars.SCHEMA_VERIFICATION.getVarname(), "false");
    client = Hive.get(conf, TestHDFSPermissionPolicyProvider.class).getMSC();

    try {
      client.dropTable("default", "tbl1");
    } catch (Exception e) {
    }
    try {
      client.dropTable("default", "tbl2");
    } catch (Exception e) {
    }
    try {
      client.dropTable("db1", "tbl1");
    } catch (Exception e) {
    }
    try {
      client.dropDatabase("db1");
    } catch (Exception e) {
    }

    defaultTbl1Loc = warehouseLocation + "/tbl1";
    defaultTbl2Loc = warehouseLocation + "/tbl2";
    db1Loc = warehouseLocation + "/db1";
    db1Tbl1Loc = warehouseLocation + "/db1/tbl1";

    int now = (int)System.currentTimeMillis() / 1000;
    FieldSchema col1 = new FieldSchema("col1", "int", "no comment");
    List<FieldSchema> cols = new ArrayList<FieldSchema>();
    cols.add(col1);
    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
    StorageDescriptor sd =
        new StorageDescriptor(cols, defaultTbl1Loc, "input", "output", false, 0, serde, null, null,
            new HashMap<String, String>());
    Table tbl =
        new Table("tbl1", "default", "foo", now, now, 0, sd, null,
            new HashMap<String, String>(), null, null, TableType.MANAGED_TABLE.toString());
    client.createTable(tbl);

    sd = new StorageDescriptor(cols, defaultTbl2Loc, "input", "output", false, 0, serde,
        null, null, new HashMap<String, String>());
    tbl = new Table("tbl2", "default", "foo", now, now, 0, sd, null,
            new HashMap<String, String>(), null, null, TableType.MANAGED_TABLE.toString());
    client.createTable(tbl);

    Database db = new Database("db1", "no description", db1Loc, new HashMap<String, String>());
    client.createDatabase(db);

    sd = new StorageDescriptor(cols, db1Tbl1Loc, "input", "output", false, 0, serde, null, null,
            new HashMap<String, String>());
    tbl = new Table("tbl1", "db1", "foo", now, now, 0, sd, null,
            new HashMap<String, String>(), null, null, TableType.MANAGED_TABLE.toString());
    client.createTable(tbl);
  }
Test cases for privilege synchronizer for storage based authorizer
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestHDFSPermissionPolicyProvider.java