use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.
the class ExtensionMessageSourceTestCase method failOnExceptionWithConnectionExceptionAndGetsReconnected.
@Test
public void failOnExceptionWithConnectionExceptionAndGetsReconnected() throws Exception {
messageSource.initialise();
messageSource.start();
messageSource.onException(new ConnectionException(ERROR_MESSAGE));
verify(source, times(2)).onStart(sourceCallback);
verify(source, times(1)).onStop();
}
use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.
the class LifecycleAwareConfigurationInstanceAsyncRetryTestCase method testConnectivityFailsUponStart.
@Override
@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();
interceptable.start();
new PollingProber().check(new JUnitLambdaProbe(() -> {
verify(connectionManager, times(RECONNECTION_MAX_ATTEMPTS + 1)).testConnectivity(interceptable);
return true;
}));
}
}
use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.
the class ConnectionInterceptorTestCase method onConnectionException.
@Test
public void onConnectionException() throws Exception {
interceptor.before(operationContext);
interceptor.onError(operationContext, new ConnectionException("Bleh"));
interceptor.after(operationContext, null);
verify(connectionHandler).invalidate();
}
use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.
the class ReconnectableHeisenbergSource method reconnect.
@Override
public void reconnect(ConnectionException exception, ReconnectionCallback reconnectionCallback) {
if (reconnectable) {
succesfulReconnections++;
reconnectionCallback.success();
} else {
failedReconnections++;
reconnectionCallback.failed(new ConnectionException("Boss said no", exception));
}
}
use of org.mule.runtime.api.connection.ConnectionException in project mule by mulesoft.
the class ReconectionSource method onStart.
@Override
public void onStart(SourceCallback<ReconnectableConnection, Void> sourceCallback) throws MuleException {
ReconnectableConnection connection;
try {
connection = connectionProvider.connect();
scheduler = schedulerService.ioScheduler();
scheduler.execute(() -> {
boolean shouldFinish = false;
while (!shouldFinish) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
shouldFinish = true;
}
if (ReconnectableConnectionProvider.fail) {
sourceCallback.onConnectionException(new ConnectionException(new RuntimeException(), connection));
shouldFinish = true;
} else {
sourceCallback.handle(Result.<ReconnectableConnection, Void>builder().output(connection).build());
}
}
});
} catch (Exception e) {
sourceCallback.onConnectionException(new ConnectionException(e));
}
}
Aggregations