AttributeImpl implements Attribute { public void setOwner(Element owner) { Assert.isInstance(owner, "owner", ElementImpl.class); if (owner == null) { this.owner = null; return; } if ((this.owner != null) && (this.owner != owner )) { String msg = MessageFormat .format( "The attribute ''{0}'' is already owned by element ''<{1}>''", this, owner.getName()); throw new IllegalArgumentException(msg); } this.owner = owner; } protected  AttributeImpl(String namespaceURI, String prefix, String name,
			String value); String getNamespaceUri(); String getPrefix(); String getName(); String getValue(); void setOwner(Element owner); Element getOwnerElement(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); Object clone();  }
@Test public void testSetOwner() { ConcreteAttributeImpl attr = new ConcreteAttributeImpl("ns", "pre", "name", "value"); ConcreteElementImpl elem1 = new ConcreteElementImpl("ns", "pre", "name"); ConcreteElementImpl elem2 = new ConcreteElementImpl("ns", "pre", "name"); attr.setOwner(elem1); attr.setOwner(elem1); try { attr.setOwner(elem2); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } }