I'm trying to work out how to write a unit test for my Camel route. It's part of a Spring Boot application (Camel v.2.24.2; Spring Boot v.2.1.10.RELEASE).
The route is defined in a class like this:
@Component
public class MyRoutes extends RouteBuilder {
@Value("${uri.directory.in}")
private String inDirectoryUri;
@Value("${uri.directory.out}")
private String outDirectoryUri;
@Inject
private MyProcessor myProcessor;
@Override
public void configure() throws Exception {
from(inDirectoryUri) //
.log(LoggingLevel.TRACE, "Processing file ${file:name}") //
.process(myProcessor) //
.to(outDirectoryUri) //
.end();
}
}
I'd like to create a unit test to ensure that the route works: it picks up a file, initiated a Camel processor and moves it to the other directory.
The directory values are populated via an external property file by Spring. In another unit test, I've been able to point to a test property file using @RunWith(SpringJUnit4ClassRunner.class), @EnableAutoConfiguration and @PropertySource("file:myTestProperties.properties")
I would preferably mock the processor as I have a separate unit test elsewhere which tests the functionality in the processor class. Presumably I'd use something like this in the route's unit test:
@Mock
private MyProcessor myProcessor;
I've searched around a lot but can't find a specific example which matches the scenario that I have above. Also, I'm a bit confused about how I would wire it all together as some parts are done by Spring and others by Camel.
Thanks in advance for any advice.