use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class SpringAdviceWithContextScopedErrorHandlerIssueTest method testAdviceWith.
public void testAdviceWith() throws Exception {
context.getRouteDefinition("route-a").adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("direct:bar").skipSendToOriginalEndpoint().throwException(new IllegalArgumentException("Forced"));
}
});
getMockEndpoint("mock:error").expectedMessageCount(1);
getMockEndpoint("mock:bar").expectedMessageCount(0);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class UseOverridePropertiesWithPropertiesComponentTest method doSomethingBefore.
@Before
public void doSomethingBefore() throws Exception {
AdviceWithRouteBuilder mocker = new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
replaceFromWith("direct:sftp");
interceptSendToEndpoint("file:*").skipSendToOriginalEndpoint().to("mock:file");
}
};
context.getRouteDefinition("myRoute").adviceWith(context, mocker);
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class IsUseAdviceWithTest method testIsUseAdviceWith.
@Test
public void testIsUseAdviceWith() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
// replace the from with seda:foo
replaceFromWith("seda:foo");
}
});
// we must manually start when we are done with all the advice with
context.start();
getMockEndpoint("mock:result").expectedMessageCount(1);
template.sendBody("seda:foo", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceTest method advice.
void advice(@Observes CamelContextStartingEvent event, @Uri("mock:messages") MockEndpoint messages, ModelCamelContext context) throws Exception {
messages.expectedMessageCount(2);
messages.expectedBodiesReceived("Hello", "Bye");
verifier.messages = messages;
context.getRouteDefinition("route").adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() {
weaveAddLast().to("mock:messages");
}
});
}
use of org.apache.camel.builder.AdviceWithRouteBuilder in project camel by apache.
the class AdviceWithTransactionIssueTest method testAdviceWithAddLast.
@Test
public void testAdviceWithAddLast() throws Exception {
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
@Override
public void configure() throws Exception {
weaveAddLast().to("mock:last");
}
});
context.start();
MockEndpoint mockLast = getMockEndpoint("mock:last");
mockLast.expectedBodiesReceived("bar");
mockLast.setExpectedMessageCount(1);
template.sendBody("seda:start", "bar");
assertMockEndpointsSatisfied();
}
Aggregations