@Test
public void testEscapeCharacters() throws KerberosOperationException {

  KerberosOperationHandler handler = createHandler();
  HashSet<Character> specialCharacters = new HashSet<Character>() {
    {
      add('/');
      add(',');
      add('\\');
      add('#');
      add('+');
      add('<');
      add('>');
      add(';');
      add('"');
      add('=');
      add(' ');
    }
  };
  Assert.assertEquals("\\/\\,\\\\\\#\\+\\<\\>\\;\\\"\\=\\ ", handler.escapeCharacters("/,\\#+<>;\"= ", specialCharacters, '\\'));
  Assert.assertNull(handler.escapeCharacters(null, specialCharacters, '\\'));
  Assert.assertEquals("", handler.escapeCharacters("", specialCharacters, '\\'));
  Assert.assertEquals("nothing_special_here", handler.escapeCharacters("nothing_special_here", specialCharacters, '\\'));
  Assert.assertEquals("\\/\\,\\\\\\#\\+\\<\\>\\;\\\"\\=\\ ", handler.escapeCharacters("/,\\#+<>;\"= ", specialCharacters, '\\'));
  Assert.assertEquals("nothing<>special#here!", handler.escapeCharacters("nothing<>special#here!", null, '\\'));
  Assert.assertEquals("nothing<>special#here!", handler.escapeCharacters("nothing<>special#here!", Collections.<Character>emptySet(), '\\'));
  Assert.assertEquals("nothing<>special#here!", handler.escapeCharacters("nothing<>special#here!", Collections.singleton('?'), '\\'));
  Assert.assertEquals("\\A's are special!", handler.escapeCharacters("A's are special!", Collections.singleton('A'), '\\'));
}