use of org.apache.camel.CamelExecutionException in project camel by apache.
the class BeanLanguageMethodMissingParenthesisTest method testFooMissingParenthesis.
public void testFooMissingParenthesis() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").filter(method(BeanLanguageMethodMissingParenthesisTest.class, "couldThisBeFoo(${body}, ${header.foo}")).to("mock:foo").end().to("mock:result");
}
});
context.start();
try {
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "yes");
fail("Should throw exception");
} catch (CamelExecutionException e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Method should end with parenthesis, was couldThisBeFoo(${body}, ${header.foo}", iae.getMessage());
}
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class SplitterParallelStopOnExceptionTest method testSplitParallelStopOnExceptionStop.
public void testSplitParallelStopOnExceptionStop() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:split");
mock.expectedMinimumMessageCount(0);
mock.allMessages().body().isNotEqualTo("Kaboom");
try {
template.sendBody("direct:start", "Hello World,Goodday World,Kaboom,Bye World");
fail("Should thrown an exception");
} catch (CamelExecutionException e) {
CamelExchangeException cause = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
assertTrue(cause.getMessage().startsWith("Parallel processing failed for number "));
assertEquals("Forced", cause.getCause().getMessage());
String body = cause.getExchange().getIn().getBody(String.class);
assertTrue(body.contains("Kaboom"));
}
assertMockEndpointsSatisfied();
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class SplitterNoAggregationStrategyTest method testSplitNoAggregationStrategyException.
public void testSplitNoAggregationStrategyException() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:split");
mock.expectedBodiesReceived("Hello World", "Bye World", "Hi World");
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(0);
try {
template.sendBody("direct:start", "Hello World,Kaboom,Bye World,Hi World");
fail("Should thrown an exception");
} catch (CamelExecutionException e) {
assertEquals("Forced", e.getCause().getMessage());
}
assertMockEndpointsSatisfied();
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class SplitterStopOnExceptionTest method testSplitStopOnExceptionStop.
public void testSplitStopOnExceptionStop() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:split");
// we do stop so we stop splitting when the exception occurs and thus we only receive 1 message
mock.expectedBodiesReceived("Hello World");
try {
template.sendBody("direct:start", "Hello World,Kaboom,Bye World");
fail("Should thrown an exception");
} catch (CamelExecutionException e) {
CamelExchangeException cause = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
assertTrue(cause.getMessage().startsWith("Sequential processing failed for number 1."));
assertEquals("Forced", cause.getCause().getMessage());
}
assertMockEndpointsSatisfied();
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class PollEnricherAggregateOnExceptionTest method testEnrichFalseKaboom.
public void testEnrichFalseKaboom() throws Exception {
template.send("seda:foo", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.setException(new IllegalArgumentException("I cannot do this"));
}
});
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(0);
try {
template.sendBody("direct:start2", "Kaboom");
fail("Should have thrown exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("I cannot do this", e.getCause().getMessage());
}
assertMockEndpointsSatisfied();
}
Aggregations