XmlMessageValidationContext validationContext = new XmlMessageValidationContext();
validationContext.setMessageBuilder(controlMessageBuilder);
controlMessageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");
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);
Message controlMessage = new SoapMessage("<TestRequest><Message>Hello World!</Message></TestRequest>");
reset(endpoint, consumer, endpointConfiguration, attachmentValidator);
expect(endpoint.createConsumer()).andReturn(consumer).anyTimes();
expect(endpoint.getEndpointConfiguration()).andReturn(endpointConfiguration).anyTimes();
expect(endpointConfiguration.getTimeout()).andReturn(5000L).anyTimes();
expect(consumer.receive(anyObject(TestContext.class), anyLong())).andReturn(controlMessage).once();
attachmentValidator.validateAttachment((SoapMessage)anyObject(), (List)anyObject());
expectLastCall().andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
Assert.assertEquals(((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).size(), 2L);
SoapAttachment soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(0);
Assert.assertEquals(soapAttachment.getContent(), "<TestAttachment><Message>Hello World1!</Message></TestAttachment>");
Assert.assertEquals(soapAttachment.getContentId(), "1stAttachment");
Assert.assertEquals(soapAttachment.getContentType(), "text/xml");
Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-8");
soapAttachment = ((List<SoapAttachment>)EasyMock.getCurrentArguments()[1]).get(1);
Assert.assertEquals(soapAttachment.getContent(), "<TestAttachment><Message>Hello World2!</Message></TestAttachment>");
Assert.assertEquals(soapAttachment.getContentId(), "2ndAttachment");
Assert.assertEquals(soapAttachment.getContentType(), "text/xml");
Assert.assertEquals(soapAttachment.getCharsetName(), "UTF-16");
return null;
}
});
expect(endpoint.getActor()).andReturn(null).anyTimes();