Change error response to the same as request text
This commit is contained in:
parent
0805de459d
commit
f72e510fea
3 changed files with 15 additions and 11 deletions
|
@ -40,7 +40,7 @@ class ContextExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ex.sendResponseHeaders(404, 0)
|
ex.sendResponseHeaders(404, 0)
|
||||||
ex.responseBody << "<invalidInput/>"
|
ex.responseBody << request.text
|
||||||
ex.responseBody.close()
|
ex.responseBody.close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,4 +28,8 @@ class Util {
|
||||||
EntityUtils.consumeQuietly(entity)
|
EntityUtils.consumeQuietly(entity)
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void consumeResponse(CloseableHttpResponse response) {
|
||||||
|
EntityUtils.consumeQuietly(response.entity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ class MockServerIntegrationTest extends Specification {
|
||||||
204 | 204
|
204 | 204
|
||||||
}
|
}
|
||||||
|
|
||||||
def "should return response code 404 and error body when mocks does not apply"() {
|
def "should return response code 404 and error body the same as request body when mocks does not apply"() {
|
||||||
given:
|
given:
|
||||||
controlServerClient.addMock(new AddMockRequestData(
|
controlServerClient.addMock(new AddMockRequestData(
|
||||||
name: 'testRest1',
|
name: 'testRest1',
|
||||||
|
@ -253,7 +253,7 @@ class MockServerIntegrationTest extends Specification {
|
||||||
then:
|
then:
|
||||||
response.statusLine.statusCode == 404
|
response.statusLine.statusCode == 404
|
||||||
GPathResult secondXmlResponse = Util.extractXmlResponse(response)
|
GPathResult secondXmlResponse = Util.extractXmlResponse(response)
|
||||||
secondXmlResponse.name() == 'invalidInput'
|
secondXmlResponse.name() == 'request1'
|
||||||
}
|
}
|
||||||
|
|
||||||
def "should inform that there was problem during adding mock - invalid port"() {
|
def "should inform that there was problem during adding mock - invalid port"() {
|
||||||
|
@ -473,8 +473,8 @@ class MockServerIntegrationTest extends Specification {
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
||||||
then:
|
then:
|
||||||
GPathResult badRestPostResponse = Util.extractXmlResponse(badResponse)
|
badResponse.statusLine.statusCode == 404
|
||||||
badRestPostResponse.name() == 'invalidInput'
|
Util.consumeResponse(badResponse)
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse response = client.execute(restPost)
|
CloseableHttpResponse response = client.execute(restPost)
|
||||||
then:
|
then:
|
||||||
|
@ -497,8 +497,8 @@ class MockServerIntegrationTest extends Specification {
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
||||||
then:
|
then:
|
||||||
GPathResult badRestPostResponse = Util.extractXmlResponse(badResponse)
|
badResponse.statusLine.statusCode == 404
|
||||||
badRestPostResponse.name() == 'invalidInput'
|
Util.consumeResponse(badResponse)
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse response = client.execute(restPost)
|
CloseableHttpResponse response = client.execute(restPost)
|
||||||
then:
|
then:
|
||||||
|
@ -522,8 +522,8 @@ class MockServerIntegrationTest extends Specification {
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
||||||
then:
|
then:
|
||||||
GPathResult badRestPostResponse = Util.extractXmlResponse(badResponse)
|
badResponse.statusLine.statusCode == 404
|
||||||
badRestPostResponse.name() == 'invalidInput'
|
Util.consumeResponse(badResponse)
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse response = client.execute(restPost)
|
CloseableHttpResponse response = client.execute(restPost)
|
||||||
then:
|
then:
|
||||||
|
@ -547,8 +547,8 @@ class MockServerIntegrationTest extends Specification {
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
CloseableHttpResponse badResponse = client.execute(badRestPost)
|
||||||
then:
|
then:
|
||||||
GPathResult badRestPostResponse = Util.extractXmlResponse(badResponse)
|
badResponse.statusLine.statusCode == 404
|
||||||
badRestPostResponse.name() == 'invalidInput'
|
Util.consumeResponse(badResponse)
|
||||||
when:
|
when:
|
||||||
CloseableHttpResponse response = client.execute(restPost)
|
CloseableHttpResponse response = client.execute(restPost)
|
||||||
then:
|
then:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue