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;
}
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);
}
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;
}
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();
}
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();
}
Aggregations