final User tableAdmin = User.createUserForTesting(conf, "TestUser", new String[0]);
// We need to create a new table here because we will be testing what
// happens when it is deleted
final byte[] tableName = Bytes.toBytes("testTableDeletion");
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
HTableDescriptor htd = new HTableDescriptor(tableName);
htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
admin.createTable(htd);
TEST_UTIL.waitTableEnabled(tableName, 5000);
// Grant TABLE ADMIN privs
HTable acl = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
try {
AccessControllerProtocol protocol = acl.coprocessorProxy(
AccessControllerProtocol.class, tableName);
protocol.grant(new UserPermission(Bytes.toBytes(tableAdmin.getShortName()),
tableName, null, Permission.Action.ADMIN));
} finally {
acl.close();
}
PrivilegedExceptionAction deleteTableAction = new PrivilegedExceptionAction() {
public Object run() throws Exception {
HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
try {
admin.disableTable(tableName);
admin.deleteTable(tableName);
} finally {
admin.close();
}
return null;
}
};