use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentInvalidKey.
public void testPropertiesComponentInvalidKey() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:{{foo.unknown}}");
}
});
try {
context.start();
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Property with key [foo.unknown] not found in properties from text: {{foo.unknown}}", iae.getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentPropertyPrefixFallbackDefaultNotFound.
public void testPropertiesComponentPropertyPrefixFallbackDefaultNotFound() throws Exception {
PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
pc.setPropertyPrefix("cool.");
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:doesnotexist");
}
});
try {
context.start();
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
assertEquals("Property with key [cool.doesnotexist] (and original key [doesnotexist]) not found in properties from text: {{doesnotexist}}", iae.getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class PropertiesComponentTest method testJvmSystemPropertyNotFound.
public void testJvmSystemPropertyNotFound() throws Exception {
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:xxx?locations=foo/${xxx}");
}
});
context.start();
fail("Should thrown an exception");
} catch (FailedToCreateRouteException e) {
IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("Cannot find JVM system property with key: xxx", cause.getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class BeanWithMethodHeaderTest method testMethodNotExists.
public void testMethodNotExists() throws Exception {
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:typo").bean("myBean", "ups").to("mock:result");
}
});
fail("Should throw an exception");
} catch (FailedToCreateRouteException e) {
MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
assertEquals("ups", mnfe.getMethodName());
assertSame(bean, mnfe.getBean());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class FileProducerChmodOptionTest method testInvalidChmod.
public void testInvalidChmod() throws Exception {
if (!canTest()) {
return;
}
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:writeBadChmod1").to("file://" + TEST_DIRECTORY + "?chmod=abc").to("mock:badChmod1");
}
});
fail("Expected FailedToCreateRouteException");
} catch (Exception e) {
assertTrue("Expected FailedToCreateRouteException, was " + e.getClass().getCanonicalName(), e instanceof FailedToCreateRouteException);
assertTrue("Message was [" + e.getMessage() + "]", e.getMessage().endsWith("conversion possible: chmod option [abc] is not valid"));
}
}
Aggregations