Exam >
On this page

POST

Specifying use cases of a POST-endpoint

Overview

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

attributedescexample
url Context path that will be appended to base web service url configured in WsPlugin. Required. Default: -
url="/some/url"
contentType Content-Type HTTP header. Required. Default: application/json
contentType="text/plain"
headers Comma-separated name=value list of HTTP header, will be applied to all cases if not overridden. Optional. Default: empty
headers="type=String, contentEncoding=UTF-8"
case.headers Comma-separated name=value list of HTTP headers, will completely override headers for specific case. Optional. Default: empty
e:case headers="type=String, contentEncoding=UTF-8"
cookies Comma-separated name=value list of HTTP cookies, will be applied to all cases if not overridden. Optional. Default: empty
cookies="one=1, two=2"
case.cookies Comma-separated name=value list of HTTP cookies, will completely override cookies for specific case. Optional. Default: empty
e:case cookies="one=1, two=2"
case.desc Description of use case. Optional. Default: ""
desc="Some description"
case.urlParams Additional params to add to query string. Optional. Default: ""
urlParams="param1=1&amp;param2=2"
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: -
e:body from="/request.json"
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: -
e:expected from="/response.json"
case.expected.statusCode Expected response status code Optional. Default: 200
e:expected statusCode="400"
case.expected.reasonPhrase Expected response reason phrase Optional. Default: OK
e:expected reasonPhrase="Not Found"
case.expected.protocol Expected status line protocol Optional. Default: HTTP/1.1"
e:expected protocol="HTTP/1.1"
case.expected.verifyAs Content verifier to use. Built-in verifiers: json, xml, text. Optional. Default: -
verifyAs="customFormat"

Examples

Query string

To specify case specific query string case.urlParams attribute may be used.

urlParams
POST /mirror/request
Content-Type application/json
Use cases:
1) POST with query parameters
POST /mirror/request?param1=1&param2=2 HTTP/1.1
20015ms
{ "bodyValue": 111 }

How to