40. curl -I http://foo.org/img/dog.jpg -HAccept:image/*
HTTP/1.1 406 Not Acceptable
Content-Length: 0
Verify that it is an image
406 —› Test failed
41. curl -I http://foo.org/blog/entries
-HAccept:application/atom+xml
HTTP/1.1 200 Ok
Content-Type: application/atom+xml
Verify that it is a collection
200 —› Test passed
50. GET /stock-quote/COKE HTTP/1.0
HTTP/1.0 200 Ok
Date: Wed, 3 Jun 2010 11:00:00 GMT
Content-Type: text/plain
Current weather in Berlin: 25 degrees
Celsius, sunny.
?
55. GET /orders/42 HTTP/1.0
Accept: application/order
HTTP/1.0 406 Not Acceptable
Date: Wed, 3 Jun 2010 11:00:00 GMT
Content-Type: text/plain
Media type application/order no longer
available. Try application/order.v2
?
57. TESTS
Resource
Level
•Does resource match link semantics?
•Is resource available over time?
•Are resource semantics stable over time?
•Are variants available over time?
59. What’s an application anyway?
•Buying a book in an online store
•Looking up a word in an online dictionary
•Taking an online exam
•Indexing a set of Web sites
•Checking for updates in monitored feeds
•Monitoring programming language
adoption using stackoverflow.com
61. GET /shop-home.html HTTP/1.0
Host: www.bestbookshop.com
HTTP/1.0 200 Ok
Content-Type: text/html
<html><body><p>
Sorry, buying is not possible here anymore.
Check out the store catalog at <a href=”/
catalog.html”/> and walk to one of our
stores. </p></body></html>
?
63. Application Level Tests
Does the service work
as expected by the application?
Testable only in context of the application. The server
cannot know how it is being re-used!
67. Resource
Level
•Does resource match link semantics?
•Is resource available over time?
•Are resource semantics stable over time?
•Are variants available over time?
Testing REST Web Services
Message
Level
•Correct HTTP syntax?
•Correct HTTP semantics?
•Correct payload syntax?
•Correct payload semantics?
68. Resource
Level
•Does resource match link semantics?
•Is resource available over time?
•Are resource semantics stable over time?
•Are variants available over time?
Testing REST Web Services
Application
Level
•Does service offer expected capability?
•Is the user goal reachable?
Message
Level
•Correct HTTP syntax?
•Correct HTTP semantics?
•Correct payload syntax?
•Correct payload semantics?
74. Server must...
•Conform to HTTP
•Conform to the media types used
•Resources must match link semantics
•Keep URIs around
•Keep resource semantics stable
•Maintain variants over time
•Maintain capabilities
78. Client may rely on...
•Message level correctness
•Resources matching link semantics
•Bookmarkable URIs
•Stable resource semantics
•Variant availability over time
•Stable service nature