getMockEndpoint is when you extend CamelSpringTestSupport class which
you do NOT do.

For more information about notifier, testing and whatnot there is the
Camel docs, and then also the Camel books.
For example the Camel in Action 2nd edition is up to date with latest
Camel stuff

On Tue, Feb 21, 2017 at 1:03 PM, owain <owain@integration.technology> wrote:
> Well it looks as though everything has changed!  Just for Spring Boot?
>
> MockEndpoint mockOut = getMockEndpoint("mock:out");
>
> is now
>
> MockEndpoint mockOut = camelContext.getEndpoint("mock:out",
> MockEndpoint.class);
>
> The documentation is somewhat thin on the ground to say the least.
>
> This is all I found which helped me.
> https://github.com/apache/camel/blob/master/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/mockendpoints/MockEndpointsTest.java
>
> Previously I was looking in camel-examples for 2.18.2 which are out of date.
> Would it not make sense for these to be tested against current releases?
>
> So the following test works now, hopefully easier to find.
>
> @RunWith(CamelSpringBootRunner.class)
> @MockEndpoints
> @SpringBootTest(classes = SpringBootCamelVanilla.class)
> public class RouteBTests {
>
>   @Autowired
>   private CamelContext camelContext;
>
>   @Autowired
>   private ProducerTemplate template;
>
>   @Test
>   public void whereIsBuckinghamPalaceTest() throws Exception {
>
>     camelContext.getRouteDefinition("RouteB")
>             .adviceWith(camelContext, new AdviceWithRouteBuilder() {
>               @Override
>               public void configure() throws Exception {
>                 replaceFromWith("direct:in");
>                 // send the outgoing message to mock:out
>                 weaveAddLast().to("mock:out");
>               }
>             });
>
>     camelContext.start();
>     MockEndpoint mockOut = camelContext.getEndpoint("mock:out",
> MockEndpoint.class);
>     mockOut.expectedMessageCount(1);
>     template.sendBody("direct:in","Buckingham Palace");
>     mockOut.assertIsSatisfied();
>
>   }
> }
>
> My next task is to work out how to replace
>
>     @Override
>     public boolean isUseAdviceWith() {
>         return true;
>     }
>
> so I don't start all the routes in the application each time.  I suspect it
> is something to do with the CamelContext configuration on route behaviour.
>
> Additionally I see most test examples seem to use Notifier.  Does anyone
> have a reference as to when to use it and the advantages it provides?
>
> Apologies for the whinging tone of  the reply.  It took ages to get to the
> answer.
>
> O.
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-2-18-2-Spring-Boot-Unit-Tests-Does-mockOut-expectedMessageCount-work-tp5794070p5794181.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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

Reply via email to