verify(soapResponse, soapEnvelope, soapBody, soapHeader, soapHeaderElement);
}
@Test
public void testInboundSoapAttachment() throws TransformerException, IOException {
SoapAttachment attachment = new SoapAttachment();
attachment.setContentId("attContentId");
attachment.setContent("This is a SOAP attachment" + System.getProperty("line.separator") + "with multi-line");
attachment.setContentType("plain/text");
SoapMessageConverter soapMessageConverter = new SoapMessageConverter();
StringSource soapBodySource = new StringSource(responsePayload);
Set<SoapHeaderElement> soapHeaders = new HashSet<SoapHeaderElement>();
Set<Attachment> soapAttachments = new HashSet<Attachment>();
soapAttachments.add(attachment);
reset(soapResponse, soapEnvelope, soapBody, soapHeader);
expect(soapResponse.getEnvelope()).andReturn(soapEnvelope).anyTimes();
expect(soapResponse.getPayloadSource()).andReturn(soapBodySource).times(2);
expect(soapResponse.getSoapHeader()).andReturn(soapHeader).anyTimes();
expect(soapEnvelope.getHeader()).andReturn(soapHeader).anyTimes();
expect(soapHeader.examineAllHeaderElements()).andReturn(soapHeaders.iterator()).once();
expect(soapHeader.getSource()).andReturn(null).once();
expect(soapResponse.getSoapAction()).andReturn("soapOperation").anyTimes();
expect(soapResponse.getAttachments()).andReturn(soapAttachments.iterator()).once();
replay(soapResponse, soapEnvelope, soapBody, soapHeader);
Message responseMessage = soapMessageConverter.convertInbound(soapResponse, new WebServiceEndpointConfiguration());
Assert.assertTrue(SoapMessage.class.isInstance(responseMessage));
SoapMessage soapResponseMessage = (SoapMessage) responseMessage;
Assert.assertEquals(soapResponseMessage.getPayload(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + responsePayload);
Assert.assertEquals(soapResponseMessage.getSoapAction(), "soapOperation");
Assert.assertEquals(soapResponseMessage.getHeaderData().size(), 0L);
List<SoapAttachment> attachments = soapResponseMessage.getAttachments();
Assert.assertEquals(attachments.size(), 1L);
Assert.assertEquals(attachments.get(0).getContentId(), attachment.getContentId());
Assert.assertEquals(attachments.get(0).getContentType(), attachment.getContentType());
Assert.assertEquals(FileUtils.readToString(attachments.get(0).getInputStream()), attachment.getContent());
verify(soapResponse, soapEnvelope, soapBody, soapHeader);
}