@Test
 public void testIteratorWithDeprecatedKeys() {
   Configuration conf = new Configuration();
   Configuration.addDeprecation("dK", new String[] {"nK"});
   conf.set("k", "v");
   conf.set("dK", "V");
   assertEquals("V", conf.get("dK"));
   assertEquals("V", conf.get("nK"));
   conf.set("nK", "VV");
   assertEquals("VV", conf.get("dK"));
   assertEquals("VV", conf.get("nK"));
   boolean kFound = false;
   boolean dKFound = false;
   boolean nKFound = false;
   for (Map.Entry<String, String> entry : conf) {
     if (entry.getKey().equals("k")) {
       assertEquals("v", entry.getValue());
       kFound = true;
     }
     if (entry.getKey().equals("dK")) {
       assertEquals("VV", entry.getValue());
       dKFound = true;
     }
     if (entry.getKey().equals("nK")) {
       assertEquals("VV", entry.getValue());
       nKFound = true;
     }
   }
   assertTrue("regular Key not found", kFound);
   assertTrue("deprecated Key not found", dKFound);
   assertTrue("new Key not found", nKFound);
 }
 @Test
 public void testSetBeforeAndGetAfterDeprecation() {
   Configuration conf = new Configuration();
   conf.set("oldkey", "hello");
   Configuration.addDeprecation("oldkey", new String[] {"newkey"});
   assertEquals("hello", conf.get("newkey"));
 }
 @Test
 public void testSetBeforeAndGetAfterDeprecationAndDefaults() {
   Configuration conf = new Configuration();
   conf.set("tests.fake-default.old-key", "hello");
   Configuration.addDeprecation(
       "tests.fake-default.old-key", new String[] {"tests.fake-default.new-key"});
   assertEquals("hello", conf.get("tests.fake-default.new-key"));
 }
 private void addDeprecationToConfiguration() {
   Configuration.addDeprecation("A", new String[] {"B"});
   Configuration.addDeprecation("C", new String[] {"D"});
   Configuration.addDeprecation("E", new String[] {"F"});
   Configuration.addDeprecation("G", new String[] {"H"});
   Configuration.addDeprecation("I", new String[] {"J"});
   Configuration.addDeprecation("M", new String[] {"N"});
   Configuration.addDeprecation("X", new String[] {"Y", "Z"});
   Configuration.addDeprecation("P", new String[] {"Q", "R"});
 }
 @Test
 public void testNoFalseDeprecationWarning() throws IOException {
   Configuration conf = new Configuration();
   Configuration.addDeprecation("AA", "BB");
   conf.set("BB", "bb");
   conf.get("BB");
   conf.writeXml(new ByteArrayOutputStream());
   assertEquals(false, Configuration.hasWarnedDeprecation("AA"));
   conf.set("AA", "aa");
   assertEquals(true, Configuration.hasWarnedDeprecation("AA"));
 }
 @Test
 public void testUnsetWithDeprecatedKeys() {
   Configuration conf = new Configuration();
   Configuration.addDeprecation("dK", new String[] {"nK"});
   conf.set("nK", "VV");
   assertEquals("VV", conf.get("dK"));
   assertEquals("VV", conf.get("nK"));
   conf.unset("dK");
   assertNull(conf.get("dK"));
   assertNull(conf.get("nK"));
   conf.set("nK", "VV");
   assertEquals("VV", conf.get("dK"));
   assertEquals("VV", conf.get("nK"));
   conf.unset("nK");
   assertNull(conf.get("dK"));
   assertNull(conf.get("nK"));
 }