use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithOnExceptionTest method testAdviceWithOnException.
public void testAdviceWithOnException() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("b").after().to("mock:result");
}
});
context.start();
getMockEndpoint("mock:a").expectedMessageCount(1);
getMockEndpoint("mock:b").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithPolicyTest method testAdviceWithPolicy.
public void testAdviceWithPolicy() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("b").after().to("mock:result");
}
});
context.start();
getMockEndpoint("mock:a").expectedMessageCount(1);
getMockEndpoint("mock:b").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithRoutePolicyTest method testAdviceRoutePolicyRemoved.
public void testAdviceRoutePolicyRemoved() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// remove the route policy so we can test without it
getOriginalRoute().setRoutePolicies(null);
}
});
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:foo").message(0).header("MyRoutePolicy").isNull();
getMockEndpoint("mock:bar").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:bar").message(0).header("MyRoutePolicy").isNull();
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithCBRTest method testAdviceCBR.
public void testAdviceCBR() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveById("foo").after().to("mock:foo2");
weaveById("bar").after().to("mock:bar2");
}
});
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:foo2").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:bar").expectedBodiesReceived("Bye World");
getMockEndpoint("mock:bar2").expectedBodiesReceived("Bye World");
getMockEndpoint("mock:baz").expectedBodiesReceived("Hi World");
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
template.sendBodyAndHeader("direct:start", "Bye World", "bar", "123");
template.sendBody("direct:start", "Hi World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithCBRTest method testAdviceToStringCBR.
public void testAdviceToStringCBR() throws Exception {
RouteDefinition route = context.getRouteDefinitions().get(0);
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveByToString("To[mock:foo]").after().to("mock:foo2");
weaveByToString("To[mock:bar]").after().to("mock:bar2");
}
});
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:foo2").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:bar").expectedBodiesReceived("Bye World");
getMockEndpoint("mock:bar2").expectedBodiesReceived("Bye World");
getMockEndpoint("mock:baz").expectedBodiesReceived("Hi World");
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
template.sendBodyAndHeader("direct:start", "Bye World", "bar", "123");
template.sendBody("direct:start", "Hi World");
assertMockEndpointsSatisfied();
}
Aggregations