@Test
  public void testBindException() throws KrbException, IOException {
    SimpleKdcServer kdc = null;
    try {
      File dir = new File(UTIL.getDataTestDir().toString());
      kdc = SimpleKdcServerUtil.getRunningSimpleKdcServer(dir,
        HBaseCommonTestingUtil::randomFreePort, true);
      kdc.createPrincipal("wah");
    } finally {
      kdc.stop();
    }
  }
Test we are able to ride over clashing port... BindException.. when starting up a kdc server.
hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestSimpleKdcServerUtil.java