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-spring-boot-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 80dd083  Improved examples by improving output and demonstrating some 
use cases through tests. (#48)
80dd083 is described below

commit 80dd083dcc73d2405384f54dfbad0b4b0ece42e7
Author: Steve Storck <steve...@gmail.com>
AuthorDate: Sat Feb 5 02:19:38 2022 -0500

    Improved examples by improving output and demonstrating some use cases 
through tests. (#48)
---
 dynamic-router-eip/README.adoc                     | 12 ++++
 dynamic-router-eip/pom.xml                         | 16 ++++-
 .../config/DynamicRouterComponentConfig.java       | 28 ++++++++
 .../springboot/numbers/config/ExampleConfig.java   | 82 ++++++++++++++++++++++
 .../springboot/numbers/service/NumbersService.java | 55 +++++++++------
 .../springboot/numbers/service/ResultsService.java | 75 ++++++++++++--------
 .../src/main/resources/application.yml             |  8 ++-
 dynamic-router-eip/src/main/resources/logback.xml  | 12 ++++
 .../springboot/AllRecipientsApplicationTest.java   | 16 +++++
 .../springboot/FirstRecipientApplicationTest.java  | 16 +++++
 .../springboot/LessExpectedApplicationTest.java    | 16 +++++
 .../resources/application-test-all.yml}            | 14 ++--
 .../resources/application-test-first.yml}          | 12 ++--
 .../resources/application-test-less.yml}           | 12 ++--
 .../src/test/resources/logback-test.xml            | 14 ++++
 15 files changed, 319 insertions(+), 69 deletions(-)

diff --git a/dynamic-router-eip/README.adoc b/dynamic-router-eip/README.adoc
index b1c0a7e..b1b60e6 100644
--- a/dynamic-router-eip/README.adoc
+++ b/dynamic-router-eip/README.adoc
@@ -110,6 +110,18 @@ If you want to run the Dynamic Router in "allMatch" 
receiver mode, run the examp
 
 The results should show up in less than ten seconds, and the program will 
immediately terminate.
 
+=== Run Tests
+
+You can run the tests using:
+
+    $mvn test
+
+There are some demos that run during the test phase.  Currently, there are 
three:
+
+ 1. AllRecipientsApplicationTest: the recipient mode is set to "allMatch" and 
1,000,000 messages are sent through the router.
+ 2. FirstRecipientApplicationTest: the recipient mode is set to "firstMatch" 
and 1,000,000 messages are sent through the router.
+ 3. LessExpectedApplicationTest: the recipient mode is set to "firstMatch", 
and 10,000 messages are sent through the router.  The difference, here, is that 
the expected count is set to only 1,000 messages, so the results are calculated 
and displayed before all 10,000 messages are routed.
+
 === Help and contributions
 
 If you hit any problem using Camel or have some feedback, then please
diff --git a/dynamic-router-eip/pom.xml b/dynamic-router-eip/pom.xml
index 170f763..4b7f82a 100644
--- a/dynamic-router-eip/pom.xml
+++ b/dynamic-router-eip/pom.xml
@@ -76,7 +76,21 @@
             <artifactId>spring-boot-configuration-processor</artifactId>
             <optional>true</optional>
         </dependency>
-
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java
 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java
index 237f61c..a7403e6 100644
--- 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java
+++ 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java
@@ -19,6 +19,8 @@ package org.apache.camel.example.springboot.numbers.config;
 import org.apache.camel.ConsumerTemplate;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.dynamicrouter.DynamicRouterConfiguration;
+import org.apache.camel.component.dynamicrouter.DynamicRouterConstants;
 import 
org.apache.camel.example.springboot.numbers.participants.PredicateConstants;
 import 
org.apache.camel.example.springboot.numbers.participants.RoutingParticipant;
 import org.apache.camel.example.springboot.numbers.service.ResultsService;
@@ -26,7 +28,10 @@ import 
org.springframework.boot.context.properties.EnableConfigurationProperties
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
+import java.util.concurrent.CountDownLatch;
+
 import static 
org.apache.camel.component.dynamicrouter.DynamicRouterConstants.COMPONENT_SCHEME;
+import static 
org.apache.camel.component.dynamicrouter.DynamicRouterConstants.MODE_FIRST_MATCH;
 import static 
org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_EIGHTS;
 import static 
org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_EVEN;
 import static 
