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 2022/12/02 08:08:52 UTC

[camel-kamelets] 20/28: Move AWS S3 binary output type to generic level

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-kamelets.git

commit 606adff22fe9165d6372d35440640b594e63f3c7
Author: Christoph Deppisch <cd...@redhat.com>
AuthorDate: Tue Nov 29 09:53:51 2022 +0100

    Move AWS S3 binary output type to generic level
---
 .../utils/format/DefaultDataTypeConverter.java     | 10 +++-
 .../utils/format/DefaultDataTypeRegistry.java      | 15 ++++--
 .../converter/aws2/s3/AWS2S3BinaryOutputType.java  | 55 ----------------------
 .../format/converter/standard/BinaryDataType.java  | 38 +++++++++++++++
 .../format/converter/standard/StringDataType.java  | 38 +++++++++++++++
 .../converter/{aws2-s3-binary => camel-binary}     |  2 +-
 .../converter/{aws2-s3-binary => camel-jsonObject} |  2 +-
 .../converter/{aws2-s3-binary => camel-string}     |  2 +-
 .../utils/format/DefaultDataTypeRegistryTest.java  |  8 ++--
 .../BinaryDataTypeTest.java}                       | 41 +++++++++-------
 .../StringDataTypeTest.java}                       | 49 +++++++++----------
 11 files changed, 150 insertions(+), 110 deletions(-)

diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeConverter.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeConverter.java
index 9f2c31ce..b639ceae 100644
--- a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeConverter.java
+++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeConverter.java
@@ -17,9 +17,12 @@
 
 package org.apache.camel.kamelets.utils.format;
 
+import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
 import org.apache.camel.kamelets.utils.format.spi.annotations.DataType;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Default data type converter receives a name and a target type in order to use traditional exchange body conversion
@@ -53,7 +56,12 @@ public class DefaultDataTypeConverter implements DataTypeConverter {
             return;
         }
 
-        exchange.getMessage().setBody(exchange.getMessage().getBody(type));
+        try {
+            exchange.getMessage().setBody(exchange.getMessage().getMandatoryBody(type));
+        } catch (InvalidPayloadException e) {
+            throw new CamelExecutionException(String.format("Failed to convert exchange body to '%s' content using type %s",
+                    name, ObjectHelper.name(type)), exchange, e);
+        }
     }
 
     @Override
diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistry.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistry.java
index 3d5b514e..1e530468 100644
--- a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistry.java
+++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistry.java
@@ -26,6 +26,9 @@ import java.util.Optional;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.kamelets.utils.format.converter.standard.BinaryDataType;
+import org.apache.camel.kamelets.utils.format.converter.standard.JsonModelDataType;
+import org.apache.camel.kamelets.utils.format.converter.standard.StringDataType;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeConverterResolver;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeLoader;
@@ -55,6 +58,7 @@ public class DefaultDataTypeRegistry extends ServiceSupport implements DataTypeR
     private DataTypeConverterResolver dataTypeConverterResolver;
 
     private boolean classpathScan = true;
+    private boolean useDefaultConverters = true;
 
     private final Map<String, List<DataTypeConverter>> dataTypeConverters = new HashMap<>();
 
@@ -100,11 +104,12 @@ public class DefaultDataTypeRegistry extends ServiceSupport implements DataTypeR
 
         if (classpathScan) {
             dataTypeLoaders.add(new AnnotationDataTypeLoader());
+        } else if (useDefaultConverters) {
+            addDataTypeConverter(new BinaryDataType());
+            addDataTypeConverter(new StringDataType());
+            addDataTypeConverter(new JsonModelDataType());
         }
 
-        addDataTypeConverter(new DefaultDataTypeConverter(DataType.DEFAULT_SCHEME, "string", "text/plain", String.class));
-        addDataTypeConverter(new DefaultDataTypeConverter(DataType.DEFAULT_SCHEME, "binary", "application/octet-stream", byte[].class));
-
         for (DataTypeLoader loader : dataTypeLoaders) {
             CamelContextAware.trySetCamelContext(loader, getCamelContext());
             loader.load(this);
@@ -180,6 +185,10 @@ public class DefaultDataTypeRegistry extends ServiceSupport implements DataTypeR
         this.classpathScan = classpathScan;
     }
 
