You can simply make your from
endpoint configurable and configure it through application properties.
For example if you use Spring:
@Value("${endpoint.consumer}")
private String consumerEndpoint;
...
from(consumerEndpoint)
...
You can then provide a test configuration that configures the endpoint as direct:input
and use a ProducerTemplate
to send test messages with different payloads to this endpoint.
Real application properties:
endpoint.consumer=file://target/input?delay=5s
Test properties:
endpoint.consumer=direct:input
Like this you get rid of any file endpoints in your tests.
If you also got to
endpoints, you can make them configurable too. You can turn them into mocks in your tests by configure them as mock:whatever
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…