assertNotNull(ap);
assertNotNull(bp);
assertEquals(ap.getClass(), bp.getClass());
assertTrue(ap != bp);
if (ap instanceof Content) {
final Content a = (Content)ap;
final Content b = (Content)bp;
if (a.getParent() != null) {
assertTrue(a.getParent() != b.getParent());
}
switch (a.getCType()) {
case Text:
assertEquals(a.getValue(), b.getValue());
break;
case CDATA:
assertEquals(a.getValue(), b.getValue());
break;
case Comment:
assertEquals(((Comment)a).getText(), ((Comment)b).getText());
break;
case DocType:
DocType da = (DocType)a;
DocType db = (DocType)b;
assertEquals(da.getElementName(), db.getElementName());
assertEquals(da.getPublicID(), db.getPublicID());
assertEquals(da.getSystemID(), db.getSystemID());
assertEquals(da.getInternalSubset(), db.getInternalSubset());
break;
case Element:
Element ea = (Element)a;
Element eb = (Element)b;
assertEquals(ea.getName(), eb.getName());
compare(ea.getAttributes(), eb.getAttributes());
assertEquals(ea.getNamespacesInScope(), eb.getNamespacesInScope());
final int sz = ea.getContentSize();
assertTrue(sz == eb.getContentSize());
for (int i = 0; i < sz; i++) {
compare(ea.getContent(i), eb.getContent(i));
}
break;
case EntityRef:
assertEquals(((EntityRef)a).getName(), ((EntityRef)b).getName());
break;
case ProcessingInstruction:
ProcessingInstruction pa = (ProcessingInstruction)a;
ProcessingInstruction pb = (ProcessingInstruction)b;
assertEquals(pa.getTarget(), pb.getTarget());
assertEquals(pa.getData(), pb.getData());
break;
}
} else if (ap instanceof Attribute) {
compare ((Attribute)ap, (Attribute)bp);
} else if (ap instanceof Document) {
Document a = (Document)ap;
Document b = (Document)bp;
assertEquals(a.getBaseURI(), b.getBaseURI());
final int sz = a.getContentSize();
assertTrue(sz == b.getContentSize());
for (int i = 0; i < sz; i++) {
compare(a.getContent(i), b.getContent(i));
}
}
}