Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ private static boolean content_equal(XmlCursor a, XmlCursor b, boolean mixed) {
TokenType tokenA = skip_ignorable(a, mixed);
TokenType tokenB = skip_ignorable(b, mixed);

// a value rooted at a document - such as one made by copy() - ends
// in ENDDOC where an element ends in END: either way, it has run
// out of content
if (tokenA.isFinish() || tokenB.isFinish()) {
return tokenA.isFinish() && tokenB.isFinish();
}

if (tokenA != tokenB) {
return false;
}
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/xmlobject/detailed/ValueEqualsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ void testNestedElementDifference() throws Exception {
.valueEquals(clm3.getCarLocationMessage().getEventStatusArray(0)));
}

@Test
void testCopyEqualsOriginal() throws Exception {
CarLocationMessageDocument clm = CarLocationMessageDocument.Factory.parse(CLM);

// copy() roots the copy at a document, the original is an element in one
CarLocationMessageDocument.CarLocationMessage msg = clm.getCarLocationMessage();
XmlObject copy = msg.copy();
assertTrue(copy.valueEquals(msg));
assertTrue(msg.valueEquals(copy));

XmlObject eventStatus = msg.getEventStatusArray(0);
XmlObject eventStatusCopy = eventStatus.copy();
assertTrue(eventStatusCopy.valueEquals(eventStatus));
assertTrue(eventStatus.valueEquals(eventStatusCopy));

CarLocationMessageDocument other =
CarLocationMessageDocument.Factory.parse(CLM.replace("DALLAS", "AUSTIN"));
assertFalse(copy.valueEquals(other.getCarLocationMessage()));
assertFalse(other.getCarLocationMessage().valueEquals(copy));
}

@Test
void testAttributesCompared() throws Exception {
CarLocationMessageDocument clm1 = CarLocationMessageDocument.Factory.parse(CLM);
Expand Down
Loading