You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/10/20 13:13:23 UTC

[camel] branch j21-xml created (now 2c38cacff82)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch j21-xml
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 2c38cacff82 CAMEL-20008 - Improve assertion to compare xml (java 21 fix)

This branch includes the following new commits:

     new 2c38cacff82 CAMEL-20008 - Improve assertion to compare xml (java 21 fix)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/01: CAMEL-20008 - Improve assertion to compare xml (java 21 fix)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch j21-xml
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 2c38cacff825cf78c178ca02b120f77445e30f49
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Oct 20 15:12:58 2023 +0200

    CAMEL-20008 - Improve assertion to compare xml (java 21 fix)
---
 .../XMLTokenExpressionIteratorGroupingTest.java    |   8 +-
 .../XMLTokenizeExpressionIteratorWModeTest.java    |   8 +-
 .../XMLTokenizeLanguageGroupingTest.java           |  76 ++++++++-------
 .../XMLTokenizeLanguageStreamingFileTest.java      |  24 ++++-
 .../xtokenizer/XMLTokenizeLanguageTest.java        |  65 +++++++------
 .../XMLTokenizeWrapLanguageGroupingTest.java       |  97 ++++++++++---------
 .../xtokenizer/XMLTokenizeWrapLanguageTest.java    | 104 +++++++++++----------
 7 files changed, 221 insertions(+), 161 deletions(-)

diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenExpressionIteratorGroupingTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenExpressionIteratorGroupingTest.java
index 3394a77d181..47fc659ecb7 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenExpressionIteratorGroupingTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenExpressionIteratorGroupingTest.java
@@ -28,6 +28,7 @@ import java.util.Map;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
@@ -430,7 +431,12 @@ public class XMLTokenExpressionIteratorGroupingTest {
 
         assertEquals(expected.length, results.size(), "token count");
         for (int i = 0; i < expected.length; i++) {
-            assertEquals(expected[i], results.get(i), "mismatch [" + i + "]");
+            String expectedToken = expected[i];
+            if (expectedToken.startsWith("<")) {
+                XmlAssert.assertThat(results.get(i)).and(expectedToken).areIdentical();
+            } else {
+                assertEquals(expectedToken, results.get(i), "mismatch [" + i + "]");
+            }
         }
     }
 }
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeExpressionIteratorWModeTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeExpressionIteratorWModeTest.java
index 2722e690290..7b330c0b829 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeExpressionIteratorWModeTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeExpressionIteratorWModeTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
@@ -143,7 +144,12 @@ public class XMLTokenizeExpressionIteratorWModeTest {
 
         assertEquals(expected.length, results.size(), "token count");
         for (int i = 0; i < expected.length; i++) {
-            assertEquals(expected[i], results.get(i), "mismatch [" + i + "]");
+            String expectedToken = expected[i];
+            if (expectedToken.startsWith("<")) {
+                XmlAssert.assertThat(results.get(i)).and(expectedToken).areIdentical();
+            } else {
+                assertEquals(expectedToken, results.get(i), "mismatch [" + i + "]");
+            }
         }
     }
 
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageGroupingTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageGroupingTest.java
index ee7bfcd0b07..6fd4822be08 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageGroupingTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageGroupingTest.java
@@ -21,119 +21,125 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
 
 public class XMLTokenizeLanguageGroupingTest extends CamelTestSupport {
 
     @Test
     public void testSendClosedTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived("<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\"></c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\"></c:child></group>");
+        String expected = "<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\"></c:child>"
+                          + "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\"></c:child></group>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendClosedTagWithLineBreaksMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived("<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\">\n</c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\">\n</c:child></group>");
+        String expected = "<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\">\n</c:child>"
+                          + "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\">\n</c:child></group>";
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?>\n" + "<c:parent xmlns:c='urn:c'>\n"
                                           + "<c:child some_attr='a' anotherAttr='a'>\n" + "</c:child>\n"
                                           + "<c:child some_attr='b' anotherAttr='b'>\n" + "</c:child>\n" + "</c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendSelfClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived("<group><c:child some_attr='a' anotherAttr='a'  xmlns:c=\"urn:c\"/>"
