Search in sources :

Example 1 with FailedToCreateRouteException

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

the class BeanInvokeStaticTest method testB.

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

        @Override
        public void configure() throws Exception {
            from("direct:a").bean(MyStaticClass.class, "doSomething").to("mock:a");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
        assertIsInstanceOf(MethodNotFoundException.class, e.getCause().getCause());
        assertEquals("Static method with name: doSomething not found on class: org.apache.camel.component.bean.MyStaticClass", e.getCause().getCause().getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) RuntimeCamelException(org.apache.camel.RuntimeCamelException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 2 with FailedToCreateRouteException

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

the class SameSedaQueueMultipleConsumersDifferenceTest method testAddConsumer.

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

            @Override
            public void configure() throws Exception {
                from("seda:foo").routeId("fail").to("mock:fail");
            }
        });
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        assertEquals("fail", e.getRouteId());
        assertEquals("Cannot use existing queue seda://foo as the existing queue multiple consumers true does not match given multiple consumers false", e.getCause().getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 3 with FailedToCreateRouteException

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

the class PropertiesComponentTest method testPropertiesComponentPropertySuffixFallbackFalse.

public void testPropertiesComponentPropertySuffixFallbackFalse() throws Exception {
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setPropertySuffix(".end");
    pc.setFallbackToUnaugmentedProperty(false);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:cool.end");
        }
    });
    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.end.end] not found in properties from text: {{cool.end}}", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 4 with FailedToCreateRouteException

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

the class PropertiesComponentTest method testPropertiesComponentCircularReference.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:cool.a");
        }
    });
    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("Circular reference detected with key [cool.a] from text: {{cool.a}}", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 5 with FailedToCreateRouteException

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

the class PropertiesComponentTest method testPropertiesComponentPropertyPrefixFallbackFalse.

public void testPropertiesComponentPropertyPrefixFallbackFalse() throws Exception {
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setPropertyPrefix("cool.");
    pc.setFallbackToUnaugmentedProperty(false);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:cool.end");
            from("direct:foo").to("properties:mock:{{result}}");
        }
    });
    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.cool.end] not found in properties from text: {{cool.end}}", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

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