use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class ExceptionsTestCase method testRoutingExceptionNullMessageValidProcessor.
@Test
public final void testRoutingExceptionNullMessageValidProcessor() throws MuleException {
Processor processor = mock(Processor.class);
RoutingException rex = new RoutingException(processor);
assertSame(processor, rex.getRoute());
}
use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class ReactiveInterceptorAdapterTestCase method interceptorThrowsExceptionAroundAfterProceedInCallbackChained.
@Test
public void interceptorThrowsExceptionAroundAfterProceedInCallbackChained() throws Exception {
RuntimeException expectedException = new RuntimeException("Some Error");
ProcessorInterceptor interceptor = prepareInterceptor(new ProcessorInterceptor() {
@Override
public CompletableFuture<InterceptionEvent> around(ComponentLocation location, Map<String, ProcessorParameterValue> parameters, InterceptionEvent event, InterceptionAction action) {
return action.proceed().thenApplyAsync(e -> {
throw expectedException;
});
}
});
startFlowWithInterceptors(interceptor);
expected.expect(MessagingException.class);
expected.expect(withEventThat(hasErrorType(UNKNOWN.getNamespace(), UNKNOWN.getName())));
expected.expectCause(sameInstance(expectedException));
try {
process(flow, eventBuilder(muleContext).message(Message.of("")).build());
} finally {
if (useMockInterceptor) {
InOrder inOrder = inOrder(processor, interceptor);
inOrder.verify(interceptor).before(any(), any(), any());
inOrder.verify(interceptor).around(any(), any(), any(), any());
inOrder.verify(processor).process(any());
inOrder.verify(interceptor).after(any(), any(), eq(of(expectedException)));
verifyParametersResolvedAndDisposed(times(1));
}
}
}
use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class ExceptionListenerTestCase method setGoodProcessors.
@Test
public void setGoodProcessors() throws Exception {
List<Processor> list = new ArrayList<Processor>();
list.add(mock(Processor.class));
list.add(mock(Processor.class));
AbstractExceptionListener router = new OnErrorPropagateHandler();
assertNotNull(router.getMessageProcessors());
assertEquals(0, router.getMessageProcessors().size());
router.setMessageProcessors(singletonList(mock(Processor.class)));
assertEquals(1, router.getMessageProcessors().size());
router.setMessageProcessors(list);
assertNotNull(router.getMessageProcessors());
assertEquals(2, router.getMessageProcessors().size());
}
use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class ExceptionListenerTestCase method setSingleGoodProcessorEndpoint.
@Test
public void setSingleGoodProcessorEndpoint() throws Exception {
AbstractExceptionListener router = new OnErrorPropagateHandler();
Processor messageProcessor = mock(Processor.class);
router.setMessageProcessors(singletonList(messageProcessor));
assertNotNull(router.getMessageProcessors());
assertTrue(router.getMessageProcessors().contains(messageProcessor));
}
use of org.mule.runtime.core.api.processor.Processor in project mule by mulesoft.
the class DefaultMessageProcessorChainTestCase method testMPChainLifecycle.
@Test
public void testMPChainLifecycle() throws Exception {
DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
AppendingInterceptingMP mp1 = new AppendingInterceptingMP("1");
AppendingInterceptingMP mp2 = new AppendingInterceptingMP("2");
Processor chain = builder.chain(mp1, mp2).build();
initialiseIfNeeded(chain, muleContext);
((Lifecycle) chain).start();
((Lifecycle) chain).stop();
((Lifecycle) chain).dispose();
assertLifecycle(mp1);
assertLifecycle(mp2);
}
Aggregations