Search in sources :

Example 1 with StopProcessingService

use of com.adaptris.core.services.StopProcessingService in project interlok by adaptris.

the class DoWhileTest method testStopProcessingServiceCancelsLoop.

@Test
public void testStopProcessingServiceCancelsLoop() throws Exception {
    when(mockCondition.evaluate(message)).thenReturn(true);
    Service stopProcessingService = new StopProcessingService();
    ServiceList services = new ServiceList();
    services.add(stopProcessingService);
    services.add(mockService);
    thenService = new ThenService();
    thenService.setService(services);
    doWhile = new DoWhile().withThen(thenService).withCondition(mockCondition);
    LifecycleHelper.init(doWhile);
    LifecycleHelper.start(doWhile);
    doWhile.doService(message);
    // The default would loop 10 times, but the stop-processing-service should
    // limit us to only a single loop and the condition will never be tested.
    verify(mockCondition, times(0)).evaluate(message);
}
Also used : ServiceList(com.adaptris.core.ServiceList) StopProcessingService(com.adaptris.core.services.StopProcessingService) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) StopProcessingService(com.adaptris.core.services.StopProcessingService) Test(org.junit.Test)

Example 2 with StopProcessingService

use of com.adaptris.core.services.StopProcessingService in project interlok by adaptris.

the class WhileTest method testStopProcessingServiceCancelsLoop.

@Test
public void testStopProcessingServiceCancelsLoop() throws Exception {
    when(mockCondition.evaluate(message)).thenReturn(true);
    Service stopProcessingService = new StopProcessingService();
    ServiceList services = new ServiceList();
    services.add(stopProcessingService);
    services.add(mockService);
    thenService = new ThenService();
    thenService.setService(services);
    logicalExpression = new While().withThen(thenService).withCondition(mockCondition);
    startMe(logicalExpression);
    logicalExpression.doService(message);
    // The default would loop 10 times, but the stop-processing-service should limit us to only a single loop.
    verify(mockCondition, times(1)).evaluate(message);
}
Also used : ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) StopProcessingService(com.adaptris.core.services.StopProcessingService) StopProcessingService(com.adaptris.core.services.StopProcessingService) Test(org.junit.Test)

Aggregations

Service (com.adaptris.core.Service)2 ServiceList (com.adaptris.core.ServiceList)2 LogMessageService (com.adaptris.core.services.LogMessageService)2 StopProcessingService (com.adaptris.core.services.StopProcessingService)2 Test (org.junit.Test)2