use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentNever.
public void testPropertiesComponentNever() throws Exception {
System.setProperty("cool.result", "bar");
System.setProperty("beer", "Carlsberg");
PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
pc.setSystemPropertiesMode(PropertiesComponent.SYSTEM_PROPERTIES_MODE_NEVER);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:foo").to("mock:{{beer}}").to("mock:{{cool.result}}");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
assertEquals("Property with key [beer] not found in properties from text: mock:{{beer}}", e.getCause().getMessage());
}
System.clearProperty("cool.result");
System.clearProperty("beer");
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured2.
public void testOnExceptionMisconfigured2() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Exception.class).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 OnExceptionMisconfiguredTest method testOnExceptionMisconfigured5.
public void testOnExceptionMisconfigured5() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
@SuppressWarnings("unchecked")
public void configure() throws Exception {
from("direct:start").onException().end().to("mock:result");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
assertTrue(iae.getMessage().startsWith("At least one exception must be configured"));
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured.
public void testOnExceptionMisconfigured() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Exception.class);
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 OnExceptionMisconfiguredTest method testOnExceptionMisconfigured3.
public void testOnExceptionMisconfigured3() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
@SuppressWarnings("unchecked")
public void configure() throws Exception {
onException();
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());
}
}
Aggregations