Search in sources :

Example 1 with LifecycleTrackerProcessor

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();
}
Also used : Startable(org.mule.runtime.api.lifecycle.Startable) LifecycleException(org.mule.runtime.api.lifecycle.LifecycleException) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) ReactiveProcessor(org.mule.runtime.core.api.processor.ReactiveProcessor) LifecycleTrackerProcessor(org.mule.tck.core.lifecycle.LifecycleTrackerProcessor) Processor(org.mule.runtime.core.api.processor.Processor) LifecycleTrackerProcessor(org.mule.tck.core.lifecycle.LifecycleTrackerProcessor) ArrayList(java.util.ArrayList) MessageSource(org.mule.runtime.core.api.source.MessageSource) Stoppable(org.mule.runtime.api.lifecycle.Stoppable) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 LifecycleException (org.mule.runtime.api.lifecycle.LifecycleException)1 Startable (org.mule.runtime.api.lifecycle.Startable)1 Stoppable (org.mule.runtime.api.lifecycle.Stoppable)1 Processor (org.mule.runtime.core.api.processor.Processor)1 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)1 MessageSource (org.mule.runtime.core.api.source.MessageSource)1 SensingNullMessageProcessor (org.mule.tck.SensingNullMessageProcessor)1 LifecycleTrackerProcessor (org.mule.tck.core.lifecycle.LifecycleTrackerProcessor)1