You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/03/01 10:27:59 UTC
[camel-examples] branch main updated: CAMEL-17690: Add a simple test using @CamelMainTest
This is an automated email from the ASF dual-hosted git repository.
acosentino 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 f769696 CAMEL-17690: Add a simple test using @CamelMainTest
f769696 is described below
commit f769696aae0edaa0c8622c479dbd971784468326
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;
- }
}