diff --git a/components/camel-jmx/pom.xml b/components/camel-jmx/pom.xml index d2749d1ac27dc..366b5f9ad97e9 100644 --- a/components/camel-jmx/pom.xml +++ b/components/camel-jmx/pom.xml @@ -64,8 +64,7 @@ org.xmlunit - xmlunit-core - ${xmlunit-version} + xmlunit-assertj3 test diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java index 8ae7c726002dc..1e1dbd69e2099 100644 --- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java +++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/XmlFixture.java @@ -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 { @@ -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) diff --git a/components/camel-schematron/pom.xml b/components/camel-schematron/pom.xml index 6de80b6a45b46..513df4d295f69 100644 --- a/components/camel-schematron/pom.xml +++ b/components/camel-schematron/pom.xml @@ -56,8 +56,7 @@ org.xmlunit - xmlunit-core - ${xmlunit-version} + xmlunit-assertj3 test diff --git a/components/camel-xj/pom.xml b/components/camel-xj/pom.xml index 9b541ecd0dfe4..ebc2cd4ff2c3d 100644 --- a/components/camel-xj/pom.xml +++ b/components/camel-xj/pom.xml @@ -61,8 +61,7 @@ org.xmlunit - xmlunit-core - ${xmlunit-version} + xmlunit-assertj3 test diff --git a/components/camel-xj/src/test/java/org/apache/camel/component/xj/XJTestUtils.java b/components/camel-xj/src/test/java/org/apache/camel/component/xj/XJTestUtils.java index 906801b535c97..b854a087d1637 100644 --- a/components/camel-xj/src/test/java/org/apache/camel/component/xj/XJTestUtils.java +++ b/components/camel-xj/src/test/java/org/apache/camel/component/xj/XJTestUtils.java @@ -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 { @@ -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(); } } diff --git a/components/camel-xmlsecurity/pom.xml b/components/camel-xmlsecurity/pom.xml index e5127d7ae0d22..51cf448760892 100644 --- a/components/camel-xmlsecurity/pom.xml +++ b/components/camel-xmlsecurity/pom.xml @@ -96,8 +96,7 @@ org.xmlunit - xmlunit-core - ${xmlunit-version} + xmlunit-assertj3 test diff --git a/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java b/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java index 9786efdf315de..369c8036e0aa7 100644 --- a/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java +++ b/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java @@ -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; @@ -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 { diff --git a/parent/pom.xml b/parent/pom.xml index c4de9d7a06769..297f3e220e45e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -2697,6 +2697,11 @@ pom import + + org.xmlunit + xmlunit-assertj3 + ${xmlunit-version} +