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
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## XMLUnit for Java 2.10.1 - /not released, yet/

* `Comparison` has earned a new convenience constructor.
PR [#280](https://github.com/xmlunit/xmlunit/pull/280) by
[@hiufung-kwok](https://github.com/hiufung-kwok)

* `Input.from` now detects `Reader` arguments and uses `fromReader`.
PR [#281](https://github.com/xmlunit/xmlunit/pull/281) by
[@SThomasP](https://github.com/SThomasP)
Expand Down
5 changes: 3 additions & 2 deletions xmlunit-core/src/main/java/org/xmlunit/diff/Comparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ public Comparison(ComparisonType t,
* @param testContext xpathContext object contains the current and parent XPath
* @param testTarget the test node the comparison applies to
* @param testValue value from the test node used during comparison
* @since XMLUnit 2.10.1
*/
public Comparison(ComparisonType t,
XPathContext controlContext, Node controlTarget, Object controlValue,
XPathContext testContext, Node testTarget,Object testValue) {
this (t,
controlTarget, getXPath(controlContext), controlValue, getParentXPath(controlContext),
testTarget, getXPath(testContext), testValue, getParentXPath(testContext));
controlTarget, getXPath(controlContext), controlValue, getParentXPath(controlContext),
testTarget, getXPath(testContext), testValue, getParentXPath(testContext));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ ComparisonState compareNodes(final Node control, final XPathContext controlConte
controlContext, control, control.getPrefix(),
testContext, test, test.getPrefix()))
.andIfTrueThen(control.getNodeType() != Node.ATTRIBUTE_NODE,
new Comparison(ComparisonType.CHILD_NODELIST_LENGTH,
controlContext, control, Linqy.count(controlChildren),
testContext, test, Linqy.count(testChildren)))
new Comparison(ComparisonType.CHILD_NODELIST_LENGTH,
controlContext, control,
Linqy.count(controlChildren),
testContext, test, Linqy.count(testChildren)))
.andThen(new DeferredComparison() {
@Override
public ComparisonState apply() {
Expand Down Expand Up @@ -262,8 +263,8 @@ private ComparisonState compareCharacterData(CharacterData control,
CharacterData test,
XPathContext testContext) {
return compare(new Comparison(ComparisonType.TEXT_VALUE,
controlContext, control, control.getData(),
testContext, test, test.getData()));
controlContext, control, control.getData(),
testContext, test, test.getData()));
}

/**
Expand All @@ -277,7 +278,8 @@ private ComparisonState compareDocuments(final Document control,
final DocumentType testDt = filterNode(test.getDoctype());

return compare(new Comparison(ComparisonType.HAS_DOCTYPE_DECLARATION,
controlContext, control, Boolean.valueOf(controlDt != null),
controlContext, control,
Boolean.valueOf(controlDt != null),
testContext, test, Boolean.valueOf(testDt != null)))
.andIfTrueThen(controlDt != null && testDt != null,
new DeferredComparison() {
Expand All @@ -304,8 +306,8 @@ private <T extends Node> T filterNode(T n) {
DocumentType test,
XPathContext testContext) {
return compare(new Comparison(ComparisonType.DOCTYPE_NAME,
controlContext, control, control.getName(),
testContext, test, test.getName()))
controlContext, control, control.getName(),
testContext, test, test.getName()))
.andThen(new Comparison(ComparisonType.DOCTYPE_PUBLIC_ID,
controlContext, control, control.getPublicId(),
testContext, test, test.getPublicId()))
Expand All @@ -326,8 +328,8 @@ private DeferredComparison compareDeclarations(final Document control,
public ComparisonState apply() {
return
compare(new Comparison(ComparisonType.XML_VERSION,
controlContext, control, control.getXmlVersion(),
testContext, test, test.getXmlVersion()))
controlContext, control, control.getXmlVersion(),
testContext, test, test.getXmlVersion()))
.andThen(new Comparison(ComparisonType.XML_STANDALONE,
controlContext, control, control.getXmlStandalone(),
testContext, test, test.getXmlStandalone()))
Expand All @@ -348,8 +350,8 @@ private ComparisonState compareElements(final Element control,
final XPathContext testContext) {
return
compare(new Comparison(ComparisonType.ELEMENT_TAG_NAME,
controlContext, control, Nodes.getQName(control).getLocalPart(),
testContext, test, Nodes.getQName(test).getLocalPart()))
controlContext, control, Nodes.getQName(control).getLocalPart(),
testContext, test, Nodes.getQName(test).getLocalPart()))
.andThen(new DeferredComparison() {
@Override
public ComparisonState apply() {
Expand All @@ -376,8 +378,10 @@ private ComparisonState compareElementAttributes(final Element control,
QNAME_MAPPER));

return compare(new Comparison(ComparisonType.ELEMENT_NUM_ATTRIBUTES,
controlContext, control, controlAttributes.remainingAttributes.size(),
testContext, test, testAttributes.remainingAttributes.size()))
controlContext, control,
controlAttributes.remainingAttributes.size(),
testContext, test,
testAttributes.remainingAttributes.size()))
.andThen(new DeferredComparison() {
@Override
public ComparisonState apply() {
Expand Down