Search in sources :

Example 6 with FailedToCreateRouteException

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

the class PropertiesComponentTest method testPropertiesComponentNever.

public void testPropertiesComponentNever() throws Exception {
    System.setProperty("cool.result", "bar");
    System.setProperty("beer", "Carlsberg");
    PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
    pc.setSystemPropertiesMode(PropertiesComponent.SYSTEM_PROPERTIES_MODE_NEVER);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:foo").to("mock:{{beer}}").to("mock:{{cool.result}}");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        assertEquals("Property with key [beer] not found in properties from text: mock:{{beer}}", e.getCause().getMessage());
    }
    System.clearProperty("cool.result");
    System.clearProperty("beer");
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 7 with FailedToCreateRouteException

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

the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured2.

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

        @Override
        public void configure() throws Exception {
            onException(Exception.class).end();
            from("direct:start").to("mock:result");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("OnException[[class java.lang.Exception] -> []] is not configured.", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) SOAPException(javax.xml.soap.SOAPException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) IOException(java.io.IOException)

Example 8 with FailedToCreateRouteException

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

the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured5.

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

        @Override
        @SuppressWarnings("unchecked")
        public void configure() throws Exception {
            from("direct:start").onException().end().to("mock:result");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertTrue(iae.getMessage().startsWith("At least one exception must be configured"));
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) SOAPException(javax.xml.soap.SOAPException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) IOException(java.io.IOException)

Example 9 with FailedToCreateRouteException

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

the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured.

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

        @Override
        public void configure() throws Exception {
            onException(Exception.class);
            from("direct:start").to("mock:result");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("OnException[[class java.lang.Exception] -> []] is not configured.", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) SOAPException(javax.xml.soap.SOAPException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) IOException(java.io.IOException)

Example 10 with FailedToCreateRouteException

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

the class OnExceptionMisconfiguredTest method testOnExceptionMisconfigured3.

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

        @Override
        @SuppressWarnings("unchecked")
        public void configure() throws Exception {
            onException();
            from("direct:start").to("mock:result");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("OnException[[class java.lang.Exception] -> []] is not configured.", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) SOAPException(javax.xml.soap.SOAPException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) IOException(java.io.IOException)

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