AdviceWithPage edited by Claus IbsenAdviceWithAvailable as of Camel 2.1 AdviceWith is used for testing Camel routes where you can advice an existing route before its being tested. What adviceWith allows is to changes some factors on the route before the test is being run. At current time you can advice an existing route by adding Intercept, Exception Clause etc. which then will apply for the route being advice. For example in the route below we intercept sending a message to the mock:foo endpoint and detour the message. public void testAdvised() throws Exception { // advice the first route using the inlined route builder context.getRouteDefinitions().get(0).adviceWith(new RouteBuilder() { @Override public void configure() throws Exception { // intercept sending to mock:foo and do something else interceptSendToEndpoint("mock:foo") .skipSendToOriginalEndpoint() .to("log:foo") .to("mock:advised"); } }); getMockEndpoint("mock:foo").expectedMessageCount(0); getMockEndpoint("mock:advised").expectedMessageCount(1); getMockEndpoint("mock:result").expectedMessageCount(1); template.sendBody("direct:start", "Hello World"); assertMockEndpointsSatisfied(); } At current time you cannot alter the route by adding or changing exiting nodes in the route path. In the future we may want to introduce a special AdviceRouteBuilder which has special builder methods for altering the route etc.
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|