@Test
public void testGetPrincipalNamesFromKeytabWithPattern() throws IOException {

  createKeyTab(testKeytab, testPrincipals); 
  // read the keytab file
  // look for principals with HTTP as the first part
  Pattern httpPattern = Pattern.compile("HTTP/.*");
  String[] httpPrincipals =
      KerberosUtil.getPrincipalNames(testKeytab, httpPattern);
  Assert.assertNotNull("principals cannot be null", httpPrincipals);
  
  int expectedSize = 0;
  List<String> httpPrincipalList = Arrays.asList(httpPrincipals);
  for (String principal : testPrincipals) {
    if (httpPattern.matcher(principal).matches()) {
      Assert.assertTrue("missing principal "+principal,
          httpPrincipalList.contains(principal));
      expectedSize++;
    }
  }
  Assert.assertEquals(expectedSize, httpPrincipals.length);
}