Hi

Yeah you can also have getter/setter for the bean and then set a new
bean in the route builder class before starting the test.
Or as suggested by Luiz you can inject other beans from the @Autowried
@BeanInject and what else annotations are there.
And for advice with, you can also use its replace with, and then set
up another node  that calls another bean.


On Fri, Jan 18, 2019 at 7:45 PM Bradford Fisher
<[email protected]> wrote:
>
> Thanks Luiz! Constructor injection should work for us. Just wanted to make
> sure there wasn't something built in to Camel!
>
> On Fri, Jan 18, 2019 at 1:09 PM Luiz Eduardo Valmont <
> [email protected]> wrote:
>
> > 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");
> > >     }
> > > }
> > >
> >



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to