@Test
  public void testInitCredentialsForCluster1() throws Exception {
    HBaseTestingUtil util1 = new HBaseTestingUtil();
    HBaseTestingUtil util2 = new HBaseTestingUtil();

    util1.startMiniCluster();
    try {
      util2.startMiniCluster();
      try {
        Configuration conf1 = util1.getConfiguration();
        Job job = Job.getInstance(conf1);

        TableMapReduceUtil.initCredentialsForCluster(job, util2.getConfiguration());

        Credentials credentials = job.getCredentials();
        Collection<Token<? extends TokenIdentifier>> tokens = credentials.getAllTokens();
        assertTrue(tokens.isEmpty());
      } finally {
        util2.shutdownMiniCluster();
      }
    } finally {
      util1.shutdownMiniCluster();
    }
  }
Test different variants of initTableMapperJob method
hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceUtil.java