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

oscerd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git


The following commit(s) were added to refs/heads/main by this push:
     new c8ad976119 chore: assert the ckcMarshal route template still marshals 
(#1818)
c8ad976119 is described below

commit c8ad9761196b0e5bd32fccb77eae691322770095
Author: Andrea Cosentino <[email protected]>
AuthorDate: Mon Aug 24 18:45:49 2026 +0200

    chore: assert the ckcMarshal route template still marshals (#1818)
    
    #1796 added testUnmarshalRouteActuallyUnmarshals, which guards the 
direction of
    the ckcUnMarshal template after the fix for #1795. Nothing asserted the 
same for
    ckcMarshal, so the symmetric mistake in the other template would pass CI.
    
    Add the marshal-direction case: a SyslogMessage sent through a route built 
with
    camel.source.marshal must come back encoded rather than as a SyslogMessage.
    Confirmed the test fails when ckcMarshal is flipped to .unmarshal().
    
    Signed-off-by: Andrea Cosentino <[email protected]>
    Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
 .../camel/kafkaconnector/DataFormatTest.java       | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git 
a/core/src/test/java/org/apache/camel/kafkaconnector/DataFormatTest.java 
b/core/src/test/java/org/apache/camel/kafkaconnector/DataFormatTest.java
index 4d63a7ea38..b56813ea97 100644
--- a/core/src/test/java/org/apache/camel/kafkaconnector/DataFormatTest.java
+++ b/core/src/test/java/org/apache/camel/kafkaconnector/DataFormatTest.java
@@ -174,4 +174,34 @@ public class DataFormatTest {
         assertFalse(hl7dfLoaded.isValidate());
         cms.stop();
     }
+
+    @Test
+    public void testMarshalRouteActuallyMarshals() throws Exception {
+        // Symmetric guard for testUnmarshalRouteActuallyUnmarshals: nothing 
asserted that ckcMarshal still
+        // applies marshal, so the mistake fixed in #1795 could be 
reintroduced in the other template unnoticed.
+        Map<String, String> props = new HashMap<>();
+        props.put("camel.source.url", "direct://test");
+        props.put("topics", "mytopic");
+        props.put("camel.source.marshal", "syslog");
+
+        DefaultCamelContext dcc = new DefaultCamelContext();
+        CamelKafkaConnectMain cms = 
CamelKafkaConnectMain.builder("direct://start", "log://test")
+            .withProperties(props)
+            .withMarshallDataFormat("syslog")
+            .build(dcc);
+
+        dcc.getRegistry().bind("syslog", new SyslogDataFormat());
+
+        cms.start();
+        ProducerTemplate template = dcc.createProducerTemplate();
+        SyslogMessage message = new SyslogMessage();
+        message.setHostname("mymachine");
+        message.setLogMessage("su root failed for lonvick");
+        Object result = template.requestBody("direct://start", message);
+
+        // marshal turns the SyslogMessage into its wire form; unmarshal would 
have thrown instead
+        assertNotNull(result);
+        assertFalse(result instanceof SyslogMessage, "camel.*.marshal must 
encode, not decode: got " + result);
+        cms.stop();
+    }
 }

Reply via email to