Search in sources :

Example 21 with FailedToCreateRouteException

use of org.apache.camel.FailedToCreateRouteException in project camel by apache.

the class StartingRoutesErrorReportedTest method testInvalidFrom.

public void testInvalidFrom() throws Exception {
    try {
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("direct:start?foo=bar").routeId("route1").to("mock:result");
            }
        });
        context.start();
        fail();
    } catch (FailedToCreateRouteException e) {
        assertTrue(e.getMessage().startsWith("Failed to create route route1: Route(route1)[[From[direct:start?foo=bar]] -> [To[mock:resul... because of"));
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 22 with FailedToCreateRouteException

use of org.apache.camel.FailedToCreateRouteException in project camel by apache.

the class WeightedRandomLoadBalanceTest method testUnmatchedRatiosToProcessors.

public void testUnmatchedRatiosToProcessors() throws Exception {
    try {
        context.addRoutes(new RouteBuilder() {

            public void configure() {
                // START SNIPPET: example
                from("direct:start").loadBalance().weighted(false, "2,3").to("mock:x", "mock:y", "mock:z");
            // END SNIPPET: example
            }
        });
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 23 with FailedToCreateRouteException

use of org.apache.camel.FailedToCreateRouteException in project camel by apache.

the class WeightedRoundRobinLoadBalanceTest method testUnmatchedRatiosToProcessors.

public void testUnmatchedRatiosToProcessors() throws Exception {
    try {
        context.addRoutes(new RouteBuilder() {

            public void configure() {
                // START SNIPPET: example
                from("direct:start").loadBalance().weighted(true, "2,3").to("mock:x", "mock:y", "mock:z");
            // END SNIPPET: example
            }
        });
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("Loadbalacing with 3 should match number of distributions 2", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder)

Example 24 with FailedToCreateRouteException

use of org.apache.camel.FailedToCreateRouteException in project camel by apache.

the class BeanWithMethodHeaderTest method testMethodNotExistsOnInstance.

public void testMethodNotExistsOnInstance() throws Exception {
    final MyBean myBean = new MyBean();
    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(myBean, mnfe.getBean());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) CamelExecutionException(org.apache.camel.CamelExecutionException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 25 with FailedToCreateRouteException

use of org.apache.camel.FailedToCreateRouteException in project camel by apache.

the class MethodCallBeanRefNotFoundTest method testMethodCallBeanRefNotFound.

public void testMethodCallBeanRefNotFound() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:a").routeId("a").split().method("foo", "hello").to("mock:a");
            from("direct:b").routeId("b").split().method("bar", "hello").to("mock:b");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        assertEquals("b", e.getRouteId());
        NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
        assertEquals("bar", cause.getName());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) NoSuchBeanException(org.apache.camel.NoSuchBeanException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) NoSuchBeanException(org.apache.camel.NoSuchBeanException)

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