You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/03/01 10:15:56 UTC

[camel-examples] branch CAMEL-17690/camel-test-main-annotations created (now f019f20)

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a change to branch CAMEL-17690/camel-test-main-annotations
in repository https://gitbox.apache.org/repos/asf/camel-examples.git.


      at f019f20  CAMEL-17690: Add a simple test using @CamelMainTest

This branch includes the following new commits:

     new f019f20  CAMEL-17690: Add a simple test using @CamelMainTest

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[camel-examples] 01/01: CAMEL-17690: Add a simple test using @CamelMainTest

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-17690/camel-test-main-annotations
in repository https://gitbox.apache.org/repos/asf/camel-examples.git

commit f019f2061551a0ba939bd2d253b1ab19d2fead7b
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Tue Mar 1 11:15:29 2022 +0100

    CAMEL-17690: Add a simple test using @CamelMainTest
---
 .../src/test/java/org/apache/camel/example/MainTest.java |  2 +-
 .../{MainTest.java => MainWithAnnotationTest.java}       | 16 +++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/examples/main/src/test/java/org/apache/camel/example/MainTest.java b/examples/main/src/test/java/org/apache/camel/example/MainTest.java
index 2bedd32..8b037bf 100644
--- a/examples/main/src/test/java/org/apache/camel/example/MainTest.java
+++ b/examples/main/src/test/java/org/apache/camel/example/MainTest.java
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
- * A unit test checking that Camel supports binding via annotations.
+ * A unit test using the legacy approach checking that Camel supports binding via annotations.
  */
 class MainTest extends CamelMainTestSupport {
 
diff --git a/examples/main/src/test/java/org/apache/camel/example/MainTest.java b/examples/main/src/test/java/org/apache/camel/example/MainWithAnnotationTest.java
similarity index 79%
copy from examples/main/src/test/java/org/apache/camel/example/MainTest.java
copy to examples/main/src/test/java/org/apache/camel/example/MainWithAnnotationTest.java
index 2bedd32..2afb2ff 100644
--- a/examples/main/src/test/java/org/apache/camel/example/MainTest.java
+++ b/examples/main/src/test/java/org/apache/camel/example/MainWithAnnotationTest.java
@@ -18,16 +18,23 @@ 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.junit5.CamelMainTest;
 import org.apache.camel.test.main.junit5.CamelMainTestSupport;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
- * A unit test 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 MainWithAnnotationTest {
+
+    @BeanInject
+    CamelContext context;
 
     @Test
     void should_support_binding_via_annotations() {
@@ -37,9 +44,4 @@ class MainTest extends CamelMainTestSupport {
             notify.matches(20, TimeUnit.SECONDS), "1 message should be completed"
         );
     }
-
-    @Override
-    protected Class<?> getMainClass() {
-        return MyApplication.class;
-    }
 }