Search in sources :

Example 16 with ConnectionException

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

the class DefaultExecutionMediatorTestCase method decoratedException.

@Test
public void decoratedException() throws Throwable {
    stubException();
    final Exception decoratedException = mock(Exception.class);
    when(configurationInterceptor2.onError(same(operationContext), same(connectionException))).thenReturn(decoratedException);
    assertException(e -> {
        assertThat(e, is(sameInstance(decoratedException)));
        assertAfter(null);
    });
}
Also used : HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) MuleException(org.mule.runtime.api.exception.MuleException) ExpectedException(org.junit.rules.ExpectedException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 17 with ConnectionException

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

the class ExtensionMessageSourceTestCase method failWithConnectionExceptionWhenStartingAndGetsReconnected.

@Test
public void failWithConnectionExceptionWhenStartingAndGetsReconnected() throws Exception {
    doThrow(new RuntimeException(new ConnectionException(ERROR_MESSAGE))).doThrow(new RuntimeException(new ConnectionException(ERROR_MESSAGE))).doNothing().when(source).onStart(sourceCallback);
    messageSource.initialise();
    messageSource.start();
    verify(source, times(3)).onStart(sourceCallback);
    verify(source, times(2)).onStop();
}
Also used : ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test)

Example 18 with ConnectionException

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

the class ExtensionMessageSourceTestCase method handleExceptionAndRestart.

@Test
public void handleExceptionAndRestart() throws Exception {
    start();
    messageSource.onException(new ConnectionException(ERROR_MESSAGE));
    verify(source).onStop();
    verify(ioScheduler, never()).stop();
    verify(cpuLightScheduler, never()).stop();
    verify(source, times(2)).onStart(sourceCallback);
}
Also used : ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test)

Example 19 with ConnectionException

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

the class LifecycleAwareConfigurationInstanceTestCase method testConnectivityFailsUponStart.

@Test
public void testConnectivityFailsUponStart() throws Exception {
    if (connectionProvider.isPresent()) {
        Exception connectionException = new ConnectionException("Oops!");
        when(connectionManager.testConnectivity(interceptable)).thenReturn(failure(connectionException.getMessage(), connectionException));
        interceptable.initialise();
        try {
            interceptable.start();
            fail("Was expecting connectivity testing to fail");
        } catch (Exception e) {
            verify(connectionManager, times(RECONNECTION_MAX_ATTEMPTS + 1)).testConnectivity(interceptable);
            assertThat(e.getCause(), is(instanceOf(RetryPolicyExhaustedException.class)));
        }
    }
}
Also used : RetryPolicyExhaustedException(org.mule.runtime.core.api.retry.policy.RetryPolicyExhaustedException) RetryPolicyExhaustedException(org.mule.runtime.core.api.retry.policy.RetryPolicyExhaustedException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) ExpectedException(org.junit.rules.ExpectedException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 20 with ConnectionException

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

the class ExceptionHandlerManagerTestCase method handleConnectionException.

@Test
public void handleConnectionException() {
    ConnectionException rootCause = new ConnectionException(ERROR_MESSAGE, new Exception());
    Throwable throwable = manager.handleThrowable(new Throwable(new RuntimeException(new ExecutionException(rootCause))));
    assertThat(throwable, is(instanceOf(ConnectionException.class)));
    assertThat(throwable.getMessage(), is(ERROR_MESSAGE));
    assertThat(throwable, is(sameInstance(rootCause)));
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) HeisenbergException(org.mule.test.heisenberg.extension.exception.HeisenbergException) IOException(java.io.IOException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) ExecutionException(java.util.concurrent.ExecutionException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

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