testing camel quartz route

后端 未结 1 1893
北恋
北恋 2021-01-15 02:04

I try to make a junit test for apache camel route. Something like this :

@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(
    loader = Cam         


        
相关标签:
1条回答
  • 2021-01-15 02:30

    You can replace quartz2 component in your test with direct using AdviceWithRouteBuilder#replaceFromWith.

    @Test
    public void test() throws Exception{
       //mock input route (replace quartz with direct)
       context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
           @Override
           public void configure() throws Exception {
               replaceFromWith("direct:triggerQuartz");
           }
       });
    
       //trigger endpoint
       sendBody("direct:triggerQuartz", null);
    
       //do some assertions
    }    
    
    0 讨论(0)
提交回复
热议问题