public static void setRuleMechanism(String ruleMech) {
    if (ruleMech != null
            && (!ruleMech.equalsIgnoreCase(MECHANISM_HADOOP)
            && !ruleMech.equalsIgnoreCase(MECHANISM_MIT))) {
      throw new IllegalArgumentException("Invalid rule mechanism: " + ruleMech);
    }
    ruleMechanism = ruleMech;
  }
@Test
  public void testAntiPatterns() throws Exception {
    KerberosName.setRuleMechanism(KerberosName.MECHANISM_HADOOP);
    checkBadName("owen/owen/owen@FOO.COM");
    checkBadName("owen@foo/bar.com");

    checkBadTranslation("foo@ACME.COM");
    checkBadTranslation("root/joe@FOO.COM");

    KerberosName.setRuleMechanism(KerberosName.MECHANISM_MIT);
    checkTranslation("foo@ACME.COM", "foo@ACME.COM");
    checkTranslation("root/joe@FOO.COM", "root/joe@FOO.COM");
  }