POST
Specifying use cases of a POST
-endpoint
Overview
e:post
<e:post url="/some/url" contentType="application/json"> <e:case desc="use-case 1"> <e:body> {"request": "body"} </e:body> <e:expected statusCode="201" reasonPhrase="Created"> { "response": "body" } </e:expected> </e:case> <e:case desc="use-case 2"> <e:body from="/ws/request.json"/> <e:expected from="/ws/response.json" statusCode="201" reasonPhrase="Created"/> </e:case> </e:post>
Usage
1. Configure the connection to the Web Service via WsPlugin.
2. Use e:post
tag in specification:
src/test/resources/specs/Specs.html
<e:post url="/some/url" contentType="application/json">
<e:case desc="use-case 1">
<e:body>
{"request": "body"}
</e:body>
<e:expected statusCode="201" reasonPhrase="Created">
{ "response": "body" }
</e:expected>
</e:case>
<e:case desc="use-case 2">
<e:body from="/ws/request.json"/>
<e:expected from="/ws/response.json" statusCode="201" reasonPhrase="Created"/>
</e:case>
</e:post>
Attributes
attribute | desc | example |
---|---|---|
url |
Context path that will be appended to base web service url configured in WsPlugin. | Required. Default: -
|
contentType |
Content-Type HTTP header. | Required. Default: application/json
|
headers |
Comma-separated name=value list of HTTP header, will be applied to all cases if not overridden. | Optional. Default: empty
|
case.headers |
Comma-separated name=value list of HTTP headers, will completely override headers for specific case. | Optional. Default: empty
|
cookies |
Comma-separated name=value list of HTTP cookies, will be applied to all cases if not overridden. | Optional. Default: empty
|
case.cookies |
Comma-separated name=value list of HTTP cookies, will completely override cookies for specific case. | Optional. Default: empty
|
case.desc |
Description of use case. | Optional. Default: ""
|
case.urlParams |
Additional params to add to query string. | Optional. Default: ""
|
case.body.from |
Use content of the specified file as a value of a request body instead of the tag body (empty tag can be used) | Optional. Default: -
|
case.expected.from |
Use content of the specified file as a value of an expected response body instead of the tag body (empty tag can be used) | Optional. Default: -
|
case.expected.statusCode |
Expected response status code | Optional. Default: 200
|
case.expected.reasonPhrase |
Expected response reason phrase | Optional. Default: OK
|
case.expected.protocol |
Expected status line protocol | Optional. Default: HTTP/1.1"
|
case.expected.verifyAs |
Content verifier to use. Built-in verifiers: json, xml, text. |
Optional. Default: -
|
Examples
Query string
To specify case specific query string case.urlParams
attribute may be used.
Use cases: | |
---|---|
1) POST with query parameters | |
| 20015ms |
{ "bodyValue": 111 } |