java - Can anyone tell me how to test my Camel Route if I have a choice operation? -


i have camel route has implemented content based routing eip(choice operation). need test it. i'm new camel. so, i'm unsure how it. can tell me how test operation. have mentioned sample code below has tested.

public void configure() throws exception  {        onexception(exception.class).handled(true).bean(errorhandler.class).stop();      from("{{input}}?concurrentconsumers=10")     .routeid("actions")         .choice()             .when().simple("${header.action} == ${type:status1}")                 .bean(class, "method1")             .when().simple("${header.action} == ${type:status2}")                 .bean(class, "method2")             .when().simple("${header.action} == ${type:status3}")                 .bean(class, "method3")             .otherwise()                 .bean(class, "method4")         .end();        } 

you can "advice" route , add mocks each choice of content-based router

public void testadvised() throws exception {     // advice first route using inlined route builder     context.getroutedefinition("actions").advicewith(context, new routebuilder() {         @override         public void configure() throws exception {             replacefromwith("direct:start");             weavebytostring(".*method1.*").after().to("mock:choice1");             weavebytostring(".*method2.*").after().to("mock:choice2");         }     });      getmockendpoint("mock:choice1").expectedmessagecount(1);     getmockendpoint("mock:choice2").expectedmessagecount(0);      template.sendbody("direct:start", "hello world");      assertmockendpointssatisfied(); } 

this needs little more modifications working. let me know if needed more clarification or proper real test scenario route.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -