Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-17690

camel-test-main - Annotation based testing

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.16.0
    • camel-test
    • None
    • Unknown

    Description

      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.

       

      @CamelMainTest(MyApp.class)
      public class MyAppTest {
          @BeanInject
          CamelContext camelContext;
          @Test
          public void testFoo() throws Exception {
            // my test content here
          }
      }
      
      

       

      And also a variation where you can refer to classes and properties to set as initial properties on the properties component

       

      @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
          }
      }
      
      

      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

       

      @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
          }
      }
      

       

      Attachments

        Issue Links

          Activity

            People

              essobedo Nicolas Filotto
              davsclaus Claus Ibsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: