Search in sources :

Example 71 with DefaultCamelContext

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

the class EventNotifierExchangeSentTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext(createRegistry());
    context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() {

        public void notify(EventObject event) throws Exception {
            events.add(event);
        }

        public boolean isEnabled(EventObject event) {
            return true;
        }

        @Override
        protected void doStart() throws Exception {
            // filter out unwanted events
            setIgnoreCamelContextEvents(true);
            setIgnoreServiceEvents(true);
            setIgnoreRouteEvents(true);
            setIgnoreExchangeCreatedEvent(true);
            setIgnoreExchangeCompletedEvent(true);
            setIgnoreExchangeFailedEvents(true);
            setIgnoreExchangeRedeliveryEvents(true);
        }

        @Override
        protected void doStop() throws Exception {
        }
    });
    return context;
}
Also used : EventNotifierSupport(org.apache.camel.support.EventNotifierSupport) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) EventObject(java.util.EventObject)

Example 72 with DefaultCamelContext

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

the class LoggingEventNotifierTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    LoggingEventNotifier notifier = new LoggingEventNotifier();
    notifier.setLogName("org.apache.camel.EventLog");
    notifier.setIgnoreCamelContextEvents(true);
    notifier.setIgnoreRouteEvents(true);
    notifier.setIgnoreServiceEvents(true);
    CamelContext context = new DefaultCamelContext(createRegistry());
    context.getManagementStrategy().addEventNotifier(notifier);
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 73 with DefaultCamelContext

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

the class SimpleWithPropertiesTest method testProperty.

/**
     * A property from the property component in a expression 
     * is processed when the expression is evaluated with exchange
     * See https://issues.apache.org/jira/browse/CAMEL-4843
     * Now camel doesn't support the properties expression of {{test}}
     */
@Test
public void testProperty() throws Exception {
    System.setProperty("test", "testValue");
    PropertiesComponent pc = new PropertiesComponent();
    CamelContext context = new DefaultCamelContext();
    context.addComponent("properties", pc);
    // try to setup the property
    Exchange exchange = new DefaultExchange(context);
    String result = SimpleBuilder.simple("${properties:test}").evaluate(exchange, String.class);
    Assert.assertEquals("testValue", result);
    System.clearProperty("test");
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 74 with DefaultCamelContext

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

the class JmxNotificationEventNotifierTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    // START SNIPPET: e1
    // Set up the JmxNotificationEventNotifier
    notifier = new JmxNotificationEventNotifier();
    notifier.setSource("MyCamel");
    notifier.setIgnoreCamelContextEvents(true);
    notifier.setIgnoreRouteEvents(true);
    notifier.setIgnoreServiceEvents(true);
    CamelContext context = new DefaultCamelContext(createRegistry());
    context.getManagementStrategy().addEventNotifier(notifier);
    // END SNIPPET: e1
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 75 with DefaultCamelContext

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

the class CamelContextDisableJmxTest method testDisableJmx.

public void testDisableJmx() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.disableJMX();
    context.start();
    // JMX should be disabled and therefore not a ManagedManagementStrategy instance
    assertFalse(context.getManagementStrategy() instanceof ManagedManagementStrategy);
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

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