Search in sources :

Example 96 with DefaultCamelContext

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

the class ManagedStreamCachingStrategyTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            DefaultCamelContext dcc = (DefaultCamelContext) context;
            dcc.setName("myCamel");
            context.setStreamCaching(true);
            context.getStreamCachingStrategy().setSpoolDirectory("target/cachedir/#name#/");
            from("direct:start").routeId("foo").convertBodyTo(int.class).to("mock:a");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 97 with DefaultCamelContext

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

the class AbstractJsseParametersTest method createPropertiesPlaceholderAwareContext.

protected CamelContext createPropertiesPlaceholderAwareContext(Properties supplementalProperties) throws IOException {
    Properties properties = new Properties(supplementalProperties);
    properties.load(AbstractJsseParametersTest.class.getResourceAsStream("test.properties"));
    if (supplementalProperties != null) {
        Properties mergedProps = new Properties();
        Set<String> keys = new HashSet<String>();
        keys.addAll(properties.stringPropertyNames());
        keys.addAll(supplementalProperties.stringPropertyNames());
        for (String key : keys) {
            mergedProps.setProperty(key, properties.getProperty(key));
        }
        properties = mergedProps;
    }
    properties.store(new FileOutputStream("target/jsse-test.properties"), "Generated by " + AbstractJsseParametersTest.class.getName());
    PropertiesComponent pc = new PropertiesComponent();
    pc.setLocation("file:./target/jsse-test.properties");
    CamelContext context = new DefaultCamelContext();
    context.addComponent("properties", pc);
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) HashSet(java.util.HashSet)

Example 98 with DefaultCamelContext

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

the class GroupTokenIteratorTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    context = new DefaultCamelContext();
    context.start();
    exchange = new DefaultExchange(context);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 99 with DefaultCamelContext

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

the class MessageHelperTest method testCopyHeadersWithHeaderFilterStrategy.

public void testCopyHeadersWithHeaderFilterStrategy() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.start();
    message = new DefaultExchange(context).getIn();
    Message source = message;
    Message target = message.getExchange().getOut();
    DefaultHeaderFilterStrategy headerFilterStrategy = new DefaultHeaderFilterStrategy();
    headerFilterStrategy.setInFilterPattern("foo");
    source.setHeader("foo", 123);
    source.setHeader("bar", 456);
    target.setHeader("bar", "yes");
    MessageHelper.copyHeaders(source, target, headerFilterStrategy, true);
    assertEquals(null, target.getHeader("foo"));
    assertEquals(456, target.getHeader("bar"));
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultHeaderFilterStrategy(org.apache.camel.impl.DefaultHeaderFilterStrategy) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 100 with DefaultCamelContext

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

the class MessageHelperTest method testDumpAsXmlPlainBody.

public void testDumpAsXmlPlainBody() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.start();
    message = new DefaultExchange(context).getIn();
    // xml message body
    message.setBody("Hello World");
    message.setHeader("foo", 123);
    String out = MessageHelper.dumpAsXml(message);
    assertTrue("Should contain body", out.contains("<body type=\"java.lang.String\">Hello World</body>"));
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) 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