You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/11/18 09:36:52 UTC
[camel-quarkus] 01/01: [Camel 3.7] JSON-B data format support
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch camel-master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit f5801126129fb7221b41a00ee6452444c91d2c1b
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Thu Nov 5 13:02:17 2020 +0100
[Camel 3.7] JSON-B data format support
---
catalog/pom.xml | 13 ++
.../ROOT/pages/reference/extensions/jsonb.adoc | 38 +++++
.../partials/reference/dataformats/json-jsonb.adoc | 14 +-
extensions/jsonb/deployment/pom.xml | 67 +++++++++
.../component/jsonb/deployment/JsonbProcessor.java | 31 +++++
extensions/jsonb/pom.xml | 39 ++++++
extensions/jsonb/runtime/pom.xml | 105 ++++++++++++++
.../jsonb/runtime/src/main/doc/configuration.adoc | 1 +
.../main/resources/META-INF/quarkus-extension.yaml | 31 +++++
extensions/pom.xml | 1 +
integration-tests/jsonb/pom.xml | 154 +++++++++++++++++++++
.../quarkus/component/jsonb/it/JsonbResource.java | 81 +++++++++++
.../component/jsonb/it/JsonbRouteBuilder.java | 38 +++++
.../camel/quarkus/component/jsonb/it/TestPojo.java | 48 +++++++
.../camel/quarkus/component/jsonb/it/JsonbIT.java | 24 ++++
.../quarkus/component/jsonb/it/JsonbTest.java | 119 ++++++++++++++++
integration-tests/pom.xml | 1 +
poms/bom/pom.xml | 15 ++
tooling/scripts/test-categories.yaml | 1 +
19 files changed, 820 insertions(+), 1 deletion(-)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index ce7b9de..c7a7ae0 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -2207,6 +2207,19 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jsonpath</artifactId>
<version>${project.version}</version>
<type>pom</type>
diff --git a/docs/modules/ROOT/pages/reference/extensions/jsonb.adoc b/docs/modules/ROOT/pages/reference/extensions/jsonb.adoc
new file mode 100644
index 0000000..6ec6abf
--- /dev/null
+++ b/docs/modules/ROOT/pages/reference/extensions/jsonb.adoc
@@ -0,0 +1,38 @@
+// Do not edit directly!
+// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
+= JSON JSON-B
+:cq-artifact-id: camel-quarkus-jsonb
+:cq-native-supported: true
+:cq-status: Stable
+:cq-description: Marshal POJOs to JSON and back using JSON-B.
+:cq-deprecated: false
+:cq-jvm-since: 1.4.0
+:cq-native-since: 1.4.0
+
+[.badges]
+[.badge-key]##JVM since##[.badge-supported]##1.4.0## [.badge-key]##Native since##[.badge-supported]##1.4.0##
+
+Marshal POJOs to JSON and back using JSON-B.
+
+== What's inside
+
+* xref:latest@components:dataformats:json-jsonb-dataformat.adoc[JSON JSON-B data format]
+
+Please refer to the above link for usage and configuration details.
+
+== Maven coordinates
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb</artifactId>
+</dependency>
+----
+
+Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Additional Camel Quarkus configuration
+
+Extension contains `io.quarkus:quarkus-jsonb` dependency. No jsonb implementation has to be provided.
+
diff --git a/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc b/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc
index a509c1d..4e3bf50 100644
--- a/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc
+++ b/docs/modules/ROOT/partials/reference/dataformats/json-jsonb.adoc
@@ -1 +1,13 @@
-// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page
+// Do not edit directly!
+// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
+:cq-artifact-id: camel-quarkus-jsonb
+:cq-artifact-id-base: jsonb
+:cq-native-supported: true
+:cq-status: Stable
+:cq-deprecated: false
+:cq-jvm-since: 1.4.0
+:cq-native-since: 1.4.0
+:cq-camel-part-name: json-jsonb
+:cq-camel-part-title: JSON JSON-B
+:cq-camel-part-description: Marshal POJOs to JSON and back using JSON-B.
+:cq-extension-page-title: JSON JSON-B
diff --git a/extensions/jsonb/deployment/pom.xml b/extensions/jsonb/deployment/pom.xml
new file mode 100644
index 0000000..7eee533
--- /dev/null
+++ b/extensions/jsonb/deployment/pom.xml
@@ -0,0 +1,67 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-jsonb-deployment</artifactId>
+ <name>Camel Quarkus :: JSON JSON-B :: Deployment</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jsonb-deployment</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/jsonb/deployment/src/main/java/org/apache/camel/quarkus/component/jsonb/deployment/JsonbProcessor.java b/extensions/jsonb/deployment/src/main/java/org/apache/camel/quarkus/component/jsonb/deployment/JsonbProcessor.java
new file mode 100644
index 0000000..54bff2b
--- /dev/null
+++ b/extensions/jsonb/deployment/src/main/java/org/apache/camel/quarkus/component/jsonb/deployment/JsonbProcessor.java
@@ -0,0 +1,31 @@
+/*
+ * 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.quarkus.component.jsonb.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+
+class JsonbProcessor {
+
+ private static final String FEATURE = "camel-jsonb";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+}
diff --git a/extensions/jsonb/pom.xml b/extensions/jsonb/pom.xml
new file mode 100644
index 0000000..0204576
--- /dev/null
+++ b/extensions/jsonb/pom.xml
@@ -0,0 +1,39 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-jsonb-parent</artifactId>
+ <name>Camel Quarkus :: JSON JSON-B</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/jsonb/runtime/pom.xml b/extensions/jsonb/runtime/pom.xml
new file mode 100644
index 0000000..529191e
--- /dev/null
+++ b/extensions/jsonb/runtime/pom.xml
@@ -0,0 +1,105 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb-parent</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-jsonb</artifactId>
+ <name>Camel Quarkus :: JSON JSON-B :: Runtime</name>
+ <description>Marshal POJOs to JSON and back using JSON-B.</description>
+
+ <properties>
+ <camel.quarkus.jvmSince>1.4.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>1.4.0</camel.quarkus.nativeSince>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jsonb</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>org.apache.geronimo.specs</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jsonb</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-extension-doc-page</id>
+ <goals><goal>update-extension-doc-page</goal></goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/jsonb/runtime/src/main/doc/configuration.adoc b/extensions/jsonb/runtime/src/main/doc/configuration.adoc
new file mode 100644
index 0000000..5487a90
--- /dev/null
+++ b/extensions/jsonb/runtime/src/main/doc/configuration.adoc
@@ -0,0 +1 @@
+Extension contains `io.quarkus:quarkus-jsonb` dependency. No jsonb implementation has to be provided.
\ No newline at end of file
diff --git a/extensions/jsonb/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/jsonb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..8b3e41a
--- /dev/null
+++ b/extensions/jsonb/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+# This is a generated file. Do not edit directly!
+# To re-generate, run the following command from the top level directory:
+#
+# mvn -N cq:update-quarkus-metadata
+#
+---
+name: "Camel JSON JSON-B"
+description: "Marshal POJOs to JSON and back using JSON-B"
+metadata:
+ guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/jsonb.html"
+ categories:
+ - "integration"
+ status:
+ - "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 8e996d3..15e5c8e 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -134,6 +134,7 @@
<module>jpa</module>
<module>jslt</module>
<module>json-validator</module>
+ <module>jsonb</module>
<module>jsonpath</module>
<module>jta</module>
<module>kafka</module>
diff --git a/integration-tests/jsonb/pom.xml b/integration-tests/jsonb/pom.xml
new file mode 100644
index 0000000..d1cd4ec
--- /dev/null
+++ b/integration-tests/jsonb/pom.xml
@@ -0,0 +1,154 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-jsonb</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: JSON JSON-B</name>
+ <description>Integration tests for Camel Quarkus JSON JSON-B extension</description>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-test</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/JsonbResource.java b/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/JsonbResource.java
new file mode 100644
index 0000000..393f51c
--- /dev/null
+++ b/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/JsonbResource.java
@@ -0,0 +1,81 @@
+/*
+ * 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.quarkus.component.jsonb.it;
+
+import java.net.URI;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ProducerTemplate;
+import org.jboss.logging.Logger;
+
+@Path("/jsonb")
+@ApplicationScoped
+public class JsonbResource {
+
+ private static final Logger LOG = Logger.getLogger(JsonbResource.class);
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/marshallMap")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String marshallMap(Map map) {
+ return producerTemplate.requestBody("direct:marshallMap", map, String.class);
+ }
+
+ @Path("/unmarshallMap")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Map marshall(String message) throws Exception {
+ return producerTemplate.requestBody("direct:unmarshallMap", message, Map.class);
+ }
+
+ @Path("/marshallPojo")
+ @POST
+ @Consumes(MediaType.APPLICATION_OCTET_STREAM)
+ @Produces(MediaType.TEXT_PLAIN)
+ public String marshallPojo(byte[] message) throws Exception {
+ TestPojo tp = new TestPojo();
+ tp.setName(message);
+ return producerTemplate.requestBody("direct:marshallPojo", tp, String.class);
+ }
+
+ @Path("/unmarshallPojo")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ public Response marshallPojo(String message) throws Exception {
+ TestPojo tp = producerTemplate.requestBody("direct:unmarshallPojo", message, TestPojo.class);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(tp.getName())
+ .build();
+
+ }
+}
diff --git a/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/JsonbRouteBuilder.java b/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/JsonbRouteBuilder.java
new file mode 100644
index 0000000..c365b41
--- /dev/null
+++ b/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/JsonbRouteBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.quarkus.component.jsonb.it;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jsonb.JsonbDataFormat;
+
+public class JsonbRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() {
+
+ JsonbDataFormat format = new JsonbDataFormat();
+
+ from("direct:marshallMap").marshal(format);
+ from("direct:unmarshallMap").unmarshal(format);
+
+ JsonbDataFormat formatPojo = new JsonbDataFormat(TestPojo.class);
+
+ from("direct:marshallPojo").marshal(formatPojo);
+ from("direct:unmarshallPojo").unmarshal(formatPojo);
+ }
+
+}
diff --git a/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/TestPojo.java b/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/TestPojo.java
new file mode 100644
index 0000000..53be0ca
--- /dev/null
+++ b/integration-tests/jsonb/src/main/java/org/apache/camel/quarkus/component/jsonb/it/TestPojo.java
@@ -0,0 +1,48 @@
+/*
+ * 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.quarkus.component.jsonb.it;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+public class TestPojo {
+
+ private byte[] name;
+
+ public byte[] getName() {
+ return this.name;
+ }
+
+ public void setName(byte[] name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this.name.equals(((TestPojo) obj).getName());
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
+
+ @Override
+ public String toString() {
+ return "TestPojo[" + name + "]";
+ }
+}
diff --git a/integration-tests/jsonb/src/test/java/org/apache/camel/quarkus/component/jsonb/it/JsonbIT.java b/integration-tests/jsonb/src/test/java/org/apache/camel/quarkus/component/jsonb/it/JsonbIT.java
new file mode 100644
index 0000000..a326c80
--- /dev/null
+++ b/integration-tests/jsonb/src/test/java/org/apache/camel/quarkus/component/jsonb/it/JsonbIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.jsonb.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class JsonbIT extends JsonbTest {
+
+}
diff --git a/integration-tests/jsonb/src/test/java/org/apache/camel/quarkus/component/jsonb/it/JsonbTest.java b/integration-tests/jsonb/src/test/java/org/apache/camel/quarkus/component/jsonb/it/JsonbTest.java
new file mode 100644
index 0000000..116880b
--- /dev/null
+++ b/integration-tests/jsonb/src/test/java/org/apache/camel/quarkus/component/jsonb/it/JsonbTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.quarkus.component.jsonb.it;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class JsonbTest {
+
+ private final Map MSG = new HashMap() {
+ {
+ put("greeting", "Hello");
+ put("name", "Sheldon");
+ }
+ };
+ private final String MARSHALLED_MSG = "\\{\"greeting\":\"Hello\",\"name\":\"Sheldon\"\\}";
+
+ @Test
+ public void testMap() throws Exception {
+ Map<String, Object> in = new HashMap<>();
+ in.put("greeting", "Hello");
+ in.put("name", serialize("Sheldon"));
+
+ String marshalled = RestAssured.given()
+ .contentType(ContentType.JSON)
+ .body(MSG)
+ .queryParam("route", "in")
+ .post("/jsonb/marshallMap")
+ .then()
+ .statusCode(200)
+ .extract()
+ .asString();
+
+ assertTrue(marshalled.matches(MARSHALLED_MSG),
+ String.format("Expected '%s', but got '%s'", MARSHALLED_MSG, marshalled));
+
+ Map unmarshalled = RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(marshalled)
+ .post("/jsonb/unmarshallMap")
+ .then()
+ .statusCode(200)
+ .extract()
+ .as(Map.class);
+
+ assertTrue(unmarshalled.containsKey("greeting"), "Key 'greeting' should be present.");
+ assertEquals("Hello", unmarshalled.get("greeting"));
+ assertTrue(unmarshalled.containsKey("name"), "Key 'name' should be present.");
+ assertEquals("Sheldon", unmarshalled.get("name"));
+ }
+
+ @Test
+ public void testPojo() throws Exception {
+ String s = RestAssured.given()
+ .contentType(ContentType.BINARY)
+ .body(serialize("Sheldon"))
+ .queryParam("route", "in")
+ .post("/jsonb/marshallPojo")
+ .then()
+ .statusCode(200)
+ .extract()
+ .asString();
+
+ assertTrue(s.matches("\\{\"name\":\".*\"\\}"), String.format("Expected '{\"name\":\".*\"}', but got '%s'", s));
+
+ InputStream is = RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(s)
+ .post("/jsonb/unmarshallPojo")
+ .then()
+ .statusCode(201)
+ .extract()
+ .asInputStream();
+
+ assertEquals("Sheldon", deserialize(is));
+ }
+
+ private byte[] serialize(String s) throws Exception {
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos)) {
+ oos.writeObject(s);
+ return baos.toByteArray();
+ }
+ }
+
+ private Object deserialize(InputStream is) throws Exception {
+ try (ObjectInputStream ois = new ObjectInputStream(is)) {
+ return ois.readObject();
+ }
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index eab78ea..7a86021 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -114,6 +114,7 @@
<module>jpa</module>
<module>jslt</module>
<module>json-validator</module>
+ <module>jsonb</module>
<module>jsonpath</module>
<module>jta</module>
<module>kafka</module>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 07104d7..8e2f52c 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -1259,6 +1259,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-jsonb</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-jsonpath</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -3702,6 +3707,16 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-jsonb-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jsonpath</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 3355be6..4ec8877 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -61,6 +61,7 @@ dataformats:
- csv
- dataformat
- jaxb
+ - jsonb
- soap
- xstream
foundation: