From 9558a71d96c1da3cc3c5cb70e7e90dc08a64a768 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Thu, 1 Aug 2019 16:39:44 +0200 Subject: [PATCH] Allow endpoint DSL in Camel k #122 --- camel-k-loader-groovy/pom.xml | 5 +++ .../k/loader/groovy/GroovyRoutesLoader.groovy | 3 +- .../dsl/IntegrationConfiguration.groovy | 24 ++++++++++---- .../camel/k/loader/groovy/LoaderTest.groovy | 31 ++++++++++++++++++- .../resources/routes-with-endpoint-dsl.groovy | 21 +++++++++++++ camel-k-loader-java/pom.xml | 5 +++ .../camel/k/loader/java/RoutesLoaderTest.java | 3 +- .../resources/MyRoutesWithEndpointDsl.java | 23 ++++++++++++++ camel-k-loader-js/pom.xml | 9 ++++++ .../k/loader/js/JavaScriptRoutesLoader.java | 3 +- .../js/dsl/IntegrationConfiguration.java | 19 ++++++++---- .../camel/k/loader/js/RoutesLoaderTest.java | 1 + .../resources/routes-with-endpoint-dsl.js | 22 +++++++++++++ camel-k-loader-kotlin/pom.xml | 7 ++++- .../k/loader/kotlin/KotlinRoutesLoader.kt | 12 +++---- .../kotlin/dsl/IntegrationConfiguration.kt | 10 ++++-- .../camel/k/loader/kotlin/LoaderTest.kt | 26 ++++++++++++++-- .../resources/routes-with-endpoint-dsl.kts | 21 +++++++++++++ .../maven/processors/CatalogProcessor3x.java | 4 +++ 19 files changed, 222 insertions(+), 27 deletions(-) create mode 100644 camel-k-loader-groovy/src/test/resources/routes-with-endpoint-dsl.groovy create mode 100644 camel-k-loader-java/src/test/resources/MyRoutesWithEndpointDsl.java create mode 100644 camel-k-loader-js/src/test/resources/routes-with-endpoint-dsl.js create mode 100644 camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts diff --git a/camel-k-loader-groovy/pom.xml b/camel-k-loader-groovy/pom.xml index fb383f9c0..bd96dc861 100644 --- a/camel-k-loader-groovy/pom.xml +++ b/camel-k-loader-groovy/pom.xml @@ -42,6 +42,11 @@ camel-log provided + + org.apache.camel + camel-endpointdsl + provided + org.apache.camel camel-groovy diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovyRoutesLoader.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovyRoutesLoader.groovy index 1321cb9e5..7af01f746 100644 --- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovyRoutesLoader.groovy +++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/GroovyRoutesLoader.groovy @@ -18,6 +18,7 @@ package org.apache.camel.k.loader.groovy import org.apache.camel.CamelContext import org.apache.camel.builder.RouteBuilder +import org.apache.camel.builder.endpoint.EndpointRouteBuilder import org.apache.camel.k.RoutesLoader import org.apache.camel.k.Source import org.apache.camel.k.loader.groovy.dsl.IntegrationConfiguration @@ -34,7 +35,7 @@ class GroovyRoutesLoader implements RoutesLoader { @Override RouteBuilder load(CamelContext camelContext, Source source) throws Exception { - return new RouteBuilder() { + return new EndpointRouteBuilder() { @Override void configure() throws Exception { def ic = new ImportCustomizer() diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationConfiguration.groovy b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationConfiguration.groovy index 918afeab7..4eff02d75 100644 --- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationConfiguration.groovy +++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/IntegrationConfiguration.groovy @@ -19,16 +19,24 @@ package org.apache.camel.k.loader.groovy.dsl import org.apache.camel.Exchange import org.apache.camel.Predicate import org.apache.camel.Processor -import org.apache.camel.builder.RouteBuilder -import org.apache.camel.model.* +import org.apache.camel.builder.BuilderSupport +import org.apache.camel.builder.EndpointConsumerBuilder +import org.apache.camel.builder.endpoint.EndpointBuilderFactory +import org.apache.camel.builder.endpoint.EndpointRouteBuilder +import org.apache.camel.model.InterceptDefinition +import org.apache.camel.model.InterceptFromDefinition +import org.apache.camel.model.InterceptSendToEndpointDefinition +import org.apache.camel.model.OnCompletionDefinition +import org.apache.camel.model.OnExceptionDefinition +import org.apache.camel.model.RouteDefinition import org.apache.camel.spi.Registry -class IntegrationConfiguration extends org.apache.camel.builder.BuilderSupport { +class IntegrationConfiguration extends BuilderSupport implements EndpointBuilderFactory { final Registry registry final Components components - final RouteBuilder builder + final EndpointRouteBuilder builder - IntegrationConfiguration(RouteBuilder builder) { + IntegrationConfiguration(EndpointRouteBuilder builder) { super(builder.context) this.registry = this.context.registry @@ -74,7 +82,11 @@ class IntegrationConfiguration extends org.apache.camel.builder.BuilderSupport { } } - ProcessorDefinition from(String endpoint) { + RouteDefinition from(String endpoint) { + return builder.from(endpoint) + } + + RouteDefinition from(EndpointConsumerBuilder endpoint) { return builder.from(endpoint) } diff --git a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/LoaderTest.groovy b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/LoaderTest.groovy index e019b03dc..056b47c26 100644 --- a/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/LoaderTest.groovy +++ b/camel-k-loader-groovy/src/test/groovy/org/apache/camel/k/loader/groovy/LoaderTest.groovy @@ -19,12 +19,13 @@ package org.apache.camel.k.loader.groovy import org.apache.camel.impl.DefaultCamelContext import org.apache.camel.k.Source import org.apache.camel.k.support.RuntimeSupport +import org.apache.camel.model.FromDefinition import org.apache.camel.model.ToDefinition import spock.lang.Specification class LoaderTest extends Specification { - def "load route from classpath"() { + def "load routes"() { given: def context = new DefaultCamelContext() def source = Source.create("classpath:routes.groovy") @@ -46,4 +47,32 @@ class LoaderTest extends Specification { routes[0].outputs[0] instanceof ToDefinition routes[0].input.endpointUri == 'timer:tick' } + + def "load routes with endpoint dsl"() { + given: + def context = new DefaultCamelContext() + def source = Source.create("classpath:routes-with-endpoint-dsl.groovy") + + when: + def loader = RuntimeSupport.loaderFor(context, source) + def builder = loader.load(context, source) + + then: + loader instanceof GroovyRoutesLoader + builder != null + + builder.setContext(context) + builder.configure() + + def routes = builder.routeCollection.routes + + routes.size() == 1 + + with(routes[0].input, FromDefinition) { + it.endpointUri == 'timer:tick?period=1s' + } + with(routes[0].outputs[0], ToDefinition) { + it.endpointUri == 'log:info' + } + } } diff --git a/camel-k-loader-groovy/src/test/resources/routes-with-endpoint-dsl.groovy b/camel-k-loader-groovy/src/test/resources/routes-with-endpoint-dsl.groovy new file mode 100644 index 000000000..1e6993112 --- /dev/null +++ b/camel-k-loader-groovy/src/test/resources/routes-with-endpoint-dsl.groovy @@ -0,0 +1,21 @@ +/* + * 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. + */ +def f = timer('tick').period('1s') +def t = log('info') + +from(f) + .to(t) \ No newline at end of file diff --git a/camel-k-loader-java/pom.xml b/camel-k-loader-java/pom.xml index e2f3799c8..80f51ee20 100644 --- a/camel-k-loader-java/pom.xml +++ b/camel-k-loader-java/pom.xml @@ -37,6 +37,11 @@ camel-core-engine provided + + org.apache.camel + camel-endpointdsl + provided + org.jooq joor-java-8 diff --git a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java index a778a0798..3db52d4fe 100644 --- a/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java +++ b/camel-k-loader-java/src/test/java/org/apache/camel/k/loader/java/RoutesLoaderTest.java @@ -140,7 +140,8 @@ static Stream parameters() { Arguments.arguments("classpath:" + MyRoutes.class.getName() + ".class", JavaClassRoutesLoader.class), Arguments.arguments("classpath:MyRoutes.java", JavaSourceRoutesLoader.class), Arguments.arguments("classpath:MyRoutesWithNameOverride.java?name=MyRoutes.java", JavaSourceRoutesLoader.class), - Arguments.arguments("classpath:MyRoutesWithPackage.java", JavaSourceRoutesLoader.class) + Arguments.arguments("classpath:MyRoutesWithPackage.java", JavaSourceRoutesLoader.class), + Arguments.arguments("classpath:MyRoutesWithEndpointDsl.java", JavaSourceRoutesLoader.class) ); } } diff --git a/camel-k-loader-java/src/test/resources/MyRoutesWithEndpointDsl.java b/camel-k-loader-java/src/test/resources/MyRoutesWithEndpointDsl.java new file mode 100644 index 000000000..2a6093134 --- /dev/null +++ b/camel-k-loader-java/src/test/resources/MyRoutesWithEndpointDsl.java @@ -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. + */ +public class MyRoutesWithEndpointDsl extends org.apache.camel.builder.endpoint.EndpointRouteBuilder { + @Override + public void configure() throws Exception { + from(timer("tick")) + .to(log("info")); + } +} \ No newline at end of file diff --git a/camel-k-loader-js/pom.xml b/camel-k-loader-js/pom.xml index 561c1c254..99d2cb753 100644 --- a/camel-k-loader-js/pom.xml +++ b/camel-k-loader-js/pom.xml @@ -37,6 +37,11 @@ camel-core-engine provided + + org.apache.camel + camel-endpointdsl + provided + org.graalvm.js js @@ -127,6 +132,10 @@ ${log4j2.version} test + + org.apache.camel + camel-endpointdsl + diff --git a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptRoutesLoader.java b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptRoutesLoader.java index c6ad4d2c2..e443a45d0 100644 --- a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptRoutesLoader.java +++ b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptRoutesLoader.java @@ -23,6 +23,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.builder.endpoint.EndpointRouteBuilder; import org.apache.camel.k.RoutesLoader; import org.apache.camel.k.Source; import org.apache.camel.k.loader.js.dsl.IntegrationConfiguration; @@ -42,7 +43,7 @@ public List getSupportedLanguages() { @Override public RouteBuilder load(CamelContext camelContext, Source source) throws Exception { - return new RouteBuilder() { + return new EndpointRouteBuilder() { @Override public void configure() throws Exception { final Context context = Context.newBuilder("js").allowAllAccess(true).build(); diff --git a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/IntegrationConfiguration.java b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/IntegrationConfiguration.java index a8782b8d4..11fee49f9 100644 --- a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/IntegrationConfiguration.java +++ b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/IntegrationConfiguration.java @@ -16,23 +16,26 @@ */ package org.apache.camel.k.loader.js.dsl; -import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.builder.BuilderSupport; +import org.apache.camel.builder.EndpointConsumerBuilder; +import org.apache.camel.builder.endpoint.EndpointBuilderFactory; +import org.apache.camel.builder.endpoint.EndpointRouteBuilder; import org.apache.camel.model.InterceptDefinition; import org.apache.camel.model.InterceptFromDefinition; import org.apache.camel.model.InterceptSendToEndpointDefinition; import org.apache.camel.model.OnCompletionDefinition; import org.apache.camel.model.OnExceptionDefinition; -import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.rest.RestConfigurationDefinition; import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.spi.Registry; -public class IntegrationConfiguration extends org.apache.camel.builder.BuilderSupport { +public class IntegrationConfiguration extends BuilderSupport implements EndpointBuilderFactory { public final Registry registry; public final Components components; - public final RouteBuilder builder; + public final EndpointRouteBuilder builder; - public IntegrationConfiguration(RouteBuilder builder) { + public IntegrationConfiguration(EndpointRouteBuilder builder) { super(builder.getContext()); this.registry = builder.getContext().getRegistry(); @@ -40,7 +43,11 @@ public IntegrationConfiguration(RouteBuilder builder) { this.builder = builder; } - public ProcessorDefinition from(String endpoint) { + public RouteDefinition from(String endpoint) { + return builder.from(endpoint); + } + + public RouteDefinition from(EndpointConsumerBuilder endpoint) { return builder.from(endpoint); } diff --git a/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/RoutesLoaderTest.java b/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/RoutesLoaderTest.java index 05e417f94..8be5e9fad 100644 --- a/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/RoutesLoaderTest.java +++ b/camel-k-loader-js/src/test/java/org/apache/camel/k/loader/js/RoutesLoaderTest.java @@ -55,6 +55,7 @@ public void testLoaders(String location, Class type) thr static Stream parameters() { return Stream.of( Arguments.arguments("classpath:routes.js", JavaScriptRoutesLoader.class), + Arguments.arguments("classpath:routes-with-endpoint-dsl.js", JavaScriptRoutesLoader.class), Arguments.arguments("classpath:routes-compressed.js.gz.b64?language=js&compression=true", JavaScriptRoutesLoader.class), Arguments.arguments("classpath:routes.mytype?language=js", JavaScriptRoutesLoader.class) ); diff --git a/camel-k-loader-js/src/test/resources/routes-with-endpoint-dsl.js b/camel-k-loader-js/src/test/resources/routes-with-endpoint-dsl.js new file mode 100644 index 000000000..fc8456d92 --- /dev/null +++ b/camel-k-loader-js/src/test/resources/routes-with-endpoint-dsl.js @@ -0,0 +1,22 @@ +/* + * 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. + */ + +f = timer("tick"); +t = log("info"); + +from(f) + .to(t); \ No newline at end of file diff --git a/camel-k-loader-kotlin/pom.xml b/camel-k-loader-kotlin/pom.xml index 573c570af..f7c3b755a 100644 --- a/camel-k-loader-kotlin/pom.xml +++ b/camel-k-loader-kotlin/pom.xml @@ -39,7 +39,7 @@ org.apache.camel - camel-main + camel-endpointdsl provided @@ -102,6 +102,11 @@ camel-properties test + + org.apache.camel + camel-main + test + diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt index ea1950b9e..cc8fb2209 100644 --- a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt +++ b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/KotlinRoutesLoader.kt @@ -17,7 +17,7 @@ package org.apache.camel.k.loader.kotlin import org.apache.camel.CamelContext -import org.apache.camel.builder.RouteBuilder +import org.apache.camel.builder.endpoint.EndpointRouteBuilder import org.apache.camel.k.RoutesLoader import org.apache.camel.k.Source import org.apache.camel.k.loader.kotlin.dsl.IntegrationConfiguration @@ -25,11 +25,11 @@ import org.apache.camel.k.support.URIResolver import org.slf4j.Logger import org.slf4j.LoggerFactory import java.io.InputStreamReader -import kotlin.script.experimental.api.* +import kotlin.script.experimental.api.ScriptDiagnostic +import kotlin.script.experimental.api.ScriptEvaluationConfiguration +import kotlin.script.experimental.api.constructorArgs import kotlin.script.experimental.host.toScriptSource import kotlin.script.experimental.jvm.BasicJvmScriptEvaluator -import kotlin.script.experimental.jvm.dependenciesFromClassloader -import kotlin.script.experimental.jvm.jvm import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost import kotlin.script.experimental.jvmhost.JvmScriptCompiler import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate @@ -44,8 +44,8 @@ class KotlinRoutesLoader : RoutesLoader { } @Throws(Exception::class) - override fun load(camelContext: CamelContext, source: Source): RouteBuilder? { - return object : RouteBuilder() { + override fun load(camelContext: CamelContext, source: Source): EndpointRouteBuilder? { + return object : EndpointRouteBuilder() { @Throws(Exception::class) override fun configure() { val builder = this diff --git a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt index 84dccc218..a6b6b8eb5 100644 --- a/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt +++ b/camel-k-loader-kotlin/src/main/kotlin/org/apache/camel/k/loader/kotlin/dsl/IntegrationConfiguration.kt @@ -19,7 +19,10 @@ package org.apache.camel.k.loader.kotlin.dsl import org.apache.camel.Exchange import org.apache.camel.Predicate import org.apache.camel.Processor -import org.apache.camel.builder.RouteBuilder +import org.apache.camel.builder.BuilderSupport +import org.apache.camel.builder.EndpointConsumerBuilder +import org.apache.camel.builder.endpoint.EndpointBuilderFactory +import org.apache.camel.builder.endpoint.EndpointRouteBuilder import org.apache.camel.k.loader.kotlin.KotlinCompilationConfiguration import org.apache.camel.model.* import org.apache.camel.spi.Registry @@ -28,7 +31,7 @@ import kotlin.script.experimental.annotations.KotlinScript @KotlinScript(fileExtension = "kts", compilationConfiguration = KotlinCompilationConfiguration::class) abstract class IntegrationConfiguration( private val registry : Registry, - private val builder : RouteBuilder) : org.apache.camel.builder.BuilderSupport(builder.context) { + private val builder : EndpointRouteBuilder) : BuilderSupport(builder.context), EndpointBuilderFactory { fun rest(block: RestConfiguration.() -> Unit) { RestConfiguration(builder).block() @@ -53,6 +56,9 @@ abstract class IntegrationConfiguration( return builder.from(uri) } + fun from(endpoint: EndpointConsumerBuilder): RouteDefinition { + return builder.from(endpoint) + } fun intercept() : InterceptDefinition { return builder.intercept() diff --git a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt b/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt index 9567b0aeb..2bde81206 100644 --- a/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt +++ b/camel-k-loader-kotlin/src/test/kotlin/org/apache/camel/k/loader/kotlin/LoaderTest.kt @@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test class LoaderTest { @Test - fun `load route from classpath`() { + fun `load routes`() { var context = DefaultCamelContext() var source = Source.create("classpath:routes.kts") val loader = RuntimeSupport.loaderFor(context, source) @@ -41,8 +41,30 @@ class LoaderTest { val routes = builder.routeCollection.routes assertThat(routes).hasSize(1) - assertThat(routes[0].getInput().endpointUri).isEqualTo("timer:tick") + assertThat(routes[0].input.endpointUri).isEqualTo("timer:tick") assertThat(routes[0].outputs[0]).isInstanceOf(ProcessDefinition::class.java) assertThat(routes[0].outputs[1]).isInstanceOf(ToDefinition::class.java) } + + @Test + fun `load routes with endpoint dsl`() { + var context = DefaultCamelContext() + var source = Source.create("classpath:routes-with-endpoint-dsl.kts") + val loader = RuntimeSupport.loaderFor(context, source) + val builder = loader.load(context, source) + + assertThat(loader).isInstanceOf(KotlinRoutesLoader::class.java) + assertThat(builder).isNotNull + + builder.context = context + builder.configure() + + val routes = builder.routeCollection.routes + assertThat(routes).hasSize(1) + assertThat(routes[0].input.endpointUri).isEqualTo("timer:tick?period=1s") + assertThat(routes[0].outputs[0]).isInstanceOfSatisfying(ToDefinition::class.java) { + assertThat(it.endpointUri).isEqualTo("log:info") + } + + } } diff --git a/camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts b/camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts new file mode 100644 index 000000000..fc04af96b --- /dev/null +++ b/camel-k-loader-kotlin/src/test/resources/routes-with-endpoint-dsl.kts @@ -0,0 +1,21 @@ +/* + * 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. + */ +var f = timer("tick").period("1s") +var t = log("info") + +from(f) + .to(t) \ No newline at end of file diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java index 698850f04..962f95c45 100644 --- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java +++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java @@ -111,6 +111,7 @@ public void process(MavenProject project, CamelCatalog catalog, Map