Search in sources :

Example 46 with FailedToCreateRouteException

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"));
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) Test(org.junit.Test)

Example 47 with FailedToCreateRouteException

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());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 48 with FailedToCreateRouteException

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());
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) EventBus(com.google.common.eventbus.EventBus) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) Test(org.junit.Test)

Example 49 with FailedToCreateRouteException

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());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) Test(org.junit.Test)

Example 50 with FailedToCreateRouteException

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());
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)66 RouteBuilder (org.apache.camel.builder.RouteBuilder)63 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)13 Test (org.junit.Test)9 IOException (java.io.IOException)6 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)6 SOAPException (javax.xml.soap.SOAPException)5 CamelContext (org.apache.camel.CamelContext)5 FileNotFoundException (java.io.FileNotFoundException)3 NoSuchBeanException (org.apache.camel.NoSuchBeanException)3 ArrayList (java.util.ArrayList)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 CamelExecutionException (org.apache.camel.CamelExecutionException)2 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 DefaultRouteContext (org.apache.camel.impl.DefaultRouteContext)2 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)2 RouteContext (org.apache.camel.spi.RouteContext)2 EventBus (com.google.common.eventbus.EventBus)1 HttpException (com.meterware.httpunit.HttpException)1