You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2021/02/16 12:57:01 UTC
[camel-quarkus] branch master updated: Added CBOR data format
native support #1754
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new d4532d6 Added CBOR data format native support #1754
d4532d6 is described below
commit d4532d6fe706178a1f2da9897eec546844b985ac
Author: aldettinger <al...@gmail.com>
AuthorDate: Tue Feb 16 11:00:44 2021 +0100
Added CBOR data format native support #1754
---
.../ROOT/pages/reference/extensions/cbor.adoc | 8 +-
.../ROOT/partials/reference/dataformats/cbor.adoc | 6 +-
.../quarkus/component/cbor/it/CborResource.java | 51 ------------
extensions-jvm/pom.xml | 1 -
.../cbor/deployment/pom.xml | 0
.../component/cbor/deployment/CborProcessor.java | 14 ----
{extensions-jvm => extensions}/cbor/pom.xml | 1 -
.../cbor/runtime/pom.xml | 1 +
.../main/resources/META-INF/quarkus-extension.yaml | 3 +-
extensions/pom.xml | 1 +
.../cbor}/pom.xml | 75 +++++++++++++++++-
.../quarkus/component/cbor/it/CborResource.java | 91 ++++++++++++++++++++++
.../quarkus/component/cbor/it/CborRoutes.java | 54 +++++++++++++
.../quarkus/component/cbor/it/model/Author.java | 33 +++++---
.../component/cbor/it/model/DummyObject.java | 26 ++++---
.../camel/quarkus/component/cbor/it/CborIT.java | 16 +---
.../camel/quarkus/component/cbor/it/CborTest.java | 91 ++++++++++++++++++++++
integration-tests/pom.xml | 1 +
tooling/scripts/test-categories.yaml | 1 +
19 files changed, 357 insertions(+), 117 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/cbor.adoc b/docs/modules/ROOT/pages/reference/extensions/cbor.adoc
index 2f2d11a..9e00594 100644
--- a/docs/modules/ROOT/pages/reference/extensions/cbor.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/cbor.adoc
@@ -2,15 +2,15 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= CBOR
:cq-artifact-id: camel-quarkus-cbor
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-description: Unmarshal a CBOR payload to POJO and back.
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.7.0
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.7.0##
Unmarshal a CBOR payload to POJO and back.
diff --git a/docs/modules/ROOT/partials/reference/dataformats/cbor.adoc b/docs/modules/ROOT/partials/reference/dataformats/cbor.adoc
index 07242b9..f71a30a 100644
--- a/docs/modules/ROOT/partials/reference/dataformats/cbor.adoc
+++ b/docs/modules/ROOT/partials/reference/dataformats/cbor.adoc
@@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-cbor
:cq-artifact-id-base: cbor
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.7.0
:cq-camel-part-name: cbor
:cq-camel-part-title: CBOR
:cq-camel-part-description: Unmarshal a CBOR payload to POJO and back.
diff --git a/extensions-jvm/cbor/integration-test/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborResource.java b/extensions-jvm/cbor/integration-test/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborResource.java
deleted file mode 100644
index 5ce2c9f..0000000
--- a/extensions-jvm/cbor/integration-test/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborResource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.cbor.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-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.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/cbor")
-@ApplicationScoped
-public class CborResource {
-
- private static final Logger LOG = Logger.getLogger(CborResource.class);
-
- private static final String DATAFORMAT_CBOR = "cbor";
- @Inject
- CamelContext context;
-
- @Path("/load/dataformat/cbor")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadDataformatCbor() throws Exception {
- /* This is an autogenerated test */
- if (context.resolveDataFormat(DATAFORMAT_CBOR) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", DATAFORMAT_CBOR);
- return Response.status(500, DATAFORMAT_CBOR + " could not be loaded from the Camel context").build();
- }
-}
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 41c2b3b..e0bf63a 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -44,7 +44,6 @@
<module>beanio</module>
<module>beanstalk</module>
<module>bonita</module>
- <module>cbor</module>
<module>chatscript</module>
<module>chunk</module>
<module>cm-sms</module>
diff --git a/extensions-jvm/cbor/deployment/pom.xml b/extensions/cbor/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/cbor/deployment/pom.xml
rename to extensions/cbor/deployment/pom.xml
diff --git a/extensions-jvm/cbor/deployment/src/main/java/org/apache/camel/quarkus/component/cbor/deployment/CborProcessor.java b/extensions/cbor/deployment/src/main/java/org/apache/camel/quarkus/component/cbor/deployment/CborProcessor.java
similarity index 68%
rename from extensions-jvm/cbor/deployment/src/main/java/org/apache/camel/quarkus/component/cbor/deployment/CborProcessor.java
rename to extensions/cbor/deployment/src/main/java/org/apache/camel/quarkus/component/cbor/deployment/CborProcessor.java
index df6f72b..2467032 100644
--- a/extensions-jvm/cbor/deployment/src/main/java/org/apache/camel/quarkus/component/cbor/deployment/CborProcessor.java
+++ b/extensions/cbor/deployment/src/main/java/org/apache/camel/quarkus/component/cbor/deployment/CborProcessor.java
@@ -17,11 +17,7 @@
package org.apache.camel.quarkus.component.cbor.deployment;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
import org.jboss.logging.Logger;
class CborProcessor {
@@ -33,14 +29,4 @@ class CborProcessor {
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}
-
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
- }
}
diff --git a/extensions-jvm/cbor/pom.xml b/extensions/cbor/pom.xml
similarity index 97%
rename from extensions-jvm/cbor/pom.xml
rename to extensions/cbor/pom.xml
index 4d903ce..fbfd533 100644
--- a/extensions-jvm/cbor/pom.xml
+++ b/extensions/cbor/pom.xml
@@ -33,6 +33,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
- <module>integration-test</module>
</modules>
</project>
diff --git a/extensions-jvm/cbor/runtime/pom.xml b/extensions/cbor/runtime/pom.xml
similarity index 98%
rename from extensions-jvm/cbor/runtime/pom.xml
rename to extensions/cbor/runtime/pom.xml
index 2b8f953..e79f98b 100644
--- a/extensions-jvm/cbor/runtime/pom.xml
+++ b/extensions/cbor/runtime/pom.xml
@@ -32,6 +32,7 @@
<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>1.7.0</camel.quarkus.nativeSince>
</properties>
<dependencyManagement>
diff --git a/extensions-jvm/cbor/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/cbor/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from extensions-jvm/cbor/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/cbor/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index 3f12b01..a8397c4 100644
--- a/extensions-jvm/cbor/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/cbor/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
name: "Camel CBOR"
description: "Unmarshal a CBOR payload to POJO and back"
metadata:
- unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/cbor.html"
categories:
- "integration"
status:
- - "preview"
+ - "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 0c845f0..b228037 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -89,6 +89,7 @@
<module>browse</module>
<module>caffeine</module>
<module>cassandraql</module>
+ <module>cbor</module>
<module>componentdsl</module>
<module>consul</module>
<module>controlbus</module>
diff --git a/extensions-jvm/cbor/integration-test/pom.xml b/integration-tests/cbor/pom.xml
similarity index 54%
rename from extensions-jvm/cbor/integration-test/pom.xml
rename to integration-tests/cbor/pom.xml
index ac64337..685dffb 100644
--- a/extensions-jvm/cbor/integration-test/pom.xml
+++ b/integration-tests/cbor/pom.xml
@@ -21,13 +21,12 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.7.0-SNAPSHOT</version>
- <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>
- <artifactId>camel-quarkus-cbor-integration-test</artifactId>
- <name>Camel Quarkus :: CBOR :: Integration Test</name>
+ <artifactId>camel-quarkus-integration-test-cbor</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: CBOR</name>
<description>Integration tests for Camel Quarkus CBOR extension</description>
<dependencyManagement>
@@ -48,9 +47,21 @@
<artifactId>camel-quarkus-cbor</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-mock</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jackson</artifactId>
+ </dependency>
<!-- test dependencies -->
<dependency>
@@ -78,6 +89,62 @@
</exclusion>
</exclusions>
</dependency>
+ <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>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-mock-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
+ <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/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborResource.java b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborResource.java
new file mode 100644
index 0000000..e5002fc
--- /dev/null
+++ b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborResource.java
@@ -0,0 +1,91 @@
+/*
+ * 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.cbor.it;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.quarkus.component.cbor.it.model.Author;
+import org.apache.camel.quarkus.component.cbor.it.model.DummyObject;
+import org.jboss.logging.Logger;
+
+import static java.util.stream.Collectors.toList;
+
+@Path("/cbor")
+@ApplicationScoped
+public class CborResource {
+
+ private static final Logger LOG = Logger.getLogger(CborResource.class);
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Inject
+ CamelContext context;
+
+ @Path("/marshalUnmarshalMap")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Map<?, ?> marshalUnmarshalMap(Map<String, String> in) {
+ LOG.debug("Calling marshalUnmarshalMap(...)");
+ Object marshalled = producerTemplate.requestBody("direct:marshal-map", in);
+ return producerTemplate.requestBody("direct:unmarshal-map", marshalled, Map.class);
+ }
+
+ @Path("/marshalUnmarshalAuthor")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Author marshalUnmarshalAuthor(Author author) {
+ LOG.debug("Calling marshalUnmarshalAuthor(...)");
+ Object marshalled = producerTemplate.requestBody("direct:marshal-author", author);
+ return producerTemplate.requestBody("direct:unmarshal-author", marshalled, Author.class);
+ }
+
+ @Path("/unmarshalAuthorViaJmsTypeHeader")
+ @GET
+ @Consumes(MediaType.APPLICATION_OCTET_STREAM)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Author unmarshalAuthorViaJmsTypeHeader(byte[] authorCborBytes) {
+ LOG.debug("Calling unmarshalAuthorViaJmsTypeHeader(...)");
+ String uri = "direct:unmarshal-via-jms-type-header";
+ return producerTemplate.requestBodyAndHeader(uri, authorCborBytes, "JMSType", Author.class.getName(), Author.class);
+ }
+
+ @Path("/unmarshalDummyObjectList")
+ @GET
+ @Consumes(MediaType.APPLICATION_OCTET_STREAM)
+ @Produces(MediaType.APPLICATION_JSON)
+ public List<DummyObject> unmarshalDummyObjectList(byte[] dummyObjectListCborBytes) {
+ LOG.debug("Calling unmarshalDummyObjectList(...)");
+ MockEndpoint mockResult = context.getEndpoint("mock:unmarshal-dummy-object-list", MockEndpoint.class);
+ producerTemplate.requestBody("direct:unmarshal-dummy-object-list", dummyObjectListCborBytes);
+ return mockResult.getExchanges().stream().map(e -> e.getIn().getBody(DummyObject.class)).collect(toList());
+ }
+}
diff --git a/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborRoutes.java b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborRoutes.java
new file mode 100644
index 0000000..4b2c76b
--- /dev/null
+++ b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/CborRoutes.java
@@ -0,0 +1,54 @@
+/*
+ * 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.cbor.it;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cbor.CBORDataFormat;
+import org.apache.camel.quarkus.component.cbor.it.model.Author;
+import org.apache.camel.quarkus.component.cbor.it.model.DummyObject;
+
+public class CborRoutes extends RouteBuilder {
+
+ @Override
+ public void configure() {
+ CBORDataFormat useMapDf = new CBORDataFormat();
+ useMapDf.useMap();
+ from("direct:marshal-map").marshal(useMapDf);
+ from("direct:unmarshal-map").unmarshal(useMapDf);
+
+ CBORDataFormat authorDf = new CBORDataFormat();
+ authorDf.setUseDefaultObjectMapper(false);
+ authorDf.setUnmarshalType(Author.class);
+ from("direct:marshal-author").marshal(authorDf);
+ from("direct:unmarshal-author").unmarshal(authorDf);
+
+ CBORDataFormat allowJmsTypeDf = new CBORDataFormat();
+ allowJmsTypeDf.setUseDefaultObjectMapper(false);
+ allowJmsTypeDf.setAllowJmsType(true);
+ from("direct:unmarshal-via-jms-type-header").unmarshal(allowJmsTypeDf);
+
+ CBORDataFormat dummyObjectListDf = new CBORDataFormat();
+ dummyObjectListDf.setUseDefaultObjectMapper(false);
+ dummyObjectListDf.useList();
+ dummyObjectListDf.setUnmarshalType(DummyObject.class);
+ from("direct:unmarshal-dummy-object-list")
+ .unmarshal(dummyObjectListDf)
+ .split(body())
+ .to("mock:unmarshal-dummy-object-list");
+ }
+
+}
diff --git a/extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/model/Author.java
similarity index 61%
copy from extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
copy to integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/model/Author.java
index 35a4e8f..acf5f33 100644
--- a/extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
+++ b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/model/Author.java
@@ -14,21 +14,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.cbor.it;
+package org.apache.camel.quarkus.component.cbor.it.model;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.runtime.annotations.RegisterForReflection;
-@QuarkusTest
-class CborTest {
+@RegisterForReflection(fields = false)
+public class Author {
- @Test
- public void loadDataformatCbor() {
- /* A simple autogenerated test */
- RestAssured.get("/cbor/load/dataformat/cbor")
- .then()
- .statusCode(200);
+ private String name;
+ private String surname;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getSurname() {
+ return surname;
+ }
+
+ public void setSurname(String surname) {
+ this.surname = surname;
}
}
diff --git a/extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/model/DummyObject.java
similarity index 67%
copy from extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
copy to integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/model/DummyObject.java
index 35a4e8f..178ed88 100644
--- a/extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
+++ b/integration-tests/cbor/src/main/java/org/apache/camel/quarkus/component/cbor/it/model/DummyObject.java
@@ -14,21 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.cbor.it;
+package org.apache.camel.quarkus.component.cbor.it.model;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.runtime.annotations.RegisterForReflection;
-@QuarkusTest
-class CborTest {
+@RegisterForReflection(fields = false)
+public class DummyObject {
- @Test
- public void loadDataformatCbor() {
- /* A simple autogenerated test */
- RestAssured.get("/cbor/load/dataformat/cbor")
- .then()
- .statusCode(200);
+ private String dummy;
+
+ public DummyObject() {
+ }
+
+ public String getDummy() {
+ return dummy;
}
+ public void setDummy(String dummy) {
+ this.dummy = dummy;
+ }
}
diff --git a/extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java b/integration-tests/cbor/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborIT.java
similarity index 70%
rename from extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
rename to integration-tests/cbor/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborIT.java
index 35a4e8f..b297fdb 100644
--- a/extensions-jvm/cbor/integration-test/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
+++ b/integration-tests/cbor/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborIT.java
@@ -16,19 +16,9 @@
*/
package org.apache.camel.quarkus.component.cbor.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
-@QuarkusTest
-class CborTest {
-
- @Test
- public void loadDataformatCbor() {
- /* A simple autogenerated test */
- RestAssured.get("/cbor/load/dataformat/cbor")
- .then()
- .statusCode(200);
- }
+@NativeImageTest
+class CborIT extends CborTest {
}
diff --git a/integration-tests/cbor/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java b/integration-tests/cbor/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
new file mode 100644
index 0000000..96f6b43
--- /dev/null
+++ b/integration-tests/cbor/src/test/java/org/apache/camel/quarkus/component/cbor/it/CborTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.cbor.it;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.component.cbor.it.model.Author;
+import org.apache.camel.quarkus.component.cbor.it.model.DummyObject;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.given;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+@QuarkusTest
+class CborTest {
+
+ private static final ObjectMapper CBOR_MAPPER = new ObjectMapper(new CBORFactory());
+
+ @Test
+ void marshalUnmarshalMapShouldSucceed() {
+ Map<String, String> in = Collections.singletonMap("name", "Camel");
+
+ String uri = "/cbor/marshalUnmarshalMap";
+ Map<?, ?> out = given().contentType(ContentType.JSON).body(in).get(uri).then().statusCode(200).extract().as(Map.class);
+ assertEquals(1, out.size());
+ }
+
+ @Test
+ void marshalUnmarshalAuthorShouldSucceed() {
+ Author in = new Author();
+ in.setName("Don");
+ in.setSurname("Winslow");
+
+ String uri = "/cbor/marshalUnmarshalAuthor";
+ Author out = given().contentType(ContentType.JSON).body(in).get(uri).then().statusCode(200).extract().as(Author.class);
+ assertEquals("Don", out.getName());
+ assertEquals("Winslow", out.getSurname());
+ }
+
+ @Test
+ void unmarshalAuthorViaJmsTypeHeaderShouldSucceed() throws JsonProcessingException {
+ Author author = new Author();
+ author.setName("David");
+ author.setSurname("Foster Wallace");
+
+ byte[] authorCborBytes = CBOR_MAPPER.writeValueAsBytes(author);
+
+ String uri = "/cbor/unmarshalAuthorViaJmsTypeHeader";
+ Author unmarshalled = given().body(authorCborBytes).get(uri).then().statusCode(200).extract().as(Author.class);
+ assertNotNull(unmarshalled);
+ assertEquals("David", unmarshalled.getName());
+ assertEquals("Foster Wallace", unmarshalled.getSurname());
+ }
+
+ @Test
+ void unmarshalDummyObjectListShouldSucceed() throws JsonProcessingException {
+ DummyObject first = new DummyObject();
+ first.setDummy("value1");
+ DummyObject second = new DummyObject();
+ second.setDummy("value2");
+
+ byte[] listCborBytes = CBOR_MAPPER.writeValueAsBytes(Arrays.asList(first, second));
+
+ String uri = "/cbor/unmarshalDummyObjectList";
+ DummyObject[] objects = given().body(listCborBytes).get(uri).then().statusCode(200).extract().as(DummyObject[].class);
+ assertEquals(2, objects.length);
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index bfac96c..94ca84b 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -82,6 +82,7 @@
<module>braintree</module>
<module>caffeine</module>
<module>cassandraql</module>
+ <module>cbor</module>
<module>compression</module>
<module>consul</module>
<module>couchdb</module>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index a88eba6..9571ed7 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -72,6 +72,7 @@ dataformats:
- avro
- base64
- bindy
+ - cbor
- csv
- dataformat
- jaxb