You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/11/18 13:02:34 UTC

[camel] branch main updated (c434998 -> cc4c4cf)

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

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from c434998  Regen for commit 794c5b3c5c0fac7408ebe34d0deefe6ba37b6b4d (#6446)
     new d64c906  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new a7a6e55  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new 2eb1702  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new 8cc5f4e  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new e9b94b6  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new f9ccda8  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new 5c0c7ed  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new 9b546cf  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new f5685ab  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
     new cc4c4cf  CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/catalog/dataformats/json-jackson.json    |  1 +
 .../org/apache/camel/catalog/models/json.json      |  1 +
 .../apache/camel/catalog/schemas/camel-spring.xsd  |  7 ++++
 .../jackson/JacksonDataFormatConfigurer.java       |  2 +
 .../camel/component/jackson/json-jackson.json      |  1 +
 .../jackson/AbstractJacksonDataFormat.java         | 45 ++++++++++++++++++++++
 ....java => JacksonMarshalNamingStrategyTest.java} | 25 +++++-------
 ...{TestOtherPojo.java => PojoNamingStrategy.java} | 24 ++++++------
 ...ngJacksonJsonDataFormatNamingStrategyTest.java} | 21 ++++++----
 ...ingJacksonJsonDataFormatNamingStrategyTest.xml} |  9 ++---
 .../org/apache/camel/model/dataformat/json.json    |  1 +
 .../camel/model/dataformat/JsonDataFormat.java     | 21 ++++++++++
 .../reifier/dataformat/JsonDataFormatReifier.java  |  1 +
 .../java/org/apache/camel/xml/in/ModelParser.java  |  1 +
 .../dsl/yaml/deserializers/ModelDeserializers.java |  6 +++
 .../src/generated/resources/camel-yaml-dsl.json    |  3 ++
 16 files changed, 129 insertions(+), 40 deletions(-)
 copy components/camel-jackson/src/test/java/org/apache/camel/component/jackson/{JacksonMarshalDateTimezoneTest.java => JacksonMarshalNamingStrategyTest.java} (73%)
 copy components/camel-jackson/src/test/java/org/apache/camel/component/jackson/{TestOtherPojo.java => PojoNamingStrategy.java} (70%)
 copy components/camel-jackson/src/test/java/org/apache/camel/component/jackson/{SpringJacksonEnableFeatureTest.java => SpringJacksonJsonDataFormatNamingStrategyTest.java} (61%)
 copy components/{camel-jacksonxml/src/test/resources/org/apache/camel/component/jacksonxml/SpringJacksonMarshalUnmarshalListTest.xml => camel-jackson/src/test/resources/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.xml} (82%)

[camel] 09/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f5685aba0df29c045e2f774a22f646fc8c4c0e8c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 14:00:42 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../generated/resources/org/apache/camel/model/dataformat/json.json | 2 +-
 .../main/java/org/apache/camel/model/dataformat/JsonDataFormat.java | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json
index 6ec5f3e..96b0815 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json
@@ -33,7 +33,7 @@
     "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" },
     "schemaResolver": { "kind": "attribute", "displayName": "Schema Resolver", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Optional schema resolver used to lookup schemas for the data in transit." },
     "autoDiscoverSchemaResolver": { "kind": "attribute", "displayName": "Auto Discover Schema Resolver", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "When not disabled, the SchemaResolver will be looked up into the registry" },
-    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy" },
+    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy.Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
index 96290df..02a2e03 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
@@ -98,7 +98,7 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
     private String autoDiscoverSchemaResolver;
     @XmlAttribute
     @Metadata(description = "If set then Jackson will use the the defined Property Naming Strategy."
-                            + "Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE" )
+                            + "Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE")
     private String namingStrategy;
 
     public JsonDataFormat() {
@@ -441,8 +441,8 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
     }
 
     /**
-     * If set then Jackson will use the the defined Property Naming Strategy.
-     * Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE
+     * If set then Jackson will use the the defined Property Naming Strategy. Possible values are: LOWER_CAMEL_CASE,
+     * LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE
      */
     public void setNamingStrategy(String namingStrategy) {
         this.namingStrategy = namingStrategy;

[camel] 06/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f9ccda8afc2128b2a4b636c45d359e874aba4e13
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 13:49:03 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../jackson/JacksonDataFormatConfigurer.java       |  2 +-
 .../jackson/AbstractJacksonDataFormat.java         | 39 +++++++++++++++++--
 .../jackson/JacksonMarshalNamingStrategyTest.java  |  3 +-
 ...ngJacksonJsonDataFormatNamingStrategyTest.java} | 21 ++++-------
 ...ringJacksonJsonDataFormatNamingStrategyTest.xml | 44 ++++++++++++++++++++++
 .../reifier/dataformat/JsonDataFormatReifier.java  |  1 +
 6 files changed, 89 insertions(+), 21 deletions(-)

diff --git a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
index 7c60bd1..55ad712 100644
--- a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
+++ b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
@@ -55,7 +55,7 @@ public class JacksonDataFormatConfigurer extends PropertyConfigurerSupport imple
         case "autodiscoverschemaresolver":
         case "autoDiscoverSchemaResolver": dataformat.setAutoDiscoverSchemaResolver(property(camelContext, boolean.class, value)); return true;
         case "namingstrategy":
-        case "namingStrategy": dataformat.setNamingStrategy(property(camelContext, com.fasterxml.jackson.databind.PropertyNamingStrategy.class, value)); return true;
+        case "namingStrategy": dataformat.setNamingStrategy(property(camelContext, java.lang.String.class, value)); return true;
         default: return false;
         }
     }
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
index aa04e68..67f838d6 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
@@ -33,6 +33,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.MapperFeature;
 import com.fasterxml.jackson.databind.Module;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.PropertyNamingStrategies;
 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.type.CollectionType;
@@ -81,7 +82,7 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
     private boolean autoDiscoverObjectMapper;
     private SchemaResolver schemaResolver;
     private boolean autoDiscoverSchemaResolver = true;
-    private PropertyNamingStrategy namingStrategy;
+    private String namingStrategy;
 
     /**
      * Use the default Jackson {@link ObjectMapper} and {@link Object}
@@ -287,11 +288,11 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
         return modules;
     }
 
-    public PropertyNamingStrategy getNamingStrategy() {
+    public String getNamingStrategy() {
         return namingStrategy;
     }
 
-    public void setNamingStrategy(PropertyNamingStrategy namingStrategy) {
+    public void setNamingStrategy(String namingStrategy) {
         this.namingStrategy = namingStrategy;
     }
 
@@ -659,7 +660,10 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
             }
 
             if (org.apache.camel.util.ObjectHelper.isNotEmpty(namingStrategy)) {
-                objectMapper.setPropertyNamingStrategy(namingStrategy);
+                PropertyNamingStrategy selectedNamingStrategy = determineNamingStrategy(namingStrategy);
+                if (org.apache.camel.util.ObjectHelper.isNotEmpty(selectedNamingStrategy)) {
+                    objectMapper.setPropertyNamingStrategy(selectedNamingStrategy);
+                }
             }
         } else {
             LOG.debug("The objectMapper was already found in the registry, no customizations will be applied");
@@ -682,6 +686,33 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
         }
     }
 
+    private PropertyNamingStrategy determineNamingStrategy(String namingStrategy) {
+        PropertyNamingStrategy strategy = null;
+        switch (namingStrategy) {
+            case "LOWER_CAMEL_CASE":
+                strategy = PropertyNamingStrategies.LOWER_CAMEL_CASE;
+                break;
+            case "LOWER_DOT_CASE":
+                strategy = PropertyNamingStrategies.LOWER_DOT_CASE;
+                break;
+            case "LOWER_CASE":
+                strategy = PropertyNamingStrategies.LOWER_CASE;
+                break;
+            case "KEBAB_CASE":
+                strategy = PropertyNamingStrategies.KEBAB_CASE;
+                break;
+            case "SNAKE_CASE":
+                strategy = PropertyNamingStrategies.SNAKE_CASE;
+                break;
+            case "UPPER_CAMEL_CASE":
+                strategy = PropertyNamingStrategies.UPPER_CAMEL_CASE;
+                break;
+            default:
+                break;
+        }
+        return strategy;
+    }
+
     @Override
     protected void doStop() throws Exception {
         // noop
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
index 612a2f1..4437e6a 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.jackson;
 
-import com.fasterxml.jackson.databind.PropertyNamingStrategies;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
@@ -48,7 +47,7 @@ public class JacksonMarshalNamingStrategyTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 JacksonDataFormat format = new JacksonDataFormat();
-                format.setNamingStrategy(PropertyNamingStrategies.LOWER_DOT_CASE);
+                format.setNamingStrategy("LOWER_DOT_CASE");
                 from("direct:in").marshal(format).to("mock:result");
             }
         };
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.java
similarity index 71%
copy from components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
copy to components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.java
index 612a2f1..665140d 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.java
@@ -16,15 +16,15 @@
  */
 package org.apache.camel.component.jackson;
 
-import com.fasterxml.jackson.databind.PropertyNamingStrategies;
-import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
 import org.junit.jupiter.api.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-public class JacksonMarshalNamingStrategyTest extends CamelTestSupport {
+public class SpringJacksonJsonDataFormatNamingStrategyTest extends CamelSpringTestSupport {
 
     @Test
     public void testMarshalAndUnmarshalMap() throws Exception {
@@ -42,16 +42,9 @@ public class JacksonMarshalNamingStrategyTest extends CamelTestSupport {
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-
-            @Override
-            public void configure() throws Exception {
-                JacksonDataFormat format = new JacksonDataFormat();
-                format.setNamingStrategy(PropertyNamingStrategies.LOWER_DOT_CASE);
-                from("direct:in").marshal(format).to("mock:result");
-            }
-        };
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+                "org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.xml");
     }
 
 }
diff --git a/components/camel-jackson/src/test/resources/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.xml b/components/camel-jackson/src/test/resources/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.xml
new file mode 100644
index 0000000..0ce8cea
--- /dev/null
+++ b/components/camel-jackson/src/test/resources/org/apache/camel/component/jackson/SpringJacksonJsonDataFormatNamingStrategyTest.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+
+        <!-- we define the json jackson data formats to be used -->
+        <dataFormats>
+            <json id="jack" library="Jackson" namingStrategy="LOWER_DOT_CASE"/>
+        </dataFormats>
+
+        <route>
+            <from uri="direct:in"/>
+            <marshal><custom ref="jack"/></marshal>
+            <to uri="mock:result"/>
+        </route>
+
+    </camelContext>
+    <!-- END SNIPPET: e1 -->
+
+</beans>
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifier.java
index 383037d..848c49e 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JsonDataFormatReifier.java
@@ -75,6 +75,7 @@ public class JsonDataFormatReifier extends DataFormatReifier<JsonDataFormat> {
         if (definition.getLibrary() == JsonLibrary.Jackson) {
             properties.put("schemaResolver", asRef(definition.getSchemaResolver()));
             properties.put("autoDiscoverSchemaResolver", definition.getAutoDiscoverSchemaResolver());
+            properties.put("namingStrategy", definition.getNamingStrategy());
         }
     }
 

[camel] 03/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2eb170222c43a43525c70e9a03428ea5ff52ed24
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 11:53:46 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java | 2 +-
 .../org/apache/camel/component/jackson/AbstractJacksonDataFormat.java   | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
index 42ea935..bc227a6 100644
--- a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
+++ b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
@@ -51,7 +51,7 @@ public class JacksonDataFormatConfigurer extends PropertyConfigurerSupport imple
         case "autodiscoverobjectmapper":
         case "autoDiscoverObjectMapper": dataformat.setAutoDiscoverObjectMapper(property(camelContext, boolean.class, value)); return true;
         case "schemaresolver":
-        case "schemaResolver": dataformat.setSchemaResolver(property(camelContext, com.fasterxml.jackson.databind.SchemaResolver.class, value)); return true;
+        case "schemaResolver": dataformat.setSchemaResolver(property(camelContext, org.apache.camel.component.jackson.SchemaResolver.class, value)); return true;
         case "autodiscoverschemaresolver":
         case "autoDiscoverSchemaResolver": dataformat.setAutoDiscoverSchemaResolver(property(camelContext, boolean.class, value)); return true;
         default: return false;
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
index 3a8cb16..aa04e68 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
@@ -32,7 +32,6 @@ import com.fasterxml.jackson.core.FormatSchema;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.MapperFeature;
 import com.fasterxml.jackson.databind.Module;
-import com.fasterxml.jackson.databind.Module;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
 import com.fasterxml.jackson.databind.SerializationFeature;

[camel] 05/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e9b94b6c205dba65b860969d0eefd40581e54247
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 12:41:48 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../org/apache/camel/catalog/dataformats/json-jackson.json         | 1 +
 .../generated/resources/org/apache/camel/catalog/models/json.json  | 1 +
 .../resources/org/apache/camel/catalog/schemas/camel-spring.xsd    | 7 +++++++
 .../camel/component/jackson/JacksonDataFormatConfigurer.java       | 2 ++
 .../resources/org/apache/camel/component/jackson/json-jackson.json | 1 +
 .../resources/org/apache/camel/model/dataformat/json.json          | 1 +
 .../src/generated/java/org/apache/camel/xml/in/ModelParser.java    | 1 +
 .../apache/camel/dsl/yaml/deserializers/ModelDeserializers.java    | 6 ++++++
 .../camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json     | 3 +++
 9 files changed, 23 insertions(+)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/json-jackson.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/json-jackson.json
index 0487fb3..45e9875 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/json-jackson.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/json-jackson.json
@@ -35,6 +35,7 @@
     "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" },
     "schemaResolver": { "kind": "attribute", "displayName": "Schema Resolver", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Optional schema resolver used to lookup schemas for the data in transit." },
     "autoDiscoverSchemaResolver": { "kind": "attribute", "displayName": "Auto Discover Schema Resolver", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "When not disabled, the SchemaResolver will be looked up into the registry" },
+    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/json.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/json.json
index 9f90440..6ec5f3e 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/json.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/json.json
@@ -33,6 +33,7 @@
     "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" },
     "schemaResolver": { "kind": "attribute", "displayName": "Schema Resolver", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Optional schema resolver used to lookup schemas for the data in transit." },
     "autoDiscoverSchemaResolver": { "kind": "attribute", "displayName": "Auto Discover Schema Resolver", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "When not disabled, the SchemaResolver will be looked up into the registry" },
+    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 4138063..71478e9 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -7611,6 +7611,13 @@ Default value: true
             ]]></xs:documentation>
           </xs:annotation>
         </xs:attribute>
+        <xs:attribute name="namingStrategy" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en"><![CDATA[
+If set then Jackson will use the the defined Property Naming Strategy.
+            ]]></xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
       </xs:extension>
     </xs:complexContent>
   </xs:complexType>
diff --git a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
index bc227a6..7c60bd1 100644
--- a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
+++ b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
@@ -54,6 +54,8 @@ public class JacksonDataFormatConfigurer extends PropertyConfigurerSupport imple
         case "schemaResolver": dataformat.setSchemaResolver(property(camelContext, org.apache.camel.component.jackson.SchemaResolver.class, value)); return true;
         case "autodiscoverschemaresolver":
         case "autoDiscoverSchemaResolver": dataformat.setAutoDiscoverSchemaResolver(property(camelContext, boolean.class, value)); return true;
+        case "namingstrategy":
+        case "namingStrategy": dataformat.setNamingStrategy(property(camelContext, com.fasterxml.jackson.databind.PropertyNamingStrategy.class, value)); return true;
         default: return false;
         }
     }
diff --git a/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json b/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json
index 0487fb3..45e9875 100644
--- a/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json
+++ b/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json
@@ -35,6 +35,7 @@
     "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" },
     "schemaResolver": { "kind": "attribute", "displayName": "Schema Resolver", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Optional schema resolver used to lookup schemas for the data in transit." },
     "autoDiscoverSchemaResolver": { "kind": "attribute", "displayName": "Auto Discover Schema Resolver", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "When not disabled, the SchemaResolver will be looked up into the registry" },
+    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json
index 9f90440..6ec5f3e 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/dataformat/json.json
@@ -33,6 +33,7 @@
     "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" },
     "schemaResolver": { "kind": "attribute", "displayName": "Schema Resolver", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Optional schema resolver used to lookup schemas for the data in transit." },
     "autoDiscoverSchemaResolver": { "kind": "attribute", "displayName": "Auto Discover Schema Resolver", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "When not disabled, the SchemaResolver will be looked up into the registry" },
+    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 25e848a..8be755e 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -2162,6 +2162,7 @@ public class ModelParser extends BaseParser {
                 case "library": def.setLibrary(JsonLibrary.valueOf(val)); break;
                 case "moduleClassNames": def.setModuleClassNames(val); break;
                 case "moduleRefs": def.setModuleRefs(val); break;
+                case "namingStrategy": def.setNamingStrategy(val); break;
                 case "objectMapper": def.setObjectMapper(val); break;
                 case "permissions": def.setPermissions(val); break;
                 case "prettyPrint": def.setPrettyPrint(val); break;
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index 7a5d329..095eb74 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -7285,6 +7285,7 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
                     @YamlProperty(name = "library", type = "enum:Fastjson,Gson,Jackson,Johnzon,Jsonb,XStream"),
                     @YamlProperty(name = "module-class-names", type = "string"),
                     @YamlProperty(name = "module-refs", type = "string"),
+                    @YamlProperty(name = "naming-strategy", type = "string"),
                     @YamlProperty(name = "object-mapper", type = "string"),
                     @YamlProperty(name = "permissions", type = "string"),
                     @YamlProperty(name = "pretty-print", type = "boolean"),
@@ -7383,6 +7384,11 @@ public final class ModelDeserializers extends YamlDeserializerSupport {
                     target.setModuleRefs(val);
                     break;
                 }
+                case "naming-strategy": {
+                    String val = asText(node);
+                    target.setNamingStrategy(val);
+                    break;
+                }
                 case "object-mapper": {
                     String val = asText(node);
                     target.setObjectMapper(val);
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
index 47f34cf..b6b98fc 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/camel-yaml-dsl.json
@@ -4678,6 +4678,9 @@
           "module-refs" : {
             "type" : "string"
           },
+          "naming-strategy" : {
+            "type" : "string"
+          },
           "object-mapper" : {
             "type" : "string"
           },

[camel] 01/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d64c90615ffec0bddd1c002e3325825537df4eb0
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 11:51:30 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../jackson/AbstractJacksonDataFormat.java         | 18 +++++--
 .../jackson/JacksonMarshalNamingStrategyTest.java  | 60 ++++++++++++++++++++++
 .../component/jackson/PojoNamingStrategy.java      | 24 +++++++++
 3 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
index d5c62ce..7b83b0d 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
@@ -29,11 +29,8 @@ import java.util.TimeZone;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.FormatSchema;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.*;
 import com.fasterxml.jackson.databind.Module;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.type.CollectionType;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
@@ -80,6 +77,7 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
     private boolean autoDiscoverObjectMapper;
     private SchemaResolver schemaResolver;
     private boolean autoDiscoverSchemaResolver = true;
+    private PropertyNamingStrategy namingStrategy;
 
     /**
      * Use the default Jackson {@link ObjectMapper} and {@link Object}
@@ -285,6 +283,14 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
         return modules;
     }
 
+    public PropertyNamingStrategy getNamingStrategy() {
+        return namingStrategy;
+    }
+
+    public void setNamingStrategy(PropertyNamingStrategy namingStrategy) {
+        this.namingStrategy = namingStrategy;
+    }
+
     /**
      * To use custom Jackson {@link Module}s
      */
@@ -647,6 +653,10 @@ public abstract class AbstractJacksonDataFormat extends ServiceSupport
                 LOG.debug("Setting timezone to Object Mapper: {}", timezone);
                 objectMapper.setTimeZone(timezone);
             }
+
+            if (org.apache.camel.util.ObjectHelper.isNotEmpty(namingStrategy)) {
+                objectMapper.setPropertyNamingStrategy(namingStrategy);
+            }
         } else {
             LOG.debug("The objectMapper was already found in the registry, no customizations will be applied");
         }
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
new file mode 100644
index 0000000..c6de91e
--- /dev/null
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jackson;
+
+import com.fasterxml.jackson.databind.PropertyNamingStrategies;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class JacksonMarshalNamingStrategyTest extends CamelTestSupport {
+
+    @Test
+    public void testMarshalAndUnmarshalMap() throws Exception {
+        PojoNamingStrategy pojoNamingStrategy = new PojoNamingStrategy();
+        pojoNamingStrategy.setFieldOne("test");
+        pojoNamingStrategy.setFieldTwo("supertest");
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        Object marshalled = template.requestBody("direct:in", pojoNamingStrategy);
+        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
+        assertEquals("{\"field.one\":\"test\",\"field.two\":\"supertest\"}", marshalledAsString);
+
+        mock.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+
+            @Override
+            public void configure() throws Exception {
+                JacksonDataFormat format = new JacksonDataFormat();
+                format.setNamingStrategy(PropertyNamingStrategies.LOWER_DOT_CASE);
+                from("direct:in").marshal(format).to("mock:result");
+            }
+        };
+    }
+
+}
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
new file mode 100644
index 0000000..b7bd28f
--- /dev/null
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
@@ -0,0 +1,24 @@
+package org.apache.camel.component.jackson;
+
+public class PojoNamingStrategy {
+
+        private String fieldOne;
+
+        private String fieldTwo;
+
+        public String getFieldOne() {
+            return fieldOne;
+        }
+
+        public void setFieldOne(String fieldOne) {
+            this.fieldOne = fieldOne;
+        }
+
+        public String getFieldTwo() {
+            return fieldTwo;
+        }
+
+        public void setFieldTwo(String kFieldTwo) {
+            this.fieldTwo = kFieldTwo;
+        }
+}

[camel] 10/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cc4c4cf1f894241641ee86026e34e5aa64946df2
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 14:01:33 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../resources/org/apache/camel/component/jackson/json-jackson.json      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json b/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json
index 45e9875..348b941 100644
--- a/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json
+++ b/components/camel-jackson/src/generated/resources/org/apache/camel/component/jackson/json-jackson.json
@@ -35,7 +35,7 @@
     "contentTypeHeader": { "kind": "attribute", "displayName": "Content Type Header", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether the data format should set the Content-Type header with the type from the data format. For example application\/xml for data formats marshalling to XML, or application\/json for data formats marshalling to JSON" },
     "schemaResolver": { "kind": "attribute", "displayName": "Schema Resolver", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Optional schema resolver used to lookup schemas for the data in transit." },
     "autoDiscoverSchemaResolver": { "kind": "attribute", "displayName": "Auto Discover Schema Resolver", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "When not disabled, the SchemaResolver will be looked up into the registry" },
-    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy" },
+    "namingStrategy": { "kind": "attribute", "displayName": "Naming Strategy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the the defined Property Naming Strategy.Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
   }
 }

[camel] 02/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a7a6e55173d669d26bac04a6f3003d7b57e18064
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 11:53:04 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../jackson/JacksonDataFormatConfigurer.java       |  2 +-
 .../jackson/AbstractJacksonDataFormat.java         |  7 +++++-
 .../jackson/JacksonMarshalNamingStrategyTest.java  |  3 ---
 .../component/jackson/PojoNamingStrategy.java      | 28 +++++++++++-----------
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
index bc227a6..42ea935 100644
--- a/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
+++ b/components/camel-jackson/src/generated/java/org/apache/camel/component/jackson/JacksonDataFormatConfigurer.java
@@ -51,7 +51,7 @@ public class JacksonDataFormatConfigurer extends PropertyConfigurerSupport imple
         case "autodiscoverobjectmapper":
         case "autoDiscoverObjectMapper": dataformat.setAutoDiscoverObjectMapper(property(camelContext, boolean.class, value)); return true;
         case "schemaresolver":
-        case "schemaResolver": dataformat.setSchemaResolver(property(camelContext, org.apache.camel.component.jackson.SchemaResolver.class, value)); return true;
+        case "schemaResolver": dataformat.setSchemaResolver(property(camelContext, com.fasterxml.jackson.databind.SchemaResolver.class, value)); return true;
         case "autodiscoverschemaresolver":
         case "autoDiscoverSchemaResolver": dataformat.setAutoDiscoverSchemaResolver(property(camelContext, boolean.class, value)); return true;
         default: return false;
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
index 7b83b0d..3a8cb16 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/AbstractJacksonDataFormat.java
@@ -29,8 +29,13 @@ import java.util.TimeZone;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.FormatSchema;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
 import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.type.CollectionType;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
index c6de91e..612a2f1 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/JacksonMarshalNamingStrategyTest.java
@@ -22,9 +22,6 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class JacksonMarshalNamingStrategyTest extends CamelTestSupport {
diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
index b7bd28f..0eb2416 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
@@ -2,23 +2,23 @@ package org.apache.camel.component.jackson;
 
 public class PojoNamingStrategy {
 
-        private String fieldOne;
+    private String fieldOne;
 
-        private String fieldTwo;
+    private String fieldTwo;
 
-        public String getFieldOne() {
-            return fieldOne;
-        }
+    public String getFieldOne() {
+        return fieldOne;
+    }
 
-        public void setFieldOne(String fieldOne) {
-            this.fieldOne = fieldOne;
-        }
+    public void setFieldOne(String fieldOne) {
+        this.fieldOne = fieldOne;
+    }
 
-        public String getFieldTwo() {
-            return fieldTwo;
-        }
+    public String getFieldTwo() {
+        return fieldTwo;
+    }
 
-        public void setFieldTwo(String kFieldTwo) {
-            this.fieldTwo = kFieldTwo;
-        }
+    public void setFieldTwo(String kFieldTwo) {
+        this.fieldTwo = kFieldTwo;
+    }
 }

[camel] 04/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8cc5f4ed835edcc103462681fb47e9174258357e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 12:01:13 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../apache/camel/model/dataformat/JsonDataFormat.java  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
index 052062b..1ab4d95 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
@@ -96,6 +96,8 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
     @XmlAttribute
     @Metadata(javaType = "java.lang.Boolean", defaultValue = "true")
     private String autoDiscoverSchemaResolver;
+    @XmlAttribute
+    private String namingStrategy;
 
     public JsonDataFormat() {
         super("json");
@@ -432,6 +434,17 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
         this.autoDiscoverSchemaResolver = autoDiscoverSchemaResolver;
     }
 
+    public String getNamingStrategy() {
+        return namingStrategy;
+    }
+
+    /**
+     * If set then Jackson will use the the defined Property Naming Strategy
+     */
+    public void setNamingStrategy(String namingStrategy) {
+        this.namingStrategy = namingStrategy;
+    }
+
     //
     // Fluent builders
     //
@@ -569,4 +582,9 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
         return this;
     }
 
+    public JsonDataFormat namingStrategy(String namingStrategy) {
+        this.namingStrategy = namingStrategy;
+        return this;
+    }
+
 }

[camel] 07/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5c0c7edeed66ee04828414e5843f52975122c97c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 13:49:37 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../camel/component/jackson/PojoNamingStrategy.java      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
index 0eb2416..7e70b3d 100644
--- a/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
+++ b/components/camel-jackson/src/test/java/org/apache/camel/component/jackson/PojoNamingStrategy.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.jackson;
 
 public class PojoNamingStrategy {

[camel] 08/10: CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9b546cfc88225f57aeb63796ddec4698d1e83849
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Nov 18 13:54:02 2021 +0100

    CAMEL-16912 - camel-jackson - Make it easy to configure property naming strategy
---
 .../main/java/org/apache/camel/model/dataformat/JsonDataFormat.java  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
index 1ab4d95..96290df 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
@@ -97,6 +97,8 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
     @Metadata(javaType = "java.lang.Boolean", defaultValue = "true")
     private String autoDiscoverSchemaResolver;
     @XmlAttribute
+    @Metadata(description = "If set then Jackson will use the the defined Property Naming Strategy."
+                            + "Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE" )
     private String namingStrategy;
 
     public JsonDataFormat() {
@@ -439,7 +441,8 @@ public class JsonDataFormat extends DataFormatDefinition implements ContentTypeH
     }
 
     /**
-     * If set then Jackson will use the the defined Property Naming Strategy
+     * If set then Jackson will use the the defined Property Naming Strategy.
+     * Possible values are: LOWER_CAMEL_CASE, LOWER_DOT_CASE, LOWER_CASE, KEBAB_CASE, SNAKE_CASE and UPPER_CAMEL_CASE
      */
     public void setNamingStrategy(String namingStrategy) {
         this.namingStrategy = namingStrategy;