There are many ways to test your production camel routes – you’ve included a few with Mock and AdviceWith. With this approach you shouldn’t need to include any mock endpoints in your prod route. Instead, in your test you instructing camel to advice the prod route with your mock endpoints.
Lastly (assuming your mock/advice is setup correctly) you’re missing the actual route invocation for the test. Something like the following invokes the route and returns the result: Object response = template.requestBody("direct:someCamelEndpoint ", "blah"); More info here: http://camel.apache.org/mock.html On 11/4/16, 11:42 AM, "catequil" <brat...@yahoo.com> wrote: Using CamelTestSupport how do you test the out, or result of the route when it does not end in a endpoint call? Would I just put in my production route code a .to("mock:result) for each API call/route and intercept it or is there a better way that does not put a mock:endpoint in my production route code? code example: @Path("/v1") @Api(value = "/v1", description = "My API") class RestController { @GET @Path("/rest/service") @Produces("application/json") public Response someRestService() { return producerTemplate.requestBody("direct:someCamelEndpoint", someRestBody); } } class CamelRoute extends RouteBuilder { @Override public void configure() throws Exception { from("direct:someCamelEndpoint").routeId("myRouteId") .to("direct:someOtherEndpoint") .process(new MyJsonResponseProcessor()) //.to("mock:result") ??? .end(); } } class CamelUnitTests extends CamelTestSupport { @Override protected AbstractApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("camel-config.xml"); } @Override public boolean isUseAdviceWith() { return true; } @Test public void testSomeOtherEndpoint() throws Exception { RouteDefinition route = context.getRouteDefinition("myRouteId"); route.adviceWith(context, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { this.interceptSendToEndpoint("direct:someOtherEndpoint") .skipSendToOriginalEndpoint(); mockEndpoints("mock:direct:someOtherEndpoint"); } }); context.start(); MockEndpoint mock = getMockEndpoint("mock:direct:someOtherEndpoint"); mock.expectedMessageCount(1); mock.assertIsSatisfied(); } @Test public void testOuputAfterProcessor() { //Test the result going back to the initial rest call. } } -- View this message in context: http://camel.465427.n5.nabble.com/CamelTestSupport-best-way-to-unit-test-the-OUT-or-result-of-the-route-tp5789761.html Sent from the Camel - Users mailing list archive at Nabble.com. American Express made the following annotations ****************************************************************************** "This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you." American Express a ajouté le commentaire suivant le Ce courrier et toute pièce jointe qu'il contient sont réservés au seul destinataire indiqué et peuvent renfermer des renseignements confidentiels et privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, duplication, utilisation ou distribution du courrier ou de toute pièce jointe est interdite. Si vous avez reçu cette communication par erreur, veuillez nous en aviser par courrier et détruire immédiatement le courrier et les pièces jointes. Merci. ******************************************************************************