Search in sources :

Example 36 with FailedToCreateRouteException

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

the class BeanLanguageInvalidOGNLTest method testBeanLanguageInvalidOGNL.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").transform().method(MyReallyCoolBean.class, "getOther[xx");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        RuntimeCamelException rce = assertIsInstanceOf(RuntimeCamelException.class, e.getCause());
        MethodNotFoundException mnfe = assertIsInstanceOf(MethodNotFoundException.class, rce.getCause());
        assertEquals("getOther[xx", mnfe.getMethodName());
        ExpressionIllegalSyntaxException cause = assertIsInstanceOf(ExpressionIllegalSyntaxException.class, mnfe.getCause());
        assertEquals("Illegal syntax: getOther[xx", cause.getMessage());
        assertEquals("getOther[xx", cause.getExpression());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) ExpressionIllegalSyntaxException(org.apache.camel.ExpressionIllegalSyntaxException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) MethodNotFoundException(org.apache.camel.component.bean.MethodNotFoundException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ExpressionIllegalSyntaxException(org.apache.camel.ExpressionIllegalSyntaxException) MethodNotFoundException(org.apache.camel.component.bean.MethodNotFoundException)

Example 37 with FailedToCreateRouteException

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

the class ThreadsZeroInCoreAndMaxPoolTest method testThreadsCoreBeZero.

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

            @Override
            public void configure() throws Exception {
                from("direct:start").threads(-1, 2).to("mock:result");
            }
        });
        fail("Expect FailedToCreateRouteException exception here");
    } catch (FailedToCreateRouteException ex) {
        assertTrue(ex.getCause() instanceof IllegalArgumentException);
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 38 with FailedToCreateRouteException

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

the class ThrottlerInvalidConfiguredTest method testInvalid.

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

        @Override
        public void configure() throws Exception {
            // null is invalid
            from("seda:a").throttle(null).to("mock:result");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertTrue(cause.getMessage().startsWith("MaxRequestsPerPeriod expression must be provided"));
    }
    context.stop();
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 39 with FailedToCreateRouteException

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

the class ThreadsCoreAndMaxPoolInvalidTest method testInvalidSyntax.

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

            @Override
            public void configure() throws Exception {
                from("direct:start").threads(5, 2).to("mock:result");
            }
        });
        fail("Should have thrown an exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("MaxPoolSize must be >= corePoolSize, was 2 >= 5", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException)

Example 40 with FailedToCreateRouteException

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

the class HttpsTwoDifferentSslContextParametersGetTest method httpsTwoDifferentSSLContextNotSupported.

@Test
public void httpsTwoDifferentSSLContextNotSupported() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:foo").to("https4://127.0.0.1:" + localServer.getLocalPort() + "/mail?x509HostnameVerifier=x509HostnameVerifier&sslContextParametersRef=sslContextParameters");
            from("direct:bar").to("https4://127.0.0.1:" + localServer.getLocalPort() + "/mail?x509HostnameVerifier=x509HostnameVerifier&sslContextParametersRef=sslContextParameters2");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = (IllegalArgumentException) e.getCause().getCause();
        assertNotNull(iae);
        assertTrue(iae.getMessage().startsWith("Only same instance of SSLContextParameters is supported."));
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) Test(org.junit.Test)

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