Search in sources :

Example 6 with ModelCamelContext

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;
}
Also used : CamelContext(org.apache.camel.CamelContext) ModelCamelContext(org.apache.camel.model.ModelCamelContext)

Example 7 with ModelCamelContext

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");
}
Also used : ModelCamelContext(org.apache.camel.model.ModelCamelContext) TimerComponent(org.apache.camel.component.timer.TimerComponent)

Example 8 with ModelCamelContext

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());
    }
}
Also used : FromDefinition(org.apache.camel.model.FromDefinition) RouteDefinition(org.apache.camel.model.RouteDefinition) ModelCamelContext(org.apache.camel.model.ModelCamelContext)

Example 9 with ModelCamelContext

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;
}
Also used : CamelContext(org.apache.camel.CamelContext) ModelCamelContext(org.apache.camel.model.ModelCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteDefinition(org.apache.camel.model.RouteDefinition) List(java.util.List) RoutePolicy(org.apache.camel.spi.RoutePolicy) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ModelCamelContext(org.apache.camel.model.ModelCamelContext)

Example 10 with ModelCamelContext

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());
}
Also used : ModelCamelContext(org.apache.camel.model.ModelCamelContext)

Aggregations

ModelCamelContext (org.apache.camel.model.ModelCamelContext)14 RouteDefinition (org.apache.camel.model.RouteDefinition)5 CamelContext (org.apache.camel.CamelContext)4 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)4 List (java.util.List)2 FromDefinition (org.apache.camel.model.FromDefinition)2 RoutePolicy (org.apache.camel.spi.RoutePolicy)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ErrorHandlerFactory (org.apache.camel.ErrorHandlerFactory)1 NoSuchEndpointException (org.apache.camel.NoSuchEndpointException)1 RoutesBuilder (org.apache.camel.RoutesBuilder)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 TimerComponent (org.apache.camel.component.timer.TimerComponent)1 DefaultDebugger (org.apache.camel.impl.DefaultDebugger)1 InterceptSendToMockEndpointStrategy (org.apache.camel.impl.InterceptSendToMockEndpointStrategy)1 ManagedRoute (org.apache.camel.management.mbean.ManagedRoute)1 ManagedSuspendableRoute (org.apache.camel.management.mbean.ManagedSuspendableRoute)1 InterceptFromDefinition (org.apache.camel.model.InterceptFromDefinition)1