This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-examples.git
The following commit(s) were added to refs/heads/main by this push:
new d747186 CAMEL-17611: Add examples to show how to use templatedRoute
(#71)
d747186 is described below
commit d747186b8ae653fbfe0c009e2a4d4b6b67289cb9
Author: Nicolas Filotto <[email protected]>
AuthorDate: Thu Feb 10 09:20:51 2022 +0100
CAMEL-17611: Add examples to show how to use templatedRoute (#71)
---
examples/README.adoc | 4 +-
examples/pom.xml | 1 +
.../README.adoc | 11 +-
examples/routetemplate-xml/pom.xml | 112 +++++++++++++++++++++
.../org/apache/camel/example/MyApplication.java | 19 +---
.../src/main/resources/application.properties | 12 +--
.../resources/builders/my-template-builder.xml | 31 ++++++
.../src/main/resources/logback.xml | 30 ++++++
.../resources/templates/my-route-templates.xml | 40 ++++++++
.../camel/example/RouteTemplateXMLTest.java} | 24 +++--
examples/routetemplate/README.adoc | 2 +-
.../org/apache/camel/example/MyApplication.java | 4 +-
.../org/apache/camel/example/MyRouteTemplates.java | 2 +-
.../apache/camel/example/MyTemplateBuilder.java | 21 ++--
.../src/main/resources/application.properties | 4 +-
.../apache/camel/example/RouteTemplateTest.java | 7 +-
16 files changed, 260 insertions(+), 64 deletions(-)
diff --git a/examples/README.adoc b/examples/README.adoc
index e5c0b8a..35a2a9a 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -11,7 +11,7 @@ View the individual example READMEs for details.
== Examples
// examples: START
-Number of Examples: 83 (0 deprecated)
+Number of Examples: 84 (0 deprecated)
[width="100%",cols="4,2,4",options="header"]
|===
@@ -86,6 +86,8 @@ Number of Examples: 83 (0 deprecated)
| link:routetemplate/README.adoc[Routetemplate] (routetemplate) | Beginner |
How to use route templates (parameterized routes)
+| link:routetemplate-xml/README.adoc[Routetemplate XML] (routetemplate-xml) |
Beginner | How to use route templates (parameterized routes) in XML
+
| link:servlet-tomcat/README.adoc[Servlet Tomcat] (servlet-tomcat) | Beginner
| An example using Camel Servlet with Apache Tomcat
| link:spring/README.adoc[Spring] (spring) | Beginner | An example showing how
to work with Camel and Spring
diff --git a/examples/pom.xml b/examples/pom.xml
index b4bffe3..0e050e9 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -140,6 +140,7 @@
<module>route-throttling</module>
<module>routeloader</module>
<module>routetemplate</module>
+ <module>routetemplate-xml</module>
<module>routes-configuration</module>
<module>salesforce-consumer</module>
<module>servlet-tomcat</module>
diff --git a/examples/routetemplate/README.adoc
b/examples/routetemplate-xml/README.adoc
similarity index 58%
copy from examples/routetemplate/README.adoc
copy to examples/routetemplate-xml/README.adoc
index 04c872b..84f465e 100644
--- a/examples/routetemplate/README.adoc
+++ b/examples/routetemplate-xml/README.adoc
@@ -1,14 +1,11 @@
-== Camel Example Route Template
+== Camel Example Route Template in XML
This examples shows how to use Route Templates (parameterized routes) to
specify a skeleton route
-which can be used for creating and adding new routes via parameters.
+which can be used for creating and adding new routes via parameters in pure
XML.
-The route template is defined via Java or XML DSL (RouteBuilder) in the
`MyRouteTemplates.java` source file.
+The route template is defined via XML DSL (RouteBuilder) in the resource
`templates/my-route-templates.xml`.
-The `application.properties` is used to create two routes from the template
using different set of parameters.
-
-An alternative to create routes is from Java which is done in the
`MyTemplateBuilder.java` class.
-See the `MyApplication.java` where you can change the source to use java
instead of property file for the template parameters.
+The resource `builders/my-template-builder.xml` is used to create two routes
from the template using different set of parameters by leveraging the XML DSL.
The example runs standalone via Camel Main in the `MyApplication.java` source
file.
diff --git a/examples/routetemplate-xml/pom.xml
b/examples/routetemplate-xml/pom.xml
new file mode 100644
index 0000000..dd77058
--- /dev/null
+++ b/examples/routetemplate-xml/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel.example</groupId>
+ <artifactId>examples</artifactId>
+ <version>3.16.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-routetemplate-xml</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Example :: RouteTemplate :: XML</name>
+ <description>How to use route templates (parameterized routes) in
XML</description>
+
+ <properties>
+ <category>Beginner</category>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Add Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-bom</artifactId>
+ <version>${camel.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <!-- use camel-main to bootstrap camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-main</artifactId>
+ </dependency>
+ <!-- use fast and light-weight xml parser -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-xml-io-dsl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-quartz</artifactId>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j2-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logback-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback-version}</version>
+ </dependency>
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${camel.version}</version>
+ <configuration>
+ <logClasspath>false</logClasspath>
+
<mainClass>org.apache.camel.example.MyApplication</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
b/examples/routetemplate-xml/src/main/java/org/apache/camel/example/MyApplication.java
similarity index 62%
copy from
examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
copy to
examples/routetemplate-xml/src/main/java/org/apache/camel/example/MyApplication.java
index 3a2d357..933fa9e 100644
---
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
+++
b/examples/routetemplate-xml/src/main/java/org/apache/camel/example/MyApplication.java
@@ -19,7 +19,7 @@ package org.apache.camel.example;
import org.apache.camel.main.Main;
/**
- * Main class that boot the Camel application
+ * Main class that boots up the Camel application
*/
public final class MyApplication {
@@ -29,19 +29,10 @@ public final class MyApplication {
public static void main(String[] args) throws Exception {
// use Camels Main class
Main main = new Main();
- // and add route templates via routes builder
- main.configure().addRoutesBuilder(MyRouteTemplates.class);
- // add configuration class which set up the routes from the route
templates
-
- // to configure route templates we can use java code as below from a
template builder class,
- // gives more power as its java code.
- // or we can configure as well from application.properties,
- // less power as its key value pair properties
- // and you can also use both java and properties together
-
- // in this example we use properties by default and have disabled java
- // main.bind("myTemplateBuilder", new MyTemplateBuilder());
-
+ // and add all the XML templates and builders
+ // make sure that the templates are listed before the builders to
prevent
+ // route creation error
+
main.configure().withRoutesIncludePattern("templates/*.xml,builders/*.xml");
// now keep the application running until the JVM is terminated (ctrl
+ c or sigterm)
main.run(args);
}
diff --git a/examples/routetemplate/src/main/resources/application.properties
b/examples/routetemplate-xml/src/main/resources/application.properties
similarity index 72%
copy from examples/routetemplate/src/main/resources/application.properties
copy to examples/routetemplate-xml/src/main/resources/application.properties
index 658ff9b..cb87bf7 100644
--- a/examples/routetemplate/src/main/resources/application.properties
+++ b/examples/routetemplate-xml/src/main/resources/application.properties
@@ -17,18 +17,8 @@
# to configure camel main
# here you can configure options on camel main (see
MainConfigurationProperties class)
-camel.main.name = MyCoolCamel
+camel.main.name = MyRootTemplateInXML
# turn on lightweight mode
camel.main.lightweight = true
-# create routes from the route template
-# this can also be done in Java code, see MyTemplateBuilder.java
-camel.route-template[0].template-id = myTemplate
-camel.route-template[0].name = one
-camel.route-template[0].greeting = Hello
-camel.route-template[1].template-id = myTemplate
-camel.route-template[1].name = two
-camel.route-template[1].greeting = Bonjour
-camel.route-template[1].my-period = 5s
-
diff --git
a/examples/routetemplate-xml/src/main/resources/builders/my-template-builder.xml
b/examples/routetemplate-xml/src/main/resources/builders/my-template-builder.xml
new file mode 100644
index 0000000..28da731
--- /dev/null
+++
b/examples/routetemplate-xml/src/main/resources/builders/my-template-builder.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<templatedRoutes id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <!-- create two routes from the template -->
+ <templatedRoute routeTemplateRef="myTemplate">
+ <parameter name="name" value="one"/>
+ <parameter name="greeting" value="Hello"/>
+ </templatedRoute>
+ <templatedRoute routeTemplateRef="myTemplate">
+ <parameter name="name" value="deux"/>
+ <parameter name="greeting" value="Bonjour"/>
+ <parameter name="myPeriod" value="5s"/>
+ </templatedRoute>
+</templatedRoutes>
diff --git a/examples/routetemplate-xml/src/main/resources/logback.xml
b/examples/routetemplate-xml/src/main/resources/logback.xml
new file mode 100644
index 0000000..a798d0b
--- /dev/null
+++ b/examples/routetemplate-xml/src/main/resources/logback.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} -
%msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration>
diff --git
a/examples/routetemplate-xml/src/main/resources/templates/my-route-templates.xml
b/examples/routetemplate-xml/src/main/resources/templates/my-route-templates.xml
new file mode 100644
index 0000000..e53897b
--- /dev/null
+++
b/examples/routetemplate-xml/src/main/resources/templates/my-route-templates.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<routeTemplates id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <!-- create a route template with the given name -->
+ <routeTemplate id="myTemplate">
+ <!-- here we define the required input parameters (can have default
values) -->
+ <templateParameter name="name"/>
+ <templateParameter name="greeting"/>
+ <templateParameter name="myPeriod" defaultValue="3s"/>
+ <!--
+ here comes the route in the template
+ notice how we use {{name}} to refer to the template parameters
+ we can also use {{propertyName}} to refer to property placeholders
+ -->
+ <route>
+ <from uri="timer:{{name}}?period={{myPeriod}}"/>
+ <setBody>
+ <simple>{{greeting}} {{name}}</simple>
+ </setBody>
+ <log message="${body}"/>
+ </route>
+ </routeTemplate>
+</routeTemplates>
diff --git
a/examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
b/examples/routetemplate-xml/src/test/java/org/apache/camel/example/RouteTemplateXMLTest.java
similarity index 62%
copy from
examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
copy to
examples/routetemplate-xml/src/test/java/org/apache/camel/example/RouteTemplateXMLTest.java
index 421e5b4..74bb0c2 100644
---
a/examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
+++
b/examples/routetemplate-xml/src/test/java/org/apache/camel/example/RouteTemplateXMLTest.java
@@ -16,25 +16,27 @@
*/
package org.apache.camel.example;
+import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.spi.PackageScanResourceResolver;
+import org.apache.camel.spi.Resource;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.junit.jupiter.api.Test;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- * A unit test checking that Camel supports parameterized routes.
+ * A unit test checking that Camel supports parameterized routes in XML.
*/
-class RouteTemplateTest extends CamelTestSupport {
+class RouteTemplateXMLTest extends CamelTestSupport {
@Test
void should_support_parameterized_routes() {
- // Manually adds the templated routes
- new MyTemplateBuilder().configure(context);
-
NotifyBuilder notify = new
NotifyBuilder(context).from("timer:*").whenCompleted(2).create();
assertTrue(
notify.matches(20, TimeUnit.SECONDS), "2 messages should be
completed"
@@ -42,7 +44,15 @@ class RouteTemplateTest extends CamelTestSupport {
}
@Override
- protected RoutesBuilder createRouteBuilder() {
- return new MyRouteTemplates();
+ protected RoutesBuilder[] createRouteBuilders() throws Exception {
+ final ExtendedCamelContext ecc =
context.adapt(ExtendedCamelContext.class);
+ final PackageScanResourceResolver resolver =
ecc.getPackageScanResourceResolver();
+ final List<RoutesBuilder> routesBuilders = new ArrayList<>();
+ for (String location : List.of("templates/*","builders/*")) {
+ for (Resource resource : resolver.findResources(location)) {
+
routesBuilders.addAll(ecc.getRoutesLoader().findRoutesBuilders(resource));
+ }
+ }
+ return routesBuilders.toArray(RoutesBuilder[]::new);
}
}
diff --git a/examples/routetemplate/README.adoc
b/examples/routetemplate/README.adoc
index 04c872b..1e639b6 100644
--- a/examples/routetemplate/README.adoc
+++ b/examples/routetemplate/README.adoc
@@ -7,7 +7,7 @@ The route template is defined via Java or XML DSL
(RouteBuilder) in the `MyRoute
The `application.properties` is used to create two routes from the template
using different set of parameters.
-An alternative to create routes is from Java which is done in the
`MyTemplateBuilder.java` class.
+An alternative to create routes is from Java which is done in the
`MyTemplateBuilder.java` class thanks to the Java DSL.
See the `MyApplication.java` where you can change the source to use java
instead of property file for the template parameters.
The example runs standalone via Camel Main in the `MyApplication.java` source
file.
diff --git
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
b/examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
index 3a2d357..3f2665e 100644
---
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
+++
b/examples/routetemplate/src/main/java/org/apache/camel/example/MyApplication.java
@@ -19,7 +19,7 @@ package org.apache.camel.example;
import org.apache.camel.main.Main;
/**
- * Main class that boot the Camel application
+ * Main class that boots up the Camel application
*/
public final class MyApplication {
@@ -40,7 +40,7 @@ public final class MyApplication {
// and you can also use both java and properties together
// in this example we use properties by default and have disabled java
- // main.bind("myTemplateBuilder", new MyTemplateBuilder());
+ // main.configure().addRoutesBuilder(MyTemplateBuilder.class);
// now keep the application running until the JVM is terminated (ctrl
+ c or sigterm)
main.run(args);
diff --git
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyRouteTemplates.java
b/examples/routetemplate/src/main/java/org/apache/camel/example/MyRouteTemplates.java
index 6040577..4d4bc88 100644
---
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyRouteTemplates.java
+++
b/examples/routetemplate/src/main/java/org/apache/camel/example/MyRouteTemplates.java
@@ -37,7 +37,7 @@ public class MyRouteTemplates extends RouteBuilder {
// notice how we use {{name}} to refer to the template parameters
// we can also use {{propertyName}} to refer to property
placeholders
.from("timer:{{name}}?period={{myPeriod}}")
- .setBody(simple("{{greeting}} ${body}"))
+ .setBody(simple("{{greeting}} {{name}}"))
.log("${body}");
}
}
diff --git
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyTemplateBuilder.java
b/examples/routetemplate/src/main/java/org/apache/camel/example/MyTemplateBuilder.java
index 6e0ba67..6e3cc32 100644
---
a/examples/routetemplate/src/main/java/org/apache/camel/example/MyTemplateBuilder.java
+++
b/examples/routetemplate/src/main/java/org/apache/camel/example/MyTemplateBuilder.java
@@ -16,28 +16,23 @@
*/
package org.apache.camel.example;
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.TemplatedRouteBuilder;
-import org.apache.camel.main.ConfigureRouteTemplates;
+import org.apache.camel.builder.RouteBuilder;
-public class MyTemplateBuilder implements ConfigureRouteTemplates {
+public class MyTemplateBuilder extends RouteBuilder {
/**
* Configure and adds routes from route templates.
*/
- public void configure(CamelContext context) {
+ public void configure() {
// create two routes from the template
-
- TemplatedRouteBuilder.builder(context, "myTemplate")
+ templatedRoute("myTemplate")
.parameter("name", "one")
- .parameter("greeting", "Hello")
- .add();
+ .parameter("greeting", "Hello");
- TemplatedRouteBuilder.builder(context, "myTemplate")
- .parameter("name", "two")
+ templatedRoute("myTemplate")
+ .parameter("name", "deux")
.parameter("greeting", "Bonjour")
- .parameter("myPeriod", "5s")
- .add();
+ .parameter("myPeriod", "5s");
}
}
diff --git a/examples/routetemplate/src/main/resources/application.properties
b/examples/routetemplate/src/main/resources/application.properties
index 658ff9b..030ce11 100644
--- a/examples/routetemplate/src/main/resources/application.properties
+++ b/examples/routetemplate/src/main/resources/application.properties
@@ -17,7 +17,7 @@
# to configure camel main
# here you can configure options on camel main (see
MainConfigurationProperties class)
-camel.main.name = MyCoolCamel
+camel.main.name = MyRootTemplate
# turn on lightweight mode
camel.main.lightweight = true
@@ -28,7 +28,7 @@ camel.route-template[0].template-id = myTemplate
camel.route-template[0].name = one
camel.route-template[0].greeting = Hello
camel.route-template[1].template-id = myTemplate
-camel.route-template[1].name = two
+camel.route-template[1].name = deux
camel.route-template[1].greeting = Bonjour
camel.route-template[1].my-period = 5s
diff --git
a/examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
b/examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
index 421e5b4..ec34896 100644
---
a/examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
+++
b/examples/routetemplate/src/test/java/org/apache/camel/example/RouteTemplateTest.java
@@ -32,9 +32,6 @@ class RouteTemplateTest extends CamelTestSupport {
@Test
void should_support_parameterized_routes() {
- // Manually adds the templated routes
- new MyTemplateBuilder().configure(context);
-
NotifyBuilder notify = new
NotifyBuilder(context).from("timer:*").whenCompleted(2).create();
assertTrue(
notify.matches(20, TimeUnit.SECONDS), "2 messages should be
completed"
@@ -42,7 +39,7 @@ class RouteTemplateTest extends CamelTestSupport {
}
@Override
- protected RoutesBuilder createRouteBuilder() {
- return new MyRouteTemplates();
+ protected RoutesBuilder[] createRouteBuilders() {
+ return new RoutesBuilder[]{new MyRouteTemplates(), new
MyTemplateBuilder()};
}
}