FitNesseRoot.RestFixtureTests.OverrideContentHandlers.content.txt Maven / Gradle / Ivy
.RestFixture uses three content handlers to parse and set expectations used to verify the behaviour of HTTP calls.
These are the handlers currently available:
* '''XML''' interprets the body as an xml string and allows XPath expressions as expectations on that content
* '''JSON''' interprets the body as a JSON string and allows expectations to be written in JavaScript.
* '''TEXT''' interprets the body as a string and allows regular expression expectations.
These are the defaults
* default=XML
* application/xml=XML
* application/json=JSON
* text/plain=TEXT
!*** Note: unrecognised content types.
Content types not recogised will be mapped to the default content handler (XML).
***!
For example, XML handler is used for for content types of application/xml; hence XPaths can be used to set expectations:
| Table: Rest Fixture |http://${jettyHost}:${jettyPort}|
|GET | /resources/0 | 200 | Content-Type : application/xml;.+ |!-
/resource/name[text()='a funky name']
/resource/data[text()='an important message']
-!|
Bespoke mapping can be defined in the config using the config key '''restfixture.content.handlers.map'''
| Table: Rest Fixture Config | overridesContentHandlerConfig |
| restfixture.content.handlers.map | !-
application/xml=TEXT
-!|
| Table: Rest Fixture |http://${jettyHost}:${jettyPort}| overridesContentHandlerConfig |
|GET | /resources/0 | 200 | Content-Type : application/xml;.+ |[\s.]*a funky name [\s\w\d<>/=\:'.]* [\s]*|