From 3b07d3d95d12ec73a653fc35934ca48c2caf3945 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Tue, 14 Jul 2020 11:13:01 +0200 Subject: [PATCH] Property substitution doesn't happen in from URI #392 --- .../k/loader/yaml/parser/FromStepParser.java | 21 +--- .../k/loader/yaml/parser/RouteStepParser.java | 21 +--- .../yaml/parser/ToDynamicStepParser.java | 23 +---- .../k/loader/yaml/parser/ToStepParser.java | 23 +---- .../loader/yaml/parser/WireTapStepParser.java | 24 +---- .../k/loader/yaml/spi/StepParserSupport.java | 19 ++++ .../yaml/RouteWithPlaceholdersTest.groovy | 98 +++++++++++++++++++ .../camel/k/loader/yaml/RoutesTest.groovy | 24 ++--- .../camel/k/loader/yaml/TestSupport.groovy | 39 +++++--- .../camel/k/loader/yaml/parser/ToTest.groovy | 4 +- .../RouteWithPlaceholdersTest_from.yaml | 23 +++++ .../RouteWithPlaceholdersTest_route.yaml | 24 +++++ .../routes/RouteWithPlaceholdersTest_to.yaml | 30 ++++++ .../routes/RouteWithPlaceholdersTest_tod.yaml | 30 ++++++ .../routes/RoutesTest_onExceptionHandled.yaml | 2 +- .../camel/component/knative/knative.json | 2 +- 16 files changed, 277 insertions(+), 130 deletions(-) create mode 100644 camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RouteWithPlaceholdersTest.groovy create mode 100644 camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_from.yaml create mode 100644 camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_route.yaml create mode 100644 camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_to.yaml create mode 100644 camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_tod.yaml diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java index de986c063..360597b09 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java @@ -16,12 +16,9 @@ */ package org.apache.camel.k.loader.yaml.parser; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; import java.util.List; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; @@ -29,14 +26,13 @@ import org.apache.camel.k.loader.yaml.spi.StartStepParser; import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.RouteDefinition; -import org.apache.camel.util.URISupport; @YAMLStepParser(id = "from", definition = FromStepParser.Definition.class) public class FromStepParser implements StartStepParser { @Override public Object process(Context context) { final Definition definition = context.node(Definition.class); - final String uri = definition.getEndpointUri(); + final String uri = StepParserSupport.createEndpointUri(definition.uri, definition.parameters); final RouteDefinition route = context.builder().from(uri); // as this is a start converter, steps are mandatory @@ -57,21 +53,6 @@ public static final class Definition { public Map parameters; @JsonProperty(required = true) public List steps; - - @JsonIgnore - public String getEndpointUri() { - String answer = uri; - - if (parameters != null) { - try { - answer = URISupport.appendParametersToURI(answer, parameters); - } catch (URISyntaxException | UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - return answer; - } } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java index b78dc0391..6cbc0d7e2 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java @@ -16,12 +16,9 @@ */ package org.apache.camel.k.loader.yaml.parser; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; import java.util.List; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; @@ -30,14 +27,13 @@ import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.RouteDefinition; import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.URISupport; @YAMLStepParser(id = "route", definition = RouteStepParser.Definition.class) public class RouteStepParser implements StartStepParser { @Override public Object process(Context context) { final Definition definition = context.node(Definition.class); - final String uri = definition.from.getEndpointUri(); + final String uri = StepParserSupport.createEndpointUri(definition.from.uri, definition.from.parameters); final RouteDefinition route = context.builder().from(uri); ObjectHelper.ifNotEmpty(definition.id, route::routeId); @@ -78,21 +74,6 @@ public From() { public From(String uri) { this.uri = uri; } - - @JsonIgnore - public String getEndpointUri() { - String answer = uri; - - if (parameters != null) { - try { - answer = URISupport.appendParametersToURI(answer, parameters); - } catch (URISyntaxException | UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - return answer; - } } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java index 932f3b678..75ede02cc 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java @@ -16,25 +16,23 @@ */ package org.apache.camel.k.loader.yaml.parser; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ToDynamicDefinition; -import org.apache.camel.util.URISupport; @YAMLStepParser(id = "tod", definition = ToDynamicStepParser.Definition.class) public class ToDynamicStepParser implements ProcessorStepParser { @Override public ProcessorDefinition toProcessor(Context context) { final Definition definition = context.node(Definition.class); - final ToDynamicDefinition answer = new ToDynamicDefinition(definition.getEndpointUri()); + final String uri = StepParserSupport.createEndpointUri(definition.getUri(), definition.parameters); + final ToDynamicDefinition answer = new ToDynamicDefinition(uri); return answer; } @@ -50,21 +48,6 @@ public Definition() { public Definition(String uri) { super(uri); } - - @JsonIgnore - public String getEndpointUri() { - String answer = getUri(); - - if (parameters != null) { - try { - answer = URISupport.appendParametersToURI(answer, parameters); - } catch (URISyntaxException | UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - return answer; - } } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java index 6308084f5..b43a1a92b 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java @@ -16,25 +16,23 @@ */ package org.apache.camel.k.loader.yaml.parser; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ToDefinition; -import org.apache.camel.util.URISupport; @YAMLStepParser(id = "to", definition = ToStepParser.Definition.class) public class ToStepParser implements ProcessorStepParser { @Override public ProcessorDefinition toProcessor(Context context) { final Definition definition = context.node(Definition.class); - final ToDefinition answer = new ToDefinition(definition.getEndpointUri()); + final String uri = StepParserSupport.createEndpointUri(definition.getUri(), definition.parameters); + final ToDefinition answer = new ToDefinition(uri); return answer; } @@ -50,21 +48,6 @@ public Definition() { public Definition(String uri) { super(uri); } - - @JsonIgnore - public String getEndpointUri() { - String answer = uri; - - if (parameters != null) { - try { - answer = URISupport.appendParametersToURI(answer, parameters); - } catch (URISyntaxException | UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - return answer; - } } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java index 2b4465251..05ad623cb 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java @@ -16,15 +16,13 @@ */ package org.apache.camel.k.loader.yaml.parser; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; import java.util.List; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ExpressionSubElementDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetHeaderDefinition; @@ -33,7 +31,6 @@ import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.reifier.WireTapReifier; import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.URISupport; @YAMLStepParser(id = "wiretap", definition = WireTapStepParser.Definition.class) public class WireTapStepParser implements ProcessorStepParser { @@ -56,7 +53,9 @@ public ProcessorDefinition toProcessor(Context context) { } } - answer.setUri(definition.getEndpointUri()); + answer.setUri( + StepParserSupport.createEndpointUri(definition.getUri(), definition.parameters) + ); return answer; } @@ -70,21 +69,6 @@ public static final class Definition extends ToDynamicDefinition { public Boolean dynamicUri; public NewExchangeDefinition newExchange; public Map parameters; - - @JsonIgnore - public String getEndpointUri() { - String answer = getUri(); - - if (parameters != null) { - try { - answer = URISupport.appendParametersToURI(answer, parameters); - } catch (URISyntaxException | UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - return answer; - } } @YAMLNodeDefinition diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java index 014ec7b7f..b18b7a1b2 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java @@ -17,6 +17,8 @@ package org.apache.camel.k.loader.yaml.spi; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.apache.camel.k.loader.yaml.model.Step; import org.apache.camel.model.OutputNode; @@ -60,4 +62,21 @@ public static ProcessorDefinition convertSteps(ProcessorStepParser.Context co return parent; } + + public static String createEndpointUri(String uri, Map parameters) { + String answer = uri; + + if (parameters != null) { + String queryString = parameters.entrySet().stream() + .filter(entry -> entry.getValue() != null) + .map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue())) + .collect(Collectors.joining("&")); + + if (ObjectHelper.isNotEmpty(queryString)) { + answer += "?" + queryString; + } + } + + return answer; + } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RouteWithPlaceholdersTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RouteWithPlaceholdersTest.groovy new file mode 100644 index 000000000..eece0829d --- /dev/null +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RouteWithPlaceholdersTest.groovy @@ -0,0 +1,98 @@ +/* + * 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.k.loader.yaml + +import org.apache.camel.component.direct.DirectEndpoint + +class RouteWithPlaceholdersTest extends TestSupport { + def 'route'() { + setup: + def parameters = [ + 'direct.id': 'myDirect', + 'direct.timeout': 1234, + 'direct.result': UUID.randomUUID().toString() + ] + def context = startContext { + propertiesComponent.initialProperties = parameters as Properties + } + when: + def uri = context.resolvePropertyPlaceholders('direct://{{direct.id}}?timeout={{direct.timeout}}') + def out = template(context).to(uri).request(String.class) + then: + out == parameters['direct.result'] + cleanup: + context?.stop() + } + def 'from'() { + setup: + def parameters = [ + 'direct.id': 'myDirect', + 'direct.timeout': 1234, + 'direct.result': UUID.randomUUID().toString() + ] + def context = startContext { + propertiesComponent.initialProperties = parameters as Properties + } + when: + def uri = context.resolvePropertyPlaceholders('direct://{{direct.id}}?timeout={{direct.timeout}}') + def out = template(context).to(uri).request(String.class) + def eps = context.getEndpoints().find { it instanceof DirectEndpoint } + then: + out == parameters['direct.result'] + with (eps, DirectEndpoint) { + timeout == parameters['direct.timeout'] + } + cleanup: + context?.stop() + } + + def 'to'() { + setup: + def parameters = [ + 'direct.id': 'myDirect', + 'direct.timeout': 1234, + 'direct.result': UUID.randomUUID().toString() + ] + def context = startContext { + propertiesComponent.initialProperties = parameters as Properties + } + when: + def out = template(context).to('direct:start').request(String.class) + then: + out == parameters['direct.result'] + cleanup: + context?.stop() + } + + def 'tod'() { + setup: + def parameters = [ + 'direct.id': 'myDirect', + 'direct.timeout': 1234, + 'direct.result': UUID.randomUUID().toString() + ] + def context = startContext { + propertiesComponent.initialProperties = parameters as Properties + } + when: + def out = template(context).to('direct:start').request(String.class) + then: + out == parameters['direct.result'] + cleanup: + context?.stop() + } +} diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesTest.groovy index 882e03aa2..29263cd45 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/RoutesTest.groovy @@ -81,9 +81,9 @@ class RoutesTest extends TestSupport { def 'aggregator'() { setup: - def context = startContext([ - 'aggregatorStrategy': new UseLatestAggregationStrategy() - ]) + def context = startContext { + registry.bind('aggregatorStrategy', new UseLatestAggregationStrategy()) + } mockEndpoint(context, 'mock:route') { expectedMessageCount 2 @@ -104,9 +104,9 @@ class RoutesTest extends TestSupport { def 'idempotentConsumer'() { setup: - def context = startContext([ - 'myRepo': new MemoryIdempotentRepository() - ]) + def context = startContext { + registry.bind('myRepo', new MemoryIdempotentRepository()) + } mockEndpoint(context,'mock:idempotent') { expectedMessageCount = 3 @@ -132,9 +132,9 @@ class RoutesTest extends TestSupport { def 'onExceptionHandled'() { setup: - def context = startContext([ - 'myFailingProcessor' : new MyFailingProcessor() - ]) + def context = startContext { + registry.bind('myFailingProcessor', new MyFailingProcessor()) + } when: def out = context.createProducerTemplate().requestBody('direct:start', 'Hello World'); then: @@ -145,9 +145,9 @@ class RoutesTest extends TestSupport { def 'errorHandler'() { setup: - def context = startContext([ - 'myFailingProcessor' : new MyFailingProcessor() - ]) + def context = startContext { + registry.bind('myFailingProcessor', new MyFailingProcessor()) + } mockEndpoint(context, 'mock:on-error') { expectedMessageCount = 1 diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy index a2426a655..0971ad068 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy @@ -19,6 +19,7 @@ package org.apache.camel.k.loader.yaml import com.fasterxml.jackson.databind.JsonNode import groovy.util.logging.Slf4j import org.apache.camel.CamelContext +import org.apache.camel.FluentProducerTemplate import org.apache.camel.builder.RouteBuilder import org.apache.camel.component.mock.MockEndpoint import org.apache.camel.impl.DefaultCamelContext @@ -58,32 +59,37 @@ class TestSupport extends Specification { } static CamelContext startContext(String content) { - return startContext(content, [:]) + return startContext(content, null) } - static CamelContext startContext(String content, Map beans) { + static CamelContext startContext( + String content, + @DelegatesTo(CamelContext) Closure closure) { return startContext( new ByteArrayInputStream(content.stripMargin().getBytes(StandardCharsets.UTF_8)), - beans + closure ) } static CamelContext startContext(InputStream content) { - return startContext(content, [:]) + return startContext(content, null) } - static CamelContext startContext(InputStream content, Map beans) { + static CamelContext startContext( + InputStream content, + @DelegatesTo(CamelContext) Closure closure) { def context = new DefaultCamelContext() def builder = new YamlSourceLoader().builder(content) - if (beans) { - beans.each { - k, v -> context.registry.bind(k, v) - } - } - context.disableJMX() context.setStreamCaching(true) + + if (closure) { + closure.resolveStrategy = Closure.DELEGATE_ONLY + closure.delegate = context + closure.call() + } + context.addRoutes(builder) context.start() @@ -91,16 +97,16 @@ class TestSupport extends Specification { } CamelContext startContext() { - return startContext([:]) + return startContext(null as Closure) } - CamelContext startContext(Map beans) { + CamelContext startContext(@DelegatesTo(CamelContext) Closure closure) { def name = specificationContext.currentIteration.name.replace(' ', '_') def path = "/routes/${specificationContext.currentSpec.name}_${name}.yaml" return startContext( TestSupport.class.getResourceAsStream(path) as InputStream, - beans + closure ) } @@ -136,4 +142,9 @@ class TestSupport extends Specification { } throw new IllegalArgumentException("No parser of ${id}") } + + static FluentProducerTemplate template(CamelContext context) { + return context.createFluentProducerTemplate() + } + } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ToTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ToTest.groovy index bfd54ae16..a60db224c 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ToTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ToTest.groovy @@ -33,7 +33,7 @@ class ToTest extends TestSupport { def processor = new ToStepParser().toProcessor(stepContext) then: with(processor, ToDefinition) { - endpointUri == 'seda://test?queueSize=1' + endpointUri ==~ /seda:(\/\/)?test\?queueSize=1/ } } @@ -45,7 +45,7 @@ class ToTest extends TestSupport { def processor = new ToStepParser().toProcessor(stepContext) then: with(processor, ToDefinition) { - endpointUri == 'seda://test' + endpointUri ==~ /seda:(\/\/)?test/ } } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_from.yaml b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_from.yaml new file mode 100644 index 000000000..c5df34341 --- /dev/null +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_from.yaml @@ -0,0 +1,23 @@ +# +# 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. +# +- from: + uri: "direct:{{direct.id}}" + parameters: + timeout: "{{direct.timeout}}" + steps: + - set-body: + constant: "{{direct.result}}" \ No newline at end of file diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_route.yaml b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_route.yaml new file mode 100644 index 000000000..08e979127 --- /dev/null +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_route.yaml @@ -0,0 +1,24 @@ +# +# 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. +# +- route: + from: + uri: "direct:{{direct.id}}" + parameters: + timeout: "{{direct.timeout}}" + steps: + - set-body: + constant: "{{direct.result}}" \ No newline at end of file diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_to.yaml b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_to.yaml new file mode 100644 index 000000000..a42700e01 --- /dev/null +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_to.yaml @@ -0,0 +1,30 @@ +# +# 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. +# +- from: + uri: "direct:start" + steps: + - to: + uri: "direct:{{direct.id}}" + parameters: + timeout: "{{direct.timeout}}" +- from: + uri: "direct:{{direct.id}}" + parameters: + timeout: "{{direct.timeout}}" + steps: + - set-body: + constant: "{{direct.result}}" \ No newline at end of file diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_tod.yaml b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_tod.yaml new file mode 100644 index 000000000..1ff60fd3d --- /dev/null +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RouteWithPlaceholdersTest_tod.yaml @@ -0,0 +1,30 @@ +# +# 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. +# +- from: + uri: "direct:start" + steps: + - tod: + uri: "direct:{{direct.id}}" + parameters: + timeout: "{{direct.timeout}}" +- from: + uri: "direct:{{direct.id}}" + parameters: + timeout: "{{direct.timeout}}" + steps: + - set-body: + constant: "{{direct.result}}" \ No newline at end of file diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesTest_onExceptionHandled.yaml b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesTest_onExceptionHandled.yaml index 3bd3bcb7e..56d5a172b 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesTest_onExceptionHandled.yaml +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/resources/routes/RoutesTest_onExceptionHandled.yaml @@ -15,7 +15,7 @@ # limitations under the License. # - on-exception: - exceptioons: + exceptions: - org.apache.camel.k.loader.yaml.support.MyException handled: true steps: diff --git a/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json b/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json index 24c9cd16c..12371c697 100644 --- a/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json +++ b/camel-knative/camel-knative/src/generated/resources/org/apache/camel/component/knative/knative.json @@ -11,7 +11,7 @@ "supportLevel": "Preview", "groupId": "org.apache.camel.k", "artifactId": "camel-knative", - "version": "1.4.0-SNAPSHOT", + "version": "1.5.0-SNAPSHOT", "scheme": "knative", "extendsScheme": "", "syntax": "knative:type\/name",