Search in sources :

Example 21 with ConnectionException

use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.

the class ExceptionHandlerManagerTestCase method processAndEnrich.

@Test
public void processAndEnrich() {
    ConnectionException connectionException = new ConnectionException("Connection Error");
    Throwable throwable = manager.process(connectionException);
    assertThat(throwable, is(not(sameInstance(connectionException))));
    assertThat(throwable, is(instanceOf(HeisenbergException.class)));
    assertThat(throwable.getMessage(), is(ERROR_MESSAGE));
}
Also used : ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 22 with ConnectionException

use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.

the class ExceptionUtilsTestCase method extractRootConnectionException.

@Test
public void extractRootConnectionException() {
    Exception withConnectionExceptionCause = new Exception(new ConnectionException(ERROR_MESSAGE, new ConnectionException(new NullPointerException())));
    Optional<ConnectionException> connectionException = extractConnectionException(withConnectionExceptionCause);
    assertThat(connectionException.isPresent(), is(true));
    assertThat(connectionException.get().getMessage(), is(ERROR_MESSAGE));
}
Also used : ExceptionUtils.extractConnectionException(org.mule.runtime.core.api.util.ExceptionUtils.extractConnectionException) IOException(java.io.IOException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) ExceptionUtils.extractConnectionException(org.mule.runtime.core.api.util.ExceptionUtils.extractConnectionException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 23 with ConnectionException

use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.

the class ExceptionUtilsTestCase method extractMissingConnectionException.

@Test
public void extractMissingConnectionException() {
    Exception withoutConnectionException = new Exception(new NullPointerException());
    Optional<ConnectionException> exception = extractConnectionException(withoutConnectionException);
    assertThat(exception.isPresent(), is(false));
}
Also used : ExceptionUtils.extractConnectionException(org.mule.runtime.core.api.util.ExceptionUtils.extractConnectionException) IOException(java.io.IOException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) ExceptionUtils.extractConnectionException(org.mule.runtime.core.api.util.ExceptionUtils.extractConnectionException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 24 with ConnectionException

use of org.mule.runtime.api.connection.ConnectionException 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)

Aggregations

ConnectionException (org.mule.runtime.api.connection.ConnectionException)24 Test (org.junit.Test)18 SmallTest (org.mule.tck.size.SmallTest)10 IOException (java.io.IOException)6 MuleException (org.mule.runtime.api.exception.MuleException)6 ExceptionUtils.extractConnectionException (org.mule.runtime.core.api.util.ExceptionUtils.extractConnectionException)4 List (java.util.List)2 ExpectedException (org.junit.rules.ExpectedException)2 MuleFatalException (org.mule.runtime.api.exception.MuleFatalException)2 Error (org.mule.runtime.api.message.Error)2 HeisenbergException (org.mule.test.heisenberg.extension.exception.HeisenbergException)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Lock (java.util.concurrent.locks.Lock)1 ThrowableAssert.catchThrowable (org.assertj.core.api.ThrowableAssert.catchThrowable)1 CoreMatchers.instanceOf (org.hamcrest.CoreMatchers.instanceOf)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 Matchers.hasSize (org.hamcrest.Matchers.hasSize)1 Assert.assertThat (org.junit.Assert.assertThat)1 Matchers.any (org.mockito.Matchers.any)1