Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTPTransportError - Unexpected WS call using the mocked proxy object
    primarykey
    data
    text
    <p>I'm stuck trying to run a unit test that makes a web service request. I'm mocking the proxy object of the jax-ws request in my JUnit test using EasyMock.</p> <p>I have defined the bean using DI in my application-context as follows:</p> <pre><code>&lt;bean id="mockOrderPort" name="mockOrderPort" class="org.easymock.EasyMock" factory-method="createStrictMock" &gt; &lt;constructor-arg value="com.proyecti.perama.siman.replica.integration.schema.OrderPort" /&gt; &lt;/bean&gt; </code></pre> <p>This is the test case that is failing:</p> <pre><code>//II. Fill the authentication response will be used to mock the server calling final AuthenticationResponse authenticationResponse = new AuthenticationResponse(); authenticationResponse.setToken(encode(TestConstants.EMPTY_TOKEN)); //III. When authentication is called, mock must return the authentication request object created earlier expect(mockOrderPort.authentication(EasyMock.anyObject(AuthenticationRequest.class))).andReturn(authenticationResponse); //IV. Make the mock object available for executing the test replay(mockOrderPort); //V. Execute the test (call to server is produced inside this method) executeTest(); //VI. Verify mock behaviour is correct verify(mockOrderPort); </code></pre> <p>Inside the executeTest method, there is the call to the WS using the mocked proxy object:</p> <pre><code>authenticationResponse = portToServer.authentication(authenticationRequest); </code></pre> <p>No matter what I try, but it ALWAYS tries to connect to the actual WS, raising the following exception:</p> <pre><code>authentication request has not been successful. Exception: com.sun.xml.ws.client.ClientTransportException: HTTP Transport error: java.net.ConnectException: Connection refused: connect </code></pre> <p>Why is the mock object trying to connect instead of returning the object I have created?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload