Search in sources :

Example 6 with StatefulService

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

the class RouteSedaStopStartTest method testStopStart.

public void testStopStart() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived("A");
    template.sendBody("seda:foo", "A");
    assertMockEndpointsSatisfied();
    log.info("Stopping");
    // now suspend and dont expect a message to be routed
    resetMocks();
    mock.expectedMessageCount(0);
    context.stopRoute("foo");
    assertEquals("Stopped", context.getRouteStatus("foo").name());
    Route route = context.getRoute("foo");
    if (route instanceof StatefulService) {
        assertEquals("Stopped", ((StatefulService) route).getStatus().name());
    }
    template.sendBody("seda:foo", "B");
    mock.assertIsSatisfied(1000);
    log.info("Starting");
    // now resume and expect the previous message to be routed
    resetMocks();
    mock.expectedBodiesReceived("B");
    context.startRoute("foo");
    assertMockEndpointsSatisfied();
    assertEquals("Started", context.getRouteStatus("foo").name());
    route = context.getRoute("foo");
    if (route instanceof StatefulService) {
        assertEquals("Started", ((StatefulService) route).getStatus().name());
    }
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Route(org.apache.camel.Route) StatefulService(org.apache.camel.StatefulService)

Aggregations

StatefulService (org.apache.camel.StatefulService)6 CountDownLatch (java.util.concurrent.CountDownLatch)2 Exchange (org.apache.camel.Exchange)2 Route (org.apache.camel.Route)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 TestSubscriber (org.apache.camel.component.reactive.streams.support.TestSubscriber)2 ThrottlingInflightRoutePolicy (org.apache.camel.impl.ThrottlingInflightRoutePolicy)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Consumer (org.apache.camel.Consumer)1 PollingConsumer (org.apache.camel.PollingConsumer)1 SuspendableService (org.apache.camel.SuspendableService)1 AdviceWithRouteBuilder (org.apache.camel.builder.AdviceWithRouteBuilder)1 AdviceWithTask (org.apache.camel.builder.AdviceWithTask)1