我想使用web服务并在其响应中添加断言。我得到以下异常:
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
}
我还有其他类似的测试工作正常,输入的输入有效负载的这个特殊测试在Postman中运行良好
这是我在spock / groovy中失败的操作的响应头:
Content-Length →159
Content-Type →application/json
Date →Wed, 05 Apr 2017 06:19:16 GMT
X-Correlation-ID → xxxxx
正在运行的另一个opertion的响应标头:
Connection →close
Content-Length →273
Content-Type →application/json
Date →Wed, 05 Apr 2017 06:16:41 GMT
X-Correlation-ID → xxxxx
答案 0 :(得分:0)
非常感谢帮助结果,在我的请求中有一个特殊字符,例如Ø,服务不喜欢,因此以这种荒谬的方式回应。现在工作正常