How can I mock SOAPConnection and SOAPConnectionFactory
<p>Here is my code:</p>

<pre class="lang-java prettyprint-override"><code>URL url = new URL(getURL());  
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnFactory.createConnection();`
response=soapConnection.call(soapMsg, url);
</code></pre>

<p>I'm trying to create a mock for <code>SOAPConnection</code> but I get an exception.
Can anyone suggest me any work-around for this? </p>

<p>My test is something like this:
I created a <code>SOAPMessage</code> object and <code>URL</code> object.     </p>

<pre class="lang-java prettyprint-override"><code>Resource classUnderTest = new Resource(); 
SOAPConnection mockConnection = EasyMock.createMock(SOAPConnection.class); 
EasyMock.expect(mockConnection.call(soapmsg, url)).andReturn(soapMsg); 
EasyMock.replay(mockConnection); 
WhiteBox.setinternalState(classUnderTest, SOAPConnection.class, mockConnection);
</code></pre>