use of org.apache.camel.CamelExecutionException in project camel by apache.
the class DirectVmNoConsumerTest method testFailIfNoConsumerFalse.
@Test
public void testFailIfNoConsumerFalse() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct-vm:start").to("direct-vm:foo?failIfNoConsumers=false");
}
});
context.start();
try {
template.sendBody("direct-vm:start", "Hello World");
} catch (CamelExecutionException e) {
fail("Should not throw an exception");
}
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class DirectVmNoConsumerTest method testFailIfNoConsumersAfterConsumersLeave.
@Test
public void testFailIfNoConsumersAfterConsumersLeave() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct-vm:foo").routeId("stopThisRoute").to("mock:foo");
}
});
context.start();
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
template.sendBody("direct-vm:foo", "Hello World");
assertMockEndpointsSatisfied();
context.stopRoute("stopThisRoute");
TimeUnit.MILLISECONDS.sleep(100);
try {
template.sendBody("direct-vm:foo", "Hello World");
fail("Should throw an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(DirectVmConsumerNotAvailableException.class, e.getCause());
}
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class DirectVmNoConsumerTest method testInOut.
public void testInOut() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct-vm:start").to("direct-vm:foo");
}
});
context.start();
try {
template.requestBody("direct-vm:start", "Hello World");
fail("Should throw an exception");
} catch (CamelExecutionException e) {
assertIsInstanceOf(DirectVmConsumerNotAvailableException.class, e.getCause());
}
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class DirectVmProducerBlockingTest method testProducerBlocksWithNoConsumers.
public void testProducerBlocksWithNoConsumers() throws Exception {
DirectVmEndpoint endpoint = getMandatoryEndpoint("direct-vm:suspended", DirectVmEndpoint.class);
endpoint.getConsumer().suspend();
StopWatch watch = new StopWatch();
try {
template.sendBody("direct-vm:start?block=true&timeout=2000", "hello world");
fail("Expected CamelExecutionException");
} catch (CamelExecutionException e) {
DirectVmConsumerNotAvailableException cause = assertIsInstanceOf(DirectVmConsumerNotAvailableException.class, e.getCause());
assertIsInstanceOf(CamelExchangeException.class, cause);
assertTrue(watch.taken() > 1500);
}
}
use of org.apache.camel.CamelExecutionException in project camel by apache.
the class XsltDTDTest method sendEntityMessage.
private void sendEntityMessage(Object message) throws Exception {
MockEndpoint endpoint = getMockEndpoint("mock:result");
endpoint.reset();
endpoint.expectedMessageCount(1);
template.sendBody("direct:start1", message);
assertMockEndpointsSatisfied();
List<Exchange> list = endpoint.getReceivedExchanges();
Exchange exchange = list.get(0);
String xml = exchange.getIn().getBody(String.class);
assertTrue("Get a wrong transformed message", xml.indexOf("<transformed subject=\"\">") > 0);
try {
endpoint.reset();
endpoint.expectedMessageCount(1);
template.sendBody("direct:start2", message);
assertMockEndpointsSatisfied();
list = endpoint.getReceivedExchanges();
exchange = list.get(0);
xml = exchange.getIn().getBody(String.class);
assertTrue("Get a wrong transformed message", xml.indexOf("<transformed subject=\"\">") > 0);
} catch (Exception ex) {
// expect an exception here
assertTrue("Get a wrong exception", ex instanceof CamelExecutionException);
// the file could not be found
assertTrue("Get a wrong exception cause", ex.getCause() instanceof TransformerException);
}
}
Aggregations