-                                        + "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/></group>");
+        String expected = "<group><c:child some_attr='a' anotherAttr='a'  xmlns:c=\"urn:c\"/>"
+                          + "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/></group>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' /><c:child some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived("<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\">ha</c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/></group>",
-                        "<group><c:child some_attr='c' xmlns:c=\"urn:c\"></c:child></group>");
+        String[] expected = new String[] {
+                "<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\">ha</c:child>"
+                                           + "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/></group>",
+                "<group><c:child some_attr='c' xmlns:c=\"urn:c\"></c:child></group>" };
 
         template.sendBody(
                 "direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child>"
                                 + "<c:child some_attr='b' anotherAttr='b' /><c:child some_attr='c'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagInsideMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<group><c:child name='child1' xmlns:c=\"urn:c\"><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
-                                        + "<c:child name='child2' xmlns:c=\"urn:c\"><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></group>");
+        String expected
+                = "<group><c:child name='child1' xmlns:c=\"urn:c\"><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
+                  + "<c:child name='child2' xmlns:c=\"urn:c\"><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></group>";
 
         template.sendBody(
                 "direct:start",
                 "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
                                 + "<c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedChildMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<group><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child><c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></group>");
+        String expected
+                = "<group><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child><c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></group>";
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>"
                                           + "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedParentMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<group><c:child some_attr='a' anotherAttr='a' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"></c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"/></group>");
+        String expected = "<group><c:child some_attr='a' anotherAttr='a' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"></c:child>"
+                          + "<c:child some_attr='b' anotherAttr='b' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"/></group>";
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child>"
                                           + "<c:child some_attr='b' anotherAttr='b'/></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMoreParentsMessageToTokenize() throws Exception {
-        MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedBodiesReceived(
-                "<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"></c:child>"
-                                      + "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"/></group>");
+        String expected
+                = "<group><c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"></c:child>"
+                  + "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"/></group>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
                                           + "<c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>");
 
+        verify(expected);
+    }
+
+    private void verify(String... expected) throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(expected.length);
+
         MockEndpoint.assertIsSatisfied(context);
+
+        int i = 0;
+        for (String target : expected) {
+            String body = getMockEndpoint("mock:result").getReceivedExchanges().get(i).getMessage().getBody(String.class);
+            XmlAssert.assertThat(body).and(target).areIdentical();
+            i++;
+        }
     }
 
     @Override
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java
index 1cade1f395c..7b39662d63c 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageStreamingFileTest.java
@@ -26,6 +26,7 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.camel.test.junit5.TestSupport;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
+import org.xmlunit.assertj3.XmlAssert;
 
 public class XMLTokenizeLanguageStreamingFileTest extends CamelTestSupport {
     @TempDir
@@ -33,11 +34,11 @@ public class XMLTokenizeLanguageStreamingFileTest extends CamelTestSupport {
 
     @Test
     public void testFromFile() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived("<c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\"></c:child>",
-                        "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\"></c:child>",
-                        "<c:child some_attr='c' anotherAttr='c' xmlns:c=\"urn:c\"></c:child>",
-                        "<c:child some_attr='d' anotherAttr='d' xmlns:c=\"urn:c\"></c:child>");
+        String[] expected = new String[] {
+                "<c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\"></c:child>",
+                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\"></c:child>",
+                "<c:child some_attr='c' anotherAttr='c' xmlns:c=\"urn:c\"></c:child>",
+                "<c:child some_attr='d' anotherAttr='d' xmlns:c=\"urn:c\"></c:child>" };
 
         String body
                 = "<?xml version='1.0' encoding='UTF-8'?>" + "<c:parent xmlns:c='urn:c'>"
@@ -47,7 +48,20 @@ public class XMLTokenizeLanguageStreamingFileTest extends CamelTestSupport {
 
         template.sendBodyAndHeader(TestSupport.fileUri(testDirectory), body, Exchange.FILE_NAME, "myxml.xml");
 
+        verify(expected);
+    }
+
+    private void verify(String... expected) throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(expected.length);
+
         MockEndpoint.assertIsSatisfied(context);
+
+        int i = 0;
+        for (String target : expected) {
+            String body = getMockEndpoint("mock:result").getReceivedExchanges().get(i).getMessage().getBody(String.class);
+            XmlAssert.assertThat(body).and(target).areIdentical();
+            i++;
+        }
     }
 
     @Override
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageTest.java
index e6953f83f91..09c2c601082 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeLanguageTest.java
@@ -21,117 +21,130 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
 
 public class XMLTokenizeLanguageTest extends CamelTestSupport {
 
     @Test
     public void testSendClosedTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\"></c:child>",
-                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\"></c:child>");
+                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\"></c:child>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendClosedTagWithLineBreaksMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\">\n</c:child>",
-                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\">\n</c:child>");
+                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\">\n</c:child>" };
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?>\n" + "<c:parent xmlns:c='urn:c'>\n"
                                           + "<c:child some_attr='a' anotherAttr='a'>\n" + "</c:child>\n"
                                           + "<c:child some_attr='b' anotherAttr='b'>\n" + "</c:child>\n" + "</c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendSelfClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived("<c:child some_attr='a' anotherAttr='a'  xmlns:c=\"urn:c\"/>",
