Search in sources :

Example 31 with FailedToCreateRouteException

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

the class PropertiesComponentOnlyUseDefaultValuesTest method testOneMissing.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").to("{{foo:mock:foo}}").to("{{bar}}");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
    // expected
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 32 with FailedToCreateRouteException

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

the class PropertiesComponentDefaultTest method testNotIgnoreMissingPropertySystemPropertyOnClasspath.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:bar.end?locations=${my.home}/unknown.properties,org/apache/camel/component/properties/bar.properties" + "&ignoreMissingLocation=false");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        assertEquals("Cannot find JVM system property with key: my.home", e.getCause().getCause().getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) FileNotFoundException(java.io.FileNotFoundException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 33 with FailedToCreateRouteException

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

the class PropertiesComponentDefaultTest method testPropertiesComponentDefaultNoFileFound.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").to("properties:bar.end?locations=org/apache/camel/component/properties/unknown.properties");
        }
    });
    try {
        context.start();
        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
        FileNotFoundException fnfe = assertIsInstanceOf(FileNotFoundException.class, cause.getCause());
        assertEquals("Properties file org/apache/camel/component/properties/unknown.properties not found in classpath", fnfe.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FileNotFoundException(java.io.FileNotFoundException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) FileNotFoundException(java.io.FileNotFoundException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 34 with FailedToCreateRouteException

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

the class XsltRouteXsltWithErrorTest method testXsltWithError.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").to("xslt:org/apache/camel/component/xslt/transform-with-error.xsl");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        TransformerConfigurationException cause = ObjectHelper.getException(TransformerConfigurationException.class, e);
        assertNotNull(cause);
        // not sure if XSLT errors may be i18n and not english always so just check for the spelling mistake of select -> slect
        assertTrue(cause.getMessage().contains("slect"));
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 35 with FailedToCreateRouteException

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

the class FromHasNoOutputRouteTest method testFromHasNoOutputRoute.

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

        @Override
        public void configure() throws Exception {
            // has no output which is a mis configuration
            from("direct:start");
        }
    });
    try {
        context.start();
        fail("Should throw exception");
    } catch (FailedToCreateRouteException e) {
        assertEquals("route1", e.getRouteId());
        IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("Route route1 has no output processors. You need to add outputs to the route such as to(\"log:foo\").", cause.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

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