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 <nfilo...@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; - } }