-                "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/>");
+        String[] expected = new String[] {
+                "<c:child some_attr='a' anotherAttr='a'  xmlns:c=\"urn:c\"/>",
+                "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' /><c:child some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\">ha</c:child>",
                 "<c:child some_attr='b' anotherAttr='b'  xmlns:c=\"urn:c\"/>",
-                "<c:child some_attr='c' xmlns:c=\"urn:c\"></c:child>");
+                "<c:child some_attr='c' xmlns:c=\"urn:c\"></c:child>" };
 
         template.sendBody(
                 "direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child>"
                                 + "<c:child some_attr='b' anotherAttr='b' /><c:child some_attr='c'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagInsideMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<c:child name='child1' xmlns:c=\"urn:c\"><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>",
-                        "<c:child name='child2' xmlns:c=\"urn:c\"><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child>");
+        String[] expected = new String[] {
+                "<c:child name='child1' xmlns:c=\"urn:c\"><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>",
+                "<c:child name='child2' xmlns:c=\"urn:c\"><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child>" };
 
         template.sendBody(
                 "direct:start",
                 "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
                                 + "<c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedChildMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>",
-                "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' />");
+                "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' />" };
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>"
                                           + "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedParentMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<c:child some_attr='a' anotherAttr='a' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"></c:child>",
-                "<c:child some_attr='b' anotherAttr='b' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"/>");
+                "<c:child some_attr='b' anotherAttr='b' xmlns:d=\"urn:d\" xmlns:c=\"urn:c\"/>" };
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child>"
                                           + "<c:child some_attr='b' anotherAttr='b'/></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMoreParentsMessageToTokenize() throws Exception {
-        MockEndpoint result = getMockEndpoint("mock:result");
-        result.expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<c:child some_attr='a' anotherAttr='a' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"></c:child>",
-                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"/>");
+                "<c:child some_attr='b' anotherAttr='b' xmlns:c=\"urn:c\" xmlns:d=\"urn:d\" xmlns:g=\"urn:g\"/>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
                                           + "<c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>");
 
+        verify(expected);
+    }
+
+    private void verify(String... expected) throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(expected.length);
+
         MockEndpoint.assertIsSatisfied(context);
+
+        int i = 0;
+        for (String target : expected) {
+            String body = getMockEndpoint("mock:result").getReceivedExchanges().get(i).getMessage().getBody(String.class);
+            XmlAssert.assertThat(body).and(target).areIdentical();
+            i++;
+        }
     }
 
     @Override
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageGroupingTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageGroupingTest.java
index 1d8f6ff4c8c..d56f9b2abde 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageGroupingTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageGroupingTest.java
@@ -21,139 +21,148 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
 
 public class XMLTokenizeWrapLanguageGroupingTest extends CamelTestSupport {
 
     @Test
     public void testSendClosedTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
-                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child>"
-                                                              + "<c:child some_attr='b' anotherAttr='b'></c:child></c:parent>");
+        String expected
+                = "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child>"
+                  + "<c:child some_attr='b' anotherAttr='b'></c:child></c:parent>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendClosedTagWithLineBreaksMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?>\n<c:parent xmlns:c='urn:c'>\n<c:child some_attr='a' anotherAttr='a'>\n</c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b'>\n</c:child></c:parent>");
+        String expected
+                = "<?xml version='1.0' encoding='UTF-8'?>\n<c:parent xmlns:c='urn:c'>\n<c:child some_attr='a' anotherAttr='a'>\n</c:child>"
+                  + "<c:child some_attr='b' anotherAttr='b'>\n</c:child></c:parent>";
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?>\n" + "<c:parent xmlns:c='urn:c'>\n"
                                           + "<c:child some_attr='a' anotherAttr='a'>\n" + "</c:child>\n"
                                           + "<c:child some_attr='b' anotherAttr='b'>\n" + "</c:child>\n" + "</c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendSelfClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
