@Test @SuppressWarnings("rawtypes") public void testSoapMessageWithAttachmentDataTest() throws Exception { SendSoapMessageAction soapMessageAction = new SendSoapMessageAction(); soapMessageAction.setMessageSender(messageSender); PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder(); messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>"); soapMessageAction.setMessageBuilder(messageBuilder); soapMessageAction.setContentId("myAttachment"); soapMessageAction.setContentType("text/xml"); soapMessageAction.setAttachmentData( "<TestAttachment><Message>Hello World!</Message></TestAttachment>"); soapMessageAction.setCharsetName("UTF-16"); reset(messageSender); messageSender.send((Message) anyObject(), (Attachment) anyObject()); expectLastCall() .andAnswer( new IAnswer<Object>() { public Object answer() throws Throwable { SoapAttachment constructedAttachment = (SoapAttachment) EasyMock.getCurrentArguments()[1]; Assert.assertEquals(constructedAttachment.getContentId(), "myAttachment"); Assert.assertEquals(constructedAttachment.getContentType(), "text/xml"); Assert.assertEquals( constructedAttachment.getContent(), "<TestAttachment><Message>Hello World!</Message></TestAttachment>"); Assert.assertEquals(constructedAttachment.getCharsetName(), "UTF-16"); return null; } }) .once(); replay(messageSender); soapMessageAction.execute(context); verify(messageSender); }