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

commit 831fe3d03eac0fe8f47342d841f85f704c5db3ae
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri May 8 13:22:03 2026 +0200

    CAMEL-23400: camel-test - Add route diagram dumper
---
 main/README.adoc                                   |   9 +++++++
 main/doc/foo.png                                   | Bin 0 -> 18833 bytes
 main/pom.xml                                       |   6 +++++
 ...ithAnnotationTest.java => MainDiagramTest.java} |  27 ++++++---------------
 .../java/org/apache/camel/example/MainTest.java    |  17 +++++++------
 5 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/main/README.adoc b/main/README.adoc
index f263fb8a..938dc3e4 100644
--- a/main/README.adoc
+++ b/main/README.adoc
@@ -55,6 +55,15 @@ You can also access https://jolokia.org/[jolokia] api via 
`http://localhost:8080
 This gives you access to basic JMX operations.
 For example, to query 
https://docs.oracle.com/javase/8/docs/api/java/lang/management/MemoryMXBean.html[MemoryMBean],
 use 
`http://localhost:8080/q/jolokia/read/java.lang:type=Memory/HeapMemoryUsage/used`.
 
+=== 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/foo.png[Foo Camel Route Diagram]
+
 === How to configure for Camel Textual Route debugging
 
 Several IDEs are providing support for Camel Textual Route debugging. To 
enable this possibility, you need to launch this example with the profile 
`camel.debug`.
diff --git a/main/doc/foo.png b/main/doc/foo.png
new file mode 100644
index 00000000..38b90972
Binary files /dev/null and b/main/doc/foo.png differ
diff --git a/main/pom.xml b/main/pom.xml
index ec79bfbe..9c99d230 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -110,6 +110,12 @@
             <artifactId>camel-test-main-junit6</artifactId>
             <scope>test</scope>
         </dependency>
+        <!-- route diagram dumper -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-diagram</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/main/src/test/java/org/apache/camel/example/MainWithAnnotationTest.java 
b/main/src/test/java/org/apache/camel/example/MainDiagramTest.java
similarity index 56%
rename from 
main/src/test/java/org/apache/camel/example/MainWithAnnotationTest.java
rename to main/src/test/java/org/apache/camel/example/MainDiagramTest.java
index 26165cc4..38db8c16 100644
--- a/main/src/test/java/org/apache/camel/example/MainWithAnnotationTest.java
+++ b/main/src/test/java/org/apache/camel/example/MainDiagramTest.java
@@ -16,31 +16,18 @@
  */
 package org.apache.camel.example;
 
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.BeanInject;
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.test.main.junit6.CamelMainTest;
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
 /**
- * A unit test using the annotation based approach checking that Camel 
supports binding via annotations.
+ * To dump route diagram only once
  */
-@CamelMainTest(mainClass = MyApplication.class)
-class MainWithAnnotationTest {
-
-    @BeanInject
-    CamelContext context;
+@CamelMainTest(mainClass = MyApplication.class, dumpRouteDiagramFolder = "doc")
+class MainDiagramTest {
 
     @Test
-    void should_support_binding_via_annotations() {
-        NotifyBuilder notify = new NotifyBuilder(context)
-            .whenCompleted(1).whenBodiesDone("Hello how are you?").create();
-        assertTrue(
-            notify.matches(20, TimeUnit.SECONDS), "1 message should be 
completed"
-        );
+    void empty() {
+        // empty test method
     }
-}
+
+}
\ No newline at end of file
diff --git a/main/src/test/java/org/apache/camel/example/MainTest.java 
b/main/src/test/java/org/apache/camel/example/MainTest.java
index e4fe15ef..94ee9ea4 100644
--- a/main/src/test/java/org/apache/camel/example/MainTest.java
+++ b/main/src/test/java/org/apache/camel/example/MainTest.java
@@ -18,16 +18,22 @@ package org.apache.camel.example;
 
 import java.util.concurrent.TimeUnit;
 
+import org.apache.camel.BeanInject;
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.NotifyBuilder;
-import org.apache.camel.test.main.junit6.CamelMainTestSupport;
+import org.apache.camel.test.main.junit6.CamelMainTest;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
- * A unit test using the legacy approach checking that Camel supports binding 
via annotations.
+ * A unit test using the annotation based approach checking that Camel 
supports binding via annotations.
  */
-class MainTest extends CamelMainTestSupport {
+@CamelMainTest(mainClass = MyApplication.class)
+class MainTest {
+
+    @BeanInject
+    CamelContext context;
 
     @Test
     void should_support_binding_via_annotations() {
@@ -37,9 +43,4 @@ class MainTest extends CamelMainTestSupport {
             notify.matches(20, TimeUnit.SECONDS), "1 message should be 
completed"
         );
     }
-
-    @Override
-    protected Class<?> getMainClass() {
-        return MyApplication.class;
-    }
 }

Reply via email to