use of org.apache.camel.model.ModelCamelContext in project camel by apache.
the class CamelBlueprintTestSupport method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext answer = null;
Long timeout = getCamelContextCreationTimeout();
if (timeout == null) {
answer = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class);
} else if (timeout >= 0) {
answer = CamelBlueprintHelper.getOsgiService(bundleContext, CamelContext.class, timeout);
} else {
throw new IllegalArgumentException("getCamelContextCreationTimeout cannot return a negative value.");
}
// must override context so we use the correct one in testing
context = (ModelCamelContext) answer;
return answer;
}
use of org.apache.camel.model.ModelCamelContext in project camel by apache.
the class AddComponentInConfigureBuilder method configure.
@Override
public void configure() throws Exception {
ModelCamelContext context = getContext();
TimerComponent timerComponent = new TimerComponent();
getContext().addComponent("my-timer", timerComponent);
from("my-timer://test-timer?period=1000").to("mock://result");
}
use of org.apache.camel.model.ModelCamelContext in project camel by apache.
the class XmlConfigTestSupport method assertValidContext.
protected void assertValidContext(CamelContext context) {
assertNotNull("No context found!", context);
List<RouteDefinition> routes = ((ModelCamelContext) context).getRouteDefinitions();
LOG.debug("Found routes: " + routes);
assertEquals("One Route should be found", 1, routes.size());
for (RouteDefinition route : routes) {
List<FromDefinition> inputs = route.getInputs();
assertEquals("Number of inputs", 1, inputs.size());
FromDefinition fromType = inputs.get(0);
assertEquals("from URI", "seda:test.a", fromType.getUri());
List<?> outputs = route.getOutputs();
assertEquals("Number of outputs", 1, outputs.size());
}
}
use of org.apache.camel.model.ModelCamelContext in project camel by apache.
the class SpringScheduledRoutePolicyTest method startRouteWithPolicy.
@SuppressWarnings("unchecked")
private CamelContext startRouteWithPolicy(String policyBeanName) throws Exception {
CamelContext context = new DefaultCamelContext();
List<RouteDefinition> routes = (List<RouteDefinition>) applicationContext.getBean("testRouteContext");
RoutePolicy policy = applicationContext.getBean(policyBeanName, RoutePolicy.class);
assertTrue(getTestType() == TestType.SIMPLE ? policy instanceof SimpleScheduledRoutePolicy : policy instanceof CronScheduledRoutePolicy);
routes.get(0).routePolicy(policy);
((ModelCamelContext) context).addRouteDefinitions(routes);
context.start();
return context;
}
use of org.apache.camel.model.ModelCamelContext in project camel by apache.
the class ModelCamelContextTest method testAdapt.
public void testAdapt() throws Exception {
ModelCamelContext mcc = context.adapt(ModelCamelContext.class);
assertNotNull(mcc);
assertSame(context, mcc);
assertEquals("foo", mcc.getRouteDefinitions().get(0).getId());
}
Aggregations