I confess I'm not familiar with @BeanInject, but if it's similar in purpose as @Autowired from Spring, then I'd suggest using constructor injection. That way you can create your object with your mocked bean.
Personally I do it like that in unit testing. HTH On Fri, 18 Jan 2019, 13:42 Bradford Fisher <[email protected] wrote: > Does Camel have some built in functionality to replace a Bean within a > Route while maintaining the method called on the bean? > > For instance, given the RouteBuilder below, I would like to replace myBean > with myMockBean during testing. I've considered using AdviceWith, but that > seams to replace the entire Bean Node rather than just the instance of the > class used by the Bean Node. > > public class MyRouteBuilder extends RouteBuilder > { > @BeanInject > private MyBean myBean; > > @Override > public void configure() throws Exception > { > from("direct:myEndpoint") > .bean(myBean, "myMethod") > .id("myBeanId"); > } > } >
