use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class RouteMustHaveOutputOnExceptionTest method testInValid.
public void testInValid() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").onException(Exception.class).maximumRedeliveries(2).backOffMultiplier(1.5).handled(true).delay(1000).log("Halting for some time").to("mock:halt").end().to("mock:result");
}
});
try {
context.start();
fail("Should have thrown an exception");
} catch (FailedToCreateRouteException e) {
// expected
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class TryCatchMustHaveExceptionConfiguredTest method testTryCatchMustHaveExceptionConfigured.
public void testTryCatchMustHaveExceptionConfigured() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
@SuppressWarnings("unchecked")
public void configure() throws Exception {
from("direct:a").doTry().to("mock:b").throwException(new IllegalArgumentException("Damn")).doCatch().to("mock:catch").end();
}
});
try {
context.start();
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("At least one Exception must be configured to catch", e.getCause().getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class OnExceptionHandledAndContinueTest method testHandledAndContinued.
public void testHandledAndContinued() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
// should not be allowed
onException(IllegalArgumentException.class).continued(true).handled(true);
from("direct:start").to("mock:start").throwException(new IllegalArgumentException("Forced")).to("mock:result");
}
});
try {
context.start();
fail("Should thrown an exception");
} catch (FailedToCreateRouteException e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(e.getCause().getMessage().startsWith("Only one of handled or continued is allowed to be configured"));
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured4.
public void testOnExceptionMisconfigured4() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
@SuppressWarnings("unchecked")
public void configure() throws Exception {
onException().end();
from("direct:start").to("mock:result");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertEquals("OnException[[class java.lang.Exception] -> []] is not configured.", iae.getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class ClassComponentInvalidConfigurationTest method testPropertyNotFoundOnClass.
public void testPropertyNotFoundOnClass() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("class:org.apache.camel.component.bean.MyPrefixBean?bean.foo=bar").to("mock:result");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
assertTrue(cause.getMessage().contains("Unknown parameters"));
assertTrue(cause.getMessage().contains("foo=bar"));
}
}
Aggregations