AbstractAttributeCollection extends AbstractAttributeProvider implements AttributeCollection { @Override public final boolean renameAttribute(String oldname, String newname) { return renameAttribute(oldname, newname, false); }  @Pure @Override synchronized boolean isEventFirable(); @Override synchronized void setEventFirable(boolean isFirable); @Pure @Override AttributeCollection clone(); @Override synchronized void addAttributeChangeListener(AttributeChangeListener listener); @Override synchronized void removeAttributeChangeListener(AttributeChangeListener listener); @Override final boolean renameAttribute(String oldname, String newname);  }
@Test public void renameAttribute() { String message; assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertTrue(this.testData.hasAttribute("B")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); AttributeValue oldValue = this.testData.getAttribute("B"); assertTrue(this.testData.renameAttribute("B", "ZZZ", false)); message = this.id+": renaming B to ZZZ"; this.listenerStub.assertTypes(message, AttributeChangeEvent.Type.RENAME); this.listenerStub.assertNames(message, "ZZZ"); this.listenerStub.assertOldNames(message, "B"); this.listenerStub.assertValues(message, oldValue); this.listenerStub.assertOldValues(message, oldValue); this.listenerStub.reset(); assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertFalse(this.testData.hasAttribute("B")); assertTrue(this.testData.hasAttribute("ZZZ")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); assertEquals(oldValue, this.testData.getAttribute("ZZZ")); assertFalse(this.testData.renameAttribute("toto", "XXX", false)); message = this.id+": renaming toto to XXX"; this.listenerStub.assertEmpty(message); this.listenerStub.reset(); assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertFalse(this.testData.hasAttribute("B")); assertTrue(this.testData.hasAttribute("ZZZ")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); oldValue = this.testData.getAttribute("F"); AttributeValue oldValue2 = this.testData.getAttribute("A"); assertFalse(this.testData.renameAttribute("F", "A", false)); message = this.id+": renaming F to A"; this.listenerStub.assertEmpty(message); this.listenerStub.reset(); assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertFalse(this.testData.hasAttribute("B")); assertTrue(this.testData.hasAttribute("ZZZ")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); assertEquals(oldValue, this.testData.getAttribute("F")); assertEquals(oldValue2, this.testData.getAttribute("A")); }
@Test public void renameAttributeOverwrite() { String message; assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertTrue(this.testData.hasAttribute("B")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); AttributeValue oldValue = this.testData.getAttribute("B"); assertTrue(this.testData.renameAttribute("B", "ZZZ", true)); message = this.id+": renaming B to ZZZ"; this.listenerStub.assertTypes(message, AttributeChangeEvent.Type.RENAME); this.listenerStub.assertNames(message, "ZZZ"); this.listenerStub.assertOldNames(message, "B"); this.listenerStub.assertValues(message, oldValue); this.listenerStub.assertOldValues(message, oldValue); this.listenerStub.reset(); assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertFalse(this.testData.hasAttribute("B")); assertTrue(this.testData.hasAttribute("ZZZ")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); assertEquals(oldValue, this.testData.getAttribute("ZZZ")); assertFalse(this.testData.renameAttribute("toto", "XXX", true)); message = this.id+": renaming toto to XXX"; this.listenerStub.assertEmpty(message); this.listenerStub.reset(); assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertFalse(this.testData.hasAttribute("B")); assertTrue(this.testData.hasAttribute("ZZZ")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertTrue(this.testData.hasAttribute("F")); oldValue = this.testData.getAttribute("F"); AttributeValue oldValue2 = this.testData.getAttribute("A"); assertTrue(this.testData.renameAttribute("F", "A", true)); message = this.id+": renaming F to A"; this.listenerStub.assertTypes(message, AttributeChangeEvent.Type.REMOVAL, AttributeChangeEvent.Type.RENAME); this.listenerStub.assertNames(message, "A","A"); this.listenerStub.assertOldNames(message, "A", "F"); this.listenerStub.assertValues(message, oldValue2, oldValue); this.listenerStub.assertOldValues(message, oldValue2, oldValue); this.listenerStub.reset(); assertTrue(this.testData.hasAttribute("A")); assertFalse(this.testData.hasAttribute("X")); assertFalse(this.testData.hasAttribute("B")); assertTrue(this.testData.hasAttribute("ZZZ")); assertFalse(this.testData.hasAttribute("Y")); assertTrue(this.testData.hasAttribute("C")); assertTrue(this.testData.hasAttribute("D")); assertFalse(this.testData.hasAttribute("Z")); assertTrue(this.testData.hasAttribute("E")); assertFalse(this.testData.hasAttribute("F")); assertEquals(oldValue, this.testData.getAttribute("A")); }