Included page: .RestFixtureFitTests.SetUp (edit)
| Action Fixture | ||
| start | smartrics.rest.test.fitnesse.fixture.HttpServerFixture | |
| check | is started | true |
| press | reset resources database | |
Overriding content handlers
.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:
| Fit Rest Fixture | http://localhost:7654 | |||
| GET | /resources/0 | 200 | Content-Type : application/xml;.+ | /resource/name[text()='a funky name'] <br/> /resource/data[text()='an important message'] |
Bespoke mapping can be defined in the config using the config key restfixture.content.handlers.map
| smartrics.rest.fitnesse.fixture.RestFixtureConfig | overridesContentHandlerConfig |
| restfixture.content.handlers.map | application/xml=TEXT |
| Fit Rest Fixture | http://localhost:7654 | overridesContentHandlerConfig | ||
| GET | /resources/0 | 200 | Content-Type : application/xml;.+ | <resource>[\s.]*<name>a funky name</name>[\s\w\d<>/=\:'.]*</resource>[\s]* |