messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");
soapMessageAction.setMessageBuilder(messageBuilder);
List<SoapAttachment> attachments = new ArrayList<SoapAttachment>();
SoapAttachment attachment = new SoapAttachment();
attachment.setContentId("1stAttachment");
attachment.setContentType("text/xml");
attachment.setContent("<TestAttachment><Message>Hello World1!</Message></TestAttachment>");
attachment.setCharsetName("UTF-8");
attachments.add(attachment);
SoapAttachment attachment2 = new SoapAttachment();
attachment2.setContentId("2ndAttachment");
attachment2.setContentType("text/xml");
attachment2.setContent("<TestAttachment><Message>Hello World2!</Message></TestAttachment>");
attachment2.setCharsetName("UTF-16");
attachments.add(attachment2);
soapMessageAction.setAttachments(attachments);
reset(webServiceEndpoint, producer);
expect(webServiceEndpoint.createProducer()).andReturn(producer).once();
producer.send(anyObject(Message.class), anyObject(TestContext.class));
expectLastCall().andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
Assert.assertEquals(((SoapMessage)EasyMock.getCurrentArguments()[0]).getAttachments().size(), 2L);
SoapAttachment constructedAttachment = ((SoapMessage)EasyMock.getCurrentArguments()[0]).getAttachments().get(0);
Assert.assertEquals(constructedAttachment.getContentId(), "1stAttachment");
Assert.assertEquals(constructedAttachment.getContentType(), "text/xml");
Assert.assertEquals(constructedAttachment.getContent(), "<TestAttachment><Message>Hello World1!</Message></TestAttachment>");
Assert.assertEquals(constructedAttachment.getCharsetName(), "UTF-8");
constructedAttachment = ((SoapMessage)EasyMock.getCurrentArguments()[0]).getAttachments().get(1);
Assert.assertEquals(constructedAttachment.getContentId(), "2ndAttachment");
Assert.assertEquals(constructedAttachment.getContentType(), "text/xml");
Assert.assertEquals(constructedAttachment.getContent(), "<TestAttachment><Message>Hello World2!</Message></TestAttachment>");
Assert.assertEquals(constructedAttachment.getCharsetName(), "UTF-16");
return null;
}
}).once();