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

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit be8915851a1403c2c1428ab6ae4cfedb90381b68
Author: Luca Burgazzoli <lburgazz...@gmail.com>
AuthorDate: Mon Oct 19 14:35:47 2020 +0200

    yaml: use EndpointUriFactory to compute endpoint uri
---
 .../camel/k/loader/yaml/support/StepParserSupport.java  | 17 +++++++++++------
 camel-k-loader-yaml/camel-k-loader-yaml/pom.xml         |  5 -----
 .../camel/k/loader/yaml/RoutesWithEndpointTest.groovy   |  4 ++--
 .../resources/routes/RoutesWithEndpointTest_from.yaml   |  2 +-
 .../resources/routes/RoutesWithEndpointTest_route.yaml  |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git 
a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/StepParserSupport.java
 
b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/StepParserSupport.java
index 1889c18..017ad30 100644
--- 
a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/StepParserSupport.java
+++ 
b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/StepParserSupport.java
@@ -17,10 +17,8 @@
 package org.apache.camel.k.loader.yaml.support;
 
 import java.net.URISyntaxException;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.stream.Collectors;
 
 import org.apache.camel.CamelContext;
@@ -31,6 +29,7 @@ import org.apache.camel.k.loader.yaml.spi.StepParser;
 import org.apache.camel.k.loader.yaml.spi.StepParserException;
 import org.apache.camel.model.OutputNode;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.spi.EndpointUriFactory;
 import org.apache.camel.util.ObjectHelper;
 
 public final class StepParserSupport {
@@ -89,11 +88,17 @@ public final class StepParserSupport {
     }
 
     public static String createEndpointUri(CamelContext context, String 
scheme, Map<String, Object> parameters) {
-        try {
-            Map<String, String> params = new HashMap<>();
-            parameters.forEach((k, v) -> params.put(k, Objects.toString(v)));
+        final EndpointUriFactory factory = 
context.adapt(ExtendedCamelContext.class).getEndpointUriFactory(scheme);
 
-            return 
context.adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog().asEndpointUri(scheme,
 params, false);
+        if (factory == null) {
+            throw new IllegalArgumentException("Cannot compute endpoint URI: 
unable to find an EndpointUriFactory for scheme " + scheme);
+        }
+        if (!factory.isEnabled(scheme)) {
+            throw new IllegalArgumentException("Cannot compute endpoint URI: 
scheme " + scheme + " is not enabled");
+        }
+
+        try {
+            return factory.buildUri(scheme, parameters);
         } catch (URISyntaxException e) {
             throw new IllegalArgumentException(e);
         }
diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml 
b/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml
index 3fd3c70..4b6f176 100644
--- a/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml
+++ b/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml
@@ -36,11 +36,6 @@
         <!-- ****************************** -->
 
         <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core-catalog</artifactId>
-        </dependency>
-
-        <dependency>
             <groupId>org.apache.camel.k</groupId>
             <artifactId>camel-k-runtime-core</artifactId>
         </dependency>
diff --git 
a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesWithEndpointTest.groovy
 
b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesWithEndpointTest.groovy
index 1f9cbfc..f27ab3b 100644
--- 
a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesWithEndpointTest.groovy
+++ 
b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesWithEndpointTest.groovy
@@ -43,7 +43,7 @@ class RoutesWithEndpointTest extends TestSupport {
                 timeout == 1_234_000
             }
             with (te, TelegramEndpoint) {
-                endpointUri == 
'telegram://bots?authorizationToken=%23property:telegram.token'
+                endpointUri == 
'telegram://bots?authorizationToken=RAW(myToken+)'
                 configuration.authorizationToken == 'myToken+'
             }
             with (me, MockEndpoint) {
@@ -74,7 +74,7 @@ class RoutesWithEndpointTest extends TestSupport {
                 timeout == 1_234_000
             }
             with (te, TelegramEndpoint) {
-                endpointUri == 
'telegram://bots?authorizationToken=%23property:telegram.token'
+                endpointUri == 
'telegram://bots?authorizationToken=RAW(myToken+)'
                 configuration.authorizationToken == 'myToken+'
             }
             with (me, MockEndpoint) {
diff --git 
a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_from.yaml
 
b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_from.yaml
index 196e6c4..d7b6861 100644
--- 
a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_from.yaml
+++ 
b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_from.yaml
@@ -21,6 +21,6 @@
     steps:
       - telegram:
           type: "bots"
-          authorization-token: "#property:telegram.token"
+          authorization-token: "{{telegram.token}}"
       - mock:
           name: "telegram"
\ No newline at end of file
diff --git 
a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_route.yaml
 
b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_route.yaml
index 1f0e92d..c060c3b 100644
--- 
a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_route.yaml
+++ 
b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesWithEndpointTest_route.yaml
@@ -22,6 +22,6 @@
     steps:
       - telegram:
           type: "bots"
-          authorization-token: "#property:telegram.token"
+          authorization-token: "{{telegram.token}}"
       - mock:
           name: "telegram"
\ No newline at end of file

Reply via email to