use of org.mule.tck.core.lifecycle.LifecycleTrackerProcessor in project mule by mulesoft.
the class DefaultFlowTestCase method testFailStartingMessageSourceOnLifecycleShouldStopStartedPipelineProcesses.
@Test
public void testFailStartingMessageSourceOnLifecycleShouldStopStartedPipelineProcesses() throws Exception {
// Need to start mule context to have endpoints started during flow start
muleContext.start();
MessageSource mockMessageSource = mock(MessageSource.class, withSettings().extraInterfaces(Startable.class, Stoppable.class));
doThrow(new LifecycleException(mock(I18nMessage.class), mockMessageSource)).when(((Startable) mockMessageSource)).start();
final List<Processor> processors = new ArrayList<>(flow.getProcessors());
Processor mockMessageProcessor = spy(new LifecycleTrackerProcessor());
processors.add(mockMessageProcessor);
after();
flow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext).source(mockMessageSource).processors(processors).build();
flow.initialise();
try {
flow.start();
fail();
} catch (LifecycleException e) {
}
verify((Startable) mockMessageProcessor, times(1)).start();
verify((Stoppable) mockMessageProcessor, times(1)).stop();
verify((Startable) mockMessageSource, times(1)).start();
verify((Stoppable) mockMessageSource, times(1)).stop();
}
Aggregations