Created
February 12, 2020 11:38
-
-
Save bodewig/b21db517c221668f53cc6992d6fed488 to your computer and use it in GitHub Desktop.
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
https://stackoverflow.com/questions/60177577/xmlunit-is-comparing-2-different-completely-different-nodes | |
$ cat X.java | |
import org.xmlunit.builder.*; | |
import org.xmlunit.diff.*; | |
public class X { | |
private static final String CONTROL = "<datapower-configuration version=\"3\">" | |
+ " <export-details>" | |
+ " <description>Exported Configuration</description>" | |
+ " <user>e084583</user>" | |
+ " <domain>DEVESB</domain>" | |
+ " <comment/>" | |
+ " </export-details>" | |
+ " <configuration domain=\"DEVESB\">" | |
+ " <HTTPSourceProtocolHandler name=\"LOCALHOST_HTTP\" xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:dp=\"http://www.datapower.com/schemas/management\">" | |
+ " <mAdminState>enabled</mAdminState>" | |
+ " <UserSummary>LocalFSH</UserSummary>" | |
+ " <LocalAddress>LOCALHOST</LocalAddress>" | |
+ " <LocalPort>8090</LocalPort>" | |
+ " <HTTPVersion>HTTP/1.1</HTTPVersion>" | |
+ " <AllowedFeatures>" | |
+ " <HTTP-1.0>on</HTTP-1.0>" | |
+ " <HTTP-1.1>on</HTTP-1.1>" | |
+ " <HTTP-2.0>off</HTTP-2.0>" | |
+ " <POST>on</POST>" | |
+ " <GET>off</GET>" | |
+ " <PUT>on</PUT>" | |
+ " <HEAD>off</HEAD>" | |
+ " <OPTIONS>off</OPTIONS>" | |
+ " <TRACE>off</TRACE>" | |
+ " <DELETE>off</DELETE>" | |
+ " <CONNECT>off</CONNECT>" | |
+ " <CustomMethods>off</CustomMethods>" | |
+ " <QueryString>on</QueryString>" | |
+ " <FragmentIdentifiers>on</FragmentIdentifiers>" | |
+ " <DotDot>off</DotDot>" | |
+ " <CmdExe>off</CmdExe>" | |
+ " </AllowedFeatures>" | |
+ " <PersistentConnections>on</PersistentConnections>" | |
+ " <MaxPersistentConnectionsReuse>0</MaxPersistentConnectionsReuse>" | |
+ " <HTTP2MaxStreams>100</HTTP2MaxStreams>" | |
+ " <HTTP2MaxFrameSize>16384</HTTP2MaxFrameSize>" | |
+ " <HTTP2StreamHeader>off</HTTP2StreamHeader>" | |
+ " </HTTPSourceProtocolHandler>" | |
+ " </configuration>" | |
+ "</datapower-configuration>"; | |
private static final String TEST = "<datapower-configuration version=\"3\">" | |
+ " <export-details>" | |
+ " <description>Exported Configuration</description>" | |
+ " <user>e084583</user>" | |
+ " <domain>DEVESB</domain>" | |
+ " <comment/>" | |
+ " </export-details>" | |
+ " <configuration domain=\"DEVESB\">" | |
+ " <HTTPSourceProtocolHandler name=\"LOCALHOST_HTTP\" xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:dp=\"http://www.datapower.com/schemas/management\">" | |
+ " <mAdminState>enabled</mAdminState>" | |
+ " <UserSummary>LocalFSH</UserSummary>" | |
+ " <LocalAddress>LOCALHOST</LocalAddress>" | |
+ " <LocalPort>8090</LocalPort>" | |
+ " <HTTPVersion>HTTP/1.1</HTTPVersion>" | |
+ " <AllowedFeatures>" | |
+ " <HTTP-1.0>on</HTTP-1.0>" | |
+ " <HTTP-1.1>on</HTTP-1.1>" | |
+ " <HTTP-2.0>off</HTTP-2.0>" | |
+ " <POST>on</POST>" | |
+ " <GET>off</GET>" | |
+ " <PUT>on</PUT>" | |
+ " <HEAD>off</HEAD>" | |
+ " <OPTIONS>off</OPTIONS>" | |
+ " <TRACE>off</TRACE>" | |
+ " <DELETE>off</DELETE>" | |
+ " <CONNECT>off</CONNECT>" | |
+ " <CustomMethods>off</CustomMethods>" | |
+ " <QueryString>on</QueryString>" | |
+ " <FragmentIdentifiers>on</FragmentIdentifiers>" | |
+ " <DotDot>off</DotDot>" | |
+ " <CmdExe>off</CmdExe>" | |
+ " </AllowedFeatures>" | |
+ " <PersistentConnections>on</PersistentConnections>" | |
+ " <MaxPersistentConnectionsReuse>0</MaxPersistentConnectionsReuse>" | |
+ " <HTTP2MaxStreams>100</HTTP2MaxStreams>" | |
+ " <HTTP2MaxFrameSize>16384</HTTP2MaxFrameSize>" | |
+ " <HTTP2StreamHeader>off</HTTP2StreamHeader>" | |
+ " <ChunkedEncoding>on</ChunkedEncoding>" | |
+ " </HTTPSourceProtocolHandler>" | |
+ " </configuration>" | |
+ "</datapower-configuration>"; | |
public static void main(String[] args) { | |
Diff diff = DiffBuilder.compare(CONTROL) | |
.withTest(TEST) | |
.checkForSimilar().ignoreComments().ignoreWhitespace() | |
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndAttributes("name"))) | |
.build(); | |
for (Difference d : diff.getDifferences()) { | |
System.err.println(d); | |
} | |
} | |
} | |
$ javac -cp ~/.m2/repository/org/xmlunit/xmlunit-core/2.6.3/xmlunit-core-2.6.3.jar X.java | |
$ java -cp ~/.m2/repository/org/xmlunit/xmlunit-core/2.6.3/xmlunit-core-2.6.3.jar:. X | |
Expected child nodelist length '11' but was '12' - comparing <HTTPSourceProtocolHandler...> at /datapower-configuration[1]/configuration[1]/HTTPSourceProtocolHandler[1] to <HTTPSourceProtocolHandler...> at /datapower-configuration[1]/configuration[1]/HTTPSourceProtocolHandler[1] (DIFFERENT) | |
Expected child 'null' but was 'ChunkedEncoding' - comparing <NULL> to <ChunkedEncoding...> at /datapower-configuration[1]/configuration[1]/HTTPSourceProtocolHandler[1]/ChunkedEncoding[1] (DIFFERENT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment