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
3 changes: 1 addition & 2 deletions components/camel-jmx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit-version}</version>
<artifactId>xmlunit-assertj3</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.assertj3.XmlAssert;
import org.xmlunit.builder.Input;
import org.xmlunit.diff.Diff;

import static org.junit.jupiter.api.Assertions.assertFalse;

public final class XmlFixture {

Expand All @@ -46,15 +43,10 @@ public static Source toSource(File aFile) {
}

public static void assertXMLIgnorePrefix(String aMessage, Source aExpected, Source aActual) throws Exception {
Diff diff = DiffBuilder.compare(aExpected).withTest(aActual)
.ignoreComments().ignoreWhitespace()
.checkForSimilar().build();
try {
assertFalse(diff.hasDifferences(), aMessage + ":\n" + diff.toString());
} catch (Exception t) {
dump(aActual);
throw t;
}
XmlAssert.assertThat(aExpected).and(aActual)
.ignoreComments()
.ignoreWhitespace()
.areSimilar();
}

public static void dump(Source aActual)
Expand Down
3 changes: 1 addition & 2 deletions components/camel-schematron/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit-version}</version>
<artifactId>xmlunit-assertj3</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
3 changes: 1 addition & 2 deletions components/camel-xj/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit-version}</version>
<artifactId>xmlunit-assertj3</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@
import com.fasterxml.jackson.core.JsonParser;
import org.apache.commons.io.IOUtils;
import org.skyscreamer.jsonassert.JSONAssert;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.assertj3.XmlAssert;
import org.xmlunit.builder.Input;
import org.xmlunit.diff.Diff;

import static org.junit.jupiter.api.Assertions.assertFalse;

final class XJTestUtils {

Expand Down Expand Up @@ -161,24 +158,19 @@ static void transformJson2XmlAndCompare(String xsl, String testName) throws Exce

final String expected = IOUtils.toString(referenceFile, StandardCharsets.UTF_8.name());
final String result = byteArrayOutputStream.toString(StandardCharsets.UTF_8.name());

final Diff diff = DiffBuilder
.compare(Input.fromString(expected))
.withTest(Input.fromString(result))
.ignoreElementContentWhitespace()
.withNodeFilter(toTest -> {
if (toTest instanceof Comment) {
final Comment comment = (Comment) toTest;
final String text = comment.getNodeValue();

return text == null || !text.contains("License");
}

return true;
})
.checkForIdentical()
.build();

assertFalse(diff.hasDifferences(), "\nExpected: " + expected + "\n\nGot: " + result + "\n\nDiff: " + diff.toString());
XmlAssert.assertThat(Input.fromString(expected))
.and(Input.fromString(result))
.ignoreElementContentWhitespace()
.withNodeFilter(toTest -> {
if (toTest instanceof Comment) {
final Comment comment = (Comment) toTest;
final String text = comment.getNodeValue();

return text == null || !text.contains("License");
}

return true;
})
.areIdentical();
}
}
3 changes: 1 addition & 2 deletions components/camel-xmlsecurity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit-version}</version>
<artifactId>xmlunit-assertj3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
import org.apache.xml.security.encryption.XMLEncryptionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import org.xmlunit.assertj3.XmlAssert;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -162,10 +161,7 @@ protected void testDecryption(String fragment, CamelContext context) throws Exce
assertFalse(hasEncryptedData(inDoc), "The XML message has encrypted data.");

// verify that the decrypted message matches what was sent
Diff xmlDiff = DiffBuilder.compare(fragment).withTest(inDoc).checkForIdentical().build();

assertFalse(xmlDiff.hasDifferences(),
"The decrypted document does not match the control document:\n" + xmlDiff.toString());
XmlAssert.assertThat(fragment).and(inDoc).areIdentical();
}

protected void testDecryption(CamelContext context) throws Exception {
Expand Down
5 changes: 5 additions & 0 deletions parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2697,6 +2697,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-assertj3</artifactId>
<version>${xmlunit-version}</version>
</dependency>

<!-- Netty bom -->
<dependency>
Expand Down