This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new d253b1c9c1 Add Mino test for body as InputStream
d253b1c9c1 is described below
commit d253b1c9c17b26b889c22e0f53edfb4fe750ce16
Author: James Netherton <[email protected]>
AuthorDate: Mon Mar 2 10:36:05 2026 +0000
Add Mino test for body as InputStream
---
integration-tests/minio/pom.xml | 17 +++++++++
.../quarkus/component/minio/it/MinioResource.java | 13 ++-----
.../quarkus/component/minio/it/MinioRoutes.java | 44 ++++++++++++++++++++++
.../quarkus/component/minio/it/MinioTest.java | 23 +++++++++++
4 files changed, 88 insertions(+), 9 deletions(-)
diff --git a/integration-tests/minio/pom.xml b/integration-tests/minio/pom.xml
index 75b8071a37..2db3225af4 100644
--- a/integration-tests/minio/pom.xml
+++ b/integration-tests/minio/pom.xml
@@ -35,6 +35,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-minio</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest</artifactId>
+ </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
@@ -108,6 +112,19 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-rest-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
</profile>
<profile>
diff --git
a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioResource.java
b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioResource.java
index 74763f768a..d5fa33232d 100644
---
a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioResource.java
+++
b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioResource.java
@@ -38,7 +38,6 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
-import org.apache.camel.CamelContext;
import org.apache.camel.ConsumerTemplate;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
@@ -60,9 +59,6 @@ public class MinioResource {
@Inject
ConsumerTemplate consumerTemplate;
- @Inject
- CamelContext camelContext;
-
@Path("/consumerWithClientCreation/{endpoint}")
@GET
@Produces(MediaType.TEXT_PLAIN)
@@ -84,10 +80,9 @@ public class MinioResource {
@Produces(MediaType.TEXT_PLAIN)
public String consumer() {
- final String message = consumerTemplate.receiveBody(
+ return consumerTemplate.receiveBody(
"minio://mycamel?moveAfterRead=true&destinationBucketName=movedafterread",
5000, String.class);
- return message;
}
@Path("/consumeAndMove/{removeHeader}")
@@ -183,7 +178,7 @@ public class MinioResource {
.build();
}
formatResult(length, offset, objectList, sb, errorSB);
- var respBuilder = errorSB.length() > 0 ?
Response.status(500).entity(errorSB.toString())
+ var respBuilder = !errorSB.isEmpty() ?
Response.status(500).entity(errorSB.toString())
: Response.ok().entity(sb.toString());
return respBuilder.build();
}
@@ -192,7 +187,7 @@ public class MinioResource {
objectList.forEach(r -> {
try {
if (r instanceof Result) {
- Object o = ((Result) r).get();
+ Object o = ((Result<?>) r).get();
if (o instanceof Item) {
sb.append("item: ").append(((Item) o).objectName());
} else {
@@ -221,7 +216,7 @@ public class MinioResource {
private Map<String, Object> deserializeMap(String parametersString) {
return Arrays.stream(parametersString.split(","))
- .map(s -> new Pair<String>(s.split(":")[0], s.split(":")[1]))
+ .map(s -> new Pair<>(s.split(":")[0], s.split(":")[1]))
.map(p -> {
switch (p.getLeft()) {
case MinioConstants.OFFSET:
diff --git
a/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioRoutes.java
b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioRoutes.java
new file mode 100644
index 0000000000..f04b1334b7
--- /dev/null
+++
b/integration-tests/minio/src/main/java/org/apache/camel/quarkus/component/minio/it/MinioRoutes.java
@@ -0,0 +1,44 @@
+/*
+ * 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.minio.it;
+
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.minio.MinioConstants;
+
+public class MinioRoutes extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ rest()
+ .put("/api/minio")
+ .to("direct:put");
+
+ from("direct:put")
+ .log(LoggingLevel.INFO, "Processing ${id}")
+ .log(LoggingLevel.INFO, "Headers (before): ${headers}")
+ .log(LoggingLevel.INFO, "Body (before): ${body}")
+
+ // TODO: Remove this -
https://github.com/apache/camel-quarkus/issues/8355
+
.setHeader(MinioConstants.CONTENT_LENGTH).simple("${header.Content-Length}")
+ .setHeader(MinioConstants.OBJECT_NAME,
simple("${header.objectName}"))
+
+ .log(LoggingLevel.INFO, "Headers (in between): ${headers}")
+ .log(LoggingLevel.INFO, "Body (in between): ${body}")
+
+ .toD("minio:${header.bucketName}?minioClient=#minioClient");
+ }
+}
diff --git
a/integration-tests/minio/src/test/java/org/apache/camel/quarkus/component/minio/it/MinioTest.java
b/integration-tests/minio/src/test/java/org/apache/camel/quarkus/component/minio/it/MinioTest.java
index 1a12f033c5..c4ee421057 100644
---
a/integration-tests/minio/src/test/java/org/apache/camel/quarkus/component/minio/it/MinioTest.java
+++
b/integration-tests/minio/src/test/java/org/apache/camel/quarkus/component/minio/it/MinioTest.java
@@ -26,6 +26,8 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import io.minio.BucketExistsArgs;
+import io.minio.GetObjectArgs;
+import io.minio.GetObjectResponse;
import io.minio.MakeBucketArgs;
import io.minio.MinioClient;
import io.minio.PutObjectArgs;
@@ -44,6 +46,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
@QuarkusTest
@QuarkusTestResource(MinioTestResource.class)
@@ -376,6 +379,26 @@ class MinioTest {
.body(containsString("true"));
}
+ @Test
+ void contentAsInputStream() throws Exception {
+ String bucketName = "input-stream-test";
+ String objectName = "Some Content As InputStream";
+
+ RestAssured.given()
+ .queryParam("bucketName", bucketName)
+ .queryParam("objectName", objectName)
+ .body(objectName)
+ .put("/api/minio")
+ .then()
+ .statusCode(200);
+
+ minioClient = initClient(bucketName);
+ GetObjectResponse response =
minioClient.getObject(GetObjectArgs.builder().bucket(bucketName)
+ .object(objectName)
+ .build());
+ assertEquals(objectName, response.object());
+ }
+
private static String params(Object... os) {
return Stream.concat(Arrays.stream(new String[] { os[0].toString() }),
IntStream.range(1, os.length)