Search in sources :

Example 41 with FailedToCreateRouteException

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

the class Mina2EncodingTest method testInvalidEncoding.

@Test
public void testInvalidEncoding() throws Exception {
    final String uri = String.format("mina2:tcp://localhost:%1$s?textline=true&encoding=XXX&sync=false", getPort());
    try {
        context.addRoutes(new RouteBuilder() {

            public void configure() {
                from(uri).to("mock:result");
            }
        });
        fail("Should have thrown a ResolveEndpointFailedException due invalid encoding parameter");
    } catch (FailedToCreateRouteException e) {
        IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
        assertEquals("The encoding: XXX is not supported", iae.getMessage());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 42 with FailedToCreateRouteException

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

the class ProtobufMarshalAndUnmarshallTest method testMarshalAndUnmarshalWithDSL3.

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

            @Override
            public void configure() throws Exception {
                from("direct:unmarshalC").unmarshal().protobuf(new CamelException("wrong instance")).to("mock:reverse");
            }
        });
        fail("Expect the exception here");
    } catch (Exception ex) {
        assertTrue("Expect FailedToCreateRouteException", ex instanceof FailedToCreateRouteException);
        assertTrue("Get a wrong reason", ex.getCause() instanceof IllegalArgumentException);
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) CamelException(org.apache.camel.CamelException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) CamelException(org.apache.camel.CamelException) Test(org.junit.Test)

Example 43 with FailedToCreateRouteException

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

the class QuartzNameCollisionTest method testDupeName.

@Test
public void testDupeName() throws Exception {
    camel1 = new DefaultCamelContext();
    camel1.setName("camel-1");
    camel1.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("log:one", "mock:one");
        }
    });
    camel1.start();
    try {
        camel1.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("quartz2://myGroup/myTimerName?cron=0/2+*+*+*+*+?").to("log:two", "mock:two");
            }
        });
        Assert.fail("Should have thrown an exception");
    } catch (FailedToCreateRouteException e) {
        String reason = e.getMessage();
        Assert.assertEquals(reason.indexOf("Trigger key myGroup.myTimerName is already in use") >= 0, true);
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) Test(org.junit.Test)

Example 44 with FailedToCreateRouteException

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

the class HttpClientRouteTest method testCreateSerlvetEndpointProducer.

@Test
public void testCreateSerlvetEndpointProducer() throws Exception {
    if (!startCamelContext) {
        // don't test it with web.xml configure
        return;
    }
    try {
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("direct:start").to("servlet:///testworld");
            }
        });
        fail("Excepts exception here");
    } catch (FailedToCreateRouteException ex) {
        assertTrue("Get a wrong exception.", ex.getCause() instanceof FailedToCreateProducerException);
        assertTrue("Get a wrong cause of exception.", ex.getCause().getCause() instanceof UnsupportedOperationException);
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) FailedToCreateProducerException(org.apache.camel.FailedToCreateProducerException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateProducerException(org.apache.camel.FailedToCreateProducerException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) HttpException(com.meterware.httpunit.HttpException) Test(org.junit.Test)

Example 45 with FailedToCreateRouteException

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

the class JavaDslTransactedNoTXManagerTest method testTransactedNoTXManager.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").transacted().to("mock:result");
        }
    });
    try {
        context.start();
        fail("Should have thrown an exception");
    } catch (FailedToCreateRouteException e) {
        NoSuchBeanException cause = assertIsInstanceOf(NoSuchBeanException.class, e.getCause());
        assertEquals("No bean could be found in the registry of type: PlatformTransactionManager", cause.getMessage());
    }
}
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