Rest Fixture sample
 | Only available in Java
|
Here is an example of a fixture to test Rest web services.
RestFixture code can be found in greenpepper-extension-sandbox : RestFixture.java
RestFixture support GET POST DELETE PUT HEAD HTTP methods.
Available readable properties are responseHeader(headerName) responseBody responseStatus
| Import |
| com.greenpepper.extensions |
GET example
| GET |
/helloworld |
| check |
response status |
200 |
| check |
response header |
Content-Type |
text/plain |
| check |
response body |
Hello World |
| GET |
/unknown |
| check |
response status |
404 |
POST example (create resource)
| set request body |
Hello GreenPepper |
| GET |
/messages/0 |
| check |
response status |
200 |
| check |
response body |
Hello GreenPepper |
| set request header |
Accept |
as |
application/xml |
| GET |
/messages/0 |
| check |
response status |
200 |
| check |
response body |
<?xml version="1.0"><message id="0" value="Hello GreenPepper" />
|
PUT example (update resource)
| set request body |
Hello from GreenPepper |
| PUT |
/messages/0 |
| check |
response status |
200 |
| GET |
/messages/0 |
| check |
response body |
Hello from GreenPepper |
HEAD example (check if specified resource exists)
| HEAD |
/messages/0 |
| check |
response status |
200 |
| HEAD |
/messages/1 |
| check |
response status |
404 |
DELETE example
| DELETE |
/messages/0 |
| check |
response status |
200 |
| GET |
/messages/0 |
| check |
response status |
404 |