Search in sources :

Example 46 with DefaultCamelContext

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

the class EndpointHelperTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    SimpleRegistry reg = new SimpleRegistry();
    CamelContext context = new DefaultCamelContext(reg);
    foo = context.getEndpoint("mock:foo");
    bar = context.getEndpoint("mock:bar");
    reg.put("foo", foo);
    reg.put("coolbar", bar);
    return context;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 47 with DefaultCamelContext

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

the class ExchangeHelperTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.setProperty("foo", 123);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 48 with DefaultCamelContext

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

the class AtomGoodBlogsTest method createCamelContext.

protected CamelContext createCamelContext() throws Exception {
    // First we register a blog service in our bean registry
    SimpleRegistry registry = new SimpleRegistry();
    registry.put("blogService", new BlogService());
    // Then we create the camel context with our bean registry
    context = new DefaultCamelContext(registry);
    // Then we add all the routes we need using the route builder DSL syntax
    context.addRoutes(createMyRoutes());
    return context;
}
Also used : SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 49 with DefaultCamelContext

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

the class SqsFilterMessagesWithNoDeleteTest method testGetThroughFilter.

@Test
public void testGetThroughFilter() throws Exception {
    final String sqsURI = String.format("aws-sqs://MyQueue?amazonSQSClient=#amazonSQSClient" + // through filter, it should be deleted!
    "&deleteIfFiltered=false" + "&defaultVisibilityTimeout=1");
    AmazonSQSClientMock clientMock = new AmazonSQSClientMock();
    populateMessages(clientMock);
    SimpleRegistry registry = new SimpleRegistry();
    DefaultCamelContext ctx = new DefaultCamelContext(registry);
    ctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from(sqsURI).setHeader("login", constant(true)).filter(simple("${header.login} == true")).to("mock:result");
        }
    });
    MockEndpoint result = MockEndpoint.resolve(ctx, "mock:result");
    registry.put("amazonSQSClient", clientMock);
    clientMock.setScheduler(ctx.getExecutorServiceManager().newScheduledThreadPool(clientMock, "ClientMock Scheduler", 1));
    result.expectedMessageCount(1);
    ctx.start();
    // the message should get through filter and mock should assert this
    assertIsSatisfied(2000, TimeUnit.MILLISECONDS);
    // however, the message should not be deleted, that is, it should be left on the queue
    String response = ctx.createConsumerTemplate().receiveBody(sqsURI, 5000, String.class);
    assertNull(response);
    ctx.stop();
    clientMock.shutdown();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 50 with DefaultCamelContext

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

the class SqsFilterMessagesWithNoDeleteTest method testDoesNotGetThroughFilter.

@Test
public void testDoesNotGetThroughFilter() throws Exception {
    final String sqsURI = String.format("aws-sqs://MyQueue?amazonSQSClient=#amazonSQSClient" + // note we will NOT delete if this message gets filtered out
    "&deleteIfFiltered=false" + "&defaultVisibilityTimeout=1");
    AmazonSQSClientMock clientMock = new AmazonSQSClientMock();
    populateMessages(clientMock);
    SimpleRegistry registry = new SimpleRegistry();
    DefaultCamelContext ctx = new DefaultCamelContext(registry);
    ctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from(sqsURI).filter(simple("${header.login} == true")).to("mock:result");
        }
    });
    MockEndpoint result = MockEndpoint.resolve(ctx, "mock:result");
    clientMock.setScheduler(ctx.getExecutorServiceManager().newScheduledThreadPool(clientMock, "ClientMock Scheduler", 1));
    registry.put("amazonSQSClient", clientMock);
    result.expectedMessageCount(0);
    ctx.start();
    // we shouldn't get
    assertIsSatisfied(2000, TimeUnit.MILLISECONDS);
    // however, the message should not be deleted, that is, it should be left on the queue
    String response = ctx.createConsumerTemplate().receiveBody(sqsURI, 5000, String.class);
    assertEquals(response, "Message: hello, world!");
    ctx.stop();
    clientMock.shutdown();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

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