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 c468238e CAMEL-23400: camel-test - Add route diagram dumper
c468238e is described below

commit c468238ea1d65d285a556c38b3b241df5b91bc79
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri May 8 13:21:52 2026 +0200

    CAMEL-23400: camel-test - Add route diagram dumper
---
 spring-boot/doc/MyCamelRouter.png                  | Bin 0 -> 23704 bytes
 spring-boot/pom.xml                                |   8 ++++++
 spring-boot/readme.adoc                            |   9 +++++++
 ...onJUnit6Test.java => DumpRouteDiagramTest.java} |  28 ++++++---------------
 ...ApplicationJUnit6Test.java => MyCamelTest.java} |  10 +++++---
 5 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/spring-boot/doc/MyCamelRouter.png 
b/spring-boot/doc/MyCamelRouter.png
new file mode 100644
index 00000000..80edc50e
Binary files /dev/null and b/spring-boot/doc/MyCamelRouter.png differ
diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index a16e9250..61b8ebd7 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -107,6 +107,14 @@
             <artifactId>camel-test-spring-junit6</artifactId>
             <scope>test</scope>
         </dependency>
+        <!-- dump route diagrams -->
+        <!-- TODO: SB starter -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-diagram</artifactId>
+            <version>${camel-version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/spring-boot/readme.adoc b/spring-boot/readme.adoc
index bce9e910..a6b48565 100644
--- a/spring-boot/readme.adoc
+++ b/spring-boot/readme.adoc
@@ -52,6 +52,15 @@ For example to get route information:
 curl -XGET -s http://localhost:8080/actuator/camel/routes
 ----
 
+=== Route Diagram
+
+This example automatic generates a visual route diagram, which is generated as 
part of testing (see `MainDiagramTest.java`),
+and the file is stored in the `doc` folder.
+
+NOTE: This requires having `camel-diagram` as test scoped dependency.
+
+image::doc/MyCamelRouter.png[Foo Camel Route Diagram]
+
 === Camel CLI
 
 This application is integrated with the Camel CLI via the 
`camel-cli-connector-starter` dependency (see `pom.xml`).
diff --git 
a/spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit6Test.java 
b/spring-boot/src/test/java/sample/camel/DumpRouteDiagramTest.java
similarity index 58%
copy from 
spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit6Test.java
copy to spring-boot/src/test/java/sample/camel/DumpRouteDiagramTest.java
index ba127e48..e77e9317 100644
--- a/spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit6Test.java
+++ b/spring-boot/src/test/java/sample/camel/DumpRouteDiagramTest.java
@@ -16,34 +16,22 @@
  */
 package sample.camel;
 
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.test.spring.junit6.CamelSpringBootTest;
-import org.apache.camel.test.spring.junit6.EnableRouteCoverage;
+import org.apache.camel.test.spring.junit6.EnableRouteDiagramDump;
 import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
+/**
+ * To dump route diagram only once
+ */
 @CamelSpringBootTest
 @SpringBootTest(classes = MyCamelApplication.class)
-@EnableRouteCoverage
-public class MyCamelApplicationJUnit6Test {
-
-    @Autowired
-    private CamelContext camelContext;
+@EnableRouteDiagramDump(folder = "doc")
+public class DumpRouteDiagramTest {
 
     @Test
-    public void shouldProduceMessages() throws Exception {
-        // we expect that one or more messages is automatic done by the Camel
-        // route as it uses a timer to trigger
-        NotifyBuilder notify = new 
NotifyBuilder(camelContext).whenDone(1).create();
-
-        assertTrue(notify.matches(10, TimeUnit.SECONDS));
+    public void empty() {
+        // noop
     }
 
 }
diff --git 
a/spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit6Test.java 
b/spring-boot/src/test/java/sample/camel/MyCamelTest.java
similarity index 88%
rename from 
spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit6Test.java
rename to spring-boot/src/test/java/sample/camel/MyCamelTest.java
index ba127e48..d5684a8c 100644
--- a/spring-boot/src/test/java/sample/camel/MyCamelApplicationJUnit6Test.java
+++ b/spring-boot/src/test/java/sample/camel/MyCamelTest.java
@@ -26,20 +26,22 @@ import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 
-
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+/**
+ * A unit test using the annotation based approach
+ */
 @CamelSpringBootTest
 @SpringBootTest(classes = MyCamelApplication.class)
 @EnableRouteCoverage
-public class MyCamelApplicationJUnit6Test {
+public class MyCamelTest {
 
     @Autowired
     private CamelContext camelContext;
 
     @Test
-    public void shouldProduceMessages() throws Exception {
-        // we expect that one or more messages is automatic done by the Camel
+    public void shouldProduceMessages() {
+        // we expect that one or more messages is automatically done by the 
Camel
         // route as it uses a timer to trigger
         NotifyBuilder notify = new 
NotifyBuilder(camelContext).whenDone(1).create();
 

Reply via email to