You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ap...@apache.org on 2026/01/29 07:51:39 UTC
(camel-quarkus) branch main updated (816604dfae -> 8d597871b7)
This is an automated email from the ASF dual-hosted git repository.
apupier pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
from 816604dfae Upgrade Quarkus to 3.31.1
new 200556026e Factorize code in DoclingResource for convert action
new 8d597871b7 Add docling test with cli mode
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../docling/Readme.md | 9 +-
.../component/docling/it/DoclingResource.java | 95 +++++++---------------
.../component/docling/it/DoclingRoutes.java | 3 +
.../quarkus/component/docling/it/DoclingTest.java | 16 ++++
4 files changed, 49 insertions(+), 74 deletions(-)
copy integration-test-groups/xml/native/xslt-classpath/src/main/resources/xslt/include.xsl => integration-tests/docling/Readme.md (78%)
(camel-quarkus) 01/02: Factorize code in DoclingResource for convert action
Posted by ap...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 200556026e3fce6602bdbe600992de70fa4e24ec
Author: Aurélien Pupier <ap...@ibm.com>
AuthorDate: Wed Jan 28 16:10:55 2026 +0100
Factorize code in DoclingResource for convert action
Signed-off-by: Aurélien Pupier <ap...@ibm.com>
---
.../component/docling/it/DoclingResource.java | 87 ++++++----------------
1 file changed, 21 insertions(+), 66 deletions(-)
diff --git a/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java b/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java
index f2196437e5..2b95f86f20 100644
--- a/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java
+++ b/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java
@@ -57,17 +57,7 @@ public class DoclingResource {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response convertToMarkdown(String documentContent) throws IOException {
- java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
- Files.writeString(tempFile, documentContent);
- try {
- String result = producerTemplate.requestBody("direct:convertToMarkdown", tempFile.toString(), String.class);
- return Response.ok(result).build();
- } catch (Exception e) {
- LOG.error("Failed to convert to markdown", e);
- return Response.status(500).entity("Error: " + e.getMessage()).build();
- } finally {
- Files.deleteIfExists(tempFile);
- }
+ return convert(documentContent, "direct:convertToMarkdown", "Failed to convert to markdown");
}
@Path("/convert/html")
@@ -75,17 +65,7 @@ public class DoclingResource {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_HTML)
public Response convertToHtml(String documentContent) throws IOException {
- java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
- Files.writeString(tempFile, documentContent);
- try {
- String result = producerTemplate.requestBody("direct:convertToHtml", tempFile.toString(), String.class);
- return Response.ok(result).build();
- } catch (Exception e) {
- LOG.error("Failed to convert to HTML", e);
- return Response.status(500).entity("Error: " + e.getMessage()).build();
- } finally {
- Files.deleteIfExists(tempFile);
- }
+ return convert(documentContent, "direct:convertToHtml", "Failed to convert to HTML");
}
@Path("/extract/text")
@@ -135,17 +115,7 @@ public class DoclingResource {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public Response convertToJson(String documentContent) throws IOException {
- java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
- Files.writeString(tempFile, documentContent);
- try {
- String result = producerTemplate.requestBody("direct:convertToJson", tempFile.toString(), String.class);
- return Response.ok(result).build();
- } catch (Exception e) {
- LOG.error("Failed to convert to JSON", e);
- return Response.status(500).entity("Error: " + e.getMessage()).build();
- } finally {
- Files.deleteIfExists(tempFile);
- }
+ return convert(documentContent, "direct:convertToJson", "Failed to convert to JSON");
}
@Path("/async/convert/markdown")
@@ -153,17 +123,7 @@ public class DoclingResource {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response convertToMarkdownAsync(String documentContent) throws IOException {
- java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
- Files.writeString(tempFile, documentContent);
- try {
- String result = producerTemplate.requestBody("direct:convertToMarkdownAsync", tempFile.toString(), String.class);
- return Response.ok(result).build();
- } catch (Exception e) {
- LOG.error("Failed to convert to markdown async", e);
- return Response.status(500).entity("Error: " + e.getMessage()).build();
- } finally {
- Files.deleteIfExists(tempFile);
- }
+ return convert(documentContent, "direct:convertToMarkdownAsync", "Failed to convert to markdown async");
}
@Path("/async/convert/html")
@@ -171,17 +131,7 @@ public class DoclingResource {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_HTML)
public Response convertToHtmlAsync(String documentContent) throws IOException {
- java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
- Files.writeString(tempFile, documentContent);
- try {
- String result = producerTemplate.requestBody("direct:convertToHtmlAsync", tempFile.toString(), String.class);
- return Response.ok(result).build();
- } catch (Exception e) {
- LOG.error("Failed to convert to HTML async", e);
- return Response.status(500).entity("Error: " + e.getMessage()).build();
- } finally {
- Files.deleteIfExists(tempFile);
- }
+ return convert(documentContent, "direct:convertToHtmlAsync", "Failed to convert to HTML async");
}
@Path("/async/convert/json")
@@ -189,17 +139,7 @@ public class DoclingResource {
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public Response convertToJsonAsync(String documentContent) throws IOException {
- java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
- Files.writeString(tempFile, documentContent);
- try {
- String result = producerTemplate.requestBody("direct:convertToJsonAsync", tempFile.toString(), String.class);
- return Response.ok(result).build();
- } catch (Exception e) {
- LOG.error("Failed to convert to JSON async", e);
- return Response.status(500).entity("Error: " + e.getMessage()).build();
- } finally {
- Files.deleteIfExists(tempFile);
- }
+ return convert(documentContent, "direct:convertToJsonAsync", "Failed to convert to JSON async");
}
@Path("/metadata/extract")
@@ -232,4 +172,19 @@ public class DoclingResource {
}
}
}
+
+ private Response convert(String documentContent, String endpointUri, String logErrorMessage) throws IOException {
+ java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
+ Files.writeString(tempFile, documentContent);
+ try {
+ String result = producerTemplate.requestBody(endpointUri, tempFile.toString(), String.class);
+ return Response.ok(result).build();
+ } catch (Exception e) {
+ LOG.error(logErrorMessage, e);
+ return Response.status(500).entity("Error: " + e.getMessage()).build();
+ } finally {
+ Files.deleteIfExists(tempFile);
+ }
+ }
+
}
(camel-quarkus) 02/02: Add docling test with cli mode
Posted by ap...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 8d597871b78b9bcc00e64683d0f682a0dec8b981
Author: Aurélien Pupier <ap...@ibm.com>
AuthorDate: Wed Jan 28 16:37:05 2026 +0100
Add docling test with cli mode
the test is not activated by default to avoid the need to configure the
CI with local docling on command-line.
Signed-off-by: Aurélien Pupier <ap...@ibm.com>
---
integration-tests/docling/Readme.md | 19 +++++++++++++++++++
.../quarkus/component/docling/it/DoclingResource.java | 8 ++++++++
.../quarkus/component/docling/it/DoclingRoutes.java | 3 +++
.../quarkus/component/docling/it/DoclingTest.java | 16 ++++++++++++++++
4 files changed, 46 insertions(+)
diff --git a/integration-tests/docling/Readme.md b/integration-tests/docling/Readme.md
new file mode 100644
index 0000000000..d5984b1a38
--- /dev/null
+++ b/integration-tests/docling/Readme.md
@@ -0,0 +1,19 @@
+<!--
+
+ 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.
+
+-->
+One test requires to have docling installed, for instance with `pip install docling`. It is to test the CLI mode of the component. To activate this test, you need to set the property `docling.test.enabled` to `true`.
diff --git a/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java b/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java
index 2b95f86f20..3633edc9ec 100644
--- a/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java
+++ b/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java
@@ -173,6 +173,14 @@ public class DoclingResource {
}
}
+ @Path("/convert/json/cli")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response convertToJsonWithCLI(String documentContent) throws IOException {
+ return convert(documentContent, "direct:convertToJsonWithCLI", "Failed to convert to JSON with CLI");
+ }
+
private Response convert(String documentContent, String endpointUri, String logErrorMessage) throws IOException {
java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
Files.writeString(tempFile, documentContent);
diff --git a/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingRoutes.java b/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingRoutes.java
index e267e00c38..b0c76f33f1 100644
--- a/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingRoutes.java
+++ b/integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingRoutes.java
@@ -63,5 +63,8 @@ public class DoclingRoutes extends RouteBuilder {
from("direct:convertToJsonAsync")
.to("docling:convert?operation=CONVERT_TO_JSON&contentInBody=true&useAsyncMode=true")
.log("Converted to JSON (async): ${body}");
+
+ from("direct:convertToJsonWithCLI")
+ .to("docling:convert?operation=CONVERT_TO_JSON&contentInBody=true&useDoclingServe=false");
}
}
diff --git a/integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java b/integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java
index 26142543e9..367f3675ae 100644
--- a/integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java
+++ b/integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTest.java
@@ -22,6 +22,7 @@ import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyString;
@@ -220,4 +221,19 @@ class DoclingTest {
.statusCode(200)
.body(not(emptyString()));
}
+
+ @Test
+ @EnabledIfSystemProperty(named = "docling.test.enabled", matches = "true")
+ void convertToJsonWithCLI() {
+ String testContent = "# Test Document\nThis is a test document for JSON conversion with CLI.";
+
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(testContent)
+ .when()
+ .post("/docling/convert/json/cli")
+ .then()
+ .statusCode(200)
+ .body(not(emptyString()));
+ }
}