@Test
  public void testHttpMethod() {
    MockTestDesigner builder =
        new MockTestDesigner(applicationContext) {
          @Override
          public void configure() {
            send(httpClient)
                .http()
                .method(HttpMethod.GET)
                .payload("<TestRequest><Message>Hello World!</Message></TestRequest>");
          }
        };

    builder.configure();

    TestCase test = builder.getTestCase();
    Assert.assertEquals(test.getActionCount(), 1);
    Assert.assertEquals(test.getActions().get(0).getClass(), SendMessageAction.class);

    SendMessageAction action = ((SendMessageAction) test.getActions().get(0));
    Assert.assertEquals(action.getName(), "send");

    Assert.assertEquals(action.getEndpoint(), httpClient);
    Assert.assertEquals(action.getMessageBuilder().getClass(), PayloadTemplateMessageBuilder.class);

    PayloadTemplateMessageBuilder messageBuilder =
        (PayloadTemplateMessageBuilder) action.getMessageBuilder();
    Assert.assertEquals(
        messageBuilder.getPayloadData(),
        "<TestRequest><Message>Hello World!</Message></TestRequest>");
    Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 1L);
    Assert.assertEquals(
        messageBuilder.getMessageHeaders().get(HttpMessageHeaders.HTTP_REQUEST_METHOD),
        HttpMethod.GET.name());
  }
  @Test(
      expectedExceptions = CitrusRuntimeException.class,
      expectedExceptionsMessageRegExp = "Invalid use of http and soap action builder")
  public void testSendBuilderWithSoapAndHttpMixed() {
    reset(applicationContextMock);
    when(applicationContextMock.getBean(TestActionListeners.class))
        .thenReturn(new TestActionListeners());
    when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class))
        .thenReturn(new HashMap<String, SequenceBeforeTest>());
    when(applicationContextMock.getBeansOfType(SequenceAfterTest.class))
        .thenReturn(new HashMap<String, SequenceAfterTest>());
    MockTestDesigner builder =
        new MockTestDesigner(applicationContextMock) {
          @Override
          public void configure() {
            send("httpClient")
                .http()
                .payload("<TestRequest><Message>Hello World!</Message></TestRequest>")
                .header("operation", "soapOperation")
                .soap();
          }
        };

    builder.configure();

    TestCase test = builder.getTestCase();
    Assert.assertEquals(test.getActionCount(), 1);
    Assert.assertEquals(test.getActions().get(0).getClass(), SendMessageAction.class);

    SendMessageAction action = ((SendMessageAction) test.getActions().get(0));
    Assert.assertEquals(action.getName(), "send");
    Assert.assertEquals(action.getEndpointUri(), "httpClient");
    Assert.assertEquals(action.getMessageType(), MessageType.XML.name());
  }
  @Test
  public void testFork() {
    MockTestDesigner builder =
        new MockTestDesigner(applicationContext) {
          @Override
          public void configure() {
            send(httpClient)
                .message(new DefaultMessage("Foo").setHeader("operation", "foo"))
                .header("additional", "additionalValue");

            send(httpClient)
                .message(new DefaultMessage("Foo").setHeader("operation", "foo"))
                .fork(true);
          }
        };

    builder.configure();

    TestCase test = builder.getTestCase();
    Assert.assertEquals(test.getActionCount(), 2);
    Assert.assertEquals(test.getActions().get(0).getClass(), SendMessageAction.class);
    Assert.assertEquals(test.getActions().get(1).getClass(), SendMessageAction.class);

    SendMessageAction action = ((SendMessageAction) test.getActions().get(0));
    Assert.assertEquals(action.getName(), "send");

    Assert.assertEquals(action.getEndpoint(), httpClient);
    Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);

    StaticMessageContentBuilder messageBuilder =
        (StaticMessageContentBuilder) action.getMessageBuilder();
    Assert.assertEquals(messageBuilder.getMessage().getPayload(String.class), "Foo");
    Assert.assertEquals(messageBuilder.getMessage().getHeader("operation"), "foo");
    Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 1L);
    Assert.assertEquals(messageBuilder.getMessageHeaders().get("additional"), "additionalValue");

    Assert.assertFalse(action.isForkMode());

    action = ((SendMessageAction) test.getActions().get(1));
    Assert.assertEquals(action.getName(), "send");

    Assert.assertEquals(action.getEndpoint(), httpClient);
    Assert.assertEquals(action.getMessageBuilder().getClass(), StaticMessageContentBuilder.class);

    Assert.assertTrue(action.isForkMode());
  }
  @Test
  public void testHttpRequestUriAndQueryParams() {
    MockTestDesigner builder =
        new MockTestDesigner(applicationContext) {
          @Override
          public void configure() {
            send(httpClient)
                .http()
                .uri("http://localhost:8080/")
                .queryParam("param1", "value1")
                .queryParam("param2", "value2")
                .payload("<TestRequest><Message>Hello World!</Message></TestRequest>");
          }
        };

    builder.configure();

    TestCase test = builder.getTestCase();
    Assert.assertEquals(test.getActionCount(), 1);
    Assert.assertEquals(test.getActions().get(0).getClass(), SendMessageAction.class);

    SendMessageAction action = ((SendMessageAction) test.getActions().get(0));
    Assert.assertEquals(action.getName(), "send");

    Assert.assertEquals(action.getEndpoint(), httpClient);
    Assert.assertEquals(action.getMessageBuilder().getClass(), PayloadTemplateMessageBuilder.class);

    PayloadTemplateMessageBuilder messageBuilder =
        (PayloadTemplateMessageBuilder) action.getMessageBuilder();
    Assert.assertEquals(
        messageBuilder.getPayloadData(),
        "<TestRequest><Message>Hello World!</Message></TestRequest>");
    Assert.assertEquals(messageBuilder.getMessageHeaders().size(), 2L);
    Assert.assertEquals(
        messageBuilder.getMessageHeaders().get(DynamicEndpointUriResolver.ENDPOINT_URI_HEADER_NAME),
        "http://localhost:8080/");
    Assert.assertEquals(
        messageBuilder.getMessageHeaders().get(DynamicEndpointUriResolver.QUERY_PARAM_HEADER_NAME),
        "param1=value1,param2=value2");
  }