Search in sources :

Example 91 with CamelExecutionException

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

the class BeanOverloadedMethodFQNTest method testOrderNoFQNUnknown.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").bean(MyBean.class, "order(Unknown)").to("mock:result");
        }
    });
    context.start();
    try {
        template.sendBody("direct:start", new MyOrder());
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        NoTypeConversionAvailableException cause = assertIsInstanceOf(NoTypeConversionAvailableException.class, e.getCause().getCause());
        assertEquals("Unknown", cause.getValue());
    }
}
Also used : CamelExecutionException(org.apache.camel.CamelExecutionException) RouteBuilder(org.apache.camel.builder.RouteBuilder) NoTypeConversionAvailableException(org.apache.camel.NoTypeConversionAvailableException) NoTypeConversionAvailableException(org.apache.camel.NoTypeConversionAvailableException) CamelExecutionException(org.apache.camel.CamelExecutionException)

Example 92 with CamelExecutionException

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

the class BeanOverloadedMethodTest method testHelloOverloadedAmbiguousStringStringString.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").bean(MyBean.class, "hello(String,String,String)").to("mock:result");
        }
    });
    context.start();
    try {
        template.sendBodyAndHeader("direct:start", "Claus", "country", "Denmark");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        AmbiguousMethodCallException cause = assertIsInstanceOf(AmbiguousMethodCallException.class, e.getCause());
        assertEquals(2, cause.getMethods().size());
    }
}
Also used : CamelExecutionException(org.apache.camel.CamelExecutionException) RouteBuilder(org.apache.camel.builder.RouteBuilder) CamelExecutionException(org.apache.camel.CamelExecutionException)

Example 93 with CamelExecutionException

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

the class BeanOverloadedMethodTest method testHelloOverloadedIntString.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").bean(MyBean.class, "hello(int,String)").to("mock:result");
        }
    });
    context.start();
    try {
        template.sendBodyAndHeader("direct:start", "Claus", "country", "Denmark");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        AmbiguousMethodCallException cause = assertIsInstanceOf(AmbiguousMethodCallException.class, e.getCause());
        assertEquals(2, cause.getMethods().size());
    }
}
Also used : CamelExecutionException(org.apache.camel.CamelExecutionException) RouteBuilder(org.apache.camel.builder.RouteBuilder) CamelExecutionException(org.apache.camel.CamelExecutionException)

Example 94 with CamelExecutionException

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

the class SedaInOutChainedTimeoutTest method testSedaInOutChainedTimeout.

public void testSedaInOutChainedTimeout() throws Exception {
    // time timeout after 2 sec should trigger a immediately reply
    StopWatch watch = new StopWatch();
    try {
        template.requestBody("seda:a?timeout=5000", "Hello World");
        fail("Should have thrown an exception");
    } catch (CamelExecutionException e) {
        ExchangeTimedOutException cause = assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause());
        assertEquals(2000, cause.getTimeout());
    }
    long delta = watch.stop();
    assertTrue("Should be faster than 4000 millis, was: " + delta, delta < 4000);
}
Also used : CamelExecutionException(org.apache.camel.CamelExecutionException) ExchangeTimedOutException(org.apache.camel.ExchangeTimedOutException) StopWatch(org.apache.camel.util.StopWatch)

Example 95 with CamelExecutionException

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

the class SedaNoConsumerTest method testFailIfNoConsumer.

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

        @Override
        public void configure() throws Exception {
            from("direct:start").to("seda:foo?failIfNoConsumers=true");
        }
    });
    context.start();
    try {
        template.sendBody("direct:start", "Hello World");
        fail("Should throw an exception");
    } catch (CamelExecutionException e) {
        assertIsInstanceOf(SedaConsumerNotAvailableException.class, e.getCause());
    }
}
Also used : CamelExecutionException(org.apache.camel.CamelExecutionException) RouteBuilder(org.apache.camel.builder.RouteBuilder) ExchangeTimedOutException(org.apache.camel.ExchangeTimedOutException) CamelExecutionException(org.apache.camel.CamelExecutionException) Test(org.junit.Test)

Aggregations

CamelExecutionException (org.apache.camel.CamelExecutionException)156 RouteBuilder (org.apache.camel.builder.RouteBuilder)69 Test (org.junit.Test)64 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)59 Exchange (org.apache.camel.Exchange)23 CamelContext (org.apache.camel.CamelContext)20 Processor (org.apache.camel.Processor)17 ProducerTemplate (org.apache.camel.ProducerTemplate)17 CamelExchangeException (org.apache.camel.CamelExchangeException)13 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)13 IOException (java.io.IOException)12 Date (java.util.Date)11 StopWatch (org.apache.camel.util.StopWatch)10 ExchangeTimedOutException (org.apache.camel.ExchangeTimedOutException)7 Set (java.util.Set)6 Subject (javax.security.auth.Subject)6 ConstraintViolation (javax.validation.ConstraintViolation)6 FailedLoginException (javax.security.auth.login.FailedLoginException)5 QuartzComponent (org.apache.camel.component.quartz.QuartzComponent)5 File (java.io.File)4