Exam >
On this page

GET

Specifying use cases of a GET-endpoint

Overview

Usage

1. Configure the connection to the Web Service via WsPlugin.

2. Use e:get tag in specification:

src/test/resources/specs/Specs.html

<e:get url="/some/url" contentType="application/json">
    <!-- One or many cases -->
    <e:case desc="use-case 1" urlParams="param1=1">
        <!--  Expected response -->
        <e:expected statusCode="200">
            { "response": "body" }
        </e:expected>
        <!-- Optional block for case specific checks -->
        <e:check>
            <span c:assertTrue="true">Block for additional checks</span>
        </e:check>
    </e:case>
    <e:case desc="use-case 2" urlParams="param1=1&amp;param2=2">
        <e:expected from="/ws/response.json" statusCode="200"/>
    </e:case>
</e:get>

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.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
The following markup:
<e:get url="mirror/request">
  <e:case desc="Request with single param" urlParams="param1=1">
    <e:expected> { "GET": "/mirror/request?param1=1" } </e:expected>
  </e:case>
  <e:case desc="Request with several params" urlParams="param1=1&amp;param2=2">
    <e:expected> { "GET": "/mirror/request?param1=1&amp;param2=2" } </e:expected>
  </e:case>
</e:get>
will be rendered as:
GET mirror/request
Content-Type application/json
Use cases:
1) Request with single param
GET mirror/request?param1=1 HTTP/1.1
20022ms
2) Request with several params
GET mirror/request?param1=1&param2=2 HTTP/1.1
20015ms

How to