@Test
public void testCreateDropRole() throws Exception {

  runTestAsSubject(new TestOperation() {
    @Override
    public void runTestAsSubject() throws Exception {
      // test: create role with -cr
      String[] args = { "-cr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
      SentryShellSolr.main(args);
      // test: create role with --create_role
      args = new String[] { "--create_role", "-r", TEST_ROLE_NAME_2, "-conf",
          confPath.getAbsolutePath() };
      SentryShellSolr.main(args);
      // validate the result, list roles with -lr
      args = new String[] { "-lr", "-conf", confPath.getAbsolutePath() };
      SentryShellSolr sentryShell = new SentryShellSolr();
      Set<String> roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
      validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
      // validate the result, list roles with --list_role
      args = new String[] { "--list_role", "-conf", confPath.getAbsolutePath() };
      sentryShell = new SentryShellSolr();
      roleNames = getShellResultWithOSRedirect(sentryShell, args, true);
      validateRoleNames(roleNames, TEST_ROLE_NAME_1, TEST_ROLE_NAME_2);
      // test: drop role with -dr
      args = new String[] { "-dr", "-r", TEST_ROLE_NAME_1, "-conf", confPath.getAbsolutePath() };
      SentryShellSolr.main(args);
      // test: drop role with --drop_role
      args = new String[] { "--drop_role", "-r", TEST_ROLE_NAME_2, "-conf",
          confPath.getAbsolutePath() };
      SentryShellSolr.main(args);
      // validate the result
      Set<TSentryRole> roles = client.listAllRoles(requestorName, SOLR);
      assertEquals("Incorrect number of roles", 0, roles.size());
    }
  });
}