use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithReplaceFromTest method testReplaceFromInvalidUri.
public void testReplaceFromInvalidUri() throws Exception {
try {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
replaceFromWith("xxx:foo");
}
});
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
}
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithTasksSelectTest method testSelectIndexTwo.
public void testSelectIndexTwo() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// should match the third index (0 based)
weaveById("gold*").selectIndex(2).replace().multicast().to("mock:a").to("mock:b");
}
});
getMockEndpoint("mock:foo").expectedMessageCount(1);
getMockEndpoint("mock:bar").expectedMessageCount(1);
getMockEndpoint("mock:baz").expectedMessageCount(0);
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 AdviceWithTasksSelectTest method testSelectIndexOne.
public void testSelectIndexOne() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// should match the second index (0 based)
weaveById("gold*").selectIndex(1).replace().multicast().to("mock:a").to("mock:b");
}
});
getMockEndpoint("mock:foo").expectedMessageCount(1);
getMockEndpoint("mock:bar").expectedMessageCount(0);
getMockEndpoint("mock:baz").expectedMessageCount(1);
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 AdviceWithTasksSelectTest method testSelectFirst.
public void testSelectFirst() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// should only match the first
weaveById("gold*").selectFirst().replace().multicast().to("mock:a").to("mock:b");
}
});
getMockEndpoint("mock:foo").expectedMessageCount(0);
getMockEndpoint("mock:bar").expectedMessageCount(1);
getMockEndpoint("mock:baz").expectedMessageCount(1);
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 AdviceWithTasksSelectTest method testSelectRangeZeroOne.
public void testSelectRangeZeroOne() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// should match the first two (0-based)
weaveById("gold*").selectRange(0, 1).replace().multicast().to("mock:a").to("mock:b");
}
});
getMockEndpoint("mock:foo").expectedMessageCount(0);
getMockEndpoint("mock:bar").expectedMessageCount(0);
getMockEndpoint("mock:baz").expectedMessageCount(1);
getMockEndpoint("mock:a").expectedMessageCount(2);
getMockEndpoint("mock:b").expectedMessageCount(2);
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
Aggregations