org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_FIVES;
@@ -79,6 +84,29 @@ public class DynamicRouterComponentConfig {
     }
 
     /**
+     * Create a {@link CountDownLatch} so that we can wait on it for the total
+     * expected number of messages to be received.  Depending on the configured
+     * value of {@link ExampleConfig#getRecipientMode()}, this latch will be
+     * created with {@link ExampleConfig#getExpectedAllMatchMessageCount()} or
+     * {@link ExampleConfig#getExpectedFirstMatchMessageCount()}.
+     *
+     * @see DynamicRouterConstants#MODE_ALL_MATCH
+     * @see DynamicRouterConstants#MODE_FIRST_MATCH
+     * @see DynamicRouterConfiguration#getRecipientMode()
+     * @see ExampleConfig#getRecipientMode()
+     * @see ExampleConfig#getExpectedAllMatchMessageCount()
+     * @see ExampleConfig#getExpectedFirstMatchMessageCount()
+     *
+     * @return a countdown latch set to the number of expected messages
+     */
+    @Bean
+    CountDownLatch countDownLatch() {
+        return new 
CountDownLatch(MODE_FIRST_MATCH.equals(exampleConfig.getRecipientMode()) ?
+                exampleConfig.getExpectedFirstMatchMessageCount() :
+                exampleConfig.getExpectedAllMatchMessageCount());
+    }
+
+    /**
      * Create a {@link RoutingParticipant} that handles messages where the 
body is comprised of a number that is
      * a multiple of 10.
      *
diff --git 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java
 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java
index c96b049..187925f 100644
--- 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java
+++ 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java
@@ -18,6 +18,8 @@ package org.apache.camel.example.springboot.numbers.config;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
+import java.util.concurrent.CountDownLatch;
+
 /**
  * The config properties object from the application.yml file.
  */
