groovyx.net.http.ResponseParseException 同时从 Spock groovy 调用



我想使用一个网络服务并向其响应添加断言。我得到以下异常:

groovyx.net.http.ResponseParseException: 
    at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:495)
    ......
    at Subscription.Order Products(Subscription.groovy:14)
Caused by: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'I' with an int value of 73
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Invalid UTF-8 middle byte 0x52

我的操作如下:

  def setupSpec() {
            client = new RESTClient("http://tsi-services-dev2.canaldigital.com:9080/test/webgw-dealer/v1/");
            client.handler.failure = { resp, data -> return resp }
        }
///// orderProductPayload is a variable which has an input
    def "Order Products"() {
            when:
            def resp = client.post(path: "order/orderProduct", requestContentType: JSON, contentType: JSON, body: orderProductPayload) as HttpResponseDecorator
            then:
            println("response: " + resp.data)
            resp.status == successResponseStatus
        }

我还有其他这样的测试,它们工作正常,这个输入有效载荷的特定测试从邮递员那里工作正常

这是我对此操作的响应标头,该操作在 spock/groovy 中失败:

Content-Length →159
Content-Type →application/json
Date →Wed, 05 Apr 2017 06:19:16 GMT
X-Correlation-ID → xxxxx

另一个正在运行的操作的响应标头:

  Connection →close
    Content-Length →273
    Content-Type →application/json
    Date →Wed, 05 Apr 2017 06:16:41 GMT
    X-Correlation-ID → xxxxx

非常感谢您的帮助,事实证明,我的请求中有一个特殊的字符,例如 Ø,该服务不喜欢它,因此以如此荒谬的方式做出回应。现在工作正常

最新更新