If your DbBean is an interface, then you can have two different implementations. One for the real work of the database. And others for bullying unit tests where you simulate a database.
Then it's just a matter of creating a layout in your unit test
DbBean db = new MockDbBean()
Like plain java code. In your RouteBuilder class you can use getter / setter
public class MyRouteBuilder extends RouteBuilder {
private DbBean dbBean;
public void configure() throws Exception {
from("direct:test").bean(dbBean).to("direct:someOtherLogic");
}
}
Then from unit test you just need to install MockDbBean using the installer in the MyRouteBuilder instance.
source
share