这是我的代码:
URL url = new URL(getURL());
SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnFactory.createConnection();`
response=soapConnection.call(soapMsg, url);
我试图为SOAPConnection
创建一个模拟但我得到一个例外。
任何人都可以建议我解决这个问题吗?
我的测试是这样的:
我创建了一个SOAPMessage
对象和URL
对象。
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);