[ 
https://issues.apache.org/jira/browse/CAMEL-17690?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nicolas Filotto resolved CAMEL-17690.
-------------------------------------
    Resolution: Fixed

> camel-test-main - Annotation based testing
> ------------------------------------------
>
>                 Key: CAMEL-17690
>                 URL: https://issues.apache.org/jira/browse/CAMEL-17690
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-test
>            Reporter: Claus Ibsen
>            Assignee: Nicolas Filotto
>            Priority: Major
>             Fix For: 3.16.0
>
>
> Historically testing with camel is based on extending CamelTestSupport which 
> gives you all the testing features from the base class.
> When using spring boot, you can use spring boot style testing with 
> annotations, or extend CamelSpringTestSupport.
> For camel-main-test then we can also have a set of annotations as I think 
> users will relate to this coming from spring boot world.
>  
> {code:java}
> @CamelMainTest(MyApp.class)
> public class MyAppTest {
>     @BeanInject
>     CamelContext camelContext;
>     @Test
>     public void testFoo() throws Exception {
>       // my test content here
>     }
> }
> {code}
>  
> And also a variation where you can refer to classes and properties to set as 
> initial properties on the properties component
>  
> {code:java}
> @CamelMainTest(class = MyApp.class, properties = {"camel.component.xxx=123", 
> "period=1000", "hi=World"})
> public class MyAppTest {
>     @BeanInject
>     CamelContext camelContext;
>     @Test
>     public void testFoo() throws Exception {
>        // my test content here
>     }
> }
> {code}
> Take a look at the @SpringBootTest annotation and its features as inspiration.
> And you can also extend the base class but use the annotations to make it 
> stand out and also configure the main class etc
>  
> {code:java}
> @CamelMainTest(class = MyApp.class, properties = {"camel.component.xxx=123", 
> "period=1000", "hi=World"})
> public class MyAppTest extends CamelMainTest {
>     @Test
>     public void testFoo() throws Exception {
>         // camelContext is avail from the base class so no need for 
> @BeanInject
>     }
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to