TextImpl extends NodeImpl implements Text { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; TextImpl other = (TextImpl) obj; return text.equals(other.text); } TextImpl(String text); @Override org.w3c.dom.Text asXmlNode(Document document); String getText(); String getPlainText(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEqualsObject() { TextImpl text1 = new TextImpl("abc"); TextImpl text2 = new TextImpl("abc"); TextImpl text3 = new TextImpl("abcd"); assertEquals(text1, text1); assertEquals(text1, text2); assertFalse(text1.equals(text3)); assertFalse(text1.equals("abc")); assertFalse(text1.equals(null)); }