Search in sources :

Example 6 with ConnectionValidationResult

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)));
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) MuleException(org.mule.runtime.api.exception.MuleException) Test(org.junit.Test)

Example 7 with ConnectionValidationResult

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));
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) Test(org.junit.Test)

Example 8 with ConnectionValidationResult

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));
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) Test(org.junit.Test)

Example 9 with ConnectionValidationResult

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);
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) Test(org.junit.Test)

Example 10 with ConnectionValidationResult

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);
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) PoolingConnectionProvider(org.mule.runtime.api.connection.PoolingConnectionProvider) Test(org.junit.Test)

Aggregations

ConnectionValidationResult (org.mule.runtime.api.connection.ConnectionValidationResult)14 Test (org.junit.Test)10 ConnectionException (org.mule.runtime.api.connection.ConnectionException)3 MuleException (org.mule.runtime.api.exception.MuleException)3 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)2 SoapServiceProviderConfigurationException (org.mule.runtime.extension.api.soap.SoapServiceProviderConfigurationException)2 Lock (java.util.concurrent.locks.Lock)1 ConnectionProvider (org.mule.runtime.api.connection.ConnectionProvider)1 PoolingConnectionProvider (org.mule.runtime.api.connection.PoolingConnectionProvider)1 ConnectivityTestingService (org.mule.runtime.api.connectivity.ConnectivityTestingService)1 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)1 Scheduler (org.mule.runtime.api.scheduler.Scheduler)1 RetryCallback (org.mule.runtime.core.api.retry.RetryCallback)1 RetryContext (org.mule.runtime.core.api.retry.RetryContext)1 RetryPolicyTemplate (org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate)1 ReconnectionConfig (org.mule.runtime.core.internal.retry.ReconnectionConfig)1 NoConnectivityTest (org.mule.runtime.extension.api.connectivity.NoConnectivityTest)1 ContextAwareMessageDispatcherProvider (org.mule.runtime.extension.api.soap.ContextAwareMessageDispatcherProvider)1 MessageDispatcher (org.mule.runtime.extension.api.soap.message.MessageDispatcher)1