Search in sources :

Example 1 with CustomTransportConfiguration

use of org.mule.extension.ws.api.transport.CustomTransportConfiguration in project mule-wsc-connector by mulesoft.

the class ConfigEqualsTestCase method testCustomTransportsEquals.

@Test
public void testCustomTransportsEquals() {
    EasyRandomParameters parameters = new EasyRandomParameters();
    parameters.collectionSizeRange(1, 3);
    EasyRandom factory = new EasyRandom(parameters);
    EasyRandom factory2 = new EasyRandom(parameters);
    for (int i = 0; i < 1000; i++) {
        CustomTransportConfiguration customTransport = factory.nextObject(CustomHttpTransportConfiguration.class);
        CustomTransportConfiguration anotherCustomTransport = factory.nextObject(DefaultHttpTransportConfiguration.class);
        CustomTransportConfiguration clonedCustomTransport = factory2.nextObject(CustomHttpTransportConfiguration.class);
        CustomTransportConfiguration anotherClonedCustomTransport = factory2.nextObject(DefaultHttpTransportConfiguration.class);
        assertThat(customTransport, is(clonedCustomTransport));
        assertThat(customTransport.hashCode(), is(clonedCustomTransport.hashCode()));
        assertThat(anotherCustomTransport, is(anotherClonedCustomTransport));
        assertThat(anotherCustomTransport.hashCode(), is(anotherClonedCustomTransport.hashCode()));
        assertThat(customTransport, not(anotherCustomTransport));
        assertThat(customTransport.hashCode(), not(anotherCustomTransport.hashCode()));
        assertThat(clonedCustomTransport, not(anotherClonedCustomTransport));
        assertThat(clonedCustomTransport.hashCode(), not(anotherClonedCustomTransport.hashCode()));
    }
}
Also used : EasyRandomParameters(org.jeasy.random.EasyRandomParameters) CustomTransportConfiguration(org.mule.extension.ws.api.transport.CustomTransportConfiguration) EasyRandom(org.jeasy.random.EasyRandom) Test(org.junit.Test)

Example 2 with CustomTransportConfiguration

use of org.mule.extension.ws.api.transport.CustomTransportConfiguration in project mule-wsc-connector by mulesoft.

the class ConsumeTestCase method consumeConcurrently.

@Test
public void consumeConcurrently() {
    WsdlConnectionInfo info = mock(WsdlConnectionInfo.class);
    CountDownLatch latch = new CountDownLatch(1);
    CustomTransportConfiguration configuration = mock(CustomTransportConfiguration.class);
    ExtensionsClient extensionsClient = mock(ExtensionsClient.class);
    SoapClient soapClient = mock(SoapClient.class);
    SoapRequest soapRequest = mock(SoapRequest.class);
    CheckedSupplier<SoapClient> supplier = mock(CheckedSupplier.class);
    when(soapClient.consume(any(SoapRequest.class), any(TransportDispatcher.class))).thenReturn(mock(SoapResponse.class));
    when(supplier.get()).then(new Answer<SoapClient>() {

        @Override
        public SoapClient answer(InvocationOnMock invocation) throws Throwable {
            latch.await();
            return soapClient;
        }
    });
    WscSoapClient client = new WscSoapClient(info, supplier, configuration, null);
    executorService.submit(() -> client.consume(soapRequest, extensionsClient));
    executorService.submit(() -> client.consume(soapRequest, extensionsClient));
    latch.countDown();
    verify(supplier, times(1)).get();
}
Also used : ExtensionsClient(org.mule.runtime.extension.api.client.ExtensionsClient) CustomTransportConfiguration(org.mule.extension.ws.api.transport.CustomTransportConfiguration) WscSoapClient(org.mule.extension.ws.internal.connection.WscSoapClient) SoapClient(org.mule.soap.api.client.SoapClient) TransportDispatcher(org.mule.soap.api.transport.TransportDispatcher) CountDownLatch(java.util.concurrent.CountDownLatch) SoapRequest(org.mule.soap.api.message.SoapRequest) SoapResponse(org.mule.soap.api.message.SoapResponse) WsdlConnectionInfo(org.mule.extension.ws.internal.connection.WsdlConnectionInfo) InvocationOnMock(org.mockito.invocation.InvocationOnMock) WscSoapClient(org.mule.extension.ws.internal.connection.WscSoapClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 CustomTransportConfiguration (org.mule.extension.ws.api.transport.CustomTransportConfiguration)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 EasyRandom (org.jeasy.random.EasyRandom)1 EasyRandomParameters (org.jeasy.random.EasyRandomParameters)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 WscSoapClient (org.mule.extension.ws.internal.connection.WscSoapClient)1 WsdlConnectionInfo (org.mule.extension.ws.internal.connection.WsdlConnectionInfo)1 ExtensionsClient (org.mule.runtime.extension.api.client.ExtensionsClient)1 SoapClient (org.mule.soap.api.client.SoapClient)1 SoapRequest (org.mule.soap.api.message.SoapRequest)1 SoapResponse (org.mule.soap.api.message.SoapResponse)1 TransportDispatcher (org.mule.soap.api.transport.TransportDispatcher)1