Search in sources :

Example 6 with Route

use of org.apache.camel.Route in project camel by apache.

the class DefaultErrorHandlerTest method testRoute.

public void testRoute() {
    Route route = context.getRoutes().get(0);
    EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
    Processor processor = unwrap(consumerRoute.getProcessor());
    Pipeline pipeline = assertIsInstanceOf(Pipeline.class, processor);
    // there should be a default error handler in front of each processor in this pipeline
    for (Processor child : pipeline.getProcessors()) {
        Channel channel = assertIsInstanceOf(Channel.class, child);
        assertNotNull("There should be an error handler", channel.getErrorHandler());
        assertIsInstanceOf(DefaultErrorHandler.class, channel.getErrorHandler());
    }
}
Also used : Processor(org.apache.camel.Processor) Channel(org.apache.camel.Channel) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 7 with Route

use of org.apache.camel.Route in project camel by apache.

the class DefaultRouteStartupOrder method getServices.

public List<Service> getServices() {
    List<Service> answer = new ArrayList<Service>();
    Collection<Route> routes = routeService.getRoutes();
    for (Route route : routes) {
        answer.addAll(route.getServices());
    }
    return answer;
}
Also used : ArrayList(java.util.ArrayList) Service(org.apache.camel.Service) Route(org.apache.camel.Route)

Example 8 with Route

use of org.apache.camel.Route in project camel by apache.

the class RouteBuilderTest method testComplexExpressions.

public void testComplexExpressions() throws Exception {
    // START SNIPPET: e7
    RouteBuilder builder = new RouteBuilder() {

        public void configure() {
            errorHandler(deadLetterChannel("mock:error"));
            from("direct:a").filter(header("foo").isEqualTo(123)).to("direct:b");
        }
    };
    // END SNIPPET: e7
    List<Route> routes = getRouteList(builder);
    log.debug("Created routes: " + routes);
    assertEquals("Number routes created", 1, routes.size());
    for (Route route : routes) {
        Endpoint key = route.getEndpoint();
        assertEquals("From endpoint", "direct://a", key.getEndpointUri());
    }
}
Also used : Endpoint(org.apache.camel.Endpoint) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 9 with Route

use of org.apache.camel.Route in project camel by apache.

the class RouteBuilderTest method testCustomProcessorWithFilter.

public void testCustomProcessorWithFilter() throws Exception {
    List<Route> routes = buildCustomProcessorWithFilter();
    log.debug("Created routes: " + routes);
    assertEquals("Number routes created", 1, routes.size());
    for (Route route : routes) {
        Endpoint key = route.getEndpoint();
        assertEquals("From endpoint", "direct://a", key.getEndpointUri());
    }
}
Also used : Endpoint(org.apache.camel.Endpoint) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 10 with Route

use of org.apache.camel.Route in project camel by apache.

the class RouteBuilderTest method testRouteWithInterceptor.

public void testRouteWithInterceptor() throws Exception {
    List<Route> routes = buildRouteWithInterceptor();
    log.debug("Created routes: " + routes);
    assertEquals("Number routes created", 1, routes.size());
    for (Route route : routes) {
        Endpoint key = route.getEndpoint();
        assertEquals("From endpoint", "direct://a", key.getEndpointUri());
        EventDrivenConsumerRoute consumer = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
        Pipeline line = assertIsInstanceOf(Pipeline.class, unwrap(consumer.getProcessor()));
        assertEquals(3, line.getProcessors().size());
        // last should be our seda
        List<Processor> processors = new ArrayList<Processor>(line.getProcessors());
        Processor sendTo = assertIsInstanceOf(SendProcessor.class, unwrapChannel(processors.get(2)).getNextProcessor());
        assertSendTo(sendTo, "direct://d");
    }
}
Also used : DelegateProcessor(org.apache.camel.DelegateProcessor) Processor(org.apache.camel.Processor) MulticastProcessor(org.apache.camel.processor.MulticastProcessor) FilterProcessor(org.apache.camel.processor.FilterProcessor) EvaluateExpressionProcessor(org.apache.camel.processor.EvaluateExpressionProcessor) ThreadsProcessor(org.apache.camel.processor.ThreadsProcessor) SendProcessor(org.apache.camel.processor.SendProcessor) ChoiceProcessor(org.apache.camel.processor.ChoiceProcessor) Endpoint(org.apache.camel.Endpoint) ArrayList(java.util.ArrayList) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Pipeline(org.apache.camel.processor.Pipeline)

Aggregations

Route (org.apache.camel.Route)90 EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)27 Endpoint (org.apache.camel.Endpoint)24 Channel (org.apache.camel.Channel)17 DeadLetterChannel (org.apache.camel.processor.DeadLetterChannel)15 Processor (org.apache.camel.Processor)13 ArrayList (java.util.ArrayList)12 SendProcessor (org.apache.camel.processor.SendProcessor)11 CamelContext (org.apache.camel.CamelContext)10 ShutdownRoute (org.apache.camel.ShutdownRoute)8 FilterProcessor (org.apache.camel.processor.FilterProcessor)7 RoutePolicy (org.apache.camel.spi.RoutePolicy)6 HashMap (java.util.HashMap)5 Service (org.apache.camel.Service)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 DelegateProcessor (org.apache.camel.DelegateProcessor)4 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)4