@Test
  @SuppressWarnings("rawtypes")
  public void testSoapMessageWithAttachmentResourceVariablesSupportTest() throws Exception {
    SendSoapMessageAction soapMessageAction = new SendSoapMessageAction();
    soapMessageAction.setMessageSender(messageSender);

    PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
    messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

    context.setVariable("myText", "Hello World!");

    soapMessageAction.setAttachmentResource(
        new ClassPathResource(
            "test-attachment-with-variables.xml", SendSoapMessageActionTest.class));

    soapMessageAction.setMessageBuilder(messageBuilder);

    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.assertNull(constructedAttachment.getContentId());
                Assert.assertEquals(constructedAttachment.getContentType(), "text/plain");
                Assert.assertEquals(
                    constructedAttachment.getContent(),
                    "<TestAttachment><Message>Hello World!</Message></TestAttachment>");
                Assert.assertEquals(constructedAttachment.getCharsetName(), "UTF-8");

                return null;
              }
            })
        .once();

    replay(messageSender);

    soapMessageAction.execute(context);

    verify(messageSender);
  }
  @Test
  @SuppressWarnings("rawtypes")
  public void testSoapMessageWithHeaderResourceVariableSupportTest() throws Exception {
    SendSoapMessageAction soapMessageAction = new SendSoapMessageAction();
    soapMessageAction.setMessageSender(messageSender);

    PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
    messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

    context.setVariable("operation", "soapOperation");

    messageBuilder.setMessageHeaderResource(
        new ClassPathResource(
            "test-header-resource-with-variables.xml", SendSoapMessageActionTest.class));

    soapMessageAction.setMessageBuilder(messageBuilder);

    reset(messageSender);

    messageSender.send((Message) anyObject());
    expectLastCall()
        .andAnswer(
            new IAnswer<Object>() {
              public Object answer() throws Throwable {
                Message constructedMessage = (Message) EasyMock.getCurrentArguments()[0];

                Assert.assertNotNull(
                    constructedMessage.getHeaders().get(CitrusMessageHeaders.HEADER_CONTENT));
                Assert.assertEquals(
                    constructedMessage.getHeaders().get(CitrusMessageHeaders.HEADER_CONTENT),
                    "<TestHeader><operation>soapOperation</operation></TestHeader>");

                return null;
              }
            })
        .once();

    replay(messageSender);

    soapMessageAction.execute(context);

    verify(messageSender);
  }
  @Test
  @SuppressWarnings("rawtypes")
  public void testSoapMessageWithEmptyAttachmentContentTest() throws Exception {
    SendSoapMessageAction soapMessageAction = new SendSoapMessageAction();
    soapMessageAction.setMessageSender(messageSender);

    PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
    messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

    soapMessageAction.setMessageBuilder(messageBuilder);

    reset(messageSender);

    messageSender.send((Message) anyObject());
    expectLastCall().once();

    replay(messageSender);

    soapMessageAction.execute(context);

    verify(messageSender);
  }
  @Test
  public void testWrongMessageSenderImplementationTest() throws Exception {
    SendSoapMessageAction soapMessageAction = new SendSoapMessageAction();
    MessageSender jmsMessageSender = new JmsMessageSender();
    soapMessageAction.setMessageSender(jmsMessageSender);

    PayloadTemplateMessageBuilder messageBuilder = new PayloadTemplateMessageBuilder();
    messageBuilder.setPayloadData("<TestRequest><Message>Hello World!</Message></TestRequest>");

    soapMessageAction.setMessageBuilder(messageBuilder);

    try {
      soapMessageAction.execute(context);
    } catch (CitrusRuntimeException e) {
      Assert.assertEquals(
          e.getMessage(),
          "Sending SOAP messages requires a "
              + "'com.consol.citrus.ws.message.WebServiceMessageSender' but was 'com.consol.citrus.jms.JmsMessageSender'");
      return;
    }

    Assert.fail("Missing exception because of unsupported MessageSender implementation");
  }