I try to make a junit test for apache camel route. Something like this :
@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(
loader = CamelSpringDelegatingTestContextLoader.class
)
public class MyExportRouteBuilderIT extends CamelTestSupport {
@Test
public void test() {
// trigger and check the files made by route builder processor
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new MyExportRouteBuilder();
}
}
The builder class is defined like this
from("quartz2://exportJob?cron=" + cronTrigger)
.setHeader(FILE_NAME, expression(FILE_NAME_FORMAT))
.process(myExportRouteProcessor)
.marshal(new BindyCsvDataFormat(MyExportData.class))
.to("file:///destination);
The 'myExportRouteProcessor' class just gets some data from the JPA repository and puts the results to the route. What I want is to trigger this route in the test class to check if the whole process was properly finished. Currently, processor is not fired. What should I do more ?
You can replace quartz2 component in your test with direct using AdviceWithRouteBuilder#replaceFromWith.