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

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


The following commit(s) were added to refs/heads/main by this push:
     new 6df043350 test(#758): cover @JsonIgnoreProperties(ignoreUnknown) for 
an entity in a separate bundle (#759)
6df043350 is described below

commit 6df043350f48771235ff719ab766a603fd1ea9a0
Author: JB Onofré <[email protected]>
AuthorDate: Tue Dec 1 08:11:49 2026 +0000

    test(#758): cover @JsonIgnoreProperties(ignoreUnknown) for an entity in a 
separate bundle (#759)
    
    The camel-jackson Pax Exam test now unmarshals JSON carrying a property the 
entity does not declare, into an entity annotated with ignoreUnknown that lives 
in its own bundle. It fails if the annotation is not honoured across the bundle 
boundary.
---
 .../org/apache/karaf/camel/test/CamelJacksonRouteSupplier.java     | 3 +++
 .../test/java/org/apache/karaf/camel/itest/CamelJacksonITest.java  | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git 
a/tests/features/camel-jackson/src/main/java/org/apache/karaf/camel/test/CamelJacksonRouteSupplier.java
 
b/tests/features/camel-jackson/src/main/java/org/apache/karaf/camel/test/CamelJacksonRouteSupplier.java
index 30050eb09..afe182a73 100644
--- 
a/tests/features/camel-jackson/src/main/java/org/apache/karaf/camel/test/CamelJacksonRouteSupplier.java
+++ 
b/tests/features/camel-jackson/src/main/java/org/apache/karaf/camel/test/CamelJacksonRouteSupplier.java
@@ -25,6 +25,7 @@ import 
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRo
 import org.apache.karaf.camel.itests.CamelRouteSupplier;
 import org.osgi.service.component.annotations.Component;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonInclude;
 
 @Component(
@@ -42,6 +43,8 @@ public class CamelJacksonRouteSupplier extends 
AbstractCamelSingleFeatureResultM
         return false;
     }
 
+    // ignoreUnknown must be honoured when the entity lives in a different 
bundle than databind (#758)
+    @JsonIgnoreProperties(ignoreUnknown = true)
     @JsonInclude(JsonInclude.Include.NON_NULL)
     public static class MyData {
         private String name;
diff --git 
a/tests/features/camel-jackson/src/test/java/org/apache/karaf/camel/itest/CamelJacksonITest.java
 
b/tests/features/camel-jackson/src/test/java/org/apache/karaf/camel/itest/CamelJacksonITest.java
index 05ac97d23..1ba9a77b5 100644
--- 
a/tests/features/camel-jackson/src/test/java/org/apache/karaf/camel/itest/CamelJacksonITest.java
+++ 
b/tests/features/camel-jackson/src/test/java/org/apache/karaf/camel/itest/CamelJacksonITest.java
@@ -31,9 +31,14 @@ public class CamelJacksonITest extends 
AbstractCamelSingleFeatureResultMockBased
     private static final String JSON_SAMPLE = "{\"name\":\"%s\",\"age\":%d}"
             .formatted(CamelJacksonRouteSupplier.JSON_SAMPLE_NAME, 
CamelJacksonRouteSupplier.JSON_SAMPLE_AGE);
 
+    // carries a property MyData does not declare: only unmarshalling with 
@JsonIgnoreProperties(ignoreUnknown = true)
+    // honoured (#758) lets the route reach the mock, which then sees the JSON 
without that property
+    private static final String JSON_SAMPLE_WITH_UNKNOWN = 
"{\"name\":\"%s\",\"age\":%d,\"unknown\":\"ignored\"}"
+            .formatted(CamelJacksonRouteSupplier.JSON_SAMPLE_NAME, 
CamelJacksonRouteSupplier.JSON_SAMPLE_AGE);
+
     @Override
     public String getBodyToSend() {
-        return JSON_SAMPLE;
+        return JSON_SAMPLE_WITH_UNKNOWN;
     }
 
     @Override

Reply via email to