-                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' />"
-                                                              + "<c:child some_attr='b' anotherAttr='b' /></c:parent>");
+        String expected
+                = "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' />"
+                  + "<c:child some_attr='b' anotherAttr='b' /></c:parent>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' /><c:child some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result").expectedBodiesReceived(
+        String[] expected = new String[] {
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child>"
-                                                              + "<c:child some_attr='b' anotherAttr='b' /></c:parent>",
-                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='c'></c:child></c:parent>");
+                                           + "<c:child some_attr='b' anotherAttr='b' /></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='c'></c:child></c:parent>" };
 
         template.sendBody(
                 "direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child>"
                                 + "<c:child some_attr='b' anotherAttr='b' /><c:child some_attr='c'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagInsideMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
-                                        + "<c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>");
+        String expected
+                = "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
+                  + "<c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>";
 
         template.sendBody(
                 "direct:start",
                 "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
                                 + "<c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedChildMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>"
-                                        + "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>");
+        String expected
+                = "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>"
+                  + "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>";
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>"
                                           + "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedParentMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b'/></c:parent>");
+        String expected
+                = "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child>"
+                  + "<c:child some_attr='b' anotherAttr='b'/></c:parent>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'/></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMoreParentsMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                        + "<c:child some_attr='a' anotherAttr='a'></c:child>"
-                                        + "<c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>");
+        String expected
+                = "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                  + "<c:child some_attr='a' anotherAttr='a'></c:child>"
+                  + "<c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>";
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
                                           + "<c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendParentMessagesWithDifferentAttributesToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='e' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                        + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent></g:grandparent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='f' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                                                                                                          + "<c:child some_attr='b' anotherAttr='b'/></c:parent></g:grandparent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='e' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                                           + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent></g:grandparent>",
+                "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='f' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                                                                                                                             + "<c:child some_attr='b' anotherAttr='b'/></c:parent></g:grandparent>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='e' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
                                           + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent><c:parent name='f' xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='b' anotherAttr='b'/>"
                                           + "</c:parent></g:grandparent>");
+
+        verify(expected);
+    }
+
+    private void verify(String... expected) throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(expected.length);
+
         MockEndpoint.assertIsSatisfied(context);
+
+        int i = 0;
+        for (String target : expected) {
+            String body = getMockEndpoint("mock:result").getReceivedExchanges().get(i).getMessage().getBody(String.class);
+            XmlAssert.assertThat(body).and(target).areIdentical();
+            i++;
+        }
     }
 
     @Override