+    public void setUseDefaultConverters(boolean useDefaultConverters) {
+        this.useDefaultConverters = useDefaultConverters;
+    }
+
     @Override
     public CamelContext getCamelContext() {
         return camelContext;
diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputType.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputType.java
deleted file mode 100644
index 5f1fa0b8..00000000
--- a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputType.java
+++ /dev/null
@@ -1,55 +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.kamelets.utils.format.converter.aws2.s3;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
-import org.apache.camel.kamelets.utils.format.spi.annotations.DataType;
-import software.amazon.awssdk.utils.IoUtils;
-
-/**
- * Binary output type.
- */
-@DataType(scheme = "aws2-s3", name = "binary", mediaType = "application/octet-stream")
-public class AWS2S3BinaryOutputType implements DataTypeConverter {
-
-    @Override
-    public void convert(Exchange exchange) {
-        if (exchange.getMessage().getBody() instanceof byte[]) {
-            return;
-        }
-
-        try {
-            InputStream is = exchange.getMessage().getBody(InputStream.class);
-            if (is != null) {
-                exchange.getMessage().setBody(IoUtils.toByteArray(is));
-                return;
-            }
-
-            // Use default Camel converter utils to convert body to byte[]
-            exchange.getMessage().setBody(exchange.getMessage().getMandatoryBody(byte[].class));
-        } catch (IOException | InvalidPayloadException e) {
-            throw new CamelExecutionException("Failed to convert AWS S3 body to byte[]", exchange, e);
-        }
-    }
-}
diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/standard/BinaryDataType.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/standard/BinaryDataType.java
new file mode 100644
index 00000000..532e998b
--- /dev/null
+++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/standard/BinaryDataType.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.kamelets.utils.format.converter.standard;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.kamelets.utils.format.DefaultDataTypeConverter;
+import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
+import org.apache.camel.kamelets.utils.format.spi.annotations.DataType;
+
+/**
+ * Binary data type.
+ */
+@DataType(name = "binary", mediaType = "application/octet-stream")
+public class BinaryDataType implements DataTypeConverter {
+
+    private static final DataTypeConverter DELEGATE =
+            new DefaultDataTypeConverter(DataType.DEFAULT_SCHEME, "binary", "application/octet-stream", byte[].class);
+
+    @Override
+    public void convert(Exchange exchange) {
+        DELEGATE.convert(exchange);
+    }
+}
diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/standard/StringDataType.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/standard/StringDataType.java
new file mode 100644
index 00000000..d60b2aaa
--- /dev/null
+++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/standard/StringDataType.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.kamelets.utils.format.converter.standard;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.kamelets.utils.format.DefaultDataTypeConverter;
+import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
+import org.apache.camel.kamelets.utils.format.spi.annotations.DataType;
+
+/**
+ * String data type.
+ */
+@DataType(name = "string", mediaType = "text/plain")
+public class StringDataType implements DataTypeConverter {
+
+    private static final DataTypeConverter DELEGATE =
+            new DefaultDataTypeConverter(DataType.DEFAULT_SCHEME, "string", "text/plain", String.class);
+
+    @Override
+    public void convert(Exchange exchange) {
+        DELEGATE.convert(exchange);
+    }
+}
diff --git a/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary b/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-binary
similarity index 90%
copy from library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary
copy to library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-binary
index ba9c13f3..edf9a4ca 100644
--- a/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary
+++ b/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-binary
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.kamelets.utils.format.converter.aws2.s3.AWS2S3BinaryOutputType
\ No newline at end of file
+class=org.apache.camel.kamelets.utils.format.converter.standard.BinaryDataType
\ No newline at end of file
diff --git a/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary b/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-jsonObject
similarity index 90%
copy from library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary
copy to library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-jsonObject
index ba9c13f3..2f725f6a 100644
--- a/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary
+++ b/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-jsonObject
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.kamelets.utils.format.converter.aws2.s3.AWS2S3BinaryOutputType
\ No newline at end of file
+class=org.apache.camel.kamelets.utils.format.converter.standard.JsonModelDataType
\ No newline at end of file
diff --git a/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary b/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-string
similarity index 90%
rename from library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary
rename to library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-string
index ba9c13f3..8ef25725 100644
--- a/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/aws2-s3-binary
+++ b/library/camel-kamelets-utils/src/main/resources/META-INF/services/org/apache/camel/datatype/converter/camel-string
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.kamelets.utils.format.converter.aws2.s3.AWS2S3BinaryOutputType
\ No newline at end of file
+class=org.apache.camel.kamelets.utils.format.converter.standard.StringDataType
\ No newline at end of file
diff --git a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistryTest.java b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistryTest.java
index c72e7897..d83c474b 100644
--- a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistryTest.java
+++ b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/DefaultDataTypeRegistryTest.java
@@ -21,7 +21,9 @@ import java.util.Optional;
 
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.kamelets.utils.format.converter.standard.BinaryDataType;
 import org.apache.camel.kamelets.utils.format.converter.standard.JsonModelDataType;
+import org.apache.camel.kamelets.utils.format.converter.standard.StringDataType;
 import org.apache.camel.kamelets.utils.format.converter.test.UppercaseDataType;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
 import org.junit.jupiter.api.Assertions;
@@ -44,12 +46,10 @@ class DefaultDataTypeRegistryTest {
         Assertions.assertEquals(JsonModelDataType.class, converter.get().getClass());
         converter = dataTypeRegistry.lookup( "string");
         Assertions.assertTrue(converter.isPresent());
-        Assertions.assertEquals(DefaultDataTypeConverter.class, converter.get().getClass());
-        Assertions.assertEquals(String.class, ((DefaultDataTypeConverter) converter.get()).getType());
+        Assertions.assertEquals(StringDataType.class, converter.get().getClass());
         converter = dataTypeRegistry.lookup( "binary");
         Assertions.assertTrue(converter.isPresent());
-        Assertions.assertEquals(DefaultDataTypeConverter.class, converter.get().getClass());
-        Assertions.assertEquals(byte[].class, ((DefaultDataTypeConverter) converter.get()).getType());
+        Assertions.assertEquals(BinaryDataType.class, converter.get().getClass());
         converter = dataTypeRegistry.lookup( "lowercase");
         Assertions.assertTrue(converter.isPresent());
         converter = dataTypeRegistry.lookup( "uppercase");
diff --git a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputTypeTest.java b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/standard/BinaryDataTypeTest.java
similarity index 72%
copy from library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputTypeTest.java
copy to library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/standard/BinaryDataTypeTest.java
index 26b359f4..d2dd616a 100644
--- a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputTypeTest.java
+++ b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/standard/BinaryDataTypeTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.kamelets.utils.format.converter.aws2.s3;
+package org.apache.camel.kamelets.utils.format.converter.standard;
 
 import java.io.ByteArrayInputStream;
 import java.nio.charset.StandardCharsets;
@@ -22,32 +22,40 @@ import java.util.Optional;
 
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Exchange;
-import org.apache.camel.component.aws2.s3.AWS2S3Constants;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.kamelets.utils.format.DefaultDataTypeRegistry;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
-import software.amazon.awssdk.core.ResponseInputStream;
-import software.amazon.awssdk.http.AbortableInputStream;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-public class AWS2S3BinaryOutputTypeTest {
+public class BinaryDataTypeTest {
 
     private final DefaultCamelContext camelContext = new DefaultCamelContext();
 
-    private final AWS2S3BinaryOutputType outputType = new AWS2S3BinaryOutputType();
+    private final BinaryDataType dataType = new BinaryDataType();
+
+    @Test
+    void shouldRetainBytesModel() throws Exception {
+        Exchange exchange = new DefaultExchange(camelContext);
+
+        exchange.getMessage().setHeader("file", "test.txt");
+        exchange.getMessage().setBody("Test".getBytes(StandardCharsets.UTF_8));
+        dataType.convert(exchange);
+
+        Assertions.assertTrue(exchange.getMessage().hasHeaders());
+        assertBinaryBody(exchange, "test.txt", "Test");
+    }
 
     @Test
     void shouldMapFromStringToBytesModel() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
-        exchange.getMessage().setHeader(AWS2S3Constants.KEY, "test1.txt");
+        exchange.getMessage().setHeader("file", "test1.txt");
         exchange.getMessage().setBody("Test1");
-        outputType.convert(exchange);
+        dataType.convert(exchange);
 
         Assertions.assertTrue(exchange.getMessage().hasHeaders());
         assertBinaryBody(exchange, "test1.txt", "Test1");
@@ -57,9 +65,9 @@ public class AWS2S3BinaryOutputTypeTest {
     void shouldMapFromBytesToBytesModel() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
-        exchange.getMessage().setHeader(AWS2S3Constants.KEY, "test2.txt");
+        exchange.getMessage().setHeader("file", "test2.txt");
         exchange.getMessage().setBody("Test2".getBytes(StandardCharsets.UTF_8));
-        outputType.convert(exchange);
+        dataType.convert(exchange);
 
         Assertions.assertTrue(exchange.getMessage().hasHeaders());
         assertBinaryBody(exchange, "test2.txt", "Test2");
@@ -69,10 +77,9 @@ public class AWS2S3BinaryOutputTypeTest {
     void shouldMapFromInputStreamToBytesModel() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
-        exchange.getMessage().setHeader(AWS2S3Constants.KEY, "test3.txt");
-        exchange.getMessage().setBody(new ResponseInputStream<>(GetObjectRequest.builder().bucket("myBucket").key("test3.txt").build(),
-                AbortableInputStream.create(new ByteArrayInputStream("Test3".getBytes(StandardCharsets.UTF_8)))));
-        outputType.convert(exchange);
+        exchange.getMessage().setHeader("file", "test3.txt");
+        exchange.getMessage().setBody(new ByteArrayInputStream("Test3".getBytes(StandardCharsets.UTF_8)));
+        dataType.convert(exchange);
 
         Assertions.assertTrue(exchange.getMessage().hasHeaders());
         assertBinaryBody(exchange, "test3.txt", "Test3");
@@ -82,12 +89,12 @@ public class AWS2S3BinaryOutputTypeTest {
     public void shouldLookupDataType() throws Exception {
         DefaultDataTypeRegistry dataTypeRegistry = new DefaultDataTypeRegistry();
         CamelContextAware.trySetCamelContext(dataTypeRegistry, camelContext);
-        Optional<DataTypeConverter> converter = dataTypeRegistry.lookup("aws2-s3", "binary");
+        Optional<DataTypeConverter> converter = dataTypeRegistry.lookup( "binary");
         Assertions.assertTrue(converter.isPresent());
     }
 
     private static void assertBinaryBody(Exchange exchange, String key, String content) {
-        assertEquals(key, exchange.getMessage().getHeader(AWS2S3Constants.KEY));
+        assertEquals(key, exchange.getMessage().getHeader("file"));
 
         assertEquals(byte[].class, exchange.getMessage().getBody().getClass());
         assertEquals(content, exchange.getMessage().getBody(String.class));
diff --git a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputTypeTest.java b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/standard/StringDataTypeTest.java
similarity index 58%
rename from library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputTypeTest.java
rename to library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/standard/StringDataTypeTest.java
index 26b359f4..8ee19cba 100644
--- a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/aws2/s3/AWS2S3BinaryOutputTypeTest.java
+++ b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/format/converter/standard/StringDataTypeTest.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.kamelets.utils.format.converter.aws2.s3;
+package org.apache.camel.kamelets.utils.format.converter.standard;
 
 import java.io.ByteArrayInputStream;
 import java.nio.charset.StandardCharsets;
@@ -22,74 +22,69 @@ import java.util.Optional;
 
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Exchange;
-import org.apache.camel.component.aws2.s3.AWS2S3Constants;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.kamelets.utils.format.DefaultDataTypeRegistry;
 import org.apache.camel.kamelets.utils.format.spi.DataTypeConverter;
 import org.apache.camel.support.DefaultExchange;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
-import software.amazon.awssdk.core.ResponseInputStream;
-import software.amazon.awssdk.http.AbortableInputStream;
-import software.amazon.awssdk.services.s3.model.GetObjectRequest;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-public class AWS2S3BinaryOutputTypeTest {
+public class StringDataTypeTest {
 
     private final DefaultCamelContext camelContext = new DefaultCamelContext();
 
-    private final AWS2S3BinaryOutputType outputType = new AWS2S3BinaryOutputType();
+    private final StringDataType dataType = new StringDataType();
 
     @Test
-    void shouldMapFromStringToBytesModel() throws Exception {
+    void shouldRetainStringModel() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
-        exchange.getMessage().setHeader(AWS2S3Constants.KEY, "test1.txt");
-        exchange.getMessage().setBody("Test1");
-        outputType.convert(exchange);
+        exchange.getMessage().setHeader("file", "test.txt");
+        exchange.getMessage().setBody("Test");
+        dataType.convert(exchange);
 
         Assertions.assertTrue(exchange.getMessage().hasHeaders());
-        assertBinaryBody(exchange, "test1.txt", "Test1");
+        assertStringBody(exchange, "test.txt", "Test");
     }
 
     @Test
-    void shouldMapFromBytesToBytesModel() throws Exception {
+    void shouldMapFromBinaryToStringModel() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
-        exchange.getMessage().setHeader(AWS2S3Constants.KEY, "test2.txt");
-        exchange.getMessage().setBody("Test2".getBytes(StandardCharsets.UTF_8));
-        outputType.convert(exchange);
+        exchange.getMessage().setHeader("file", "test1.txt");
+        exchange.getMessage().setBody("Test1".getBytes(StandardCharsets.UTF_8));
+        dataType.convert(exchange);
 
         Assertions.assertTrue(exchange.getMessage().hasHeaders());
-        assertBinaryBody(exchange, "test2.txt", "Test2");
+        assertStringBody(exchange, "test1.txt", "Test1");
     }
 
     @Test
-    void shouldMapFromInputStreamToBytesModel() throws Exception {
+    void shouldMapFromInputStreamToStringModel() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
-        exchange.getMessage().setHeader(AWS2S3Constants.KEY, "test3.txt");
-        exchange.getMessage().setBody(new ResponseInputStream<>(GetObjectRequest.builder().bucket("myBucket").key("test3.txt").build(),
-                AbortableInputStream.create(new ByteArrayInputStream("Test3".getBytes(StandardCharsets.UTF_8)))));
-        outputType.convert(exchange);
+        exchange.getMessage().setHeader("file", "test3.txt");
+        exchange.getMessage().setBody(new ByteArrayInputStream("Test3".getBytes(StandardCharsets.UTF_8)));
+        dataType.convert(exchange);
 
         Assertions.assertTrue(exchange.getMessage().hasHeaders());
-        assertBinaryBody(exchange, "test3.txt", "Test3");
+        assertStringBody(exchange, "test3.txt", "Test3");
     }
 
     @Test
     public void shouldLookupDataType() throws Exception {
         DefaultDataTypeRegistry dataTypeRegistry = new DefaultDataTypeRegistry();
         CamelContextAware.trySetCamelContext(dataTypeRegistry, camelContext);
-        Optional<DataTypeConverter> converter = dataTypeRegistry.lookup("aws2-s3", "binary");
+        Optional<DataTypeConverter> converter = dataTypeRegistry.lookup( "string");
         Assertions.assertTrue(converter.isPresent());
     }
 
-    private static void assertBinaryBody(Exchange exchange, String key, String content) {
-        assertEquals(key, exchange.getMessage().getHeader(AWS2S3Constants.KEY));
+    private static void assertStringBody(Exchange exchange, String key, String content) {
+        assertEquals(key, exchange.getMessage().getHeader("file"));
 
-        assertEquals(byte[].class, exchange.getMessage().getBody().getClass());
+        assertEquals(String.class, exchange.getMessage().getBody().getClass());
         assertEquals(content, exchange.getMessage().getBody(String.class));
     }
 }