Exception 添加内容类型标头时无法分析mockserver netty上的期望值

Exception 添加内容类型标头时无法分析mockserver netty上的期望值,exception,expectations,mockserver,Exception,Expectations,Mockserver,我有一个集成测试,其中我将mockserver netty(v5.3.0)与springboot 2.0应用程序一起使用。一切正常,但如果我尝试添加内容类型头,我会遇到以下异常: java.lang.IllegalArgumentException: Exception while parsing [{ "httpRequest" : { "method" : "POST", "body" : { "type" : "XML", "xml" : "..

我有一个集成测试,其中我将mockserver netty(v5.3.0)与springboot 2.0应用程序一起使用。一切正常,但如果我尝试添加内容类型头,我会遇到以下异常:

java.lang.IllegalArgumentException: Exception while parsing [{
  "httpRequest" : {
    "method" : "POST",
    "body" : {
      "type" : "XML",
      "xml" : "......"
  },
  "times" : {
    "remainingTimes" : 0,
    "unlimited" : true
  },
  "timeToLive" : {
    "unlimited" : true
  }
}] for Expectation

    at org.mockserver.client.AbstractClient.sendRequest(AbstractClient.java:95)
    at org.mockserver.client.AbstractClient.sendExpectation(AbstractClient.java:441)
    at org.mockserver.client.ForwardChainExpectation.respond(ForwardChainExpectation.java:25)
期望如下:

{
    "method" : "POST",
    "body" : {
      "type" : "XML",
      "xml" : "......"
    }
  },
  "httpResponse" : {
    "statusCode" : 200,
    "headers" : {
      "Content-Type" : [ "text/xml" ]
    },
    "body" : "......."
  },
  "times" : {
    "remainingTimes" : 0,
    "unlimited" : true
  },
  "timeToLive" : {
    "unlimited" : true
  }
}
我使用以下代码创建它:

private static HttpResponse responseWithBody(String responseBody, int statusCode, String contentType) {
    return HttpResponse.response()
            .withStatusCode(statusCode)
            .withHeader("Content-Type",contentType)
            .withBody(responseBody);
}
如果我只是用.withHeader(“Content-Type”,contentType)语句对行进行注释,那么一切都会正常运行。有什么线索吗?
非常感谢

我也遇到了同样的问题。看起来它是由下面使用的xml解析器中的错误引起的,请参阅

升级到mockserver 5.4.1,您就会没事了:)