diff --git a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageTest.java b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageTest.java
index 98b7a2dae2b..fa184a1a824 100644
--- a/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageTest.java
+++ b/components/camel-stax/src/test/java/org/apache/camel/language/xtokenizer/XMLTokenizeWrapLanguageTest.java
@@ -21,143 +21,149 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.support.builder.Namespaces;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
+import org.xmlunit.assertj3.XmlAssert;
 
 public class XMLTokenizeWrapLanguageTest extends CamelTestSupport {
 
     @Test
     public void testSendClosedTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='b' anotherAttr='b'></c:child></c:parent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='b' anotherAttr='b'></c:child></c:parent>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendClosedTagWithLineBreaksMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?>\n<c:parent xmlns:c='urn:c'>\n<c:child some_attr='a' anotherAttr='a'>\n</c:child></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?>\n<c:parent xmlns:c='urn:c'>\n<c:child some_attr='b' anotherAttr='b'>\n</c:child></c:parent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?>\n<c:parent xmlns:c='urn:c'>\n<c:child some_attr='a' anotherAttr='a'>\n</c:child></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?>\n<c:parent xmlns:c='urn:c'>\n<c:child some_attr='b' anotherAttr='b'>\n</c:child></c:parent>" };
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?>\n" + "<c:parent xmlns:c='urn:c'>\n"
                                           + "<c:child some_attr='a' anotherAttr='a'>\n" + "</c:child>\n"
                                           + "<c:child some_attr='b' anotherAttr='b'>\n" + "</c:child>\n" + "</c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendSelfClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' /></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='b' anotherAttr='b' /></c:parent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' /></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='b' anotherAttr='b' /></c:parent>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a' /><c:child some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='b' anotherAttr='b' /></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='c'></c:child></c:parent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='b' anotherAttr='b' /></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='c'></c:child></c:parent>" };
 
         template.sendBody(
                 "direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child some_attr='a' anotherAttr='a'>ha</c:child>"
                                 + "<c:child some_attr='b' anotherAttr='b' /><c:child some_attr='c'></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMixedClosingTagInsideMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child></c:parent>",
-                        "<c:parent xmlns:c='urn:c'><c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>");
+        String[] expected = new String[] {
+                "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child></c:parent>",
+                "<c:parent xmlns:c='urn:c'><c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>" };
 
         template.sendBody(
                 "direct:start",
                 "<c:parent xmlns:c='urn:c'><c:child name='child1'><grandchild name='grandchild1'/> <grandchild name='grandchild2'/></c:child>"
                                 + "<c:child name='child2'><grandchild name='grandchild1'></grandchild><grandchild name='grandchild2'></grandchild></c:child></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedChildMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>" };
 
         template.sendBody("direct:start",
                 "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c'><c:child xmlns:c='urn:c' some_attr='a' anotherAttr='a'></c:child>"
                                           + "<c:child xmlns:c='urn:c' some_attr='b' anotherAttr='b' /></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendNamespacedParentMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child></c:parent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='b' anotherAttr='b'/></c:parent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child></c:parent>",
+                "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='b' anotherAttr='b'/></c:parent>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'/></c:parent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendMoreParentsMessageToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                        + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent></grandparent></g:greatgrandparent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                                                                                                                             + "<c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                                           + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent></grandparent></g:greatgrandparent>",
+                "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                                                                                                                                                + "<c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><g:greatgrandparent xmlns:g='urn:g'><grandparent><uncle/><aunt>emma</aunt><c:parent xmlns:c='urn:c' xmlns:d=\"urn:d\">"
                                           + "<c:child some_attr='a' anotherAttr='a'></c:child><c:child some_attr='b' anotherAttr='b'/></c:parent></grandparent></g:greatgrandparent>");
 
-        MockEndpoint.assertIsSatisfied(context);
+        verify(expected);
     }
 
     @Test
     public void testSendParentMessagesWithDifferentAttributesToTokenize() throws Exception {
-        getMockEndpoint("mock:result")
-                .expectedBodiesReceived(
-                        "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='e' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                        + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent></g:grandparent>",
-                        "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='f' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
-                                                                                                                          + "<c:child some_attr='b' anotherAttr='b'/></c:parent></g:grandparent>");
+        String[] expected = new String[] {
+                "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='e' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                                           + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent></g:grandparent>",
+                "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='f' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
+                                                                                                                             + "<c:child some_attr='b' anotherAttr='b'/></c:parent></g:grandparent>" };
 
         template
                 .sendBody("direct:start",
                         "<?xml version='1.0' encoding='UTF-8'?><g:grandparent xmlns:g='urn:g'><c:parent name='e' xmlns:c='urn:c' xmlns:d=\"urn:d\">"
                                           + "<c:child some_attr='a' anotherAttr='a'></c:child></c:parent><c:parent name='f' xmlns:c='urn:c' xmlns:d=\"urn:d\"><c:child some_attr='b' anotherAttr='b'/>"
                                           + "</c:parent></g:grandparent>");
+
+        verify(expected);
+    }
+
+    private void verify(String... expected) throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(expected.length);
+
         MockEndpoint.assertIsSatisfied(context);
+
+        int i = 0;
+        for (String target : expected) {
+            String body = getMockEndpoint("mock:result").getReceivedExchanges().get(i).getMessage().getBody(String.class);
+            XmlAssert.assertThat(body).and(target).areIdentical();
+            i++;
+        }
     }
 
     @Override