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

Croway pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 2417a18b98f CAMEL-24426: camel-gson-starter - enable 
allowUnmarshallType in unmarshal type header tests
2417a18b98f is described below

commit 2417a18b98f3317cec5d2147fbea447bceac9c75
Author: croway <[email protected]>
AuthorDate: Fri Oct 23 10:25:34 2026 +0200

    CAMEL-24426: camel-gson-starter - enable allowUnmarshallType in unmarshal 
type header tests
    
    Camel core now only honours the CamelGsonUnmarshalType header when
    allowUnmarshallType is enabled. Align the starter tests with the core
    tests and add a test that the header is ignored by default.
---
 .../springboot/GsonUnmarshalTypeFromHeaderTest.java     | 17 ++++++++++++++++-
 .../routes/SpringGsonUnmarshalTypeFromHeaderTest.xml    |  2 +-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonUnmarshalTypeFromHeaderTest.java
 
b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonUnmarshalTypeFromHeaderTest.java
index f4e61e25009..c0eeeeaefa4 100644
--- 
a/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonUnmarshalTypeFromHeaderTest.java
+++ 
b/components-starter/camel-gson-starter/src/test/java/org/apache/camel/component/gson/springboot/GsonUnmarshalTypeFromHeaderTest.java
@@ -16,14 +16,18 @@
  */
 package org.apache.camel.component.gson.springboot;
 
+import java.util.Map;
+
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.gson.GsonConstants;
+import org.apache.camel.model.dataformat.JsonDataFormat;
 import org.apache.camel.model.dataformat.JsonLibrary;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -52,6 +56,15 @@ public class GsonUnmarshalTypeFromHeaderTest {
         assertEquals("my-name", pojo.getName());
     }
 
+    @Test
+    public void testUnmarshalTypeFromHeaderIsIgnoredByDefault() {
+        String body = "{\"name\":\"my-name\"}";
+        String unmarshallType = 
"org.apache.camel.component.gson.springboot.TestPojo";
+        Object result = 
template.requestBodyAndHeader("direct:unmarshalTypeFromHeaderNotAllowed", body,
+                GsonConstants.UNMARSHAL_TYPE, unmarshallType);
+        assertInstanceOf(Map.class, result);
+    }
+
     // *************************************
     // Config
     // *************************************
@@ -64,7 +77,9 @@ public class GsonUnmarshalTypeFromHeaderTest {
             return new RouteBuilder() {
                 @Override
                 public void configure() {
-                    
from("direct:unmarshalTypeFromHeader").unmarshal().json(JsonLibrary.Gson);
+                    from("direct:unmarshalTypeFromHeader")
+                            .unmarshal(new 
JsonDataFormat(JsonLibrary.Gson).allowUnmarshallType(true));
+                    
from("direct:unmarshalTypeFromHeaderNotAllowed").unmarshal().json(JsonLibrary.Gson);
                 }
             };
         }
diff --git 
a/components-starter/camel-gson-starter/src/test/resources/routes/SpringGsonUnmarshalTypeFromHeaderTest.xml
 
b/components-starter/camel-gson-starter/src/test/resources/routes/SpringGsonUnmarshalTypeFromHeaderTest.xml
index c713a966a86..7da49cd5464 100644
--- 
a/components-starter/camel-gson-starter/src/test/resources/routes/SpringGsonUnmarshalTypeFromHeaderTest.xml
+++ 
b/components-starter/camel-gson-starter/src/test/resources/routes/SpringGsonUnmarshalTypeFromHeaderTest.xml
@@ -25,7 +25,7 @@
                 
<constant>org.apache.camel.component.gson.springboot.TestPojo</constant>
             </setHeader>
             <unmarshal>
-                <json library="Gson" />
+                <json library="Gson" allowUnmarshallType="true"/>
             </unmarshal>
         </route>
 

Reply via email to