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

gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 5b03b033dc49 CAMEL-22865: Add JSON comparison with unordered elements 
to MockValueBuilder (#20961)
5b03b033dc49 is described below

commit 5b03b033dc49b0faa5815633c12264b93219b5cd
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri Jan 23 09:48:07 2026 +0100

    CAMEL-22865: Add JSON comparison with unordered elements to 
MockValueBuilder (#20961)
    
    This commit implements a new feature for the camel-mock component that 
allows
    JSON comparison while ignoring element order in arrays and objects. This is
    particularly useful when testing Camel routes with JSON payloads where the
    order of elements can vary.
    
    Key changes:
    - Added jsonEquals(Object expected) method to MockValueBuilder that defaults
      to ignoring array element order
    - Added jsonEquals(Object expected, boolean ignoreOrder) method for more
      control over comparison behavior
    - Implemented deep JSON comparison using camel-util-json library
    - Supports various input types: String, byte[], InputStream, JsonObject,
      JsonArray
    - Handles nested JSON structures (objects and arrays)
    - Provides semantic comparison that ignores key order in objects
    - Can optionally enforce strict array element order when needed
    
    Implementation details:
    - Uses Jsoner.deserialize() from camel-util-json for JSON parsing
    - Implements recursive comparison algorithm for nested structures
    - For unordered array comparison, uses a matching algorithm that finds
      corresponding elements
    - Handles primitives, nulls, booleans, numbers, and strings correctly
    
    Testing:
    - Added comprehensive test suite with 20 test cases covering:
      * JSON objects with different key orders
      * JSON arrays with different element orders (both strict and lenient)
      * Nested JSON structures
      * Mixed type arrays
      * Edge cases (empty objects/arrays, nulls, whitespace)
      * Error cases (mismatches, different structures)
      * Different input types (String, byte[])
    
    All tests pass successfully.
---
 .../camel/component/mock/MockValueBuilder.java     | 304 +++++++++++++++++++++
 .../mock/MockValueBuilderJsonEqualsTest.java       | 273 ++++++++++++++++++
 2 files changed, 577 insertions(+)

diff --git 
a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
 
b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
index 56c4b1f4c086..9b5fe415623a 100644
--- 
a/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
+++ 
b/components/camel-mock/src/main/java/org/apache/camel/component/mock/MockValueBuilder.java
@@ -16,9 +16,16 @@
  */
 package org.apache.camel.component.mock;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Function;
 
@@ -30,6 +37,9 @@ import org.apache.camel.support.ExpressionAdapter;
 import org.apache.camel.support.ExpressionToPredicateAdapter;
 import org.apache.camel.support.builder.ExpressionBuilder;
 import org.apache.camel.support.builder.PredicateBuilder;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.camel.util.json.Jsoner;
 
 /**
  * A builder of expressions or predicates based on values.
@@ -217,6 +227,77 @@ public class MockValueBuilder implements Expression, 
Predicate {
         return onNewPredicate(PredicateBuilder.regex(expression, regex));
     }
 
+    /**
+     * Creates a predicate that compares JSON content semantically, ignoring 
element order in arrays.
+     * <p>
+     * This method is useful when testing Camel routes with JSON payloads 
where the order of elements in JSON arrays or
+     * objects can vary, making exact string comparison unreliable.
+     * </p>
+     * <p>
+     * Example usage:
+     * </p>
+     *
+     * <pre>
+     * MockEndpoint mock = getMockEndpoint("mock:result");
+     * 
mock.message(0).body().jsonEquals("{\"items\":[{\"id\":1},{\"id\":2}]}");
+     * </pre>
+     * <p>
+     * The above will match even if the actual JSON has the items in a 
different order:
+     * {@code {"items":[{"id":2},{"id":1}]}}
+     * </p>
+     *
+     * @param  expected the expected JSON value (can be String, byte[], 
InputStream, JsonObject, or JsonArray)
+     * @return          a predicate which evaluates to true if the JSON 
content matches semantically, ignoring array
+     *                  element order
+     */
+    public Predicate jsonEquals(Object expected) {
+        return jsonEquals(expected, true);
+    }
+
+    /**
+     * Creates a predicate that compares JSON content semantically.
+     * <p>
+     * This method is useful when testing Camel routes with JSON payloads 
where the order of elements in JSON arrays or
+     * objects can vary, making exact string comparison unreliable.
+     * </p>
+     * <p>
+     * Example usage:
+     * </p>
+     *
+     * <pre>
+     * MockEndpoint mock = getMockEndpoint("mock:result");
+     * // Ignore array element order
+     * 
mock.message(0).body().jsonEquals("{\"items\":[{\"id\":1},{\"id\":2}]}", true);
+     *
+     * // Strict array order comparison
+     * 
mock.message(1).body().jsonEquals("{\"items\":[{\"id\":1},{\"id\":2}]}", false);
+     * </pre>
+     *
+     * @param  expected    the expected JSON value (can be String, byte[], 
InputStream, JsonObject, or JsonArray)
+     * @param  ignoreOrder if true, ignores the order of elements in JSON 
arrays; if false, array order must match
+     * @return             a predicate which evaluates to true if the JSON 
content matches semantically
+     */
+    public Predicate jsonEquals(Object expected, boolean ignoreOrder) {
+        return onNewPredicate(new Predicate() {
+            @Override
+            public boolean matches(Exchange exchange) {
+                Object actual = expression.evaluate(exchange, Object.class);
+                try {
+                    Object expectedJson = parseJson(expected);
+                    Object actualJson = parseJson(actual);
+                    return jsonDeepEquals(expectedJson, actualJson, 
ignoreOrder);
+                } catch (Exception e) {
+                    return false;
+                }
+            }
+
+            @Override
+            public String toString() {
+                return expression + " jsonEquals(" + expected + ", 
ignoreOrder=" + ignoreOrder + ")";
+            }
+        });
+    }
+
     // Expression builders
     // 
-------------------------------------------------------------------------
 
@@ -540,4 +621,227 @@ public class MockValueBuilder implements Expression, 
Predicate {
     protected MockValueBuilder onNewValueBuilder(Expression exp) {
         return new MockValueBuilder(exp);
     }
+
+    /**
+     * Parses a JSON value from various input types.
+     *
+     * @param  value     the value to parse (String, byte[], InputStream, 
JsonObject, JsonArray, or already parsed
+     *                   object)
+     * @return           the parsed JSON object (JsonObject, JsonArray, 
String, Number, Boolean, or null)
+     * @throws Exception if parsing fails
+     */
+    private Object parseJson(Object value) throws Exception {
+        if (value == null) {
+            return null;
+        }
+
+        // Already parsed JSON objects
+        if (value instanceof JsonObject || value instanceof JsonArray) {
+            return value;
+        }
+
+        // Primitives that are valid JSON values
+        if (value instanceof String || value instanceof Number || value 
instanceof Boolean) {
+            // For strings, we need to check if it's a JSON string or a plain 
string
+            if (value instanceof String) {
+                String str = (String) value;
+                str = str.trim();
+                // Check if it looks like JSON
+                if (str.startsWith("{") || str.startsWith("[") || 
str.equals("null")
+                        || str.equals("true") || str.equals("false")
+                        || (str.startsWith("\"") && str.endsWith("\""))
+                        || str.matches("-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?")) {
+                    try (Reader reader = new StringReader(str)) {
+                        return Jsoner.deserialize(reader);
+                    }
+                }
+                // Plain string - return as is for comparison
+                return str;
+            }
+            return value;
+        }
+
+        // byte[] input
+        if (value instanceof byte[]) {
+            try (InputStream is = new ByteArrayInputStream((byte[]) value);
+                 Reader reader = new InputStreamReader(is, 
StandardCharsets.UTF_8)) {
+                return Jsoner.deserialize(reader);
+            }
+        }
+
+        // InputStream input
+        if (value instanceof InputStream) {
+            try (Reader reader = new InputStreamReader((InputStream) value, 
StandardCharsets.UTF_8)) {
+                return Jsoner.deserialize(reader);
+            }
+        }
+
+        // Try to convert to string and parse
+        String str = value.toString();
+        try (Reader reader = new StringReader(str)) {
+            return Jsoner.deserialize(reader);
+        }
+    }
+
+    /**
+     * Performs deep equality comparison of JSON values.
+     *
+     * @param  expected    the expected JSON value
+     * @param  actual      the actual JSON value
+     * @param  ignoreOrder if true, ignores the order of elements in JSON 
arrays
+     * @return             true if the JSON values are equal, false otherwise
+     */
+    private boolean jsonDeepEquals(Object expected, Object actual, boolean 
ignoreOrder) {
+        // Both null
+        if (expected == null && actual == null) {
+            return true;
+        }
+
+        // One is null
+        if (expected == null || actual == null) {
+            return false;
+        }
+
+        // Same reference
+        if (expected == actual) {
+            return true;
+        }
+
+        // JsonObject comparison
+        if (expected instanceof JsonObject && actual instanceof JsonObject) {
+            return jsonObjectEquals((JsonObject) expected, (JsonObject) 
actual, ignoreOrder);
+        }
+
+        // Map comparison (in case of deserialized maps)
+        if (expected instanceof Map && actual instanceof Map) {
+            return jsonMapEquals((Map<?, ?>) expected, (Map<?, ?>) actual, 
ignoreOrder);
+        }
+
+        // JsonArray comparison
+        if (expected instanceof JsonArray && actual instanceof JsonArray) {
+            return jsonArrayEquals((JsonArray) expected, (JsonArray) actual, 
ignoreOrder);
+        }
+
+        // List comparison (in case of deserialized lists)
+        if (expected instanceof List && actual instanceof List) {
+            return jsonListEquals((List<?>) expected, (List<?>) actual, 
ignoreOrder);
+        }
+
+        // Primitive comparison (String, Number, Boolean)
+        return expected.equals(actual);
+    }
+
+    /**
+     * Compares two JsonObjects for equality.
+     */
+    private boolean jsonObjectEquals(JsonObject expected, JsonObject actual, 
boolean ignoreOrder) {
+        if (expected.size() != actual.size()) {
+            return false;
+        }
+
+        for (Map.Entry<String, Object> entry : expected.entrySet()) {
+            String key = entry.getKey();
+            if (!actual.containsKey(key)) {
+                return false;
+            }
+            if (!jsonDeepEquals(entry.getValue(), actual.get(key), 
ignoreOrder)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Compares two Maps for equality (used for deserialized JSON objects).
+     */
+    private boolean jsonMapEquals(Map<?, ?> expected, Map<?, ?> actual, 
boolean ignoreOrder) {
+        if (expected.size() != actual.size()) {
+            return false;
+        }
+
+        for (Map.Entry<?, ?> entry : expected.entrySet()) {
+            Object key = entry.getKey();
+            if (!actual.containsKey(key)) {
+                return false;
+            }
+            if (!jsonDeepEquals(entry.getValue(), actual.get(key), 
ignoreOrder)) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Compares two JsonArrays for equality.
+     */
+    private boolean jsonArrayEquals(JsonArray expected, JsonArray actual, 
boolean ignoreOrder) {
+        if (expected.size() != actual.size()) {
+            return false;
+        }
+
+        if (ignoreOrder) {
+            // For unordered comparison, we need to find a matching element 
for each expected element
+            List<Object> actualCopy = new ArrayList<>(actual);
+            for (Object expectedElement : expected) {
+                boolean found = false;
+                for (int i = 0; i < actualCopy.size(); i++) {
+                    if (jsonDeepEquals(expectedElement, actualCopy.get(i), 
ignoreOrder)) {
+                        actualCopy.remove(i);
+                        found = true;
+                        break;
+                    }
+                }
+                if (!found) {
+                    return false;
+                }
+            }
+            return true;
+        } else {
+            // For ordered comparison, compare elements at the same index
+            for (int i = 0; i < expected.size(); i++) {
+                if (!jsonDeepEquals(expected.get(i), actual.get(i), 
ignoreOrder)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    /**
+     * Compares two Lists for equality (used for deserialized JSON arrays).
+     */
+    private boolean jsonListEquals(List<?> expected, List<?> actual, boolean 
ignoreOrder) {
+        if (expected.size() != actual.size()) {
+            return false;
+        }
+
+        if (ignoreOrder) {
+            // For unordered comparison, we need to find a matching element 
for each expected element
+            List<Object> actualCopy = new ArrayList<>(actual);
+            for (Object expectedElement : expected) {
+                boolean found = false;
+                for (int i = 0; i < actualCopy.size(); i++) {
+                    if (jsonDeepEquals(expectedElement, actualCopy.get(i), 
ignoreOrder)) {
+                        actualCopy.remove(i);
+                        found = true;
+                        break;
+                    }
+                }
+                if (!found) {
+                    return false;
+                }
+            }
+            return true;
+        } else {
+            // For ordered comparison, compare elements at the same index
+            for (int i = 0; i < expected.size(); i++) {
+                if (!jsonDeepEquals(expected.get(i), actual.get(i), 
ignoreOrder)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
 }
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/mock/MockValueBuilderJsonEqualsTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/mock/MockValueBuilderJsonEqualsTest.java
new file mode 100644
index 000000000000..b5fe26852f6f
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/mock/MockValueBuilderJsonEqualsTest.java
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.mock;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * Tests for JSON comparison functionality in MockValueBuilder.
+ */
+public class MockValueBuilderJsonEqualsTest extends ContextTestSupport {
+
+    @Test
+    public void testJsonObjectWithDifferentKeyOrder() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{\"name\":\"John\",\"age\":30}");
+
+        // Send JSON with different key order
+        template.sendBody("direct:start", "{\"age\":30,\"name\":\"John\"}");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayWithDifferentElementOrderIgnored() throws 
Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[1,2,3]", true);
+
+        // Send array with different order
+        template.sendBody("direct:start", "[3,2,1]");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayWithDifferentElementOrderStrict() throws 
Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[1,2,3]", false);
+
+        // Send array with same order
+        template.sendBody("direct:start", "[1,2,3]");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayWithDifferentElementOrderStrictFails() {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[1,2,3]", false);
+
+        // Send array with different order - should fail
+        template.sendBody("direct:start", "[3,2,1]");
+
+        assertThrows(Throwable.class, this::assertMockEndpointsSatisfied);
+    }
+
+    @Test
+    public void testNestedJsonObjectsWithDifferentOrder() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        String expected = 
"{\"person\":{\"name\":\"John\",\"age\":30},\"city\":\"NYC\"}";
+        mock.message(0).body().jsonEquals(expected);
+
+        // Send with different order at multiple levels
+        String actual = 
"{\"city\":\"NYC\",\"person\":{\"age\":30,\"name\":\"John\"}}";
+        template.sendBody("direct:start", actual);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayOfObjectsWithDifferentOrder() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        String expected = 
"[{\"id\":1,\"name\":\"A\"},{\"id\":2,\"name\":\"B\"}]";
+        mock.message(0).body().jsonEquals(expected, true);
+
+        // Send with different array order
+        String actual = 
"[{\"id\":2,\"name\":\"B\"},{\"id\":1,\"name\":\"A\"}]";
+        template.sendBody("direct:start", actual);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testComplexNestedStructure() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        String expected = 
"{\"items\":[{\"id\":1,\"tags\":[\"a\",\"b\"]},{\"id\":2,\"tags\":[\"c\",\"d\"]}],\"total\":2}";
+        mock.message(0).body().jsonEquals(expected, true);
+
+        // Send with different orders at multiple levels
+        String actual = 
"{\"total\":2,\"items\":[{\"tags\":[\"b\",\"a\"],\"id\":1},{\"tags\":[\"d\",\"c\"],\"id\":2}]}";
+        template.sendBody("direct:start", actual);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonWithNullValues() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{\"name\":\"John\",\"age\":null}");
+
+        template.sendBody("direct:start", "{\"age\":null,\"name\":\"John\"}");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonWithBooleanValues() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        
mock.message(0).body().jsonEquals("{\"active\":true,\"verified\":false}");
+
+        template.sendBody("direct:start", 
"{\"verified\":false,\"active\":true}");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonWithNumberValues() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        
mock.message(0).body().jsonEquals("{\"count\":42,\"price\":19.99,\"score\":-5}");
+
+        template.sendBody("direct:start", 
"{\"score\":-5,\"count\":42,\"price\":19.99}");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayOfPrimitives() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[\"apple\",\"banana\",\"cherry\"]", 
true);
+
+        template.sendBody("direct:start", "[\"cherry\",\"apple\",\"banana\"]");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayOfPrimitivesStrictOrder() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[\"apple\",\"banana\",\"cherry\"]", 
false);
+
+        template.sendBody("direct:start", "[\"apple\",\"banana\",\"cherry\"]");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testEmptyJsonObject() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{}");
+
+        template.sendBody("direct:start", "{}");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testEmptyJsonArray() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[]");
+
+        template.sendBody("direct:start", "[]");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonMismatchFails() {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{\"name\":\"John\"}");
+
+        template.sendBody("direct:start", "{\"name\":\"Jane\"}");
+
+        assertThrows(Throwable.class, this::assertMockEndpointsSatisfied);
+    }
+
+    @Test
+    public void testJsonDifferentStructureFails() {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{\"name\":\"John\"}");
+
+        template.sendBody("direct:start", "{\"name\":\"John\",\"age\":30}");
+
+        assertThrows(Throwable.class, this::assertMockEndpointsSatisfied);
+    }
+
+    @Test
+    public void testJsonArrayDifferentSizeFails() {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("[1,2,3]");
+
+        template.sendBody("direct:start", "[1,2]");
+
+        assertThrows(Throwable.class, this::assertMockEndpointsSatisfied);
+    }
+
+    @Test
+    public void testByteArrayInput() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{\"name\":\"John\"}");
+
+        template.sendBody("direct:start", "{\"name\":\"John\"}".getBytes());
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonWithWhitespace() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.message(0).body().jsonEquals("{\"name\":\"John\",\"age\":30}");
+
+        // Send with extra whitespace
+        template.sendBody("direct:start", "{\n  \"age\": 30,\n  \"name\": 
\"John\"\n}");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testJsonArrayWithMixedTypes() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        
mock.message(0).body().jsonEquals("[1,\"text\",true,null,{\"key\":\"value\"}]", 
true);
+
+        template.sendBody("direct:start", 
"[{\"key\":\"value\"},null,true,\"text\",1]");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:start").to("mock:result");
+            }
+        };
+    }
+}

Reply via email to