Search in sources :

Example 16 with MessagingException

use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.

the class MessagingExceptionTestCase method nonSerializableMessagingException.

@Test
public void nonSerializableMessagingException() throws Exception {
    TestNotSerializableMessageProcessor processor = new TestNotSerializableMessageProcessor();
    MessagingException e = new MessagingException(createStaticMessage(message), testEvent, processor);
    e = SerializationTestUtils.testException(e, muleContext);
    assertThat(e.getMessage(), containsString(message));
    assertThat(e.getFailingComponent(), is(nullValue()));
}
Also used : MessagingException(org.mule.runtime.core.internal.exception.MessagingException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 17 with MessagingException

use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.

the class MessagingExceptionTestCase method causedExactlyByWithNullCause.

@Test
public void causedExactlyByWithNullCause() {
    MessagingException exception = new MessagingException(createStaticMessage(""), testEvent);
    assertThat(exception.causedExactlyBy(MessagingException.class), Is.is(true));
    assertThat(exception.causedExactlyBy(Exception.class), Is.is(false));
    assertThat(exception.causedExactlyBy(DefaultMuleException.class), Is.is(false));
    assertThat(exception.causedExactlyBy(IOException.class), Is.is(false));
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) IOException(java.io.IOException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) SocketException(java.net.SocketException) MuleException(org.mule.runtime.api.exception.MuleException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 18 with MessagingException

use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.

the class MessagingExceptionTestCase method withAnnotatedFailingProcessorNoPathResolver.

@Test
public void withAnnotatedFailingProcessorNoPathResolver() {
    AnnotatedProcessor mockProcessor = mock(AnnotatedProcessor.class);
    when(mockProcessor.getAnnotation(eq(docNameAttrName))).thenReturn("Mock Component");
    configureProcessorLocation(mockProcessor);
    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:muleApp.xml:10 (Mock Component)"));
}
Also used : AnnotatedProcessor(org.mule.runtime.core.privileged.processor.AnnotatedProcessor) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 19 with MessagingException

use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.

the class MessagingExceptionTestCase method causedByWithNonMuleCause.

@Test
public void causedByWithNonMuleCause() {
    IOException causeException = new IOException("");
    MessagingException exception = new MessagingException(createStaticMessage(""), testEvent, causeException);
    assertThat(exception.causedBy(IOException.class), is(true));
    assertThat(exception.causedBy(MessagingException.class), is(true));
    assertThat(exception.causedBy(Exception.class), is(true));
    assertThat(exception.causedBy(NullPointerException.class), is(false));
}
Also used : MessagingException(org.mule.runtime.core.internal.exception.MessagingException) IOException(java.io.IOException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) SocketException(java.net.SocketException) MuleException(org.mule.runtime.api.exception.MuleException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 20 with MessagingException

use of org.mule.runtime.core.internal.exception.MessagingException in project mule by mulesoft.

the class MessagingExceptionTestCase method withAnnotatedFailingProcessorNotPathResolver.

@Test
public void withAnnotatedFailingProcessorNotPathResolver() {
    AnnotatedProcessor mockProcessor = mock(AnnotatedProcessor.class);
    when(mockProcessor.getAnnotation(eq(docNameAttrName))).thenReturn("Mock Component");
    configureProcessorLocation(mockProcessor);
    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:muleApp.xml:10 (Mock Component)"));
}
Also used : AnnotatedProcessor(org.mule.runtime.core.privileged.processor.AnnotatedProcessor) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

MessagingException (org.mule.runtime.core.internal.exception.MessagingException)69 Test (org.junit.Test)42 SmallTest (org.mule.tck.size.SmallTest)37 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)26 MuleException (org.mule.runtime.api.exception.MuleException)17 TransformerException (org.mule.runtime.core.api.transformer.TransformerException)13 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)11 Optional (java.util.Optional)9 Error (org.mule.runtime.api.message.Error)9 Message (org.mule.runtime.api.message.Message)9 IOException (java.io.IOException)8 Processor (org.mule.runtime.core.api.processor.Processor)8 Publisher (org.reactivestreams.Publisher)8 ConnectException (java.net.ConnectException)7 Component (org.mule.runtime.api.component.Component)7 ConnectionException (org.mule.runtime.api.connection.ConnectionException)7 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)7 SocketException (java.net.SocketException)6 CompletableFuture (java.util.concurrent.CompletableFuture)6 MuleFatalException (org.mule.runtime.api.exception.MuleFatalException)6