use of org.apache.camel.model.RouteDefinition 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.model.RouteDefinition 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();
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class SplitterWithCustomThreadPoolExecutorTest method getSplitter.
protected SplitDefinition getSplitter() {
SplitDefinition result = null;
List<RouteDefinition> routeDefinitions = context.getRouteDefinitions();
for (RouteDefinition routeType : routeDefinitions) {
result = firstSplitterType(routeType.getOutputs());
if (result != null) {
break;
}
}
return result;
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class TraceInitIdOnAllNodesTest method testInitIdsOnAllNodes.
public void testInitIdsOnAllNodes() throws Exception {
getMockEndpoint("mock:camel").expectedBodiesReceived("Hello Camel");
getMockEndpoint("mock:other").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:end").expectedMessageCount(2);
template.sendBody("direct:start", "Hello Camel");
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
RouteDefinition route = context.getRouteDefinitions().get(0);
assertNotNull(route);
ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
assertEquals("choice1", choice.getId());
WhenDefinition when = (WhenDefinition) choice.getOutputs().get(0);
assertEquals("when1", when.getId());
LogDefinition log1 = (LogDefinition) when.getOutputs().get(0);
assertEquals("log1", log1.getId());
ToDefinition to1 = (ToDefinition) when.getOutputs().get(1);
assertEquals("camel", to1.getId());
OtherwiseDefinition other = (OtherwiseDefinition) choice.getOutputs().get(1);
assertEquals("otherwise1", other.getId());
LogDefinition log2 = (LogDefinition) other.getOutputs().get(0);
assertEquals("log2", log2.getId());
ToDefinition to2 = (ToDefinition) other.getOutputs().get(1);
assertEquals("to1", to2.getId());
ToDefinition to3 = (ToDefinition) other.getOutputs().get(2);
assertEquals("foo", to3.getId());
ToDefinition to4 = (ToDefinition) route.getOutputs().get(1);
assertEquals("end", to4.getId());
}
use of org.apache.camel.model.RouteDefinition in project camel by apache.
the class AdviceWithTwoRoutesOnExceptionTest method testAdviceWithB.
public void testAdviceWithB() throws Exception {
RouteDefinition route = context.getRouteDefinition("b");
route.adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock://b").skipSendToOriginalEndpoint().throwException(new IllegalArgumentException("Forced"));
}
});
getMockEndpoint("mock:b").expectedMessageCount(0);
getMockEndpoint("mock:error").expectedMessageCount(1);
getMockEndpoint("mock:error").message(0).exchangeProperty(Exchange.EXCEPTION_CAUGHT).isInstanceOf(IllegalArgumentException.class);
template.sendBody("direct:b", "Hello World");
assertMockEndpointsSatisfied();
}
Aggregations