private static Closeable startSecureMiniCluster(HBaseTestingUtil util, MiniKdc kdc,
    String principal) throws Exception {
    Configuration conf = util.getConfiguration();

    SecureTestUtil.enableSecurity(conf);
    VisibilityTestUtil.enableVisiblityLabels(conf);
    SecureTestUtil.verifyConfiguration(conf);

    conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      AccessController.class.getName() + ',' + TokenProvider.class.getName());

    HBaseKerberosUtils.setSecuredConfiguration(conf, principal + '@' + kdc.getRealm(),
      HTTP_PRINCIPAL + '@' + kdc.getRealm());

    util.startMiniCluster();
    try {
      util.waitUntilAllRegionsAssigned(PermissionStorage.ACL_TABLE_NAME);
    } catch (Exception e) {
      util.shutdownMiniCluster();
      throw e;
    }

    return util::shutdownMiniCluster;
  }
Test different variants of initTableMapperJob method
hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java