错误信息无法解析服务器的重复标头,exception - 添加Content-Type标头时,无法解析对模拟服务器网络的期望 - 堆栈内存溢出...

我有一个集成测试,其中我在springboot 2.0应用程序中使用了模拟服务器网络(v5.3.0)..一切正常,但是如果我尝试添加Content-Type标头,则会出现以下异常:

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)语句注释该行,则一切运行正常。 有什么线索吗? 非常感谢