use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class ProcessorChainExecutorTestCase method testDoProcessOnErrorMessagingException.
@Test
public void testDoProcessOnErrorMessagingException() throws InterruptedException, MuleException {
final String ERROR_PAYLOAD = "ERROR_PAYLOAD";
when(chain.apply(any())).thenReturn(error(new MessagingException(createStaticMessage(""), getEventBuilder().message(of(ERROR_PAYLOAD)).build())));
ImmutableProcessorChainExecutor chainExecutor = new ImmutableProcessorChainExecutor(coreEvent, chain);
AtomicInteger successCalls = new AtomicInteger(0);
AtomicInteger errorCalls = new AtomicInteger(0);
Reference<Event> errorEvent = new Reference<>();
doProcessAndWait(chainExecutor, r -> successCalls.incrementAndGet(), (t, r) -> {
errorCalls.incrementAndGet();
errorEvent.set(((EventedResult) r).getEvent());
});
assertThat(successCalls.get(), is(0));
assertThat(errorCalls.get(), is(1));
assertThat(errorEvent.get().getMessage().getPayload().getValue(), is(ERROR_PAYLOAD));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveCriticalError.
@Test
public void resolveCriticalError() {
MessagingException me = newMessagingException(ERROR, event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, CRITICAL);
assertExceptionMessage(resolved.getMessage(), ERROR.getMessage());
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveExceptionWithUnknownUnderlyingError.
@Test
public void resolveExceptionWithUnknownUnderlyingError() {
Optional<Error> surfaceError = mockError(CONNECTION, null);
when(event.getError()).thenReturn(surfaceError);
MessagingException me = newMessagingException(new Exception(), event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, CONNECTION);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveTopExceptionWithSameError.
@Test
public void resolveTopExceptionWithSameError() {
Optional<Error> surfaceError = mockError(TRANSFORMER, TRANSFORMER_EXCEPTION);
when(event.getError()).thenReturn(surfaceError);
Exception cause = new MuleFatalException(createStaticMessage(EXPECTED_MESSAGE), new LinkageError("!"));
MessagingException me = newMessagingException(cause, event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, FATAL);
assertExceptionMessage(resolved.getMessage(), EXPECTED_MESSAGE);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionResolverTestCase method resolveExceptionWithCriticalUnderlyingError.
@Test
public void resolveExceptionWithCriticalUnderlyingError() {
Optional<Error> surfaceError = mockError(CONNECTION, null);
when(event.getError()).thenReturn(surfaceError);
MessagingException me = newMessagingException(ERROR, event, processor);
MessagingException resolved = resolver.resolve(me, context);
assertExceptionErrorType(resolved, CONNECTION);
}
Aggregations