This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c0743b60f4c2 CAMEL-24426: camel-core - JsonDataFormatReifierTest
expects allowUnmarshallType for Gson and Jsonb (#28208)
c0743b60f4c2 is described below
commit c0743b60f4c2ce122b51125e53459b7ab72a2bce
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Oct 21 10:54:19 2026 +0200
CAMEL-24426: camel-core - JsonDataFormatReifierTest expects
allowUnmarshallType for Gson and Jsonb (#28208)
* CAMEL-24426: camel-core - JsonDataFormatReifierTest expects
allowUnmarshallType for Gson and Jsonb
acc4e469d515 made the reifier pass allowUnmarshallType to Gson and Jsonb,
but
JsonDataFormatReifierTest still listed it as a Jackson-only option, so
testGsonDoesNotIncludeJacksonOnlyOptions failed on the main build. The test
now
expects the option for Gson and Jsonb, and still not for Fastjson.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
* CAMEL-24426: camel-core - JsonDataFormatReifierTest checks every library
with one helper (address review)
The Jsonb test reuses the helper with its supported options, and the option
list and
messages no longer call allowUnmarshallType a Jackson-only option.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---------
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
---
.../dataformat/JsonDataFormatReifierTest.java | 47 +++++++++-------------
1 file changed, 20 insertions(+), 27 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifierTest.java
b/core/camel-core/src/test/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifierTest.java
index a5f05c5d4786..7921270bd8a0 100644
---
a/core/camel-core/src/test/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifierTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifierTest.java
@@ -30,7 +30,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class JsonDataFormatReifierTest {
- private static final Set<String> JACKSON_ONLY_OPTIONS = Set.of(
+ // the options of the Jackson data format; another library gets only the
ones it supports
+ private static final Set<String> JACKSON_OPTIONS = Set.of(
"objectMapper", "useDefaultObjectMapper",
"autoDiscoverObjectMapper",
"include", "allowJmsType", "collectionType", "useList",
"combineUnicodeSurrogates", "moduleClassNames", "moduleRefs",
@@ -40,47 +41,39 @@ public class JsonDataFormatReifierTest {
@Test
public void testGsonDoesNotIncludeJacksonOnlyOptions() {
- assertNoJacksonOptions(JsonLibrary.Gson);
+ // Gson supports allowUnmarshallType
+ assertJacksonOptions(JsonLibrary.Gson, Set.of("allowUnmarshallType"));
}
@Test
public void testFastjsonDoesNotIncludeJacksonOnlyOptions() {
- assertNoJacksonOptions(JsonLibrary.Fastjson);
+ assertJacksonOptions(JsonLibrary.Fastjson, Set.of());
}
@Test
public void testJsonbDoesNotIncludeJacksonOnlyOptions() {
- Map<String, Object> properties = getProperties(JsonLibrary.Jsonb);
- // Jsonb supports objectMapper, so only check the rest
- Set<String> jsonbExcluded = Set.of(
- "useDefaultObjectMapper", "autoDiscoverObjectMapper",
- "include", "allowJmsType", "collectionType", "useList",
- "combineUnicodeSurrogates", "moduleClassNames", "moduleRefs",
- "enableFeatures", "disableFeatures", "allowUnmarshallType",
- "schemaResolver", "autoDiscoverSchemaResolver",
"namingStrategy",
- "timezone", "maxStringLength");
- for (String option : jsonbExcluded) {
- assertFalse(properties.containsKey(option),
- "Jsonb should not include Jackson-only option: " + option);
- }
- assertTrue(properties.containsKey("objectMapper"),
- "Jsonb should include objectMapper");
+ // Jsonb supports objectMapper and allowUnmarshallType
+ assertJacksonOptions(JsonLibrary.Jsonb, Set.of("objectMapper",
"allowUnmarshallType"));
}
@Test
public void testJacksonIncludesAllOptions() {
- Map<String, Object> properties = getProperties(JsonLibrary.Jackson);
- for (String option : JACKSON_ONLY_OPTIONS) {
- assertTrue(properties.containsKey(option),
- "Jackson should include option: " + option);
- }
+ assertJacksonOptions(JsonLibrary.Jackson, JACKSON_OPTIONS);
}
- private void assertNoJacksonOptions(JsonLibrary library) {
+ /**
+ * Asserts that the library gets the Jackson options it supports, and none
of the others.
+ */
+ private void assertJacksonOptions(JsonLibrary library, Set<String>
supported) {
Map<String, Object> properties = getProperties(library);
- for (String option : JACKSON_ONLY_OPTIONS) {
- assertFalse(properties.containsKey(option),
- library.name() + " should not include Jackson-only option:
" + option);
+ for (String option : JACKSON_OPTIONS) {
+ if (supported.contains(option)) {
+ assertTrue(properties.containsKey(option),
+ library.name() + " should include option: " + option);
+ } else {
+ assertFalse(properties.containsKey(option),
+ library.name() + " should not include option: " +
option);
+ }
}
}