Search in sources :

Example 61 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class XsltCustomErrorListenerTest method testErrorListener.

public void testErrorListener() throws Exception {
    try {
        SimpleRegistry registry = new SimpleRegistry();
        registry.put("myListener", listener);
        RouteBuilder builder = createRouteBuilder();
        CamelContext context = new DefaultCamelContext(registry);
        context.addRoutes(builder);
        context.start();
        fail("Should have thrown an exception due XSLT file not found");
    } catch (FailedToCreateRouteException e) {
    // expected
    }
    assertFalse(listener.isWarning());
    assertTrue("My error listener should been invoked", listener.isError());
    assertTrue("My error listener should been invoked", listener.isFatalError());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 62 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class XsltReferenceParameterTest method setUp.

public void setUp() throws Exception {
    JndiRegistry registry = new JndiRegistry(new JndiContext());
    RouteBuilder builder = createRouteBuilder();
    CamelContext context = new DefaultCamelContext(registry);
    testConverter = new TestConverter();
    testTransformerFactory = TransformerFactory.newInstance();
    registry.bind("testConverter", testConverter);
    registry.bind("testTransformerFactory", testTransformerFactory);
    ProcessorEndpoint pep1 = context.getEndpoint(TEST_URI_1, ProcessorEndpoint.class);
    context.addRoutes(builder);
    context.start();
    builder1 = (XsltBuilder) pep1.getProcessor();
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) JndiContext(org.apache.camel.util.jndi.JndiContext) ProcessorEndpoint(org.apache.camel.impl.ProcessorEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 63 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class ValidatorEndpointClearCachedSchemaTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    simpleReg = new SimpleRegistry();
    context = new DefaultCamelContext(simpleReg);
    context.setClassResolver(new ClassResolverImpl());
    return context;
}
Also used : SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 64 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class XsltFileNotFoundTest method testNoXsltFile.

public void testNoXsltFile() throws Exception {
    try {
        RouteBuilder builder = createRouteBuilder();
        CamelContext context = new DefaultCamelContext();
        context.addRoutes(builder);
        context.start();
        fail("Should have thrown an exception due XSLT file not found");
    } catch (FailedToCreateRouteException e) {
        assertIsInstanceOf(TransformerException.class, e.getCause());
        assertIsInstanceOf(FileNotFoundException.class, e.getCause().getCause());
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FileNotFoundException(java.io.FileNotFoundException) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) TransformerException(javax.xml.transform.TransformerException)

Example 65 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class VmMultipleConsumersKeepRouteTest method testVmMultipleConsumersKeepRoute.

public void testVmMultipleConsumersKeepRoute() throws Exception {
    CamelContext camelContext = new DefaultCamelContext();
    ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
    RouteBuilder builder = new RouteBuilder(camelContext) {

        @Override
        public void configure() throws Exception {
            from("vm:producer?multipleConsumers=true").routeId("route1").to("mock:route1");
        }
    };
    RouteBuilder builder2 = new RouteBuilder(camelContext) {

        @Override
        public void configure() throws Exception {
            from("vm:producer?multipleConsumers=true").routeId("route2").to("mock:route2");
        }
    };
    camelContext.addRoutes(builder);
    camelContext.addRoutes(builder2);
    camelContext.start();
    MockEndpoint mock1 = (MockEndpoint) camelContext.getEndpoint("mock:route1");
    MockEndpoint mock2 = (MockEndpoint) camelContext.getEndpoint("mock:route2");
    mock1.expectedMessageCount(100);
    mock2.expectedMessageCount(100);
    for (int i = 0; i < 100; i++) {
        producerTemplate.sendBody("vm:producer?multipleConsumers=true", i);
    }
    MockEndpoint.assertIsSatisfied(mock1, mock2);
    camelContext.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Aggregations

DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)474 CamelContext (org.apache.camel.CamelContext)206 Test (org.junit.Test)183 DefaultExchange (org.apache.camel.impl.DefaultExchange)128 RouteBuilder (org.apache.camel.builder.RouteBuilder)101 Exchange (org.apache.camel.Exchange)91 Before (org.junit.Before)70 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)61 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)38 ESMClass (org.jsmpp.bean.ESMClass)30 ProducerTemplate (org.apache.camel.ProducerTemplate)27 CountDownLatch (java.util.concurrent.CountDownLatch)15 Endpoint (org.apache.camel.Endpoint)13 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)13 Processor (org.apache.camel.Processor)12 RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)12 Address (org.jsmpp.bean.Address)11 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)11 Date (java.util.Date)10