Hi,

Yes, @MockEndpoints annotation is not supported at the moment. This is a
feature that has to be coded and added to our Spring Boot module.

As a workaround you can define your mocked endpoint like:

  from("from...").to("{{target:jms:queue}}");

And then set the target=direct:queue for the tests using the Spring Boot
@IntegrationTest("target=direct:queue") annotation.

Also you are more than welcome to contribute @MockEndpoints support. It is
on my TODO list, but not with high priority.

Cheers!

pon., 16.11.2015 o 09:32 użytkownik Joakim Bjørnstad <joak...@gmail.com>
napisał:

> Hello,
>
> Doesn't seem like there is any support for @MockEndpoints and
> @MockEndpointsAndSkip with Spring Boot and Camel at the moment.
>
> The reason for this is that the CamelSpringTestContextLoader is never
> loaded. Typically you use:
>
> @RunWith(CamelSpringJUnit4ClassRunner.class)
> @BootstrapWith(CamelTestContextBootstrapper.class)
>
> Together with @SpringApplicationConfiguration, it goes directly to the
> SpringApplicationContextLoader and thus Camel test annotations are not
> loaded.
>
> Please see https://issues.apache.org/jira/browse/CAMEL-7963
>
> On Mon, Nov 16, 2015 at 2:40 AM, Minh Tran <minh.t...@winning.com.au>
> wrote:
> > Hi
> >
> > I’m trying to write unit tests in camel 2.16.0 and spring boot.
> >
> > My route looks like
> >
> > from(“direct:start”).to(“direct:end”)
> >
> > My unit test looks like
> >
> > @RunWith(SpringJUnit4ClassRunner.class)
> > @SpringApplicationConfiguration(classes = Config.class)
> > @MockEndpoints
> > public class MyUnitTest {
> >
> >   @Produce(uri=“direct:start”)
> >   private ProducerTemplate producer;
> >
> >   @EndpointInject(uri=“mock:direct:end”)
> >   private MockEndpoint end;
> >
> >         @Test
> >         public void testMock() throws InterruptedException {
> >                 end.expectedBodiesReceived("blah");
> >                 producerTemplate.sendBody("blah");
> >                 end.assertIsSatisfied();
> >         }
> >
> > }
> >
> > It looks like the direct:end bit is never mocked so the assertion fails.
> It’s like @MockEndpoints is completely ignored.
> >
> > Is this the correct way to mock existing components when using spring
> boot? Thanks.
>
>
>
> --
> Kind regards
> Joakim Bjørnstad
>
-- 
Henryk Konsek
http://about.me/hekonsek

Reply via email to