Search in sources :

Example 66 with MessagingException

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

the class MessagingExceptionResolverTestCase method resolveWithMultipleErrors.

@Test
public void resolveWithMultipleErrors() {
    Optional<Error> surfaceError = mockError(TRANSFORMER, TRANSFORMER_EXCEPTION);
    when(event.getError()).thenReturn(surfaceError);
    Exception cause = new Exception(new ConnectionException(FATAL_EXCEPTION));
    MessagingException me = newMessagingException(cause, event, processor);
    MessagingException resolved = resolver.resolve(me, context);
    assertExceptionErrorType(resolved, FATAL);
    assertExceptionMessage(resolved.getMessage(), FATAL_EXCEPTION.getMessage());
}
Also used : MessagingException(org.mule.runtime.core.internal.exception.MessagingException) Error(org.mule.runtime.api.message.Error) MuleFatalException(org.mule.runtime.api.exception.MuleFatalException) MuleException(org.mule.runtime.api.exception.MuleException) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 67 with MessagingException

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

the class MessagingExceptionResolverTestCase method resolveMultipleCriticalErrors.

@Test
public void resolveMultipleCriticalErrors() {
    Throwable t = new LinkageError("this one is NOT expected", new java.lang.Error(new java.lang.Error("expected")));
    MessagingException me = newMessagingException(t, event, processor);
    MessagingException resolved = resolver.resolve(me, context);
    assertExceptionErrorType(resolved, CRITICAL);
    assertExceptionMessage(resolved.getMessage(), "expected");
}
Also used : MessagingException(org.mule.runtime.core.internal.exception.MessagingException) Error(org.mule.runtime.api.message.Error) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 68 with MessagingException

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

the class AbstractSplitterTestCase method allFilteredSplitter.

@Test
public void allFilteredSplitter() throws Exception {
    TestSplitter splitter = new TestSplitter(true);
    splitter.setListener(event -> {
        throw new MessagingException(createStaticMessage("Expected"), event, splitter);
    });
    splitter.setMuleContext(muleContext);
    Apple apple = new Apple();
    Banana banana = new Banana();
    Orange orange = new Orange();
    FruitBowl fruitBowl = new FruitBowl();
    fruitBowl.addFruit(apple);
    fruitBowl.addFruit(banana);
    fruitBowl.addFruit(orange);
    final CoreEvent inEvent = eventBuilder(muleContext).message(of(fruitBowl)).build();
    CoreEvent resultEvent = splitter.process(inEvent);
    assertThat(resultEvent.getMessage().getPayload().getValue(), nullValue());
}
Also used : Apple(org.mule.tck.testmodels.fruit.Apple) FruitBowl(org.mule.tck.testmodels.fruit.FruitBowl) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Orange(org.mule.tck.testmodels.fruit.Orange) Banana(org.mule.tck.testmodels.fruit.Banana) Test(org.junit.Test)

Example 69 with MessagingException

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

the class AbstractSplitterTestCase method failingNotFilteredSplitter.

@Test
public void failingNotFilteredSplitter() throws Exception {
    TestSplitter splitter = new TestSplitter(false);
    splitter.setListener(event -> {
        throw new MessagingException(createStaticMessage("Expected"), event, splitter);
    });
    splitter.setMuleContext(muleContext);
    Apple apple = new Apple();
    Banana banana = new Banana();
    Orange orange = new Orange();
    FruitBowl fruitBowl = new FruitBowl();
    fruitBowl.addFruit(apple);
    fruitBowl.addFruit(banana);
    fruitBowl.addFruit(orange);
    final CoreEvent inEvent = eventBuilder(muleContext).message(of(fruitBowl)).build();
    expected.expect(MessagingException.class);
    expected.expectMessage("Expected");
    splitter.process(inEvent);
}
Also used : Apple(org.mule.tck.testmodels.fruit.Apple) FruitBowl(org.mule.tck.testmodels.fruit.FruitBowl) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Orange(org.mule.tck.testmodels.fruit.Orange) Banana(org.mule.tck.testmodels.fruit.Banana) 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