use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithWeaveByToUriCBRTest method testAdviceCBR.
public void testAdviceCBR() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveByToUri("direct:branch*").replace().to("mock:foo");
mockEndpointsAndSkip("direct:branch*");
}
});
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithWeaveByTypeCBRTest method testWeaveByType.
public void testWeaveByType() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveByType(ChoiceDefinition.class).replace().to("mock:baz");
}
});
getMockEndpoint("mock:baz").expectedMessageCount(1);
template.sendBody("direct:start", "World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithIssueTest method testAdviceWithInterceptFrom.
public void testAdviceWithInterceptFrom() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptFrom().to("mock:from");
}
});
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:from").expectedBodiesReceived("World");
getMockEndpoint("mock:from").expectedHeaderReceived(Exchange.INTERCEPTED_ENDPOINT, "direct://start");
template.sendBody("direct:start", "World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithIssueTest method testAdviceWithInterceptSendToEndpoint.
public void testAdviceWithInterceptSendToEndpoint() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock:result").to("mock:to");
}
});
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:to").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:to").expectedHeaderReceived(Exchange.INTERCEPTED_ENDPOINT, "mock://result");
template.sendBody("direct:start", "World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithOnExceptionMultipleIssueTest method testMultipleAdviceWithExceptionThrown.
public void testMultipleAdviceWithExceptionThrown() throws Exception {
context.addRoutes(createRouteBuilder());
context.getRouteDefinition("RouteA").adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock:resultA").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new Exception("my exception");
}
});
}
});
context.start();
getMockEndpoint("mock:resultA").expectedMessageCount(0);
template.sendBody("direct:startA", "a trigger");
assertMockEndpointsSatisfied();
}
Aggregations