@Test
public void testClone() throws CloneNotSupportedException {

  AuthToLocalBuilder builder = new AuthToLocalBuilder("EXAMPLE.COM", Collections.<String>emptyList(), false);
  builder.addRule("nn/_HOST@EXAMPLE.COM", "hdfs");
  builder.addRule("dn/_HOST@EXAMPLE.COM", "hdfs");
  builder.addRule("jn/_HOST@EXAMPLE.COM", "hdfs");
  builder.addRule("rm/_HOST@EXAMPLE.COM", "yarn");
  builder.addRule("jhs/_HOST@EXAMPLE.COM", "mapred");
  builder.addRule("hm/_HOST@EXAMPLE.COM", "hbase");
  builder.addRule("rs/_HOST@EXAMPLE.COM", "hbase");
  builder.addRule("foobar@EXAMPLE.COM", "hdfs");
  AuthToLocalBuilder copy = (AuthToLocalBuilder) builder.clone();
  assertNotSame(builder, copy);
  assertEquals(builder.generate(), copy.generate());
  // Ensure that mutable fields do not change the copy when changed in the original
  builder.addRule("user@EXAMPLE.COM", "hdfs");
  assertTrue(!copy.generate().equals(builder.generate()));
}