This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch camel-karaf-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git
The following commit(s) were added to refs/heads/camel-karaf-4.18.x by this
push:
new 6ba3f5c48 test(#758): cover @JsonIgnoreProperties(ignoreUnknown) for
an entity in a separate bundle (#763)
6ba3f5c48 is described below
commit 6ba3f5c48c24f0dda69623e10f3e9f2f24c2785f
Author: JB Onofré <[email protected]>
AuthorDate: Tue Dec 1 10:14:47 2026 +0000
test(#758): cover @JsonIgnoreProperties(ignoreUnknown) for an entity in a
separate bundle (#763)
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.
(cherry picked from commit 1445fca130ae1f0d2208a7bb49432941fb6c377f)
---
.../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