-2

Here is my code:

URL url = new URL(getURL());  
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnFactory.createConnection();`
response=soapConnection.call(soapMsg, url);

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

My test is something like this: I created a SOAPMessage object and URL object.

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);
dur
  • 15,689
  • 25
  • 79
  • 125

1 Answers1

0

A better approach might be to mock the entire service on a localhost port. I've written a small library which does most of the heavily lifting.

ThomasRS
  • 8,215
  • 5
  • 33
  • 48