!**** Notes
A GET request is performed on the resource whose URI is specified in the second cell.
The following cell indicate:
1) the expected return HTTP code,
2) a subset of headers - regular expressions are allowed
3) a list of XPaths to be executed in the body. Each XPath is run and it suceedes only if the result of the execution
returns at least one node
****!

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/0 | 200 | Content-Length : [\d]+ |!-
 /resource/name[text()='a funky name'] <br/>
 /resource/data[text()='an important message']
-!|

!**** Absolute resource paths
A GET (as all other verbs) accepts absolute resource paths.  
****!

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | http://${jettyHost}:${jettyPort}/resources/0 | 200 | Content-Length : [\d]+ |!-
 /resource/name[text()='a funky name'] <br/>
 /resource/data[text()='an important message']
-!|

A GET request properly handles query strings. In this example the stub resource echoes the query string in a Query-String header

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/0?param=echome&something=else&another=parameter | 200 | !-Content-Length : [\d]+
Query-String : param=echome&something=else&another=parameter -! |!-
 /resource/name[text()='a funky name'] <br/>
 /resource/data[text()='an important message']
-!|

Get a non existing resource should not find it

!**** Note
Instead of XPaths you can specify 'no-body' if the operation is expected to return an empty body
****!

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/20 | 404 | Content-Length : 0 | no-body |
|GET    | /resources/20.json | 404 | Content-Length : 0 | no-body |

!**** XPaths and namespaces
Namespaces are supported by declaring the alias/uri map in the RestFixtureConfig, using the key restfixture.xml.namespace.context (See SuiteSetup)
****!

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/0 | 200 | Content-Length : [\d]+ |!-
 /resource/nstag/ns1alias:number[text()='3']
-!|


!**** Json
Expectations can be asserted also in json format for responses whose content type is 'application/json' or 'application/x-javascript'
****!

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET    | /resources/1.json | 200 |Content-Type : application/json;charset=ISO-8859-1 |!-
jsonbody.resource.name=='a funky name' <br/>
jsonbody.resource.data=='an important message'
-!|

!**** Rest requests with query string containing array parameters
A query string can contain parameter arrays and they are correctly handled by Rest Fixture.
****!

To allow correct handling of array parameters a new configuration option must be set: *http.client.use.new.http.uri.factory*

| Table: Rest Fixture Config  | withArrayParametersSupport|
| http.client.use.new.http.uri.factory | true |

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}| withArrayParametersSupport |
|GET    | /resources/0?a[0]=2&a[1]=4 | 200 | | |


!**** Follow redirects setting
To allow redirects to be followed automatically or not the configuration paramerer {{{restfixture.requests.follow.redirects}}} needs to be set (defaults to true)
****!
| Table: Rest Fixture Config  | withFollowRedirect|
| restfixture.requests.follow.redirects | false |

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}| withFollowRedirect |
|GET    | /resources/redirect/0 | 301 | Location: /resources/0 | no-body |

| Table: Rest Fixture Config  | withFollowRedirect|
| restfixture.requests.follow.redirects | true |

| Table: Rest Fixture |http://${jettyHost}:${jettyPort}| withFollowRedirect |
|GET    | /resources/redirect/0 | 200 | | |

