You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/03/01 05:42:00 UTC

[camel] branch master updated: Vertx: add Json Converters (#5145)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 90032f6  Vertx: add Json Converters (#5145)
90032f6 is described below

commit 90032f64846593e06577eadc116b3fea8999c70b
Author: James Hilliard <ja...@gmail.com>
AuthorDate: Sun Feb 28 22:41:09 2021 -0700

    Vertx: add Json Converters (#5145)
    
    Vertx Json Objects and Arrays can be sent over the eventbus,
    add Type Converters for these to make them easier to work
    with from camel.
    
    Since these types are part of vertx-core they should be part
    of camel-vertx-common so that they are available to all the
    various vertx components.
    
    Signed-off-by: James Hilliard <ja...@gmail.com>
---
 .../common/VertxJsonArrayConverterLoader.java      |  56 ++++++++++++
 .../common/VertxJsonObjectConverterLoader.java     |  56 ++++++++++++
 .../services/org/apache/camel/TypeConverterLoader  |   2 +
 .../vertx/common/VertxJsonArrayConverter.java      | 100 +++++++++++++++++++++
 .../vertx/common/VertxJsonObjectConverter.java     | 100 +++++++++++++++++++++
 .../vertx/VertxJsonArrayConverterTest.java         |  93 +++++++++++++++++++
 .../vertx/VertxJsonObjectConverterTest.java        |  93 +++++++++++++++++++
 7 files changed, 500 insertions(+)

diff --git a/components/camel-vertx-common/src/generated/java/org/apache/camel/component/vertx/common/VertxJsonArrayConverterLoader.java b/components/camel-vertx-common/src/generated/java/org/apache/camel/component/vertx/common/VertxJsonArrayConverterLoader.java
new file mode 100644
index 0000000..0f6cf1c
--- /dev/null
+++ b/components/camel-vertx-common/src/generated/java/org/apache/camel/component/vertx/common/VertxJsonArrayConverterLoader.java
@@ -0,0 +1,56 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.vertx.common;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverterLoaderException;
+import org.apache.camel.spi.TypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+import org.apache.camel.support.SimpleTypeConverter;
+import org.apache.camel.support.TypeConverterSupport;
+import org.apache.camel.util.DoubleMap;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public final class VertxJsonArrayConverterLoader implements TypeConverterLoader {
+
+    public VertxJsonArrayConverterLoader() {
+    }
+
+    @Override
+    public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException {
+        registerConverters(registry);
+    }
+
+    private void registerConverters(TypeConverterRegistry registry) {
+        addTypeConverter(registry, byte[].class, io.vertx.core.json.JsonArray.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toBytes((io.vertx.core.json.JsonArray) value));
+        addTypeConverter(registry, io.vertx.core.buffer.Buffer.class, io.vertx.core.json.JsonArray.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toBuffer((io.vertx.core.json.JsonArray) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonArray.class, byte[].class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toJsonArray((byte[]) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonArray.class, io.netty.buffer.ByteBuf.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toJsonArray((io.netty.buffer.ByteBuf) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonArray.class, io.vertx.core.buffer.Buffer.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toJsonArray((io.vertx.core.buffer.Buffer) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonArray.class, java.io.InputStream.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toJsonArray((java.io.InputStream) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonArray.class, java.lang.String.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toJsonArray((java.lang.String) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonArray.class, java.util.List.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toJsonArray((java.util.List) value));
+        addTypeConverter(registry, java.io.InputStream.class, io.vertx.core.json.JsonArray.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toInputStream((io.vertx.core.json.JsonArray) value));
+        addTypeConverter(registry, java.lang.String.class, io.vertx.core.json.JsonArray.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toString((io.vertx.core.json.JsonArray) value));
+        addTypeConverter(registry, java.util.List.class, io.vertx.core.json.JsonArray.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonArrayConverter.toList((io.vertx.core.json.JsonArray) value));
+    }
+
+    private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { 
+        registry.addTypeConverter(toType, fromType, new SimpleTypeConverter(allowNull, method));
+    }
+
+}
diff --git a/components/camel-vertx-common/src/generated/java/org/apache/camel/component/vertx/common/VertxJsonObjectConverterLoader.java b/components/camel-vertx-common/src/generated/java/org/apache/camel/component/vertx/common/VertxJsonObjectConverterLoader.java
new file mode 100644
index 0000000..0730904
--- /dev/null
+++ b/components/camel-vertx-common/src/generated/java/org/apache/camel/component/vertx/common/VertxJsonObjectConverterLoader.java
@@ -0,0 +1,56 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.vertx.common;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverterLoaderException;
+import org.apache.camel.spi.TypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+import org.apache.camel.support.SimpleTypeConverter;
+import org.apache.camel.support.TypeConverterSupport;
+import org.apache.camel.util.DoubleMap;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public final class VertxJsonObjectConverterLoader implements TypeConverterLoader {
+
+    public VertxJsonObjectConverterLoader() {
+    }
+
+    @Override
+    public void load(TypeConverterRegistry registry) throws TypeConverterLoaderException {
+        registerConverters(registry);
+    }
+
+    private void registerConverters(TypeConverterRegistry registry) {
+        addTypeConverter(registry, byte[].class, io.vertx.core.json.JsonObject.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toBytes((io.vertx.core.json.JsonObject) value));
+        addTypeConverter(registry, io.vertx.core.buffer.Buffer.class, io.vertx.core.json.JsonObject.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toBuffer((io.vertx.core.json.JsonObject) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonObject.class, byte[].class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toJsonObject((byte[]) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonObject.class, io.netty.buffer.ByteBuf.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toJsonObject((io.netty.buffer.ByteBuf) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonObject.class, io.vertx.core.buffer.Buffer.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toJsonObject((io.vertx.core.buffer.Buffer) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonObject.class, java.io.InputStream.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toJsonObject((java.io.InputStream) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonObject.class, java.lang.String.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toJsonObject((java.lang.String) value));
+        addTypeConverter(registry, io.vertx.core.json.JsonObject.class, java.util.Map.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toJsonObject((java.util.Map) value));
+        addTypeConverter(registry, java.io.InputStream.class, io.vertx.core.json.JsonObject.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toInputStream((io.vertx.core.json.JsonObject) value));
+        addTypeConverter(registry, java.lang.String.class, io.vertx.core.json.JsonObject.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toString((io.vertx.core.json.JsonObject) value));
+        addTypeConverter(registry, java.util.Map.class, io.vertx.core.json.JsonObject.class, false,
+            (type, exchange, value) -> org.apache.camel.component.vertx.common.VertxJsonObjectConverter.toMap((io.vertx.core.json.JsonObject) value));
+    }
+
+    private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { 
+        registry.addTypeConverter(toType, fromType, new SimpleTypeConverter(allowNull, method));
+    }
+
+}
diff --git a/components/camel-vertx-common/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader b/components/camel-vertx-common/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
index ae9089b..5f18180 100644
--- a/components/camel-vertx-common/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
+++ b/components/camel-vertx-common/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
@@ -1,2 +1,4 @@
 # Generated by camel build tools - do NOT edit this file!
 org.apache.camel.component.vertx.common.VertxBufferConverterLoader
+org.apache.camel.component.vertx.common.VertxJsonArrayConverterLoader
+org.apache.camel.component.vertx.common.VertxJsonObjectConverterLoader
diff --git a/components/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxJsonArrayConverter.java b/components/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxJsonArrayConverter.java
new file mode 100644
index 0000000..e8ff95b
--- /dev/null
+++ b/components/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxJsonArrayConverter.java
@@ -0,0 +1,100 @@
+/*
+ * 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.vertx.common;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import io.netty.buffer.ByteBuf;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.json.JsonArray;
+import org.apache.camel.Converter;
+import org.apache.camel.util.IOHelper;
+
+/**
+ * Converter methods to convert from / to Vert.x JsonArray
+ */
+@Converter(generateLoader = true)
+public final class VertxJsonArrayConverter {
+
+    private VertxJsonArrayConverter() {
+    }
+
+    @Converter
+    public static JsonArray toJsonArray(Buffer buffer) {
+        return new JsonArray(buffer);
+    }
+
+    @Converter
+    public static JsonArray toJsonArray(String string) {
+        return new JsonArray(string);
+    }
+
+    @Converter
+    public static JsonArray toJsonArray(byte[] bytes) {
+        return Buffer.buffer(bytes).toJsonArray();
+    }
+
+    @Converter
+    public static JsonArray toJsonArray(ByteBuf byteBuf) {
+        return Buffer.buffer(byteBuf).toJsonArray();
+    }
+
+    @Converter
+    public static JsonArray toJsonArray(List list) {
+        return new JsonArray(list);
+    }
+
+    @Converter
+    public static JsonArray toJsonArray(InputStream inputStream) throws IOException {
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            IOHelper.copy(IOHelper.buffered(inputStream), bos);
+            return Buffer.buffer(bos.toByteArray()).toJsonArray();
+        } finally {
+            IOHelper.close(inputStream);
+        }
+    }
+
+    @Converter
+    public static Buffer toBuffer(JsonArray jsonArray) {
+        return jsonArray.toBuffer();
+    }
+
+    @Converter
+    public static String toString(JsonArray jsonArray) {
+        return jsonArray.encode();
+    }
+
+    @Converter
+    public static byte[] toBytes(JsonArray jsonArray) {
+        return jsonArray.toBuffer().getBytes();
+    }
+
+    @Converter
+    public static List toList(JsonArray jsonArray) {
+        return jsonArray.getList();
+    }
+
+    @Converter
+    public static InputStream toInputStream(JsonArray jsonArray) {
+        return new ByteArrayInputStream(jsonArray.toBuffer().getBytes());
+    }
+}
diff --git a/components/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxJsonObjectConverter.java b/components/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxJsonObjectConverter.java
new file mode 100644
index 0000000..4f8dd3a
--- /dev/null
+++ b/components/camel-vertx-common/src/main/java/org/apache/camel/component/vertx/common/VertxJsonObjectConverter.java
@@ -0,0 +1,100 @@
+/*
+ * 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.vertx.common;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import io.netty.buffer.ByteBuf;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.json.JsonObject;
+import org.apache.camel.Converter;
+import org.apache.camel.util.IOHelper;
+
+/**
+ * Converter methods to convert from / to Vert.x JsonObject
+ */
+@Converter(generateLoader = true)
+public final class VertxJsonObjectConverter {
+
+    private VertxJsonObjectConverter() {
+    }
+
+    @Converter
+    public static JsonObject toJsonObject(Buffer buffer) {
+        return new JsonObject(buffer);
+    }
+
+    @Converter
+    public static JsonObject toJsonObject(String string) {
+        return new JsonObject(string);
+    }
+
+    @Converter
+    public static JsonObject toJsonObject(byte[] bytes) {
+        return Buffer.buffer(bytes).toJsonObject();
+    }
+
+    @Converter
+    public static JsonObject toJsonObject(ByteBuf byteBuf) {
+        return Buffer.buffer(byteBuf).toJsonObject();
+    }
+
+    @Converter
+    public static JsonObject toJsonObject(Map<String, Object> map) {
+        return new JsonObject(map);
+    }
+
+    @Converter
+    public static JsonObject toJsonObject(InputStream inputStream) throws IOException {
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            IOHelper.copy(IOHelper.buffered(inputStream), bos);
+            return Buffer.buffer(bos.toByteArray()).toJsonObject();
+        } finally {
+            IOHelper.close(inputStream);
+        }
+    }
+
+    @Converter
+    public static Buffer toBuffer(JsonObject jsonObject) {
+        return jsonObject.toBuffer();
+    }
+
+    @Converter
+    public static String toString(JsonObject jsonObject) {
+        return jsonObject.encode();
+    }
+
+    @Converter
+    public static byte[] toBytes(JsonObject jsonObject) {
+        return jsonObject.toBuffer().getBytes();
+    }
+
+    @Converter
+    public static Map<String, Object> toMap(JsonObject jsonObject) {
+        return jsonObject.getMap();
+    }
+
+    @Converter
+    public static InputStream toInputStream(JsonObject jsonObject) {
+        return new ByteArrayInputStream(jsonObject.toBuffer().getBytes());
+    }
+}
diff --git a/components/camel-vertx/src/test/java/org/apache/camel/component/vertx/VertxJsonArrayConverterTest.java b/components/camel-vertx/src/test/java/org/apache/camel/component/vertx/VertxJsonArrayConverterTest.java
new file mode 100644
index 0000000..711e977
--- /dev/null
+++ b/components/camel-vertx/src/test/java/org/apache/camel/component/vertx/VertxJsonArrayConverterTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.vertx;
+
+import java.io.InputStream;
+import java.util.List;
+
+import io.netty.buffer.Unpooled;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.json.JsonArray;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class VertxJsonArrayConverterTest extends CamelTestSupport {
+
+    private static final String BODY = "[\"Hello\",\"World\"]";
+
+    @Test
+    public void testBufferToJsonArray() {
+        JsonArray jsonArray = context.getTypeConverter().convertTo(JsonArray.class, Buffer.buffer(BODY));
+        Assertions.assertEquals(BODY, jsonArray.toString());
+    }
+
+    @Test
+    public void testStringToJsonArray() {
+        JsonArray jsonArray = context.getTypeConverter().convertTo(JsonArray.class, BODY);
+        Assertions.assertEquals(BODY, jsonArray.toString());
+    }
+
+    @Test
+    public void testByteArrayToJsonArray() {
+        JsonArray jsonArray = context.getTypeConverter().convertTo(JsonArray.class, BODY.getBytes());
+        Assertions.assertEquals(BODY, jsonArray.toString());
+    }
+
+    @Test
+    public void testByteBufToJsonArray() {
+        JsonArray jsonArray = context.getTypeConverter().convertTo(JsonArray.class, Unpooled.wrappedBuffer(BODY.getBytes()));
+        Assertions.assertEquals(BODY, jsonArray.toString());
+    }
+
+    @Test
+    public void testListArrayToJsonArray() {
+        JsonArray jsonArray = context.getTypeConverter().convertTo(JsonArray.class, new JsonArray(BODY).getList());
+        Assertions.assertEquals(BODY, jsonArray.toString());
+    }
+
+    @Test
+    public void testInputStreamToJsonArray() {
+        InputStream inputStream = context.getTypeConverter().convertTo(InputStream.class, BODY);
+        JsonArray jsonArray = context.getTypeConverter().convertTo(JsonArray.class, inputStream);
+        Assertions.assertEquals(BODY, jsonArray.toString());
+    }
+
+    @Test
+    public void testJsonArrayToBuffer() {
+        Buffer result = context.getTypeConverter().convertTo(Buffer.class, Buffer.buffer(BODY).toJsonArray());
+        Assertions.assertEquals(BODY, result.toString());
+    }
+
+    @Test
+    public void testJsonArrayToString() {
+        String result = context.getTypeConverter().convertTo(String.class, Buffer.buffer(BODY).toJsonArray());
+        Assertions.assertEquals(BODY, result);
+    }
+
+    @Test
+    public void testJsonArrayToByteArray() {
+        byte[] result = context.getTypeConverter().convertTo(byte[].class, Buffer.buffer(BODY.getBytes()).toJsonArray());
+        Assertions.assertEquals(BODY, new String(result));
+    }
+
+    @Test
+    public void testJsonArrayToList() {
+        List result = context.getTypeConverter().convertTo(List.class, Buffer.buffer(BODY).toJsonArray());
+        Assertions.assertEquals(BODY, new JsonArray(result).toString());
+    }
+}
diff --git a/components/camel-vertx/src/test/java/org/apache/camel/component/vertx/VertxJsonObjectConverterTest.java b/components/camel-vertx/src/test/java/org/apache/camel/component/vertx/VertxJsonObjectConverterTest.java
new file mode 100644
index 0000000..4a878f1
--- /dev/null
+++ b/components/camel-vertx/src/test/java/org/apache/camel/component/vertx/VertxJsonObjectConverterTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.vertx;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import io.netty.buffer.Unpooled;
+import io.vertx.core.buffer.Buffer;
+import io.vertx.core.json.JsonObject;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class VertxJsonObjectConverterTest extends CamelTestSupport {
+
+    private static final String BODY = "{\"Hello\":\"World\"}";
+
+    @Test
+    public void testBufferToJsonObject() {
+        JsonObject jsonObject = context.getTypeConverter().convertTo(JsonObject.class, Buffer.buffer(BODY));
+        Assertions.assertEquals(BODY, jsonObject.toString());
+    }
+
+    @Test
+    public void testStringToJsonObject() {
+        JsonObject jsonObject = context.getTypeConverter().convertTo(JsonObject.class, BODY);
+        Assertions.assertEquals(BODY, jsonObject.toString());
+    }
+
+    @Test
+    public void testByteArrayToJsonObject() {
+        JsonObject jsonObject = context.getTypeConverter().convertTo(JsonObject.class, BODY.getBytes());
+        Assertions.assertEquals(BODY, jsonObject.toString());
+    }
+
+    @Test
+    public void testByteBufToJsonObject() {
+        JsonObject jsonObject = context.getTypeConverter().convertTo(JsonObject.class, Unpooled.wrappedBuffer(BODY.getBytes()));
+        Assertions.assertEquals(BODY, jsonObject.toString());
+    }
+
+    @Test
+    public void testMapArrayToJsonObject() {
+        JsonObject jsonObject = context.getTypeConverter().convertTo(JsonObject.class, new JsonObject(BODY).getMap());
+        Assertions.assertEquals(BODY, jsonObject.toString());
+    }
+
+    @Test
+    public void testInputStreamToJsonObject() {
+        InputStream inputStream = context.getTypeConverter().convertTo(InputStream.class, BODY);
+        JsonObject jsonObject = context.getTypeConverter().convertTo(JsonObject.class, inputStream);
+        Assertions.assertEquals(BODY, jsonObject.toString());
+    }
+
+    @Test
+    public void testJsonObjectToBuffer() {
+        Buffer result = context.getTypeConverter().convertTo(Buffer.class, Buffer.buffer(BODY).toJsonObject());
+        Assertions.assertEquals(BODY, result.toString());
+    }
+
+    @Test
+    public void testJsonObjectToString() {
+        String result = context.getTypeConverter().convertTo(String.class, Buffer.buffer(BODY).toJsonObject());
+        Assertions.assertEquals(BODY, result);
+    }
+
+    @Test
+    public void testJsonObjectToByteArray() {
+        byte[] result = context.getTypeConverter().convertTo(byte[].class, Buffer.buffer(BODY.getBytes()).toJsonObject());
+        Assertions.assertEquals(BODY, new String(result));
+    }
+
+    @Test
+    public void testJsonObjectToMap() {
+        Map<String, Object> result = context.getTypeConverter().convertTo(Map.class, Buffer.buffer(BODY).toJsonObject());
+        Assertions.assertEquals(BODY, new JsonObject(result).toString());
+    }
+}