Search in sources :

Example 11 with ConnectionValidationResult

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

the class ForwardingSoapClientConnectionProviderTestCase method invalidProvider.

@Test
public void invalidProvider() throws Exception {
    ConnectionValidationResult result = new ForwardingSoapClientConnectionProvider(new ValidableServiceProvider(false), dispatcherProvider, ctx).validate(null);
    assertThat(result.isValid(), is(false));
    assertThat(result.getException(), instanceOf(SoapServiceProviderConfigurationException.class));
    assertThat(result.getMessage(), is(ERROR_MESSAGE));
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) SoapServiceProviderConfigurationException(org.mule.runtime.extension.api.soap.SoapServiceProviderConfigurationException) Test(org.junit.Test)

Example 12 with ConnectionValidationResult

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

the class ExtensionConnectivityTestingStrategyTestCase method testConnectivityWithConnectionProvider.

private ConnectionValidationResult testConnectivityWithConnectionProvider(boolean isValidConnection) throws MuleException {
    when(connectionProviderResolver.resolve(any())).thenReturn(new Pair<>(connectionProvider, mock(ResolverSetResult.class)));
    ConnectionValidationResult validationResult;
    if (isValidConnection) {
        validationResult = ConnectionValidationResult.success();
    } else {
        validationResult = ConnectionValidationResult.failure("", null);
    }
    when(connectionProvider.validate(any())).thenReturn(validationResult);
    ConnectionValidationResult connectionResult = extensionConnectivityTestingStrategy.testConnectivity(connectionProviderResolver);
    return connectionResult;
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult)

Example 13 with ConnectionValidationResult

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

the class ExtensionConnectivityTestingStrategyTestCase method connectionProviderInConfigWithInvalidConnection.

@Test
public void connectionProviderInConfigWithInvalidConnection() throws MuleException {
    ConnectionValidationResult connectionResult = testConnectivityWithConnectionProvider(false);
    assertThat(connectionResult.isValid(), is(false));
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) Test(org.junit.Test)

Example 14 with ConnectionValidationResult

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

the class TestConnectivityUtils method assertConnection.

private void assertConnection(String configName, boolean isSuccess, Matcher<Exception> exceptionMatcher, Matcher<ErrorType> codeMatcher) {
    ConnectivityTestingService testingService = registry.<ConnectivityTestingService>lookupByName(CONNECTIVITY_TESTING_SERVICE_KEY).get();
    ConnectionValidationResult validationResult = testingService.testConnection(builder().globalName(configName).build());
    assertThat(validationResult.isValid(), is(isSuccess));
    if (!isSuccess) {
        assertThat(validationResult.getException(), exceptionMatcher);
        assertThat(validationResult.getErrorType().orElse(null), codeMatcher);
    }
}
Also used : ConnectionValidationResult(org.mule.runtime.api.connection.ConnectionValidationResult) ConnectivityTestingService(org.mule.runtime.api.connectivity.ConnectivityTestingService)

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