@Test(
      groups = "wso2.esb",
      description =
          "Test to check whether the Content-Type header is preserved when sending "
              + "requests to back end")
  public void testPreserveContentTypeHeader() throws Exception {

    String proxyServiceUrl = getProxyServiceURLHttp("PreserveContentTypeHeaderTest");

    String requestPayload =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' >"
            + "<soapenv:Body>"
            + "</soapenv:Body></soapenv:Envelope> ";

    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Soapaction", "urn:mediate");
    headers.put("Content-type", "application/xml");

    HttpRequestUtil.doPost(new URL(proxyServiceUrl), requestPayload, headers);

    String wireResponse = wireMonitorServer.getCapturedMessage();
    String[] wireResponseList = wireResponse.split(System.lineSeparator());

    Assert.assertTrue(wireResponse.contains("Content-Type"));
    for (String line : wireResponseList) {
      if (line.contains("Content-Type")) {
        if (line.contains(";")) {
          Assert.fail("Content-Type header was modified - " + line);
        }
      }
    }
    // coming to this line means content type header is in expected state, hence passing the test
    Assert.assertTrue(true);
  }
  @BeforeTest(alwaysRun = true)
  public void init() throws Exception {
    super.init();

    wireMonitorServer = new WireMonitorServer(6770);
    wireMonitorServer.start();

    loadESBConfigurationFromClasspath(
        "/artifacts/ESB/passthru/transport/header/PreserveContentTypeHeaderTest.xml");
  }