You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gansheer (via GitHub)" <gi...@apache.org> on 2025/11/27 11:04:13 UTC

[PR] feat: Add docling native support and integration tests [camel-quarkus]

gansheer opened a new pull request, #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010

   <!-- Uncomment and fill this section if your PR is not trivial
   [ ] An issue should be filed for the change unless this is a trivial change (fixing a typo or similar). One issue should ideally be fixed by not more than one commit and the other way round, each commit should fix just one issue, without pulling in other changes.
   [ ] Each commit in the pull request should have a meaningful and properly spelled subject line and body. Copying the title of the associated issue is typically enough. Please include the issue number in the commit message prefixed by #.
   [ ] The pull request description should explain what the pull request does, how, and why. If the info is available in the associated issue or some other external document, a link is enough.
   [ ] Phrases like Fix #<issueNumber> or Fixes #<issueNumber> will auto-close the named issue upon merging the pull request. Using them is typically a good idea.
   [ ] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [ ] Contributor guide is your good friend: https://camel.apache.org/camel-quarkus/latest/contributor-guide.html
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Add docling native support and integration tests [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton merged PR #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Add docling native support and integration tests [camel-quarkus]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on code in PR #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010#discussion_r2570812610


##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -0,0 +1,229 @@
+/*
+ * 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.docling.it;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+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.ProducerTemplate;
+import org.jboss.logging.Logger;
+
+@Path("/docling")
+@ApplicationScoped
+public class DoclingResource {
+
+    private static final Logger LOG = Logger.getLogger(DoclingResource.class);
+    private static final String COMPONENT_DOCLING = "docling";
+
+    @Inject
+    CamelContext context;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/load/component/docling")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response loadComponentDocling() {

Review Comment:
   It's a basic smoke test as far as I am concerned. In any case it can probably be removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Add docling native support and integration tests [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on code in PR #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010#discussion_r2568162114


##########
integration-tests/docling/src/test/java/org/apache/camel/quarkus/component/docling/it/DoclingTestResource.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.docling.it;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class DoclingTestResource implements QuarkusTestResourceLifecycleManager {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DoclingTestResource.class);
+    private static final String DOCLING_IMAGE = "quay.io/docling-project/docling-serve:latest";

Review Comment:
   Please define the container image name as a Maven property in the root pom.xml under [here](https://github.com/apache/camel-quarkus/blob/main/pom.xml#L229C19-L229C29). Then you can use `ConfigProvider` to look it up. See examples in other `TestResource` classes.
   
   Also, please pin to a specific tag if possible instead of `latest`.



##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.docling.it;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+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.ProducerTemplate;
+import org.jboss.logging.Logger;
+
+@Path("/docling")
+@ApplicationScoped
+public class DoclingResource {
+
+    private static final Logger LOG = Logger.getLogger(DoclingResource.class);
+    private static final String COMPONENT_DOCLING = "docling";
+
+    @Inject
+    CamelContext context;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/load/component/docling")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response loadComponentDocling() throws Exception {
+        if (context.getComponent(COMPONENT_DOCLING) != null) {
+            return Response.ok().build();
+        }
+        LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_DOCLING);
+        return Response.status(500, COMPONENT_DOCLING + " could not be loaded from the Camel context").build();
+    }
+
+    @Path("/convert/markdown")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response convertToMarkdown(String documentContent) {
+        try {
+            // Create temp file with content
+            java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
+            Files.write(tempFile, documentContent.getBytes(StandardCharsets.UTF_8));
+
+            // Send file path to Camel route
+            String result = producerTemplate.requestBody("direct:convertToMarkdown", tempFile.toString(), String.class);
+
+            // Clean up temp file
+            Files.deleteIfExists(tempFile);
+
+            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();
+        }
+    }
+
+    @Path("/convert/html")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_HTML)
+    public Response convertToHtml(String documentContent) {
+        try {
+            java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
+            Files.write(tempFile, documentContent.getBytes(StandardCharsets.UTF_8));
+            String result = producerTemplate.requestBody("direct:convertToHtml", tempFile.toString(), String.class);
+            Files.deleteIfExists(tempFile);
+            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();
+        }
+    }
+
+    @Path("/extract/text")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response extractText(String documentContent) {
+        try {
+            java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
+            Files.write(tempFile, documentContent.getBytes(StandardCharsets.UTF_8));
+            String result = producerTemplate.requestBody("direct:extractText", tempFile.toString(), String.class);
+            Files.deleteIfExists(tempFile);
+            return Response.ok(result).build();
+        } catch (Exception e) {
+            LOG.error("Failed to extract text", e);
+            return Response.status(500).entity("Error: " + e.getMessage()).build();
+        }
+    }
+
+    @Path("/test/resource")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response testResourceDocument(@QueryParam("name") String resourceName) {
+        try {
+            InputStream is = getClass().getClassLoader().getResourceAsStream(resourceName);
+            if (is == null) {
+                return Response.status(404).entity("Resource not found: " + resourceName).build();
+            }
+            String content = new String(is.readAllBytes(), StandardCharsets.UTF_8);
+            return Response.ok(content).build();
+        } catch (Exception e) {
+            LOG.error("Failed to read resource", e);
+            return Response.status(500).entity("Error: " + e.getMessage()).build();
+        }

Review Comment:
   ```suggestion
           try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourceName)) {
               if (is == null) {
                   return Response.status(404).entity("Resource not found: " + resourceName).build();
               }
               String content = new String(is.readAllBytes(), StandardCharsets.UTF_8);
               return Response.ok(content).build();
           } catch (Exception e) {
               LOG.error("Failed to read resource", e);
               return Response.status(500).entity("Error: " + e.getMessage()).build();
           }
   ```



##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.docling.it;
+
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+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.ProducerTemplate;
+import org.jboss.logging.Logger;
+
+@Path("/docling")
+@ApplicationScoped
+public class DoclingResource {
+
+    private static final Logger LOG = Logger.getLogger(DoclingResource.class);
+    private static final String COMPONENT_DOCLING = "docling";
+
+    @Inject
+    CamelContext context;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/load/component/docling")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response loadComponentDocling() throws Exception {
+        if (context.getComponent(COMPONENT_DOCLING) != null) {
+            return Response.ok().build();
+        }
+        LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_DOCLING);
+        return Response.status(500, COMPONENT_DOCLING + " could not be loaded from the Camel context").build();
+    }
+
+    @Path("/convert/markdown")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response convertToMarkdown(String documentContent) {
+        try {
+            // Create temp file with content
+            java.nio.file.Path tempFile = Files.createTempFile("docling-test", ".md");
+            Files.write(tempFile, documentContent.getBytes(StandardCharsets.UTF_8));
+
+            // Send file path to Camel route
+            String result = producerTemplate.requestBody("direct:convertToMarkdown", tempFile.toString(), String.class);
+
+            // Clean up temp file
+            Files.deleteIfExists(tempFile);

Review Comment:
   Probably better to move file cleanup into a `finally` block. Same for the other JAX-RS methods that do `deleteIfExists `.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Add docling native support and integration tests [camel-quarkus]

Posted by "aldettinger (via GitHub)" <gi...@apache.org>.
aldettinger commented on code in PR #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010#discussion_r2569670883


##########
integration-tests/docling/src/main/java/org/apache/camel/quarkus/component/docling/it/DoclingResource.java:
##########
@@ -0,0 +1,229 @@
+/*
+ * 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.docling.it;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+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.ProducerTemplate;
+import org.jboss.logging.Logger;
+
+@Path("/docling")
+@ApplicationScoped
+public class DoclingResource {
+
+    private static final Logger LOG = Logger.getLogger(DoclingResource.class);
+    private static final String COMPONENT_DOCLING = "docling";
+
+    @Inject
+    CamelContext context;
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/load/component/docling")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response loadComponentDocling() {

Review Comment:
   Do we still need this ? Maybe other tests would dected this also ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Add docling native support and integration tests [camel-quarkus]

Posted by "gansheer (via GitHub)" <gi...@apache.org>.
gansheer commented on PR #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010#issuecomment-3586141331

   @jamesnetherton I'm confused about something: the extension is now considered as Stable but that's not something I did. Did I miss something or is there some mechanism in the code that passes the extension from Preview to Stable ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: Add docling native support and integration tests [camel-quarkus]

Posted by "jamesnetherton (via GitHub)" <gi...@apache.org>.
jamesnetherton commented on PR #8010:
URL: https://github.com/apache/camel-quarkus/pull/8010#issuecomment-3586166487

   > is there some mechanism in the code that passes the extension from Preview to Stable ?
   
   Yes, the `cq:promote` mojo does it automatically. If needed, it can be overridden in the extension runtime module via a Maven property like this:
   
   https://github.com/apache/camel-quarkus/blob/main/extensions/langchain4j-agent/runtime/pom.xml#L35


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org