private void startFlow(String flowName) throws Exception { ((Startable) getFlowConstruct(flowName)).start(); } }
private void startFlow(String flowName) throws Exception { ((Startable) getFlowConstruct(flowName)).start(); } }
private void startFlow(String flowName) throws Exception { ((Startable) registry.lookupByName(flowName).get()).start(); }
private void startFlow(String flowName) throws Exception { ((Startable) getFlowConstruct(flowName)).start(); }
private void startFlow(String flowName) throws Exception { ((Startable) getFlowConstruct(flowName)).start(); }
@Test public void testOnNotificationWithStartable() throws MuleException { this.notificationListener.onNotification(mockServerNotification); verify(mockStartable, times(1)).start(); }
@Test public void start() throws Exception { messageProcessor.start(); verify((Startable) operationExecutor).start(); }
@Test public void executorStarted() throws Exception { interceptable.start(); verify((Startable) executor).start(); }
@Test public void start() throws Exception { wrapper.start(); if (delegate instanceof Startable) { verify((Startable) delegate).start(); } }
@Test public void start() throws MuleException { CompositeArtifactExtensionManager extensionManager = new CompositeArtifactExtensionManager(parentExtensionManager, childExtensionManager); extensionManager.start(); verify(((Startable) childExtensionManager)).start(); }
@Test public void reconnectSource() throws Exception { ((Startable) getFlowConstruct("reconnectForever")).start(); check(5000, 1000, () -> !capturedEvents.isEmpty()); switchConnection(); check(10000, 1000, () -> { synchronized (capturedEvents) { return capturedEvents.stream() .map(event -> (ReconnectableConnection) event.getMessage().getPayload().getValue()) .filter(c -> c.getReconnectionAttempts() >= 3) .findAny() .isPresent(); } }); }
@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(); }
@Test public void lifecycleOrder() throws MuleException { Sink sink = mock(Sink.class, withSettings().extraInterfaces(Disposable.class)); Processor processor = mock(Processor.class, withSettings().extraInterfaces(Startable.class, Stoppable.class)); ProcessingStrategy processingStrategy = mock(ProcessingStrategy.class, withSettings().extraInterfaces(Startable.class, Stoppable.class)); when(processingStrategy.createSink(any(FlowConstruct.class), any(ReactiveProcessor.class))) .thenReturn(sink); flow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext) .source(directInboundMessageSource) .processors(singletonList(processor)) .processingStrategyFactory((muleContext, s) -> processingStrategy) .build(); flow.initialise(); flow.start(); InOrder inOrder = inOrder(sink, processor, processingStrategy); inOrder.verify((Startable) processingStrategy).start(); inOrder.verify(processingStrategy).createSink(any(FlowConstruct.class), any(ReactiveProcessor.class)); inOrder.verify((Startable) processor).start(); flow.stop(); inOrder.verify((Disposable) sink).dispose(); inOrder.verify((Stoppable) processor).stop(); inOrder.verify((Stoppable) processingStrategy).stop(); }
@Test @Ignore("MULE-16210") public void originalExceptionThrownWhenStartAndStopOfSourceBothFail() throws Exception { final Exception startException = new IllegalArgumentException(); final Exception stopException = new IllegalStateException(); MessageSource source = mock(MessageSource.class, withSettings().extraInterfaces(Startable.class, Stoppable.class)); doThrow(startException).when((Startable) source).start(); doThrow(stopException).when((Stoppable) source).stop(); muleContext = spy(muleContext); flow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext) .source(source) .processors(singletonList(mock(Processor.class))) .build(); flow.initialise(); muleContext.start(); try { flow.start(); fail("was expecting failure"); } catch (LifecycleException e) { assertThat(e.getCause(), instanceOf(MuleException.class)); assertThat(e.getCause().getCause(), sameInstance(startException)); } } }
@Test @Ignore("MULE-16210") public void originalExceptionThrownWhenStartAndStopOfProcessorBothFail() throws Exception { final Exception startException = new IllegalArgumentException(); final Exception stopException = new IllegalStateException(); Processor processor = mock(Processor.class, withSettings().extraInterfaces(Startable.class, Stoppable.class)); doThrow(startException).when((Startable) processor).start(); doThrow(stopException).when((Stoppable) processor).stop(); flow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext) .source(directInboundMessageSource) .processors(singletonList(processor)) .build(); flow.initialise(); try { flow.start(); fail("was expecting failure"); } catch (LifecycleException e) { assertThat(e.getCause(), instanceOf(MuleException.class)); assertThat(e.getCause().getCause(), sameInstance(startException)); } }
private void startServices() throws MuleException { for (Service service : registeredServices) { if (service instanceof Startable) { ClassLoader originalContextClassLoader = currentThread().getContextClassLoader(); try { currentThread().setContextClassLoader(service.getClass().getClassLoader()); ((Startable) service).start(); } finally { currentThread().setContextClassLoader(originalContextClassLoader); } } } }
@Test public void testOnNotificationWithStartable() throws MuleException { this.notificationListener.onNotification(mockServerNotification); verify(mockStartable, times(1)).start(); }