@@ -50,6 +52,33 @@ public class ExampleConfig {
      */
     private String recipientMode;
 
+    /**
+     * The number of messages to send.
+     */
+    private int sendMessageCount;
+
+    /**
+     * If the recipient mode is "firstMatch", then this is the number of
+     * messages that are expected to be received.  This value is also used
+     * to create a {@link CountDownLatch} so that all messages can be
+     * received before printing out messaging statistics.
+     */
+    private int expectedFirstMatchMessageCount;
+
+    /**
+     * If the recipient mode is "allMatch", then this is the number of
+     * messages that are expected to be received.  There is probably not an
+     * easy way to calculate this number, so the number needs to be known
+     * for a given {@link #sendMessageCount} value.  This value is also used
+     * to create a {@link CountDownLatch} so that all messages can be
+     * received before printing out messaging statistics.
+     */
+    private int expectedAllMatchMessageCount;
+
+    /**
+     * The URI where messages will be sent to as the starting point for the
+     * route that feeds the dynamic router.
+     */
     public String getStartUri() {
         return startUri;
     }
@@ -58,6 +87,9 @@ public class ExampleConfig {
         this.startUri = startUri;
     }
 
+    /**
+     * The dynamic router channel.
+     */
     public String getRoutingChannel() {
         return routingChannel;
     }
@@ -66,6 +98,9 @@ public class ExampleConfig {
         this.routingChannel = routingChannel;
     }
 
+    /**
+     * The dynamic router control channel URI
+     */
     public String getSubscribeUri() {
         return subscribeUri;
     }
@@ -74,6 +109,9 @@ public class ExampleConfig {
         this.subscribeUri = subscribeUri;
     }
 
+    /**
+     * The scheme that routing participants will use to listen for messages.
+     */
     public String getReceiverScheme() {
         return receiverScheme;
     }
@@ -82,6 +120,9 @@ public class ExampleConfig {
         this.receiverScheme = receiverScheme;
     }
 
+    /**
+     * The recipient mode -- first matching filter only, or all matching 
filters.
+     */
     public String getRecipientMode() {
         return this.recipientMode;
     }
@@ -89,4 +130,45 @@ public class ExampleConfig {
     public void setRecipientMode(String recipientMode) {
         this.recipientMode = recipientMode;
     }
+
+    /**
+     * The number of messages to send.
+     */
+    public int getSendMessageCount() {
+        return sendMessageCount;
+    }
+
+    public void setSendMessageCount(int sendMessageCount) {
+        this.sendMessageCount = sendMessageCount;
+    }
+
+    /**
+     * If the recipient mode is "firstMatch", then this is the number of
+     * messages that are expected to be received.  This value is also used
+     * to create a {@link CountDownLatch} so that all messages can be
+     * received before printing out messaging statistics.
+     */
+    public int getExpectedFirstMatchMessageCount() {
+        return expectedFirstMatchMessageCount;
+    }
+
+    public void setExpectedFirstMatchMessageCount(int 
expectedFirstMatchMessageCount) {
+        this.expectedFirstMatchMessageCount = expectedFirstMatchMessageCount;
+    }
+
+    /**
+     * If the recipient mode is "allMatch", then this is the number of
+     * messages that are expected to be received.  There is probably not an
+     * easy way to calculate this number, so the number needs to be known
+     * for a given {@link #sendMessageCount} value.  This value is also used
+     * to create a {@link CountDownLatch} so that all messages can be
+     * received before printing out messaging statistics.
+     */
+    public int getExpectedAllMatchMessageCount() {
+        return expectedAllMatchMessageCount;
+    }
+
+    public void setExpectedAllMatchMessageCount(int 
expectedAllMatchMessageCount) {
+        this.expectedAllMatchMessageCount = expectedAllMatchMessageCount;
+    }
 }
diff --git 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java
 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java
index 80c8ad2..e23c81b 100644
--- 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java
+++ 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java
@@ -23,15 +23,19 @@ import 
org.apache.camel.example.springboot.numbers.participants.RoutingParticipa
 import org.apache.camel.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
 import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.context.ApplicationContext;
 import org.springframework.context.event.EventListener;
 import org.springframework.stereotype.Service;
 
+import java.text.NumberFormat;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
 import java.util.stream.IntStream;
 
+import static java.util.concurrent.TimeUnit.*;
+
 /**
  * Create numbers and send them to the dynamic router so that they can be
  * processed and binned to demonstrate the usage of the dynamic router
@@ -42,6 +46,8 @@ public class NumbersService {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(NumbersService.class);
 
+    private final NumberFormat numberFormat = 
NumberFormat.getIntegerInstance();
+
     /**
      * The URI to send the messages to.  This URI feeds the dynamic router in a
      * Camel route.
@@ -67,32 +73,37 @@ public class NumbersService {
     private final ResultsService resultsService;
 
     /**
-     * The Spring Boot {@link ApplicationContext} so that the app can be
-     * programmatically shut down when we are finished processing all
-     * messages and displaying results.
+     * The {@link CountDownLatch} to wait for the total expected number of
+     * messages to be received.
+     */
+    final CountDownLatch countDownLatch;
+
+    /**
+     * The number of messages to generate.
      */
-    private final ApplicationContext applicationContext;
+    final int numberOfMessages;
 
     /**
-     * Create this service with all of the things.
+     * Create this service with everything.
      *
-     * @param config the configuration object representing the config 
properties
-     * @param participants the dynamic router participants
-     * @param start the producer template to send messages to the start 
endpoint
-     * @param resultsService the service that compiles routing results
-     * @param applicationContext the Spring app context for exiting when 
processing is complete
+     * @param config             the configuration object representing the 
config properties
+     * @param participants       the dynamic router participants
+     * @param start              the producer template to send messages to the 
start endpoint
+     * @param resultsService     the service that compiles routing results
+     * @param countDownLatch     the latch to wait for all messages to be 
received
      */
     public NumbersService(
             final ExampleConfig config,
             final List<RoutingParticipant> participants,
             final ProducerTemplate start,
             final ResultsService resultsService,
-            final ApplicationContext applicationContext) {
+            final CountDownLatch countDownLatch) {
         this.startUri = config.getStartUri();
         this.participants = participants;
         this.start = start;
         this.resultsService = resultsService;
-        this.applicationContext = applicationContext;
+        this.countDownLatch = countDownLatch;
+        this.numberOfMessages = config.getSendMessageCount();
     }
 
     /**
@@ -101,21 +112,23 @@ public class NumbersService {
      * display the results and exit the app.
      */
     @EventListener(ApplicationReadyEvent.class)
-    public void start() {
-        LOG.info("Subscribing participants");
+    public void start() throws InterruptedException {
+        LOG.info("Subscribing {} participants", participants.size());
         participants.forEach(RoutingParticipant::subscribe);
-        StopWatch watch = new StopWatch();
-        LOG.info("Sending messages to the dynamic router");
-        sendMessages();
+        final StopWatch watch = new StopWatch();
+        LOG.info("Sending {} messages to the dynamic router: {}", 
numberFormat.format(numberOfMessages), getStartUri());
+        CompletableFuture.runAsync(this::sendMessages, 
Executors.newSingleThreadExecutor());
+        if (!countDownLatch.await(1, MINUTES)) {
+            LOG.warn("Statistics may be inaccurate, since the operation timed 
out");
+        }
         LOG.info(resultsService.getStatistics(watch));
-        SpringApplication.exit(applicationContext);
     }
 
     /**
      * Sends the messages to the starting endpoint of the route.
      */
     public void sendMessages() {
-        IntStream.rangeClosed(1, 1000000).forEach(start::sendBody);
+        IntStream.rangeClosed(1, numberOfMessages).forEach(start::sendBody);
     }
 
     /**
diff --git 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java
 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java
index 9265678..c291ef2 100644
--- 
a/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java
+++ 
b/dynamic-router-eip/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java
@@ -16,15 +16,17 @@
  */
 package org.apache.camel.example.springboot.numbers.service;
 
+import org.apache.camel.example.springboot.numbers.config.ExampleConfig;
 import org.apache.camel.util.StopWatch;
 import org.springframework.stereotype.Service;
 
+import java.text.NumberFormat;
 import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
+import java.util.concurrent.CountDownLatch;
 
 /**
  * Holds processing results so that they can be displayed, etc.
@@ -32,32 +34,42 @@ import java.util.stream.Collectors;
 @Service
 public class ResultsService {
 
+    private final NumberFormat numberFormat = 
NumberFormat.getIntegerInstance();
+
     /**
-     * A counter to keep track of the number of results.
+     * A map of the "bin" or "category" to the list of values in that bin.
      */
-    private final AtomicInteger count = new AtomicInteger(0);
+    private final ConcurrentHashMap<String, Collection<Integer>> results;
 
     /**
-     * A map of the "bin" or "category" to the list of values in that bin.
+     * The {@link CountDownLatch} to wait for all messages to be received.
+     */
+    private final CountDownLatch countDownLatch;
+
+    /**
+     * The number of sent messages.
      */
-    private final ConcurrentHashMap<String, List<Integer>> results;
+    private final int numberSent;
 
     /**
      * Create the service and initialize the results map.
      */
-    public ResultsService() {
-        results = new ConcurrentHashMap<>();
+    public ResultsService(final CountDownLatch countDownLatch,
+            final ExampleConfig config) {
+        this.results = new ConcurrentHashMap<>();
+        this.countDownLatch = countDownLatch;
+        this.numberSent = config.getSendMessageCount();
     }
 
     /**
      * Add a result value for the given key/bin.
      *
-     * @param key the bin or category
+     * @param key   the bin or category
      * @param value the value to add to the bin
      */
     public void addResult(final String key, int value) {
-        results.computeIfAbsent(key, v -> new ArrayList<>()).add(value);
-        count.incrementAndGet();
+        results.computeIfAbsent(key, v -> 
Collections.synchronizedCollection(new ArrayList<>())).add(value);
+        countDownLatch.countDown();
     }
 
     /**
@@ -65,32 +77,39 @@ public class ResultsService {
      *
      * @return the results map
      */
-    public Map<String, List<Integer>> getResults() {
+    public Map<String, Collection<Integer>> getResults() {
         return results;
     }
 
     /**
-     * Get the result count.
-     *
-     * @return the result count
-     */
-    public int getTotal() {
-        return count.get();
-    }
-
-    /**
      * Get a message that contains the statistics of the messaging.
      *
      * @param watch a {@link StopWatch} that was started at the beginning of 
messaging
      * @return a message that contains the statistics of the messaging
      */
     public String getStatistics(final StopWatch watch) {
-        return results.entrySet().stream()
+        final long taken = watch.taken();
+        final int totalCount = getResults().values()
+                .stream()
+                .mapToInt(Collection::size)
+                .sum();
+        final int numberLength = numberFormat.format(totalCount)
+                .length();
+        StringBuilder statistics = new StringBuilder("Finished in ")
+                .append(taken).append("ms")
+                .append("\nDynamic Router Spring Boot Numbers Example 
Results:\n");
+        getResults().entrySet().stream()
                 .sorted((o1, o2) -> o2.getValue().size() - 
o1.getValue().size())
-                .map(e -> String.format("%7s: %7d", e.getKey(), 
e.getValue().size()))
-                .collect(Collectors.joining("\n\t",
-                        "Finished\nDynamic Router Spring Boot Numbers Example 
Results:\n\t",
-                        String.format("\nReceived count: %d in %dms", 
getTotal(), watch.taken())));
-
+                .map(e -> String.format("%7s: %" + numberLength + "s [%3d%% 
routed, %3d%% sent]",
+                        e.getKey(), numberFormat.format(e.getValue().size()),
+                        e.getValue().size() * 100 / totalCount,
+                        e.getValue().size() * 100 / numberSent))
+                .forEach(s -> statistics.append("\n\t").append(s));
+        statistics.append("\n\n\t")
+                .append(String.format("%7s: %" + numberLength + "s [%3d%% 
routed, %3d%% sent]",
+                        "total", numberFormat.format(totalCount),
+                        totalCount * 100 / totalCount,
+                        totalCount * 100 / numberSent));
+        return statistics.toString();
     }
 }
diff --git a/dynamic-router-eip/src/main/resources/application.yml 
b/dynamic-router-eip/src/main/resources/application.yml
index 1db08e0..bf7bc21 100644
--- a/dynamic-router-eip/src/main/resources/application.yml
+++ b/dynamic-router-eip/src/main/resources/application.yml
@@ -27,6 +27,9 @@ camel:
         receiver-scheme: direct
         start-uri: direct:start
         recipient-mode: firstMatch
+        send-message-count: 1000000
+        expected-first-match-message-count: 1000000
+        expected-all-match-message-count: 2507465
   component:
     dynamic-router:
       lazy-start-producer: true
@@ -35,9 +38,8 @@ camel:
     enabled: false
 logging:
   level:
-    org.springframework: WARN
-    org.apache.camel: WARN
-    org.apache.camel.example.springboot.numbers: INFO
+    root: WARN
+    org.apache.camel.example.springboot: INFO
 spring:
   profiles:
     active: default
diff --git a/dynamic-router-eip/src/main/resources/logback.xml 
b/dynamic-router-eip/src/main/resources/logback.xml
new file mode 100644
index 0000000..3502b16
--- /dev/null
+++ b/dynamic-router-eip/src/main/resources/logback.xml
@@ -0,0 +1,12 @@
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%8.8relative %highlight(%5.-5level) %15.-15c{0} - 
%m%n</pattern>
+        </encoder>
+    </appender>
+    <root level="error">
+        <appender-ref ref="STDOUT"/>
+    </root>
+    <logger name="org.apache.camel.example.springboot.Application" 
level="warn"/>
+    <logger name="org.apache.camel.example.springboot" level="info"/>
+</configuration>
diff --git 
a/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/AllRecipientsApplicationTest.java
 
b/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/AllRecipientsApplicationTest.java
new file mode 100644
index 0000000..851a5a0
--- /dev/null
+++ 
b/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/AllRecipientsApplicationTest.java
@@ -0,0 +1,16 @@
+package org.apache.camel.example.springboot;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+@SpringBootTest(classes = { Application.class })
+@ActiveProfiles("test-all")
+class AllRecipientsApplicationTest {
+
+    @Test
+    void testApplication() {
+        Assertions.assertTrue(true);
+    }
+}
diff --git 
a/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/FirstRecipientApplicationTest.java
 
b/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/FirstRecipientApplicationTest.java
new file mode 100644
index 0000000..c363ac9
--- /dev/null
+++ 
b/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/FirstRecipientApplicationTest.java
@@ -0,0 +1,16 @@
+package org.apache.camel.example.springboot;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+@SpringBootTest(classes = { Application.class })
+@ActiveProfiles("test-first")
+class FirstRecipientApplicationTest {
+
+    @Test
+    void testApplication() {
+        Assertions.assertTrue(true);
+    }
+}
diff --git 
a/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/LessExpectedApplicationTest.java
 
b/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/LessExpectedApplicationTest.java
new file mode 100644
index 0000000..2d889eb
--- /dev/null
+++ 
b/dynamic-router-eip/src/test/java/org/apache/camel/example/springboot/LessExpectedApplicationTest.java
@@ -0,0 +1,16 @@
+package org.apache.camel.example.springboot;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+@SpringBootTest(classes = { Application.class })
+@ActiveProfiles("test-less")
+class LessExpectedApplicationTest {
+
+    @Test
+    void testApplication() {
+        Assertions.assertTrue(true);
+    }
+}
diff --git a/dynamic-router-eip/src/main/resources/application.yml 
b/dynamic-router-eip/src/test/resources/application-test-all.yml
similarity index 80%
copy from dynamic-router-eip/src/main/resources/application.yml
copy to dynamic-router-eip/src/test/resources/application-test-all.yml
index 1db08e0..f01b644 100644
--- a/dynamic-router-eip/src/main/resources/application.yml
+++ b/dynamic-router-eip/src/test/resources/application-test-all.yml
@@ -26,7 +26,10 @@ camel:
         subscribe-uri: dynamic-router:control
         receiver-scheme: direct
         start-uri: direct:start
-        recipient-mode: firstMatch
+        recipient-mode: allMatch
+        send-message-count: 1000000
+        expected-first-match-message-count: 1000000
+        expected-all-match-message-count: 2507465
   component:
     dynamic-router:
       lazy-start-producer: true
@@ -35,9 +38,8 @@ camel:
     enabled: false
 logging:
   level:
-    org.springframework: WARN
-    org.apache.camel: WARN
-    org.apache.camel.example.springboot.numbers: INFO
+    root: WARN
+    org.apache.camel.example.springboot: INFO
 spring:
-  profiles:
-    active: default
+  main:
+    banner-mode: off
diff --git a/dynamic-router-eip/src/main/resources/application.yml 
b/dynamic-router-eip/src/test/resources/application-test-first.yml
similarity index 82%
copy from dynamic-router-eip/src/main/resources/application.yml
copy to dynamic-router-eip/src/test/resources/application-test-first.yml
index 1db08e0..ae35410 100644
--- a/dynamic-router-eip/src/main/resources/application.yml
+++ b/dynamic-router-eip/src/test/resources/application-test-first.yml
@@ -27,6 +27,9 @@ camel:
         receiver-scheme: direct
         start-uri: direct:start
         recipient-mode: firstMatch
+        send-message-count: 1000000
+        expected-first-match-message-count: 1000000
+        expected-all-match-message-count: 2507465
   component:
     dynamic-router:
       lazy-start-producer: true
@@ -35,9 +38,8 @@ camel:
     enabled: false
 logging:
   level:
-    org.springframework: WARN
-    org.apache.camel: WARN
-    org.apache.camel.example.springboot.numbers: INFO
+    root: WARN
+    org.apache.camel.example.springboot: INFO
 spring:
-  profiles:
-    active: default
+  main:
+    banner-mode: off
diff --git a/dynamic-router-eip/src/main/resources/application.yml 
b/dynamic-router-eip/src/test/resources/application-test-less.yml
similarity index 82%
copy from dynamic-router-eip/src/main/resources/application.yml
copy to dynamic-router-eip/src/test/resources/application-test-less.yml
index 1db08e0..6d43362 100644
--- a/dynamic-router-eip/src/main/resources/application.yml
+++ b/dynamic-router-eip/src/test/resources/application-test-less.yml
@@ -27,6 +27,9 @@ camel:
         receiver-scheme: direct
         start-uri: direct:start
         recipient-mode: firstMatch
+        send-message-count: 10000
+        expected-first-match-message-count: 1000
+        expected-all-match-message-count: 500000
   component:
     dynamic-router:
       lazy-start-producer: true
@@ -35,9 +38,8 @@ camel:
     enabled: false
 logging:
   level:
-    org.springframework: WARN
-    org.apache.camel: WARN
-    org.apache.camel.example.springboot.numbers: INFO
+    root: WARN
+    org.apache.camel.example.springboot: INFO
 spring:
-  profiles:
-    active: default
+  main:
+    banner-mode: off
diff --git a/dynamic-router-eip/src/test/resources/logback-test.xml 
b/dynamic-router-eip/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..2fb8398
--- /dev/null
+++ b/dynamic-router-eip/src/test/resources/logback-test.xml
@@ -0,0 +1,14 @@
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%-9relative [%-5p] %-30c{0} - %m%n</pattern>
+        </encoder>
+    </appender>
+    <root level="error">
+        <appender-ref ref="STDOUT"/>
+    </root>
+    <logger 
name="org.apache.camel.example.springboot.AllRecipientsApplicationTest" 
level="warn"/>
+    <logger 
name="org.apache.camel.example.springboot.FirstRecipientApplicationTest" 
level="warn"/>
+    <logger 
name="org.apache.camel.example.springboot.LessExpectedApplicationTest" 
level="warn"/>
+    <logger name="org.apache.camel.example.springboot" level="info"/>
+</configuration>

Reply via email to