use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method serializableMessagingException.
@Test
public void serializableMessagingException() throws Exception {
TestSerializableMessageProcessor processor = new TestSerializableMessageProcessor();
processor.setValue(value);
MessagingException e = new MessagingException(createStaticMessage(message), testEvent, processor);
e = SerializationTestUtils.testException(e, muleContext);
assertThat(e.getMessage(), containsString(message));
assertThat(e.getFailingComponent(), not(nullValue()));
assertThat(e.getFailingComponent(), instanceOf(TestSerializableMessageProcessor.class));
assertThat(((TestSerializableMessageProcessor) e.getFailingComponent()).getValue(), is(value));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method withFailingProcessorNoPathResolver.
@Test
public void withFailingProcessorNoPathResolver() {
AnnotatedProcessor mockProcessor = mock(AnnotatedProcessor.class);
when(mockProcessor.getLocation()).thenReturn(fromSingleComponent("Mock@1"));
when(mockProcessor.toString()).thenReturn("Mock@1");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, mockProcessor);
exception.getInfo().putAll(locationProvider.getContextInfo(createInfo(testEvent, exception, mockProcessor), mockProcessor));
assertThat(exception.getInfo().get(INFO_LOCATION_KEY).toString(), is("Mock@1 @ MessagingExceptionTestCase:unknown:-1"));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method payloadInfoException.
@Test
@Ignore("MULE-10266 review how the transformationService is obtained when building an exception.")
public void payloadInfoException() 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)).thenThrow(new TransformerException(createStaticMessage("exception thrown")));
when(testEvent.getMessage()).thenReturn(muleMessage);
MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
assertThat(e.getInfo().get(PAYLOAD_INFO_KEY), is(TransformerException.class.getName() + " while getting payload: exception thrown"));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method causedExactlyByWithMuleCauseWithMuleCause.
@Test
public void causedExactlyByWithMuleCauseWithMuleCause() {
DefaultMuleException causeCauseException = new DefaultMuleException("");
DefaultMuleException causeException = new DefaultMuleException(causeCauseException);
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.causedExactlyBy(DefaultMuleException.class), is(true));
assertThat(exception.causedExactlyBy(MessagingException.class), is(true));
}
use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.
the class MessagingExceptionTestCase method getCauseExceptionWithNonMuleCause.
@Test
public void getCauseExceptionWithNonMuleCause() {
IOException causeException = new IOException("");
MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
assertThat(exception.getRootCause(), is(causeException));
}
Aggregations