Created
December 17, 2019 15:28
-
-
Save bodewig/573c4d9c3bb692028d1013c9ce74f8fd to your computer and use it in GitHub Desktop.
Testcase for Issue 169 in XMLUnit for Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.xmlunit.builder.*; | |
import org.xmlunit.diff.*; | |
/** | |
* @see "https://github.com/xmlunit/xmlunit/issues/169" | |
*/ | |
public class Issue169 { | |
private static final String X1 = "<Data:Keys xmlns:Data=\"foo\">\n" | |
+ "<Data:Value Key=\"1\" Name=\"Example1\" />\n" | |
+ "<Data:Value Key=\"2\" Name=\"Example2\" />\n" | |
+ "<Data:Value Key=\"3\" Name=\"Example3\" />\n" | |
+ "</Data:Keys>"; | |
private static final String X2 = "<Data:Keys xmlns:Data=\"foo\">\n" | |
+ "<Data:Value Key=\"2\" Name=\"Example2\" />\n" | |
+ "<Data:Value Key=\"1\" Name=\"Example1\" />\n" | |
+ "<Data:Value Key=\"3\" Name=\"Example3\" />\n" | |
+ "</Data:Keys>"; | |
public static void main(String[] args) { | |
Diff diff = DiffBuilder.compare(Input.from(X1)) | |
.withTest(Input.from(X2)) | |
.ignoreComments() | |
.ignoreWhitespace() | |
.normalizeWhitespace() | |
.checkForSimilar() | |
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.conditionalBuilder() | |
.whenElementIsNamed("Value") | |
.thenUse(ElementSelectors.byNameAndAttributes("Key")) | |
.elseUse(ElementSelectors.byName) | |
.build() | |
)).build() | |
; | |
System.err.println(diff); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment