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

davsclaus pushed a commit to branch feature/CAMEL-24460-nullable-body
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c4b8192fff2e2c24afd9d3c36c7d28e1638467f1
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Sep 2 10:48:17 2026 +0200

    CAMEL-24460: Add test for null body, header value and property value via 
ProducerTemplate
    
    Drives a null body, null header value and null property value through the
    ProducerTemplate API end-to-end, verifying they are accepted and routed.
    Closes the property-value coverage gap and anchors the @Nullable contract.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../camel/impl/DefaultProducerTemplateTest.java    | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
index e8c18119298c..ebfd4ad60912 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateTest.java
@@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -257,6 +258,33 @@ public class DefaultProducerTemplateTest extends 
ContextTestSupport {
         producer.stop();
     }
 
+    @Test
+    public void testNullBodyAndValues() throws Exception {
+        // ProducerTemplate marks body, header value and property value 
parameters as @Nullable;
+        // verify null values are accepted and routed end-to-end (CAMEL-24460)
+        MockEndpoint mock = getMockEndpoint("mock:echo");
+        mock.expectedMessageCount(3);
+
+        // null body
+        template.sendBody("direct:echo", null);
+        // null body and null header value (header key must be non-null, value 
may be null)
+        template.sendBodyAndHeader("direct:echo", null, "foo", null);
+        // null body and null property value
+        template.sendBodyAndProperty("direct:echo", null, "bar", null);
+
+        assertMockEndpointsSatisfied();
+
+        // all three bodies are null
+        for (Exchange exchange : mock.getExchanges()) {
+            assertNull(exchange.getIn().getBody(), "Body should be null");
+        }
+
+        // null header value propagated
+        assertNull(mock.getExchanges().get(1).getIn().getHeader("foo"), 
"Header value should be null");
+        // null property value propagated
+        assertNull(mock.getExchanges().get(2).getProperty("bar"), "Property 
value should be null");
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
@@ -287,6 +315,8 @@ public class DefaultProducerTemplateTest extends 
ContextTestSupport {
                 }).to("mock:result");
 
                 from("direct:inout").transform(constant(123));
+
+                from("direct:echo").to("mock:echo");
             }
         };
     }

Reply via email to