use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class RouteStartupOrderSuspendResumeNoAutoStartupTest method testRouteStartupOrderSuspendResumeNoAutoStartup.
public void testRouteStartupOrderSuspendResumeNoAutoStartup() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
context.suspend();
context.resume();
// route C should still be stopped after we have resumed
assertEquals(true, context.getRouteStatus("C").isStopped());
// assert correct order
DefaultCamelContext dcc = (DefaultCamelContext) context;
List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
assertEquals(3, order.size());
assertEquals("direct://foo", order.get(0).getRoute().getEndpoint().getEndpointUri());
assertEquals("direct://start", order.get(1).getRoute().getEndpoint().getEndpointUri());
assertEquals("direct://bar", order.get(2).getRoute().getEndpoint().getEndpointUri());
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class RouteStartupOrderWithDefaultTest method testRouteStartupOrder.
public void testRouteStartupOrder() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
// assert correct order
DefaultCamelContext dcc = (DefaultCamelContext) context;
List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
assertEquals(5, order.size());
assertEquals("seda://foo", order.get(0).getRoute().getEndpoint().getEndpointUri());
assertEquals("direct://start", order.get(1).getRoute().getEndpoint().getEndpointUri());
assertEquals("seda://bar", order.get(2).getRoute().getEndpoint().getEndpointUri());
assertEquals("direct://bar", order.get(3).getRoute().getEndpoint().getEndpointUri());
// the one with no startup order should be last
assertEquals("direct://default", order.get(4).getRoute().getEndpoint().getEndpointUri());
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class AsyncEndpointEventNotifierTest 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 {
try {
ExchangeSentEvent sent = (ExchangeSentEvent) event;
time.set(sent.getTimeTaken());
} finally {
latch.countDown();
}
}
public boolean isEnabled(EventObject event) {
// we only want the async endpoint
if (event instanceof ExchangeSentEvent) {
ExchangeSentEvent sent = (ExchangeSentEvent) event;
return sent.getEndpoint().getEndpointUri().startsWith("async");
}
return false;
}
@Override
protected void doStart() throws Exception {
}
@Override
protected void doStop() throws Exception {
}
});
return context;
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class ContainerTest method testNoContainerSet.
public void testNoContainerSet() throws Exception {
MyContainer myContainer = new MyContainer();
CamelContext camel1 = new DefaultCamelContext();
CamelContext camel2 = new DefaultCamelContext();
camel1.start();
camel2.start();
assertEquals(0, myContainer.names.size());
camel1.stop();
camel2.stop();
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class ContainerTest method testContainerSet.
public void testContainerSet() throws Exception {
MyContainer myContainer = new MyContainer();
CamelContext camel1 = new DefaultCamelContext();
CamelContext camel2 = new DefaultCamelContext();
// Must call start to make contexts 'managed'
camel1.start();
camel2.start();
assertEquals(0, myContainer.names.size());
Container.Instance.set(myContainer);
// after we set, then we should manage the 2 pending contexts
assertEquals(2, myContainer.names.size());
CamelContext camel3 = new DefaultCamelContext();
camel3.start();
assertEquals(3, myContainer.names.size());
assertEquals(camel1.getName(), myContainer.names.get(0));
assertEquals(camel2.getName(), myContainer.names.get(1));
assertEquals(camel3.getName(), myContainer.names.get(2));
camel1.stop();
camel2.stop();
camel3.stop();
}
Aggregations