use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method causedByWithNullCause.
@Test
public void causedByWithNullCause() {
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent);
assertThat(exception.causedBy(MessagingException.class), Is.is(true));
assertThat(exception.causedBy(Exception.class), Is.is(true));
assertThat(exception.causedBy(DefaultMuleException.class), Is.is(false));
assertThat(exception.causedBy(IOException.class), Is.is(false));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method getCauseExceptionWithMuleCauseWithMuleCause.
@Test
public void getCauseExceptionWithMuleCauseWithMuleCause() {
DefaultMuleException causeCauseException = new DefaultMuleException("");
DefaultMuleException causeException = new DefaultMuleException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.getRootCause(), is(causeCauseException));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method payloadInfoConsumable.
@Test
public void payloadInfoConsumable() throws Exception {
MuleException.verboseExceptions = true;
CoreEvent testEvent = mock(CoreEvent.class);
when(testEvent.getError()).thenReturn(empty());
final ByteArrayInputStream payload = new ByteArrayInputStream(new byte[] {});
Message muleMessage = of(payload);
when(testEvent.getMessage()).thenReturn(muleMessage);
MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
assertThat((String) e.getInfo().get(PAYLOAD_INFO_KEY), containsString(ByteArrayInputStream.class.getName() + "@"));
verify(transformationService, never()).transform(muleMessage, DataType.STRING);
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method causedByWithNonMuleCauseWithNonMuleCause.
@Test
public void causedByWithNonMuleCauseWithNonMuleCause() {
ConnectException causeCauseException = new ConnectException();
IOException causeException = new IOException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.causedBy(NullPointerException.class), is(false));
assertThat(exception.causedBy(SocketException.class), is(true));
assertThat(exception.causedBy(IOException.class), is(true));
assertThat(exception.causedBy(MessagingException.class), is(true));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method payloadInfoNonConsumable.
@Test
@Ignore("MULE-10266 review how the transformationService is obtained when building an exception.")
public void payloadInfoNonConsumable() throws Exception {
MuleException.verboseExceptions = true;
CoreEvent testEvent = mock(CoreEvent.class);
Object payload = mock(Object.class);
// This has to be done this way since mockito doesn't allow to verify toString()
when(payload.toString()).then(new FailAnswer("toString() expected not to be called."));
Message muleMessage = of(payload);
when(transformationService.transform(muleMessage, DataType.STRING)).thenReturn(of(value));
when(testEvent.getMessage()).thenReturn(muleMessage);
MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
assertThat(e.getInfo().get(PAYLOAD_INFO_KEY), is(value));
}
Aggregations