This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new b6526f95dd Configure elasticsearch-rest-client using component options
b6526f95dd is described below

commit b6526f95dd6f3d5f30e9e5fcd2e066ce8d5b915d
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Mon Jul 22 08:59:59 2024 +0100

    Configure elasticsearch-rest-client using component options
    
    Fixes #6172
---
 .../client/it/ElasticsearchRestClientRoutes.java   | 35 +++++++++-------------
 .../client/it/ElasticsearchRestTestResource.java   | 11 ++++---
 2 files changed, 19 insertions(+), 27 deletions(-)

diff --git 
a/integration-tests/elasticsearch-rest-client/src/main/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestClientRoutes.java
 
b/integration-tests/elasticsearch-rest-client/src/main/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestClientRoutes.java
index dde90e15bc..56a7267c27 100644
--- 
a/integration-tests/elasticsearch-rest-client/src/main/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestClientRoutes.java
+++ 
b/integration-tests/elasticsearch-rest-client/src/main/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestClientRoutes.java
@@ -17,49 +17,42 @@
 package org.apache.camel.quarkus.component.elasticsearch.rest.client.it;
 
 import org.apache.camel.builder.RouteBuilder;
-import 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation;
 
-import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.*;
+import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.CREATE_INDEX;
+import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.DELETE;
+import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.DELETE_INDEX;
+import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.GET_BY_ID;
+import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.INDEX_OR_UPDATE;
+import static 
org.apache.camel.component.elasticsearch.rest.client.ElasticsearchRestClientOperation.SEARCH;
 
 public class ElasticsearchRestClientRoutes extends RouteBuilder {
     @Override
     public void configure() {
         from("direct:createIndex")
-                .to(elasticsearchRestClient(CREATE_INDEX));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
CREATE_INDEX);
 
         from("direct:createIndexSettings")
-                .to(elasticsearchRestClient(CREATE_INDEX));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
CREATE_INDEX);
 
         from("direct:delete")
-                .to(elasticsearchRestClient(DELETE));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
DELETE);
 
         from("direct:deleteIndex")
-                .to(elasticsearchRestClient(DELETE_INDEX));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
DELETE_INDEX);
 
         from("direct:get")
-                .to(elasticsearchRestClient(GET_BY_ID))
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
GET_BY_ID)
                 .convertBodyTo(String.class)
                 .unmarshal().json(Document.class);
 
         from("direct:index")
                 .marshal().json()
-                .to(elasticsearchRestClient(INDEX_OR_UPDATE));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
INDEX_OR_UPDATE);
 
         from("direct:search")
-                .to(elasticsearchRestClient(SEARCH));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
SEARCH);
 
         from("direct:searchQuery")
-                .to(elasticsearchRestClient(SEARCH));
+                .toF("elasticsearch-rest-client:camel-quarkus?operation=%s", 
SEARCH);
     }
-
-    private String elasticsearchRestClient(ElasticsearchRestClientOperation 
operation) {
-        return "elasticsearch-rest-client:camel-quarkus" +
-                "?operation=" + operation +
-                
"&hostAddressesList={{camel.elasticsearch-rest-client.host-addresses-list}}" +
-                "&user={{camel.elasticsearch-rest-client.user}}" +
-                "&password={{camel.elasticsearch-rest-client.password}}" +
-                "&certificatePath={{camel.elasticsearch-rest-client.cert}}" +
-                "&enableSniffer=true";
-    }
-
 }
diff --git 
a/integration-tests/elasticsearch-rest-client/src/test/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestTestResource.java
 
b/integration-tests/elasticsearch-rest-client/src/test/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestTestResource.java
index 7bc299fba5..3a0f32a9bf 100644
--- 
a/integration-tests/elasticsearch-rest-client/src/test/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestTestResource.java
+++ 
b/integration-tests/elasticsearch-rest-client/src/test/java/org/apache/camel/quarkus/component/elasticsearch/rest/client/it/ElasticsearchRestTestResource.java
@@ -99,13 +99,12 @@ public class ElasticsearchRestTestResource implements 
QuarkusTestResourceLifecyc
             container.start();
             String hostAddresses = String.format("%s:%s", container.getHost(), 
container.getMappedPort(ELASTICSEARCH_PORT));
 
-            // TODO: Replace this in future with component options
-            // https://issues.apache.org/jira/browse/CAMEL-20846
             return CollectionHelper.mapOf(
-                    "camel.elasticsearch-rest-client.host-addresses-list", 
hostAddresses,
-                    "camel.elasticsearch-rest-client.user", 
ELASTICSEARCH_USERNAME,
-                    "camel.elasticsearch-rest-client.password", 
ELASTICSEARCH_PASSWORD,
-                    "camel.elasticsearch-rest-client.cert", 
"file:target/certs/ca.crt");
+                    
"camel.component.elasticsearch-rest-client.host-addresses-list", hostAddresses,
+                    "camel.component.elasticsearch-rest-client.user", 
ELASTICSEARCH_USERNAME,
+                    "camel.component.elasticsearch-rest-client.password", 
ELASTICSEARCH_PASSWORD,
+                    
"camel.component.elasticsearch-rest-client.certificatePath", 
"file:target/certs/ca.crt",
+                    "camel.component.elasticsearch-rest-client.enableSniffer", 
"true");
 
         } catch (Exception e) {
             throw new RuntimeException(e);

Reply via email to