You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "djcoleman (via GitHub)" <gi...@apache.org> on 2023/03/10 13:05:45 UTC

[GitHub] [camel-quarkus] djcoleman opened a new pull request, #4641: camel-quarkus-language: Added language, resource and options tests

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

   Added tests for the following languages:
   - Bean
   - Constant
   - ExchangeProperty
   - File
   - Header
   - HL7Terser
   - JsonPath
   - Ref
   - Tokenize
   - XPath
   - Xquery (commented out due to NullPointerException. Fixed in CAMEL-19079 but awaiting alignment to 4.0.0-M2+)
   
   Also added tests for resource loading from `file` and `http`, as well as tests for the `contentCache` and `transform` options.
   
   [x] 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.
   [x] 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 #.
   [x] 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.
   [x] 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.
   [x] Please run mvn process-resources -Pformat (and amend the changes if necessary) before sending the pull request.
   [x] 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


[GitHub] [camel-quarkus] djcoleman commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   The File tests failed on Windows, but I don't think that's related to my changes. If everyone is happy with these changes please can someone merge the PR as I don't have permission. Thanks!


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java:
##########
@@ -23,21 +23,54 @@
 import jakarta.ws.rs.Path;
 import jakarta.ws.rs.PathParam;
 import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
 import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.ProducerTemplate;
 
 @Path("/language")
 @ApplicationScoped
 public class LanguageResource {
 
     @Inject
-    ProducerTemplate template;
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
 
     @Path("/route/{route}")
     @POST
     @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
     public String route(String body, @PathParam("route") String route) {
-        return template.requestBody("direct:" + route, body, String.class);
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
+    }
+
+    @Path("/route/languageFileScript")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeFileScript(String body) {
+        return consumerTemplate.receiveBody("direct:languageFileOutput", 5000, String.class);
+    }
+
+    @Path("/route/languageSimpleHttp")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleHttp(String body, @QueryParam("baseUrl") String baseUrl) {
+        return producerTemplate.requestBody("language:simple:resource:" + baseUrl + "/simple", body, String.class);
+    }
+
+    @Path("/route/languageSimpleContentCache")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleContentCache(String body, @QueryParam("baseUrl") String baseUrl,
+            @QueryParam("contentCache") String contentCache) {
+        String option = "?contentCache=" + contentCache;
+        String url = "language:simple:resource:" + baseUrl + "/simpleContentCache" + option;
+        System.out.println(url);

Review Comment:
   It could 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


[GitHub] [camel-quarkus] djcoleman commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java:
##########
@@ -16,35 +16,216 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
+import io.restassured.builder.RequestSpecBuilder;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.test.wiremock.MockServer;
 import org.hamcrest.Matchers;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.request;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 @QuarkusTest
+@QuarkusTestResource(LanguageTestResource.class)
 class LanguageTest {
 
-    @Test
-    public void languageSimpleScript() {
+    @MockServer
+    WireMockServer server;
+
+    /**
+     * Map endpoint names to objects containing exchange bodies and expected output
+     */
+    private static Map<String, TestResult> languageResultsMap = Map.ofEntries(
+            /* Test Languages */
+            Map.entry("languageBeanScript", new TestResult("Hello Bean", "HELLO BEAN")),
+            Map.entry("languageConstantScript", new TestResult("Constant", "Hello from constant language script")),
+            Map.entry("languageExchangePropertyScript",
+                    new TestResult("ExProperty", "Hello ExProperty from exchangeProperty language script")),
+            Map.entry("languageFileScript", new TestResult("", "File name is test-file.txt")),
+            Map.entry("languageHeaderScript", new TestResult("Header", "Hello Header from header language script")),
+            Map.entry("languageHl7terserScript", new TestResult(createHl7Message(), "Patient's surname is Smith")),
+            Map.entry("languageJsonPathScript",
+                    new TestResult("{\"message\": \"Hello from jsonpath\", \"user\": \"camel-quarkus\"}",
+                            "Hello from jsonpath")),
+            Map.entry("languageRefScript", new TestResult("Hello from Ref", "hello from ref")),
+            Map.entry("languageSimpleScript", new TestResult("Simple", "Hello Simple from simple language script")),
+            Map.entry("languageTokenizeScript", new TestResult("Hello,Tokenize", "Hello")),
+            Map.entry("languageXpathScript", new TestResult("<message>Hello from Xpath</message>", "Hello from Xpath")),
+            // Xquery test fails due to CAMEL-19079. Re-enable when CQ is aligned to Camel 4.0.0-M2
+            // Map.entry("languageXqueryScript", new TestResult("<message>Hello from XQuery</message>", "HELLO FROM XQUERY")),
+
+            /* Test Resource Loading */
+            Map.entry("languageSimpleResource", new TestResult("SimpleRes", "Hello SimpleRes from simple language resource")),
+            Map.entry("languageSimpleFile", new TestResult("SimpleFile", "Hello SimpleFile from simple language file")),
+
+            /* Test transform=false option */
+            Map.entry("languageSimpleTransform", new TestResult("SimpleTransform", "SimpleTransform"))
+
+    );
+
+    private static Collection<Object[]> getLanguageResultsMap() {
+        return languageResultsMap.entrySet()
+                .stream()
+                .map((entry) -> new Object[] { entry.getKey(), entry.getValue() })
+                .collect(Collectors.toList());
+    }
+
+    private static final String OUTPUT_DIRECTORY = "target";
+    private static final String TEST_FILE = "test-file.txt";
+    private static final String SIMPLE_FILE = "hello.simple-file.txt";
+
+    @BeforeAll
+    public static void setupTestFiles() throws Exception {
+        Files.createDirectories(Paths.get(OUTPUT_DIRECTORY));
+        // Write the file used in the 'file' language test
+        Files.writeString(Paths.get(OUTPUT_DIRECTORY, TEST_FILE), "Dummy text", StandardCharsets.UTF_8);
+
+        // Copy the simple script from resources to the OUTPUT_DIRECTORY to test reading a script from a file: resource
+        Files.copy(
+                LanguageTest.class.getClassLoader().getResourceAsStream(SIMPLE_FILE),
+                Paths.get(OUTPUT_DIRECTORY, SIMPLE_FILE),
+                StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    @AfterAll
+    public static void deleteTestFiles() throws Exception {
+        Files.delete(Paths.get(OUTPUT_DIRECTORY, TEST_FILE));
+        Files.delete(Paths.get(OUTPUT_DIRECTORY, SIMPLE_FILE));
+    }
+
+    /**
+     * This test is called for each entry in {@link languageResultsMap}.
+     * The body text is passed to the routeName endpoint, which is checked for successful completion
+     * and that the returned body matches the expected result from {@link TestResult}
+     * 
+     * @param routeName - The name of the endpoint exposed in {@link LanguageResource}
+     * @param result    - The {@link TestResource} containing input body and expected result
+     */
+    @ParameterizedTest
+    @MethodSource("getLanguageResultsMap")
+    public void testLanguage(String routeName, TestResult result) {
         RestAssured.given()
                 .contentType(ContentType.TEXT)
-                .body("Dolly")
-                .post("/language/route/languageSimpleScript")
+                .body(result.body)
+                .post("/language/route/" + routeName)
                 .then()
                 .statusCode(200)
-                .body(Matchers.is("Hello Dolly from simple language script"));
+                .body(Matchers.is(result.expected));
     }
 
+    /**
+     * Tests whether scripts can be loaded over HTTP.
+     * 
+     * @throws Exception
+     */
     @Test
-    public void languageSimpleResource() {
+    public void testHttpResource() throws Exception {
+        // Stub the WireMock server to return a simple script on the "/simple" endpoint
+        assertNotNull(server);
+        server.stubFor(request("GET", urlPathEqualTo("/simple"))

Review Comment:
   In this case, there is no existing REST service to mock. I just needed to test loading a resource over HTTP and figured a WireMock server would do the job. This is also handy in the contentCache test to ensure that the endpoints are called the expected number of times. However, I'm happy to add more comments to clarify this use case as it doesn't fit the pattern of other uses.



-- 
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


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java:
##########
@@ -16,35 +16,216 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
+import io.restassured.builder.RequestSpecBuilder;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.test.wiremock.MockServer;
 import org.hamcrest.Matchers;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.request;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 @QuarkusTest
+@QuarkusTestResource(LanguageTestResource.class)
 class LanguageTest {
 
-    @Test
-    public void languageSimpleScript() {
+    @MockServer
+    WireMockServer server;
+
+    /**
+     * Map endpoint names to objects containing exchange bodies and expected output
+     */
+    private static Map<String, TestResult> languageResultsMap = Map.ofEntries(
+            /* Test Languages */
+            Map.entry("languageBeanScript", new TestResult("Hello Bean", "HELLO BEAN")),
+            Map.entry("languageConstantScript", new TestResult("Constant", "Hello from constant language script")),
+            Map.entry("languageExchangePropertyScript",
+                    new TestResult("ExProperty", "Hello ExProperty from exchangeProperty language script")),
+            Map.entry("languageFileScript", new TestResult("", "File name is test-file.txt")),
+            Map.entry("languageHeaderScript", new TestResult("Header", "Hello Header from header language script")),
+            Map.entry("languageHl7terserScript", new TestResult(createHl7Message(), "Patient's surname is Smith")),
+            Map.entry("languageJsonPathScript",
+                    new TestResult("{\"message\": \"Hello from jsonpath\", \"user\": \"camel-quarkus\"}",
+                            "Hello from jsonpath")),
+            Map.entry("languageRefScript", new TestResult("Hello from Ref", "hello from ref")),
+            Map.entry("languageSimpleScript", new TestResult("Simple", "Hello Simple from simple language script")),
+            Map.entry("languageTokenizeScript", new TestResult("Hello,Tokenize", "Hello")),
+            Map.entry("languageXpathScript", new TestResult("<message>Hello from Xpath</message>", "Hello from Xpath")),
+            // Xquery test fails due to CAMEL-19079. Re-enable when CQ is aligned to Camel 4.0.0-M2
+            // Map.entry("languageXqueryScript", new TestResult("<message>Hello from XQuery</message>", "HELLO FROM XQUERY")),
+
+            /* Test Resource Loading */
+            Map.entry("languageSimpleResource", new TestResult("SimpleRes", "Hello SimpleRes from simple language resource")),
+            Map.entry("languageSimpleFile", new TestResult("SimpleFile", "Hello SimpleFile from simple language file")),
+
+            /* Test transform=false option */
+            Map.entry("languageSimpleTransform", new TestResult("SimpleTransform", "SimpleTransform"))
+
+    );
+
+    private static Collection<Object[]> getLanguageResultsMap() {
+        return languageResultsMap.entrySet()
+                .stream()
+                .map((entry) -> new Object[] { entry.getKey(), entry.getValue() })
+                .collect(Collectors.toList());
+    }
+
+    private static final String OUTPUT_DIRECTORY = "target";
+    private static final String TEST_FILE = "test-file.txt";
+    private static final String SIMPLE_FILE = "hello.simple-file.txt";
+
+    @BeforeAll
+    public static void setupTestFiles() throws Exception {
+        Files.createDirectories(Paths.get(OUTPUT_DIRECTORY));
+        // Write the file used in the 'file' language test
+        Files.writeString(Paths.get(OUTPUT_DIRECTORY, TEST_FILE), "Dummy text", StandardCharsets.UTF_8);
+
+        // Copy the simple script from resources to the OUTPUT_DIRECTORY to test reading a script from a file: resource
+        Files.copy(
+                LanguageTest.class.getClassLoader().getResourceAsStream(SIMPLE_FILE),
+                Paths.get(OUTPUT_DIRECTORY, SIMPLE_FILE),
+                StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    @AfterAll
+    public static void deleteTestFiles() throws Exception {
+        Files.delete(Paths.get(OUTPUT_DIRECTORY, TEST_FILE));
+        Files.delete(Paths.get(OUTPUT_DIRECTORY, SIMPLE_FILE));
+    }
+
+    /**
+     * This test is called for each entry in {@link languageResultsMap}.
+     * The body text is passed to the routeName endpoint, which is checked for successful completion
+     * and that the returned body matches the expected result from {@link TestResult}
+     * 
+     * @param routeName - The name of the endpoint exposed in {@link LanguageResource}
+     * @param result    - The {@link TestResource} containing input body and expected result
+     */
+    @ParameterizedTest
+    @MethodSource("getLanguageResultsMap")
+    public void testLanguage(String routeName, TestResult result) {
         RestAssured.given()
                 .contentType(ContentType.TEXT)
-                .body("Dolly")
-                .post("/language/route/languageSimpleScript")
+                .body(result.body)
+                .post("/language/route/" + routeName)
                 .then()
                 .statusCode(200)
-                .body(Matchers.is("Hello Dolly from simple language script"));
+                .body(Matchers.is(result.expected));
     }
 
+    /**
+     * Tests whether scripts can be loaded over HTTP.
+     * 
+     * @throws Exception
+     */
     @Test
-    public void languageSimpleResource() {
+    public void testHttpResource() throws Exception {
+        // Stub the WireMock server to return a simple script on the "/simple" endpoint
+        assertNotNull(server);
+        server.stubFor(request("GET", urlPathEqualTo("/simple"))
+                .willReturn(aResponse().withBody("Hello ${body} from simple language http")));
+
+        // The heart of the test is very similar to the testLanguage method above, but pass in the 
+        // URL of the WireMock server as a query parameter.
         RestAssured.given()
+                .queryParam("baseUrl", server.baseUrl())
                 .contentType(ContentType.TEXT)
-                .body("Molly")
-                .post("/language/route/languageSimpleResource")
+                .body("SimpleHttp")
+                .post("/language/route/languageSimpleHttp")
                 .then()
                 .statusCode(200)
-                .body(Matchers.is("Hello Molly from simple language resource"));
+                .body(Matchers.is("Hello SimpleHttp from simple language http"));
+        server.verify(1, getRequestedFor(urlEqualTo("/simple")));
+    }
+
+    /**
+     * Tests the contentCache option. The WireMock server is used to count how many times
+     * the script endpoint was accessed during route execution.
+     */
+    @Test
+    public void testContentCache() {
+        // Create a WireMock stub to return a simple script
+        assertNotNull(server);
+        server.stubFor(request("GET", urlPathEqualTo("/simpleContentCache"))
+                .willReturn(aResponse().withBody("Hello ${body} from simple language http")));
+
+        // Set up common request options
+        RequestSpecBuilder builder = new RequestSpecBuilder();
+        builder.addQueryParam("baseUrl", server.baseUrl());
+        builder.setContentType(ContentType.TEXT);
+        builder.setBody("SimpleHttp");
+
+        // Call the route to load the script with caching enabled
+        RestAssured.given().spec(builder.build())
+                .queryParam("contentCache", true)
+                .when().post("/language/route/languageSimpleContentCache")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Hello SimpleHttp from simple language http"));
+
+        // As this is the first time the route has been called, expect the script to have been loaded
+        server.verify(1, getRequestedFor(urlEqualTo("/simpleContentCache")));
+
+        // Call the endpoint again with caching enabled
+        RestAssured.given().spec(builder.build())
+                .queryParam("contentCache", true)
+                .when().post("/language/route/languageSimpleContentCache")
+                .then()
+                .statusCode(200);
+
+        // Expect the script to have been cached, so the request count should not have changed
+        server.verify(1, getRequestedFor(urlEqualTo("/simpleContentCache")));
+
+        // Call the route a third time without caching
+        RestAssured.given().spec(builder.build())
+                .queryParam("contentCache", false)
+                .when().post("/language/route/languageSimpleContentCache")
+                .then()
+                .statusCode(200);
+
+        // Expect the script to have been loaded a second time
+        server.verify(2, getRequestedFor(urlEqualTo("/simpleContentCache")));

Review Comment:
   The comments are really helpful :+1: 



-- 
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


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java:
##########
@@ -16,15 +16,63 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.Scanner;
 
+@RegisterForReflection(targets = { Scanner.class })
 public class LanguageRoutes extends RouteBuilder {
 
+    @Inject
+    CamelContext context;
+
     @Override
     public void configure() throws Exception {
+
+        /* Language routes using scripts passed to endpoints */
+
+        from("direct:languageBeanScript")
+                .to("language://bean:org.apache.camel.quarkus.component.language.it.CaseConverter::toUpper");
+        from("direct:languageConstantScript")
+                .to("language://constant:Hello from constant language script");
+        from("direct:languageExchangePropertyScript")
+                .setProperty("testProperty", simple("Hello ${body} from exchangeProperty language script"))
+                .to("language://exchangeProperty:testProperty");
+        from("file:target?fileName=test-file.txt&noop=true")
+                .to("language://file:File name is ${file:onlyname}")
+                .to("direct:languageFileOutput");
+        from("direct:languageHeaderScript")
+                .setHeader("testHeader", simple("Hello ${body} from header language script"))
+                .to("language://header:testHeader");
+        from("direct:languageHl7terserScript")
+                .to("language://hl7terser:PID-5")
+                .setBody(simple("Patient's surname is ${body}"));
+        from("direct:languageJsonPathScript")
+                .to("language://jsonpath:$.message");
+        from("direct:languageRefScript")
+                .to("language://ref:lowerCase");
         from("direct:languageSimpleScript")
                 .to("language://simple:Hello ${body} from simple language script");
+        from("direct:languageTokenizeScript")
+                .to("language://tokenize:,")
+                .setBody(simple("${body.next()}"));
+        from("direct:languageXpathScript")
+                .to("language://xpath:/message/text()");
+        from("direct:languageXqueryScript")
+                .to("language://xquery:upper-case(/message/text())");
+
+        /* Load simple scripts from resources */
+
         from("direct:languageSimpleResource")
-                .to("language://simple:resource:hello.simple.txt");
+                .to("language://simple:resource:hello.simple-res.txt");
+        from("direct:languageSimpleFile")
+                .to("language://simple:file:target/hello.simple-file.txt");

Review Comment:
   Or maybe it's the one created from LanguageTest.@BeforeAll



-- 
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


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/pom.xml:
##########
@@ -31,6 +31,10 @@
     <description>Integration tests for Camel Quarkus Language extension</description>
 
     <dependencies>
+		<dependency>

Review Comment:
   Isn't this caught by mvn ...-Pformat ?



-- 
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


[GitHub] [camel-quarkus] zbendhiba commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   Hello [djcoleman](https://github.com/djcoleman),
   
   Many thanks for this contribution. As this PR has a long description and a pending work for Camel 4.0.0-M2, I would like to suggest some improvements:
   
   - Can you open an issue to describe the work related to this contribution and add it to the commit message? It would be easier to look up the details related to this later when reading the code.
   
   - Can you open an issue to follow up later with the Xquery test, and add the issue link in the commented code ?
   
   
   


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java:
##########
@@ -16,15 +16,63 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.Scanner;
 
+@RegisterForReflection(targets = { Scanner.class })
 public class LanguageRoutes extends RouteBuilder {
 
+    @Inject
+    CamelContext context;
+
     @Override
     public void configure() throws Exception {
+
+        /* Language routes using scripts passed to endpoints */
+
+        from("direct:languageBeanScript")
+                .to("language://bean:org.apache.camel.quarkus.component.language.it.CaseConverter::toUpper");
+        from("direct:languageConstantScript")
+                .to("language://constant:Hello from constant language script");
+        from("direct:languageExchangePropertyScript")
+                .setProperty("testProperty", simple("Hello ${body} from exchangeProperty language script"))
+                .to("language://exchangeProperty:testProperty");
+        from("file:target?fileName=test-file.txt&noop=true")
+                .to("language://file:File name is ${file:onlyname}")
+                .to("direct:languageFileOutput");
+        from("direct:languageHeaderScript")
+                .setHeader("testHeader", simple("Hello ${body} from header language script"))
+                .to("language://header:testHeader");
+        from("direct:languageHl7terserScript")
+                .to("language://hl7terser:PID-5")
+                .setBody(simple("Patient's surname is ${body}"));
+        from("direct:languageJsonPathScript")
+                .to("language://jsonpath:$.message");
+        from("direct:languageRefScript")
+                .to("language://ref:lowerCase");
         from("direct:languageSimpleScript")
                 .to("language://simple:Hello ${body} from simple language script");
+        from("direct:languageTokenizeScript")
+                .to("language://tokenize:,")
+                .setBody(simple("${body.next()}"));
+        from("direct:languageXpathScript")
+                .to("language://xpath:/message/text()");
+        from("direct:languageXqueryScript")
+                .to("language://xquery:upper-case(/message/text())");
+
+        /* Load simple scripts from resources */
+
         from("direct:languageSimpleResource")
-                .to("language://simple:resource:hello.simple.txt");
+                .to("language://simple:resource:hello.simple-res.txt");
+        from("direct:languageSimpleFile")
+                .to("language://simple:file:target/hello.simple-file.txt");

Review Comment:
   see https://github.com/apache/camel-quarkus/blob/44fafca9d6402b59595e9de9e46b9a9e7f82418e/integration-tests/xml/src/main/java/org/apache/camel/quarkus/component/xml/it/XmlResource.java#L114-L123



-- 
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


[GitHub] [camel-quarkus] aldettinger merged pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


-- 
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


[GitHub] [camel-quarkus] aldettinger commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   > The File tests failed on Windows, but I don't think that's related to my changes. If everyone is happy with these changes please can someone merge the PR as I don't have permission. Thanks!
   
   The File tests failing might relate to this [flaky issue](https://github.com/apache/camel-quarkus/issues/3584).


-- 
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


[GitHub] [camel-quarkus] zhfeng commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java:
##########
@@ -16,15 +16,63 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.Scanner;
 
+@RegisterForReflection(targets = { Scanner.class })
 public class LanguageRoutes extends RouteBuilder {
 
+    @Inject
+    CamelContext context;
+
     @Override
     public void configure() throws Exception {
+
+        /* Language routes using scripts passed to endpoints */
+
+        from("direct:languageBeanScript")
+                .to("language://bean:org.apache.camel.quarkus.component.language.it.CaseConverter::toUpper");
+        from("direct:languageConstantScript")
+                .to("language://constant:Hello from constant language script");
+        from("direct:languageExchangePropertyScript")
+                .setProperty("testProperty", simple("Hello ${body} from exchangeProperty language script"))
+                .to("language://exchangeProperty:testProperty");
+        from("file:target?fileName=test-file.txt&noop=true")
+                .to("language://file:File name is ${file:onlyname}")
+                .to("direct:languageFileOutput");
+        from("direct:languageHeaderScript")
+                .setHeader("testHeader", simple("Hello ${body} from header language script"))
+                .to("language://header:testHeader");
+        from("direct:languageHl7terserScript")
+                .to("language://hl7terser:PID-5")
+                .setBody(simple("Patient's surname is ${body}"));
+        from("direct:languageJsonPathScript")
+                .to("language://jsonpath:$.message");
+        from("direct:languageRefScript")
+                .to("language://ref:lowerCase");
         from("direct:languageSimpleScript")
                 .to("language://simple:Hello ${body} from simple language script");
+        from("direct:languageTokenizeScript")
+                .to("language://tokenize:,")
+                .setBody(simple("${body.next()}"));
+        from("direct:languageXpathScript")
+                .to("language://xpath:/message/text()");
+        from("direct:languageXqueryScript")
+                .to("language://xquery:upper-case(/message/text())");
+
+        /* Load simple scripts from resources */
+
         from("direct:languageSimpleResource")
-                .to("language://simple:resource:hello.simple.txt");
+                .to("language://simple:resource:hello.simple-res.txt");
+        from("direct:languageSimpleFile")
+                .to("language://simple:file:target/hello.simple-file.txt");

Review Comment:
   I think it can't work on quarkus-platform and it needs to create a temporary file and copy the original content. We met the similar issue with `camel-quarkus-xstream` test with `file` schema.



-- 
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


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java:
##########
@@ -23,21 +23,54 @@
 import jakarta.ws.rs.Path;
 import jakarta.ws.rs.PathParam;
 import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
 import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.ProducerTemplate;
 
 @Path("/language")
 @ApplicationScoped
 public class LanguageResource {
 
     @Inject
-    ProducerTemplate template;
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
 
     @Path("/route/{route}")
     @POST
     @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
     public String route(String body, @PathParam("route") String route) {
-        return template.requestBody("direct:" + route, body, String.class);
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
+    }
+
+    @Path("/route/languageFileScript")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeFileScript(String body) {
+        return consumerTemplate.receiveBody("direct:languageFileOutput", 5000, String.class);
+    }
+
+    @Path("/route/languageSimpleHttp")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleHttp(String body, @QueryParam("baseUrl") String baseUrl) {
+        return producerTemplate.requestBody("language:simple:resource:" + baseUrl + "/simple", body, String.class);
+    }
+
+    @Path("/route/languageSimpleContentCache")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleContentCache(String body, @QueryParam("baseUrl") String baseUrl,
+            @QueryParam("contentCache") String contentCache) {
+        String option = "?contentCache=" + contentCache;
+        String url = "language:simple:resource:" + baseUrl + "/simpleContentCache" + option;
+        System.out.println(url);

Review Comment:
   Is there a log needed here ?



##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java:
##########
@@ -23,21 +23,54 @@
 import jakarta.ws.rs.Path;
 import jakarta.ws.rs.PathParam;
 import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
 import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.ProducerTemplate;
 
 @Path("/language")
 @ApplicationScoped
 public class LanguageResource {
 
     @Inject
-    ProducerTemplate template;
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
 
     @Path("/route/{route}")
     @POST
     @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
     public String route(String body, @PathParam("route") String route) {
-        return template.requestBody("direct:" + route, body, String.class);
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
+    }
+
+    @Path("/route/languageFileScript")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeFileScript(String body) {
+        return consumerTemplate.receiveBody("direct:languageFileOutput", 5000, String.class);
+    }
+
+    @Path("/route/languageSimpleHttp")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleHttp(String body, @QueryParam("baseUrl") String baseUrl) {
+        return producerTemplate.requestBody("language:simple:resource:" + baseUrl + "/simple", body, String.class);
+    }
+
+    @Path("/route/languageSimpleContentCache")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleContentCache(String body, @QueryParam("baseUrl") String baseUrl,
+            @QueryParam("contentCache") String contentCache) {
+        String option = "?contentCache=" + contentCache;
+        String url = "language:simple:resource:" + baseUrl + "/simpleContentCache" + option;
+        System.out.println(url);

Review Comment:
   Is there a log needed instead here ?



-- 
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


[GitHub] [camel-quarkus] djcoleman commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java:
##########
@@ -23,21 +23,54 @@
 import jakarta.ws.rs.Path;
 import jakarta.ws.rs.PathParam;
 import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
 import jakarta.ws.rs.core.MediaType;
+import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.ProducerTemplate;
 
 @Path("/language")
 @ApplicationScoped
 public class LanguageResource {
 
     @Inject
-    ProducerTemplate template;
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    ConsumerTemplate consumerTemplate;
 
     @Path("/route/{route}")
     @POST
     @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
     public String route(String body, @PathParam("route") String route) {
-        return template.requestBody("direct:" + route, body, String.class);
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
+    }
+
+    @Path("/route/languageFileScript")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeFileScript(String body) {
+        return consumerTemplate.receiveBody("direct:languageFileOutput", 5000, String.class);
+    }
+
+    @Path("/route/languageSimpleHttp")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleHttp(String body, @QueryParam("baseUrl") String baseUrl) {
+        return producerTemplate.requestBody("language:simple:resource:" + baseUrl + "/simple", body, String.class);
+    }
+
+    @Path("/route/languageSimpleContentCache")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String routeSimpleContentCache(String body, @QueryParam("baseUrl") String baseUrl,
+            @QueryParam("contentCache") String contentCache) {
+        String option = "?contentCache=" + contentCache;
+        String url = "language:simple:resource:" + baseUrl + "/simpleContentCache" + option;
+        System.out.println(url);

Review Comment:
   Nope, left over from debugging. I'll remove that.



-- 
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


[GitHub] [camel-quarkus] zbendhiba commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   Apart from the remarks of @aldettinger and @zhfeng , it's all good for me. 👍🏾 


-- 
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


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/pom.xml:
##########
@@ -43,6 +47,37 @@
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
+        
+        <!-- Non-core languages -->
+        <dependency>

Review Comment:
   We have faced situations where separating tests in their own project helped, as sometime an extension is hiding a bug from another one.
   
   Here, it might be ok to bundle everything as the main purpose is not really to test each language, but more to test that each language can be loaded in Camel Quarkus.



-- 
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


[GitHub] [camel-quarkus] zbendhiba commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   > @zbendhiba Just spotted that the Camel version has been bumped - that saves me forgetting about the Xquery language later. I already have an issue filed for this PR, so I can just add the details to that. Thanks for the feedback.
   
   Sorry, you're right, the issue number was removed by editing the description here :)


-- 
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


[GitHub] [camel-quarkus] djcoleman commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   @zbendhiba Just spotted that the Camel version has been bumped - that saves me forgetting about the Xquery language later. I already have an issue filed for this PR, so I can just add the details to that. Thanks for the feedback.


-- 
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


[GitHub] [camel-quarkus] aldettinger commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java:
##########
@@ -16,15 +16,63 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import jakarta.inject.Inject;
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.Scanner;
 
+@RegisterForReflection(targets = { Scanner.class })
 public class LanguageRoutes extends RouteBuilder {
 
+    @Inject
+    CamelContext context;
+
     @Override
     public void configure() throws Exception {
+
+        /* Language routes using scripts passed to endpoints */
+
+        from("direct:languageBeanScript")
+                .to("language://bean:org.apache.camel.quarkus.component.language.it.CaseConverter::toUpper");
+        from("direct:languageConstantScript")
+                .to("language://constant:Hello from constant language script");
+        from("direct:languageExchangePropertyScript")
+                .setProperty("testProperty", simple("Hello ${body} from exchangeProperty language script"))
+                .to("language://exchangeProperty:testProperty");
+        from("file:target?fileName=test-file.txt&noop=true")
+                .to("language://file:File name is ${file:onlyname}")
+                .to("direct:languageFileOutput");
+        from("direct:languageHeaderScript")
+                .setHeader("testHeader", simple("Hello ${body} from header language script"))
+                .to("language://header:testHeader");
+        from("direct:languageHl7terserScript")
+                .to("language://hl7terser:PID-5")
+                .setBody(simple("Patient's surname is ${body}"));
+        from("direct:languageJsonPathScript")
+                .to("language://jsonpath:$.message");
+        from("direct:languageRefScript")
+                .to("language://ref:lowerCase");
         from("direct:languageSimpleScript")
                 .to("language://simple:Hello ${body} from simple language script");
+        from("direct:languageTokenizeScript")
+                .to("language://tokenize:,")
+                .setBody(simple("${body.next()}"));
+        from("direct:languageXpathScript")
+                .to("language://xpath:/message/text()");
+        from("direct:languageXqueryScript")
+                .to("language://xquery:upper-case(/message/text())");
+
+        /* Load simple scripts from resources */
+
         from("direct:languageSimpleResource")
-                .to("language://simple:resource:hello.simple.txt");
+                .to("language://simple:resource:hello.simple-res.txt");
+        from("direct:languageSimpleFile")
+                .to("language://simple:file:target/hello.simple-file.txt");

Review Comment:
   Note sure this will work on quarkus-platform ? Or the test harness would need to create the file.
   
   Wondering... this case should already covered in Camel test ? It there is nothing specific to Camel Quarkus, then it's fine to test it at Camel level only and it's shared with other runtime that way.



-- 
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


[GitHub] [camel-quarkus] djcoleman commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/pom.xml:
##########
@@ -31,6 +31,10 @@
     <description>Integration tests for Camel Quarkus Language extension</description>
 
     <dependencies>
+		<dependency>

Review Comment:
   I just ran the format command again and it didn't pick it up. I'll fix that manually.



-- 
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


[GitHub] [camel-quarkus] zbendhiba commented on pull request #4641: camel-quarkus-language: Added language, resource and options tests

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

   Camel 4.0-M2 has been merged, so maybe we can just uncomment the XQuery test and a rebase is needed


-- 
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


[GitHub] [camel-quarkus] zbendhiba commented on a diff in pull request #4641: camel-quarkus-language: Added language, resource and options tests

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


##########
integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java:
##########
@@ -16,35 +16,216 @@
  */
 package org.apache.camel.quarkus.component.language.it;
 
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
+import io.restassured.builder.RequestSpecBuilder;
 import io.restassured.http.ContentType;
+import org.apache.camel.quarkus.test.wiremock.MockServer;
 import org.hamcrest.Matchers;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.request;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 @QuarkusTest
+@QuarkusTestResource(LanguageTestResource.class)
 class LanguageTest {
 
-    @Test
-    public void languageSimpleScript() {
+    @MockServer
+    WireMockServer server;
+
+    /**
+     * Map endpoint names to objects containing exchange bodies and expected output
+     */
+    private static Map<String, TestResult> languageResultsMap = Map.ofEntries(
+            /* Test Languages */
+            Map.entry("languageBeanScript", new TestResult("Hello Bean", "HELLO BEAN")),
+            Map.entry("languageConstantScript", new TestResult("Constant", "Hello from constant language script")),
+            Map.entry("languageExchangePropertyScript",
+                    new TestResult("ExProperty", "Hello ExProperty from exchangeProperty language script")),
+            Map.entry("languageFileScript", new TestResult("", "File name is test-file.txt")),
+            Map.entry("languageHeaderScript", new TestResult("Header", "Hello Header from header language script")),
+            Map.entry("languageHl7terserScript", new TestResult(createHl7Message(), "Patient's surname is Smith")),
+            Map.entry("languageJsonPathScript",
+                    new TestResult("{\"message\": \"Hello from jsonpath\", \"user\": \"camel-quarkus\"}",
+                            "Hello from jsonpath")),
+            Map.entry("languageRefScript", new TestResult("Hello from Ref", "hello from ref")),
+            Map.entry("languageSimpleScript", new TestResult("Simple", "Hello Simple from simple language script")),
+            Map.entry("languageTokenizeScript", new TestResult("Hello,Tokenize", "Hello")),
+            Map.entry("languageXpathScript", new TestResult("<message>Hello from Xpath</message>", "Hello from Xpath")),
+            // Xquery test fails due to CAMEL-19079. Re-enable when CQ is aligned to Camel 4.0.0-M2
+            // Map.entry("languageXqueryScript", new TestResult("<message>Hello from XQuery</message>", "HELLO FROM XQUERY")),
+
+            /* Test Resource Loading */
+            Map.entry("languageSimpleResource", new TestResult("SimpleRes", "Hello SimpleRes from simple language resource")),
+            Map.entry("languageSimpleFile", new TestResult("SimpleFile", "Hello SimpleFile from simple language file")),
+
+            /* Test transform=false option */
+            Map.entry("languageSimpleTransform", new TestResult("SimpleTransform", "SimpleTransform"))
+
+    );
+
+    private static Collection<Object[]> getLanguageResultsMap() {
+        return languageResultsMap.entrySet()
+                .stream()
+                .map((entry) -> new Object[] { entry.getKey(), entry.getValue() })
+                .collect(Collectors.toList());
+    }
+
+    private static final String OUTPUT_DIRECTORY = "target";
+    private static final String TEST_FILE = "test-file.txt";
+    private static final String SIMPLE_FILE = "hello.simple-file.txt";
+
+    @BeforeAll
+    public static void setupTestFiles() throws Exception {
+        Files.createDirectories(Paths.get(OUTPUT_DIRECTORY));
+        // Write the file used in the 'file' language test
+        Files.writeString(Paths.get(OUTPUT_DIRECTORY, TEST_FILE), "Dummy text", StandardCharsets.UTF_8);
+
+        // Copy the simple script from resources to the OUTPUT_DIRECTORY to test reading a script from a file: resource
+        Files.copy(
+                LanguageTest.class.getClassLoader().getResourceAsStream(SIMPLE_FILE),
+                Paths.get(OUTPUT_DIRECTORY, SIMPLE_FILE),
+                StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    @AfterAll
+    public static void deleteTestFiles() throws Exception {
+        Files.delete(Paths.get(OUTPUT_DIRECTORY, TEST_FILE));
+        Files.delete(Paths.get(OUTPUT_DIRECTORY, SIMPLE_FILE));
+    }
+
+    /**
+     * This test is called for each entry in {@link languageResultsMap}.
+     * The body text is passed to the routeName endpoint, which is checked for successful completion
+     * and that the returned body matches the expected result from {@link TestResult}
+     * 
+     * @param routeName - The name of the endpoint exposed in {@link LanguageResource}
+     * @param result    - The {@link TestResource} containing input body and expected result
+     */
+    @ParameterizedTest
+    @MethodSource("getLanguageResultsMap")
+    public void testLanguage(String routeName, TestResult result) {
         RestAssured.given()
                 .contentType(ContentType.TEXT)
-                .body("Dolly")
-                .post("/language/route/languageSimpleScript")
+                .body(result.body)
+                .post("/language/route/" + routeName)
                 .then()
                 .statusCode(200)
-                .body(Matchers.is("Hello Dolly from simple language script"));
+                .body(Matchers.is(result.expected));
     }
 
+    /**
+     * Tests whether scripts can be loaded over HTTP.
+     * 
+     * @throws Exception
+     */
     @Test
-    public void languageSimpleResource() {
+    public void testHttpResource() throws Exception {
+        // Stub the WireMock server to return a simple script on the "/simple" endpoint
+        assertNotNull(server);
+        server.stubFor(request("GET", urlPathEqualTo("/simple"))

Review Comment:
   FYI, when using `WireMockTestResourceLifecycleManager`, we usually put Wiremock requests/responses in json files under resources/mappings, unless we have a reason why we do the stub manually (and we comment about it).
   The stub are automatically created. 
   
   Example: https://github.com/apache/camel-quarkus/tree/main/integration-tests/digitalocean/src/test/resources/mappings



-- 
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