You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Pontus Ullgren <ul...@gmail.com> on 2017/01/10 22:13:41 UTC

Re: Spring boot + MockEndpointsAndSkip + DirtiesContext

Hi,

Did anyone ever raise a Jira for this issue ?

It seems that @MockEndpointAndSkip still (2.18.0) does not work.

Best regards
Pontus Ullgren

On Tue, 9 Aug 2016 at 02:59 Minh Tran <da...@gmail.com> wrote:

> Hi, should I raise a jira for this?
>
> > On 5 Aug 2016, at 10:03 AM, Minh Tran <da...@gmail.com> wrote:
> >
> > Hi
> >
> > I am using Camel 2.17.2, Spring Boot 1.3.6 and seeing strange behaviour
> in my unit tests. I’ve simplified it to the following example
> >
> > @RunWith(CamelSpringBootJUnit4ClassRunner.class)
> > @SpringApplicationConfiguration
> > @MockEndpointsAndSkip("direct:b")
> > @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
> > public class MockTest {
> >
> >       @Produce(uri = "direct:a")
> >       private ProducerTemplate producer;
> >
> >       @EndpointInject(uri = "mock:end")
> >       private MockEndpoint end;
> >
> >       @EndpointInject(uri = "mock:direct:b")
> >       private MockEndpoint directB;
> >
> >       @Autowired
> >       private CamelContext context;
> >
> >       @Configuration
> >       @EnableAutoConfiguration
> >       public static class Config extends SpringRouteBuilder {
> >
> >               @Override
> >               public void configure() throws Exception {
> >                       from("direct:a").to("direct:b");
> >                       from("direct:b").to("mock:end");
> >               }
> >       }
> >
> >       @Test
> >       public void testMock() throws InterruptedException {
> >               end.expectedMessageCount(0);
> >               directB.expectedBodiesReceived("hello");
> >
> >               producer.sendBody("hello");
> >
> >               MockEndpoint.assertIsSatisfied(context);
> >       }
> >
> >       @Test
> >       public void testMock2() throws InterruptedException {
> >               end.expectedMessageCount(0);
> >               directB.expectedBodiesReceived("hello");
> >
> >               producer.sendBody("hello");
> >
> >               MockEndpoint.assertIsSatisfied(context);
> >       }
> > }
> >
> > testMock and testMock2 are exactly the same and if run individually,
> they pass. However if you run both, the second one will always fail.
> Running them both inside eclipse and from maven command line exhibit the
> same behaviour.
> >
> > The error I get is
> > java.lang.AssertionError: mock://end Received message count. Expected:
> <0> but was: <1>
> >
> > Which must mean that the skipping isn’t working. Here’s the tracer
> output to confirm
> > org.apache.camel.processor.interceptor.Tracer -
> ID-minhmac-local-51406-1470352938165-1-2 >>> (route3) from(direct://a) -->
> direct://b <<< Pattern:InOnly,
> Headers:{breadcrumbId=ID-minhmac-local-51406-1470352938165-1-1},
> BodyType:String, Body:hello
> > org.apache.camel.processor.interceptor.Tracer -
> ID-minhmac-local-51406-1470352938165-1-2 >>> (route4) direct://b -->
> mock://end <<< Pattern:InOnly,
> Headers:{breadcrumbId=ID-minhmac-local-51406-1470352938165-1-1},
> BodyType:String, Body:hello
> >
> >
> >
>
>

Re: Spring boot + MockEndpointsAndSkip + DirtiesContext

Posted by Pontus Ullgren <ul...@gmail.com>.
Thanks for quick reply.

Turned out I was using the wrong runner class in the @RunWith annotation.
Following Claus instructions in the ticket solved the issue.

Thanks
Pontus

On Tue, 10 Jan 2017 at 23:24 Minh Tran <da...@gmail.com> wrote:

> Hi Pontus,
>
> Yep I ended up raising this
> https://issues.apache.org/jira/browse/CAMEL-9332 <
> https://issues.apache.org/jira/browse/CAMEL-9332>
>
> It was fixed when I last checked this in 2.17.1. Not sure about 2.18.0
> though.
>
> > On 11 Jan 2017, at 9:13 am, Pontus Ullgren <ul...@gmail.com> wrote:
> >
> > Hi,
> >
> > Did anyone ever raise a Jira for this issue ?
> >
> > It seems that @MockEndpointAndSkip still (2.18.0) does not work.
> >
> > Best regards
> > Pontus Ullgren
> >
> > On Tue, 9 Aug 2016 at 02:59 Minh Tran <da...@gmail.com> wrote:
> >
> >> Hi, should I raise a jira for this?
> >>
> >>> On 5 Aug 2016, at 10:03 AM, Minh Tran <da...@gmail.com>
> wrote:
> >>>
> >>> Hi
> >>>
> >>> I am using Camel 2.17.2, Spring Boot 1.3.6 and seeing strange behaviour
> >> in my unit tests. I’ve simplified it to the following example
> >>>
> >>> @RunWith(CamelSpringBootJUnit4ClassRunner.class)
> >>> @SpringApplicationConfiguration
> >>> @MockEndpointsAndSkip("direct:b")
> >>> @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
> >>> public class MockTest {
> >>>
> >>>      @Produce(uri = "direct:a")
> >>>      private ProducerTemplate producer;
> >>>
> >>>      @EndpointInject(uri = "mock:end")
> >>>      private MockEndpoint end;
> >>>
> >>>      @EndpointInject(uri = "mock:direct:b")
> >>>      private MockEndpoint directB;
> >>>
> >>>      @Autowired
> >>>      private CamelContext context;
> >>>
> >>>      @Configuration
> >>>      @EnableAutoConfiguration
> >>>      public static class Config extends SpringRouteBuilder {
> >>>
> >>>              @Override
> >>>              public void configure() throws Exception {
> >>>                      from("direct:a").to("direct:b");
> >>>                      from("direct:b").to("mock:end");
> >>>              }
> >>>      }
> >>>
> >>>      @Test
> >>>      public void testMock() throws InterruptedException {
> >>>              end.expectedMessageCount(0);
> >>>              directB.expectedBodiesReceived("hello");
> >>>
> >>>              producer.sendBody("hello");
> >>>
> >>>              MockEndpoint.assertIsSatisfied(context);
> >>>      }
> >>>
> >>>      @Test
> >>>      public void testMock2() throws InterruptedException {
> >>>              end.expectedMessageCount(0);
> >>>              directB.expectedBodiesReceived("hello");
> >>>
> >>>              producer.sendBody("hello");
> >>>
> >>>              MockEndpoint.assertIsSatisfied(context);
> >>>      }
> >>> }
> >>>
> >>> testMock and testMock2 are exactly the same and if run individually,
> >> they pass. However if you run both, the second one will always fail.
> >> Running them both inside eclipse and from maven command line exhibit the
> >> same behaviour.
> >>>
> >>> The error I get is
> >>> java.lang.AssertionError: mock://end Received message count. Expected:
> >> <0> but was: <1>
> >>>
> >>> Which must mean that the skipping isn’t working. Here’s the tracer
> >> output to confirm
> >>> org.apache.camel.processor.interceptor.Tracer -
> >> ID-minhmac-local-51406-1470352938165-1-2 >>> (route3) from(direct://a)
> -->
> >> direct://b <<< Pattern:InOnly,
> >> Headers:{breadcrumbId=ID-minhmac-local-51406-1470352938165-1-1},
> >> BodyType:String, Body:hello
> >>> org.apache.camel.processor.interceptor.Tracer -
> >> ID-minhmac-local-51406-1470352938165-1-2 >>> (route4) direct://b -->
> >> mock://end <<< Pattern:InOnly,
> >> Headers:{breadcrumbId=ID-minhmac-local-51406-1470352938165-1-1},
> >> BodyType:String, Body:hello
> >>>
> >>>
> >>>
> >>
> >>
>
>

Re: Spring boot + MockEndpointsAndSkip + DirtiesContext

Posted by Minh Tran <da...@gmail.com>.
Hi Pontus,

Yep I ended up raising this https://issues.apache.org/jira/browse/CAMEL-9332 <https://issues.apache.org/jira/browse/CAMEL-9332>

It was fixed when I last checked this in 2.17.1. Not sure about 2.18.0 though.

> On 11 Jan 2017, at 9:13 am, Pontus Ullgren <ul...@gmail.com> wrote:
> 
> Hi,
> 
> Did anyone ever raise a Jira for this issue ?
> 
> It seems that @MockEndpointAndSkip still (2.18.0) does not work.
> 
> Best regards
> Pontus Ullgren
> 
> On Tue, 9 Aug 2016 at 02:59 Minh Tran <da...@gmail.com> wrote:
> 
>> Hi, should I raise a jira for this?
>> 
>>> On 5 Aug 2016, at 10:03 AM, Minh Tran <da...@gmail.com> wrote:
>>> 
>>> Hi
>>> 
>>> I am using Camel 2.17.2, Spring Boot 1.3.6 and seeing strange behaviour
>> in my unit tests. I’ve simplified it to the following example
>>> 
>>> @RunWith(CamelSpringBootJUnit4ClassRunner.class)
>>> @SpringApplicationConfiguration
>>> @MockEndpointsAndSkip("direct:b")
>>> @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
>>> public class MockTest {
>>> 
>>>      @Produce(uri = "direct:a")
>>>      private ProducerTemplate producer;
>>> 
>>>      @EndpointInject(uri = "mock:end")
>>>      private MockEndpoint end;
>>> 
>>>      @EndpointInject(uri = "mock:direct:b")
>>>      private MockEndpoint directB;
>>> 
>>>      @Autowired
>>>      private CamelContext context;
>>> 
>>>      @Configuration
>>>      @EnableAutoConfiguration
>>>      public static class Config extends SpringRouteBuilder {
>>> 
>>>              @Override
>>>              public void configure() throws Exception {
>>>                      from("direct:a").to("direct:b");
>>>                      from("direct:b").to("mock:end");
>>>              }
>>>      }
>>> 
>>>      @Test
>>>      public void testMock() throws InterruptedException {
>>>              end.expectedMessageCount(0);
>>>              directB.expectedBodiesReceived("hello");
>>> 
>>>              producer.sendBody("hello");
>>> 
>>>              MockEndpoint.assertIsSatisfied(context);
>>>      }
>>> 
>>>      @Test
>>>      public void testMock2() throws InterruptedException {
>>>              end.expectedMessageCount(0);
>>>              directB.expectedBodiesReceived("hello");
>>> 
>>>              producer.sendBody("hello");
>>> 
>>>              MockEndpoint.assertIsSatisfied(context);
>>>      }
>>> }
>>> 
>>> testMock and testMock2 are exactly the same and if run individually,
>> they pass. However if you run both, the second one will always fail.
>> Running them both inside eclipse and from maven command line exhibit the
>> same behaviour.
>>> 
>>> The error I get is
>>> java.lang.AssertionError: mock://end Received message count. Expected:
>> <0> but was: <1>
>>> 
>>> Which must mean that the skipping isn’t working. Here’s the tracer
>> output to confirm
>>> org.apache.camel.processor.interceptor.Tracer -
>> ID-minhmac-local-51406-1470352938165-1-2 >>> (route3) from(direct://a) -->
>> direct://b <<< Pattern:InOnly,
>> Headers:{breadcrumbId=ID-minhmac-local-51406-1470352938165-1-1},
>> BodyType:String, Body:hello
>>> org.apache.camel.processor.interceptor.Tracer -
>> ID-minhmac-local-51406-1470352938165-1-2 >>> (route4) direct://b -->
>> mock://end <<< Pattern:InOnly,
>> Headers:{breadcrumbId=ID-minhmac-local-51406-1470352938165-1-1},
>> BodyType:String, Body:hello
>>> 
>>> 
>>> 
>> 
>>