Search in sources :

Example 46 with RouteDefinition

use of org.apache.camel.model.RouteDefinition 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 47 with RouteDefinition

use of org.apache.camel.model.RouteDefinition in project camel by apache.

the class AdviceWithInterceptSendToEndpointWithLoadbalancerTest method testSimpleMultipleAdvice.

@Test
public void testSimpleMultipleAdvice() throws Exception {
    RouteDefinition route = context.getRouteDefinitions().get(0);
    route.adviceWith(context, new RouteBuilder() {

        public void configure() throws Exception {
            interceptSendToEndpoint("seda:end1").skipSendToOriginalEndpoint().to("mock:end");
        }
    });
    context.start();
    getMockEndpoint("mock:end").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 48 with RouteDefinition

use of org.apache.camel.model.RouteDefinition in project camel by apache.

the class HystrixHierarchicalConfigurationTest method testConfiguration.

@Test
public void testConfiguration() throws Exception {
    RouteDefinition routeDefinition = camelContext.getRouteDefinition("hystrix-route");
    HystrixDefinition hystrixDefinition = findHystrixDefinition(routeDefinition);
    Assert.assertNotNull(hystrixDefinition);
    HystrixProcessorFactory factory = new HystrixProcessorFactory();
    HystrixConfigurationDefinition config = factory.buildHystrixConfiguration(camelContext, hystrixDefinition);
    Assert.assertEquals("local-conf-group-key", config.getGroupKey());
    Assert.assertEquals("global-thread-key", config.getThreadPoolKey());
    Assert.assertEquals(new Integer(5), config.getCorePoolSize());
}
Also used : RouteDefinition(org.apache.camel.model.RouteDefinition) HystrixDefinition(org.apache.camel.model.HystrixDefinition) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 49 with RouteDefinition

use of org.apache.camel.model.RouteDefinition 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 50 with RouteDefinition

use of org.apache.camel.model.RouteDefinition in project camel by apache.

the class RouteboxDispatcher method getInnerContextConsumerList.

protected List<URI> getInnerContextConsumerList(CamelContext context) throws URISyntaxException {
    List<URI> consumerList = new ArrayList<URI>();
    List<RouteDefinition> routeDefinitions = context.getRouteDefinitions();
    for (RouteDefinition routeDefinition : routeDefinitions) {
        List<FromDefinition> inputs = routeDefinition.getInputs();
        for (FromDefinition input : inputs) {
            consumerList.add(new URI(input.getUri()));
        }
    }
    return consumerList;
}
Also used : FromDefinition(org.apache.camel.model.FromDefinition) RouteDefinition(org.apache.camel.model.RouteDefinition) ArrayList(java.util.ArrayList) URI(java.net.URI)

Aggregations

RouteDefinition (org.apache.camel.model.RouteDefinition)102 AdviceWithRouteBuilder (org.apache.camel.builder.AdviceWithRouteBuilder)17 RouteBuilder (org.apache.camel.builder.RouteBuilder)17 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)9 FromDefinition (org.apache.camel.model.FromDefinition)9 HashMap (java.util.HashMap)6 Processor (org.apache.camel.Processor)6 ConnectException (java.net.ConnectException)5 Exchange (org.apache.camel.Exchange)5 ProcessorDefinition (org.apache.camel.model.ProcessorDefinition)5 IOException (java.io.IOException)4 Map (java.util.Map)4 MBeanServer (javax.management.MBeanServer)4 ObjectName (javax.management.ObjectName)4 ChoiceDefinition (org.apache.camel.model.ChoiceDefinition)4 HystrixConfigurationDefinition (org.apache.camel.model.HystrixConfigurationDefinition)4 HystrixDefinition (org.apache.camel.model.HystrixDefinition)4 LogDefinition (org.apache.camel.model.LogDefinition)4 ModelCamelContext (org.apache.camel.model.ModelCamelContext)4