SoapHeader soapRequestHeader = EasyMock.createMock(SoapHeader.class);
org.springframework.ws.soap.SoapMessage soapResponse = EasyMock.createMock(org.springframework.ws.soap.SoapMessage.class);
SoapHeader soapResponseHeader = EasyMock.createMock(SoapHeader.class);
Soap12Body soapResponseBody = EasyMock.createMock(Soap12Body.class);
final Soap12Fault soapFault = EasyMock.createMock(Soap12Fault.class);
StringResult soapResponsePayload = new StringResult();
reset(messageContext, soapRequest, soapRequestHeader, soapResponse, soapResponseHeader, soapResponseBody, soapFault);
expect(messageContext.getRequest()).andReturn(soapRequest).anyTimes();
expect(soapRequest.getPayloadSource()).andReturn(new StringSource("<TestRequest><Message>Hello World!</Message></TestRequest>")).times(2);
expect(messageContext.getPropertyNames()).andReturn(new String[]{}).once();
expect(soapRequest.getSoapHeader()).andReturn(soapRequestHeader).once();
expect(soapRequestHeader.getSource()).andReturn(null).once();
Set<SoapHeaderElement> emptyHeaderSet = Collections.emptySet();
expect(soapRequestHeader.examineAllHeaderElements()).andReturn(emptyHeaderSet.iterator()).once();
expect(soapRequest.getSoapAction()).andReturn("sayHello").anyTimes();
Set<Attachment> emptyAttachmentSet = Collections.emptySet();
expect(soapRequest.getAttachments()).andReturn(emptyAttachmentSet.iterator()).once();
expect(messageContext.getResponse()).andReturn(soapResponse).once();
expect(soapResponse.getSoapHeader()).andReturn(soapResponseHeader).anyTimes();
expect(soapResponse.getSoapBody()).andReturn(soapResponseBody).once();
expect(soapResponseBody.addServerOrReceiverFault((String)anyObject(), (Locale)anyObject())).andAnswer(new IAnswer<Soap12Fault>() {
public Soap12Fault answer() throws Throwable {
Assert.assertEquals(EasyMock.getCurrentArguments()[0], "Invalid request");
return soapFault;
}
});
soapFault.addFaultSubcode((QName)anyObject());
expectLastCall().andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
QName faultQName = (QName)EasyMock.getCurrentArguments()[0];
Assert.assertEquals(faultQName.getLocalPart(), "TEC-1000");