use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class RestRestletCustomDataFormatInvalidTest method testCustom.
@Test
public void testCustom() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.json).jsonDataFormat("bla");
// use the rest DSL to define the rest services
rest("/users/").post("lives").type(UserPojo.class).outType(CountryPojo.class).route().choice().when().simple("${body.id} < 100").bean(new UserErrorService(), "idToLowError").otherwise().bean(new UserService(), "livesWhere");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
assertTrue(e.getCause().getMessage().contains("JsonDataFormat name: bla must not be an existing bean instance from the registry"));
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class MinaEncodingTest method testInvalidEncoding.
@Test
public void testInvalidEncoding() throws Exception {
final String uri = "mina:tcp://localhost:{{port}}?textline=true&encoding=XXX&sync=false";
try {
context.addRoutes(new RouteBuilder() {
public void configure() {
from(uri).to("mock:result");
}
});
fail("Should have thrown a ResolveEndpointFailedException due invalid encoding parameter");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
assertTrue(cause.getCause() instanceof IllegalArgumentException);
assertEquals("The encoding: XXX is not supported", cause.getCause().getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class GuavaEventBusConsumerConfigurationTest method invalidConfiguration.
@Test
public void invalidConfiguration() throws Exception {
// Given
SimpleRegistry registry = new SimpleRegistry();
registry.put("eventBus", new EventBus());
CamelContext context = new DefaultCamelContext(registry);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("guava-eventbus:eventBus?listenerInterface=org.apache.camel.component.guava.eventbus.CustomListener&eventClass=org.apache.camel.component.guava.eventbus.MessageWrapper").to("mock:customListenerEvents");
}
});
try {
context.start();
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
IllegalStateException ise = assertIsInstanceOf(IllegalStateException.class, e.getCause());
assertEquals("You cannot set both 'eventClass' and 'listenerInterface' parameters.", ise.getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class IBatisUnknownStatementTypeTest method testStatementTypeNotSet.
@Test
public void testStatementTypeNotSet() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("ibatis:selectAllAccounts");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
assertEquals("statementType must be specified on: ibatis://selectAllAccounts", e.getCause().getCause().getMessage());
}
}
use of org.apache.camel.FailedToCreateRouteException in project camel by apache.
the class XsltSaxonTest method testSaxon.
public void testSaxon() throws Exception {
try {
RouteBuilder builder = createRouteBuilder();
CamelContext context = new DefaultCamelContext();
context.addRoutes(builder);
context.start();
fail("Should have thrown an exception due XSLT saxon not on classpath");
} catch (FailedToCreateRouteException e) {
assertIsInstanceOf(ClassNotFoundException.class, e.getCause());
}
}
Aggregations