use of org.mule.runtime.api.connection.ConnectionValidationResult in project mule by mulesoft.
the class ExtensionConnectivityTestingStrategyTestCase method connectionProviderThrowsException.
@Test
public void connectionProviderThrowsException() throws MuleException {
final Exception e = new RuntimeException();
when(connectionProviderResolver.resolve(any())).thenThrow(e);
ConnectionValidationResult connectionResult = extensionConnectivityTestingStrategy.testConnectivity(connectionProviderResolver);
assertThat(connectionResult.isValid(), is(false));
assertThat(connectionResult.getException(), is(sameInstance(e)));
}
use of org.mule.runtime.api.connection.ConnectionValidationResult in project mule by mulesoft.
the class DefaultConnectivityTestingServiceTestCase method testConnectionThrowsException.
@Test
public void testConnectionThrowsException() throws Exception {
RuntimeException exception = new RuntimeException();
when(mockConnectivityTestingStrategy.testConnectivity(fakeConnectivityTestingObject)).thenThrow(exception);
ConnectionValidationResult validationResult = connectivityTestingService.testConnection(builder().globalName(TEST_IDENTIFIER).build());
assertThat(validationResult.isValid(), is(false));
assertThat(validationResult.getException(), is(exception));
}
use of org.mule.runtime.api.connection.ConnectionValidationResult in project mule by mulesoft.
the class DefaultConnectivityTestingServiceTestCase method testConnection.
@Test
public void testConnection() {
when(mockConnectivityTestingStrategy.testConnectivity(fakeConnectivityTestingObject)).thenReturn(success());
ConnectionValidationResult validationResult = connectivityTestingService.testConnection(builder().globalName(TEST_IDENTIFIER).build());
assertThat(validationResult.isValid(), is(true));
}
use of org.mule.runtime.api.connection.ConnectionValidationResult in project mule by mulesoft.
the class DefaultConnectionManagerTestCase method successfulConnectionProviderConnectivity.
@Test
public void successfulConnectionProviderConnectivity() throws Exception {
ConnectionValidationResult result = connectionManager.testConnectivity(testeableConnectionProvider);
assertThat(result.isValid(), is(true));
verify(testeableConnectionProvider).connect();
verify(testeableConnectionProvider).validate(connection);
verify(testeableConnectionProvider).disconnect(connection);
}
use of org.mule.runtime.api.connection.ConnectionValidationResult in project mule by mulesoft.
the class DefaultConnectionManagerTestCase method poolingConnectionProviderConnectivity.
@Test
public void poolingConnectionProviderConnectivity() throws Exception {
testeableConnectionProvider = mockConnectionProvider(PoolingConnectionProvider.class);
ConnectionValidationResult result = connectionManager.testConnectivity(testeableConnectionProvider);
assertThat(result.isValid(), is(true));
verify(testeableConnectionProvider).connect();
verify(testeableConnectionProvider, atLeastOnce()).validate(connection);
verify(testeableConnectionProvider, never()).disconnect(connection);
}
Aggregations