Search in sources :

Example 21 with RouteStartupOrder

use of org.apache.camel.spi.RouteStartupOrder in project camel by apache.

the class RouteStartupOrderDirectReverseTest method testRouteStartupOrder.

public void testRouteStartupOrder() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:bar", "Hello World");
    assertMockEndpointsSatisfied();
    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(2, order.size());
    assertEquals("direct://bar", order.get(1).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://foo", order.get(0).getRoute().getEndpoint().getEndpointUri());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 22 with RouteStartupOrder

use of org.apache.camel.spi.RouteStartupOrder in project camel by apache.

the class RouteStartupOrderDirectTest method testRouteStartupOrder.

public void testRouteStartupOrder() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:bar", "Hello World");
    assertMockEndpointsSatisfied();
    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(2, order.size());
    assertEquals("direct://bar", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://foo", order.get(1).getRoute().getEndpoint().getEndpointUri());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 23 with RouteStartupOrder

use of org.apache.camel.spi.RouteStartupOrder in project camel by apache.

the class RouteStartupOrderSuspendResumeNoAutoStartupTest method testRouteStartupOrderSuspendResumeStartC.

public void testRouteStartupOrderSuspendResumeStartC() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    // start C
    context.startRoute("C");
    context.suspend();
    context.resume();
    // route C should be started
    assertEquals(true, context.getRouteStatus("C").isStarted());
    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(4, 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());
    // however its started manually so its started after the auto started
    assertEquals("direct://baz", order.get(3).getRoute().getEndpoint().getEndpointUri());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 24 with RouteStartupOrder

use of org.apache.camel.spi.RouteStartupOrder in project camel by apache.

the class RouteStartupOrderSuspendResumeTest method testRouteStartupOrderSuspendResume.

public void testRouteStartupOrderSuspendResume() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();
    context.suspend();
    context.resume();
    // assert correct order
    DefaultCamelContext dcc = (DefaultCamelContext) context;
    List<RouteStartupOrder> order = dcc.getRouteStartupOrder();
    assertEquals(4, order.size());
    assertEquals("direct://foo", order.get(0).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://start", order.get(1).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://baz", order.get(2).getRoute().getEndpoint().getEndpointUri());
    assertEquals("direct://bar", order.get(3).getRoute().getEndpoint().getEndpointUri());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 25 with RouteStartupOrder

use of org.apache.camel.spi.RouteStartupOrder in project camel by apache.

the class RouteStartupOrderTest 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(4, 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());
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)26 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)12 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)11 ArrayList (java.util.ArrayList)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)8 Route (org.apache.camel.Route)4 ShutdownRoute (org.apache.camel.ShutdownRoute)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Consumer (org.apache.camel.Consumer)3 SuspendableService (org.apache.camel.SuspendableService)3 LinkedHashSet (java.util.LinkedHashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Endpoint (org.apache.camel.Endpoint)2 PollingConsumer (org.apache.camel.PollingConsumer)2 Service (org.apache.camel.Service)2 LifecycleStrategy (org.apache.camel.spi.LifecycleStrategy)2