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

[GitHub] [camel-quarkus] llowinge opened a new pull request, #5170: [5162] Add elasticsearch tests

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

   Covers:
   * Index data (CQ)
   * Search (CQ)
   * Multisearch (CQ)
   * GetById (CQ)
   * Update (CQ)
   * Delete (CQ)
   * DeleteIndex (CQ)
   * Bulk (CQ)
   * Exists (CQ)
   * Ping (CQ)


-- 
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 #5170: [5162] Add elasticsearch tests

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

   Yes, that's ok in this state. Plus if we promote it to native one day, then we could update the test coverage at this stage YAGNI style.


-- 
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] llowinge commented on pull request #5170: [5162] Add elasticsearch tests

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

   @aldettinger That is great idea, but given it was only for JVM, i think we are safe there. Basically all the tests are probably overkill, but i've ported all of them for future benefits. I've created followup issue for the SSL https://github.com/apache/camel-quarkus/issues/5174.


-- 
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 #5170: [5162] Add elasticsearch tests

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

   Not sure, it's overkill. Those features are present in the camel component doc, so this is good to have them covered :+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] jamesnetherton commented on a diff in pull request #5170: [5162] Add elasticsearch tests

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


##########
integration-tests-jvm/elasticsearch/src/test/java/org/apache/camel/quarkus/component/elasticsearch/it/ElasticsearchTest.java:
##########
@@ -0,0 +1,359 @@
+/*
+ * 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.elasticsearch.it;
+
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(ElasticsearchTestResource.class)
+class ElasticsearchTest {
+
+    @AfterEach
+    public void afterEach() {
+        // Clean up all indexed data
+        RestAssured.given()
+                .queryParam("component", "elasticsearch")
+                .queryParam("indexName", "_all")
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBasicOperations(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Verify the ElasticSearch server is available
+        RestAssured.given()
+                .queryParam("component", component)
+                .get("/elasticsearch/ping")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Index data
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Retrieve indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(indexValue));
+
+        // Update indexed data
+        String updatedIndexValue = indexValue + " Updated";
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .queryParam("component", component)
+                .queryParam("indexId", indexId)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .body(updatedIndexValue)
+                .patch("/elasticsearch/update")
+                .then()
+                .statusCode(200);
+
+        // Verify updated data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(updatedIndexValue));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .delete("/elasticsearch/delete")
+                .then()
+                .statusCode(204);
+
+        // Verify data deleted
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(404);
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBulk(String component) {
+        String indexName = UUID.randomUUID().toString();
+
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .post("/elasticsearch/bulk")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", "camel")
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is("quarkus"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchDeleteIndex(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearchJSON(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search/json")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchMultiSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(100, TimeUnit.SECONDS).until(() -> {
+            String hits = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexName", indexName)
+                    .queryParam("indexKey", indexKey)
+                    .body("Sub Atomic,Super Fast,Nonsense")
+                    .get("/elasticsearch/search/multi")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return hits.equals("2");
+        });
+    }
+
+    @SuppressWarnings("unused")
+    private static String[] componentNames() {
+        return new String[] { "elasticsearch" };

Review Comment:
   In theory this is not required and we could just hard code the component name (using `to` instead of `toD`).
   
   Or is it worth keeping in case we do eventually want to test the component with the Quarkus managed ES client?



-- 
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] jamesnetherton merged pull request #5170: [5162] Add elasticsearch tests

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


-- 
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] jamesnetherton commented on a diff in pull request #5170: [5162] Add elasticsearch tests

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


##########
integration-tests-jvm/elasticsearch/src/test/java/org/apache/camel/quarkus/component/elasticsearch/it/ElasticsearchTest.java:
##########
@@ -0,0 +1,359 @@
+/*
+ * 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.elasticsearch.it;
+
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(ElasticsearchTestResource.class)
+class ElasticsearchTest {
+
+    @AfterEach
+    public void afterEach() {
+        // Clean up all indexed data
+        RestAssured.given()
+                .queryParam("component", "elasticsearch")
+                .queryParam("indexName", "_all")
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBasicOperations(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Verify the ElasticSearch server is available
+        RestAssured.given()
+                .queryParam("component", component)
+                .get("/elasticsearch/ping")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Index data
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Retrieve indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(indexValue));
+
+        // Update indexed data
+        String updatedIndexValue = indexValue + " Updated";
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .queryParam("component", component)
+                .queryParam("indexId", indexId)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .body(updatedIndexValue)
+                .patch("/elasticsearch/update")
+                .then()
+                .statusCode(200);
+
+        // Verify updated data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(updatedIndexValue));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .delete("/elasticsearch/delete")
+                .then()
+                .statusCode(204);
+
+        // Verify data deleted
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(404);
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBulk(String component) {
+        String indexName = UUID.randomUUID().toString();
+
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .post("/elasticsearch/bulk")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", "camel")
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is("quarkus"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchDeleteIndex(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearchJSON(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search/json")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchMultiSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(100, TimeUnit.SECONDS).until(() -> {
+            String hits = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexName", indexName)
+                    .queryParam("indexKey", indexKey)
+                    .body("Sub Atomic,Super Fast,Nonsense")
+                    .get("/elasticsearch/search/multi")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return hits.equals("2");
+        });
+    }
+
+    @SuppressWarnings("unused")
+    private static String[] componentNames() {
+        return new String[] { "elasticsearch" };

Review Comment:
   Yes, please add a comment.



-- 
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] llowinge commented on pull request #5170: [5162] Add elasticsearch tests

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

   @jamesnetherton Can you please review ?


-- 
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] llowinge commented on a diff in pull request #5170: [5162] Add elasticsearch tests

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


##########
integration-tests-jvm/elasticsearch/src/test/java/org/apache/camel/quarkus/component/elasticsearch/it/ElasticsearchTest.java:
##########
@@ -0,0 +1,359 @@
+/*
+ * 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.elasticsearch.it;
+
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(ElasticsearchTestResource.class)
+class ElasticsearchTest {
+
+    @AfterEach
+    public void afterEach() {
+        // Clean up all indexed data
+        RestAssured.given()
+                .queryParam("component", "elasticsearch")
+                .queryParam("indexName", "_all")
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBasicOperations(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Verify the ElasticSearch server is available
+        RestAssured.given()
+                .queryParam("component", component)
+                .get("/elasticsearch/ping")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Index data
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Retrieve indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(indexValue));
+
+        // Update indexed data
+        String updatedIndexValue = indexValue + " Updated";
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .queryParam("component", component)
+                .queryParam("indexId", indexId)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .body(updatedIndexValue)
+                .patch("/elasticsearch/update")
+                .then()
+                .statusCode(200);
+
+        // Verify updated data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(updatedIndexValue));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .delete("/elasticsearch/delete")
+                .then()
+                .statusCode(204);
+
+        // Verify data deleted
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(404);
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBulk(String component) {
+        String indexName = UUID.randomUUID().toString();
+
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .post("/elasticsearch/bulk")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", "camel")
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is("quarkus"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchDeleteIndex(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearchJSON(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search/json")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchMultiSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(100, TimeUnit.SECONDS).until(() -> {
+            String hits = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexName", indexName)
+                    .queryParam("indexKey", indexKey)
+                    .body("Sub Atomic,Super Fast,Nonsense")
+                    .get("/elasticsearch/search/multi")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return hits.equals("2");
+        });
+    }
+
+    @SuppressWarnings("unused")
+    private static String[] componentNames() {
+        return new String[] { "elasticsearch" };

Review Comment:
   I left it there for the Quarkus managed ES client. But i agree it is not useful now at all. Maybe i should add comment there why it is done like that to that method ?



-- 
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 #5170: [5162] Add elasticsearch tests

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

   LGTM. Do we need tests to cover things like `certificatePath` or `enableSSL` ? Not sure as native is not tested.


-- 
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] llowinge commented on a diff in pull request #5170: [5162] Add elasticsearch tests

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


##########
integration-tests-jvm/elasticsearch/src/test/java/org/apache/camel/quarkus/component/elasticsearch/it/ElasticsearchTest.java:
##########
@@ -0,0 +1,359 @@
+/*
+ * 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.elasticsearch.it;
+
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+@QuarkusTestResource(ElasticsearchTestResource.class)
+class ElasticsearchTest {
+
+    @AfterEach
+    public void afterEach() {
+        // Clean up all indexed data
+        RestAssured.given()
+                .queryParam("component", "elasticsearch")
+                .queryParam("indexName", "_all")
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBasicOperations(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Verify the ElasticSearch server is available
+        RestAssured.given()
+                .queryParam("component", component)
+                .get("/elasticsearch/ping")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Index data
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Retrieve indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(indexValue));
+
+        // Update indexed data
+        String updatedIndexValue = indexValue + " Updated";
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .queryParam("component", component)
+                .queryParam("indexId", indexId)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .body(updatedIndexValue)
+                .patch("/elasticsearch/update")
+                .then()
+                .statusCode(200);
+
+        // Verify updated data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is(updatedIndexValue));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .delete("/elasticsearch/delete")
+                .then()
+                .statusCode(204);
+
+        // Verify data deleted
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", indexKey)
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(404);
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchBulk(String component) {
+        String indexName = UUID.randomUUID().toString();
+
+        String indexId = RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .post("/elasticsearch/bulk")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexId", indexId)
+                .queryParam("indexKey", "camel")
+                .get("/elasticsearch/get")
+                .then()
+                .statusCode(200)
+                .body(is("quarkus"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchDeleteIndex(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "test-key";
+        String indexValue = "Hello Camel Quarkus ElasticSearch";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Delete indexed data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .delete("/elasticsearch/delete/index")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchSearchJSON(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(10, TimeUnit.SECONDS).until(() -> {
+            String searchResult = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexKey", indexKey)
+                    .body("Super Fast")
+                    .get("/elasticsearch/search/json")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return searchResult.equals(indexValue);
+        });
+    }
+
+    @ParameterizedTest
+    @MethodSource("componentNames")
+    public void testElasticsearchMultiSearch(String component) {
+        String indexName = UUID.randomUUID().toString();
+        String indexKey = "camel-quarkus";
+        String indexValue = "Sub Atomic, Super Fast Camel Quarkus";
+
+        // Index data
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .queryParam("indexKey", indexKey)
+                .contentType(ContentType.TEXT)
+                .body(indexValue)
+                .post("/elasticsearch/index")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        // Verify index exists
+        RestAssured.given()
+                .queryParam("component", component)
+                .queryParam("indexName", indexName)
+                .get("/elasticsearch/exists")
+                .then()
+                .statusCode(200)
+                .body(is("true"));
+
+        // Search data
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(100, TimeUnit.SECONDS).until(() -> {
+            String hits = RestAssured.given()
+                    .queryParam("component", component)
+                    .queryParam("indexName", indexName)
+                    .queryParam("indexKey", indexKey)
+                    .body("Sub Atomic,Super Fast,Nonsense")
+                    .get("/elasticsearch/search/multi")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .asString();
+            return hits.equals("2");
+        });
+    }
+
+    @SuppressWarnings("unused")
+    private static String[] componentNames() {
+        return new String[] { "elasticsearch" };

Review Comment:
   I left comment, i hope it is OK.



-- 
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] jamesnetherton commented on pull request #5170: [5162] Add elasticsearch tests

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

   > Do we need tests to cover things like `certificatePath` or `enableSSL`
   
   We could maybe follow up with that. These initial tests are mostly a reproduction of what we had for the previous `elasticsearch-rest` extension.


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