Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Testing REST Web Services at DEVOXX 2010

on

  • 1,165 views

 

Statistics

Views

Total Views
1,165
Views on SlideShare
1,165
Embed Views
0

Actions

Likes
0
Downloads
39
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Welcome. <br />
  • My name is Jan Algermissen. I am working as a software architect and consultant focussing on Enterprise REST. On solving classic enterprise IT problems with Web architecture. <br /> <br /> Contact Information on Intro slide. <br /> <br /> If you asked me, how well REST and the Enterprise fit together it comes as now surprise that to me personally they a re a perfect couple. <br /> <br /> <br />
  • There you have it - pure harmony. <br /> <br /> However I also think that a number of aspects of REST need more explanation to make the whole concept suitable for Enterprise development. <br /> <br /> To me, one of these aspects is testing so this is the basic motivation behind this talk. <br /> <br /> Agenda: <br /> 1. Look at contract between client and server that exists in RESTful systems <br /> 2. Explore expectations made by clients <br /> 3. Introduce a method for testing. <br /> <br /> Q. <br /> Who knows what REST is? <br /> Who has created enterprise production systems that use REST? <br /> Have you developed a dedicated testing process? <br /> And who is only here to learn about REST? <br /> <br /> I like to start out with a rather bold statement: <br /> <br /> <br />
  • The precondition for testing is having a contract. <br /> <br /> Contract is the basis for expectations. <br /> <br /> Expectations is what we are going to test. <br /> <br /> Let&#x2019;s explore the contract. <br /> <br />
  • RPC Style integration. Every provider has a special contract the consumer has to understand (implement). <br /> <br /> This leads to undesirable coupling and eventually makes evolving the system very difficult. <br /> <br /> One of the primary design goals of REST is to improve this situation. <br /> <br />
  • REST eliminates all service specific contract. <br /> <br /> Moves it to a global space. E.g. IANA, in case of the World Wide Web. <br /> <br /> Consequence is that there are no service specific contracts anymore and therefore no coupling between individual clients and servers. <br /> <br /> REST eliminates all service descriptions. <br />
  • No idl, no wsdl, no wadl, not even html because there is nothing to describe. <br /> <br />
  • No idl, no wsdl, no wadl, not even html because there is nothing to describe. <br /> <br />
  • No idl, no wsdl, no wadl, not even html because there is nothing to describe. <br /> <br />
  • No idl, no wsdl, no wadl, not even html because there is nothing to describe. <br /> <br />
  • <br />
  • So then - how and what to test. <br /> <br /> And what is informing the client developer about what she is allowed to do? <br /> <br /> Does this mean that a server developer can basically do *anything*? <br /> <br /> Let&#x2019;s look at expectations once more. <br /> <br /> Since communication exists between client and server there surely is some shared knowledge. Based on that knowledge the client makes assumptions about the server. <br /> <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Is that right? <br /> <br /> Did some digging through the mailing lists and came up with the following interesting quote: <br />
  • Where do these expectations come from? <br /> <br /> First, the server is telling us something about the resources! <br />
  • <br />
  • <br />
  • <br />
  • Another source to learn about expectations about resources is Tim Berners Lee&#x2019;s classic Web design article: &#x201C;Cool URIs Don&#x2019;t change&#x201D;. <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Testing process running over time. <br /> <br /> Accumulating information in turn used for testing. <br /> <br /> Continuous operation or explicit activation. <br /> <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Questions? <br />

Testing REST Web Services at DEVOXX 2010 Testing REST Web Services at DEVOXX 2010 Presentation Transcript

  • Testing REST Web Services Jan Algermissen, NORD Software Consulting
  • Jan Algermissen “Applying the Web to Enterprise IT” @algermissen http://www.nordsc.com/blog http://www.nordsc.com
  • REST & The Enterprise
  • TESTING REQUIRES CONTRACT
  • RPC Styles Server Client Server Server
  • RPC Styles Server Client Server Server
  • REST e.g. IANA Server Client Server Server
  • IDL WSDL WADL HTML
  • IDL WSDL WADL HTML
  • IDL WSDL WADL HTML
  • IDL WSDL WADL HTML
  • IDL WSDL WADL HTML
  • NO SERVICE DESCRIPTIONS!
  • TESTING ???
  • Expectations Client Server
  • Expectations Client Server
  • Expectation Levels
  • Expectation Levels Message
  • Expectation Levels Resource Message
  • Expectation Levels Application Resource Message
  • Expectation Levels Application Resource Message
  • Expectation Levels Application Resource Message
  • Expectations about resources...?
  • “The notion that REST-based user agents can't have expectations of a resource is clearly false.” -- Roy Fielding
  • <img src=”/dog.jpg”/>
  • <app:collection href=”/orders/”/>
  • <OpenSearchDescription> <Url type=”application/rss+xml” template=”/search?q={searchTerms}”/> </OpenSearchDescription>
  • Expectation: Link semantics match resource semantics
  • Cool URIs Don’t Change!
  • Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 HTTP/1.0 200 Ok Content-Type: text/plain 49.5 Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 HTTP/1.0 404 Not Found Content-Type: text/plain Nothing found that matches the request URI. Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 HTTP/1.0 404 Not Found Content-Type: text/plain Nothing found that matches the request URI. Monday Tuesday
  • Expectation: Resources do not just disappear
  • Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 HTTP/1.0 200 Ok Content-Type: text/plain 49.5 Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 HTTP/1.0 200 Ok Content-Type: text/plain Current weather in Berlin: 25 degrees Celsius, sunny. Monday Tuesday
  • GET /stock-quote/COKE HTTP/1.0 HTTP/1.0 200 Ok Content-Type: text/plain Current weather in Berlin: 25 degrees Celsius, sunny. Monday Tuesday
  • Expectation: Resource semantics do not change
  • Monday Tuesday
  • GET /orders/42 HTTP/1.0 Accept: application/order Monday Tuesday
  • GET /orders/42 HTTP/1.0 Accept: application/order HTTP/1.0 200 Ok Content-Type: application/order <order> ... </order> Monday Tuesday
  • GET /orders/42 HTTP/1.0 Accept: application/order Monday Tuesday
  • GET /orders/42 HTTP/1.0 Accept: application/order HTTP/1.0 406 Not Acceptable Content-Type: text/plain Media type application/order no longer available. Try application/ order.v2 Monday Tuesday
  • GET /orders/42 HTTP/1.0 Accept: application/order HTTP/1.0 406 Not Acceptable Content-Type: text/plain Media type application/order no longer available. Try application/ order.v2 Monday Tuesday
  • Expectation: Variants remain available
  • Resource Level Expectations
  • Resource Level Expectations Correct link semantics
  • Resource Level Expectations Correct link semantics Stable resources
  • Resource Level Expectations Correct link semantics Stable resources Stable resource semantics
  • Resource Level Expectations Correct link semantics Stable resources Stable resource semantics Variant availability
  • Intermission
  • Intermission Contract
  • Intermission Contract Expectations
  • Intermission Contract Expectations RESTful Testing Methodology
  • Aspects of RESTful Testing
  • Aspects of RESTful Testing Start URI Set
  • Aspects of RESTful Testing Start URI Set Crawling
  • Aspects of RESTful Testing Start URI Set Crawling Discover URIs
  • Aspects of RESTful Testing Start URI Set Extract Statements Crawling Discover URIs
  • Aspects of RESTful Testing Start URI Set Extract Statements Crawling Message Tests Discover URIs
  • Aspects of RESTful Testing Start URI Set Extract Statements Crawling Message Tests Discover URIs Resource Semantics
  • Aspects of RESTful Testing Start URI Set Extract Statements Crawling Message Tests Discover URIs Resource Semantics Regression Tests
  • Resources
  • Resources Known resource semantics
  • Resources Known resource semantics Track resources and variants
  • Resources Message level test results Known resource semantics Track resources and variants
  • Resources Message level test results Known resource Resource semantics semantic test results Track resources and variants
  • Resources Message level test results Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test results Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Regression test and variants results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Resource semantics match Regression test and variants known link semantics? results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Resource semantics match Regression test and variants known link semantics? results
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Resource semantics match Regression test and variants known link semantics? results Test resource stability over time
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Resource semantics match Regression test and variants known link semantics? results Test resource stability over time
  • Resources Message level test Crawl start set results Test message level Known resource Resource semantics Extract additional entry URIs semantic test results Extract statements about other URIs Track resources Resource semantics match Regression test and variants known link semantics? results Test resource stability over time
  • “Self-Feeding” Testing Loop
  • Message Level Tests HTTP HTTP Entity Entity Resource Variant Date Syntax Semantic Syntax Semantic 10-10-2010 http://srv/customer-search application/atom+xml 12:00:00 ok ok ok ok 10-10-2010 application/rss+xml 12:00:00 ok ok fail 10-10-2010 http://srv/orders/ application/atom+xml 12:00:00 ok ok ok fail 10-10-2010 http://srv/orders/42 application/order 12:00:00 ok ok ok ok 10-10-2010 http://srv/invoices/123 text/uri-list 12:00:00 ok ok ok ok
  • Resource Semantics Test Resource Date Semantic Test Remark 10-10-2010 Available as Atom feed http://srv/customer-search 12:00:00 OpenSearch Search Result ok Available as RSS feed 10-10-2010 Available as Atom feed http://srv/orders/ 12:00:00 AtomPub Collection ok Accepts application/order Available as application/order 10-10-2010 http://srv/orders/42 12:00:00 Procurement Order ok Allows GET, PUT, PATCH, DELETE Not available in any recognized invoice 10-10-2010 media type, such as application/invoice http://srv/invoices/123 12:00:00 Procurement Invoice fail or application/pdf. Available only as text/uri-list
  • Regression Tests Stable Variant Resource Variant Date Found? Semantic? Available? 10-10-2010 http://srv/customer-search application/atom+xml 12:00:00 ok ok ok 10-10-2010 application/rss+xml 12:00:00 - - ok 10-10-2010 http://srv/orders/ application/atom+xml 12:00:00 ok ok ok 10-10-2010 http://srv/orders/42 application/order 12:00:00 ok ok ok 10-10-2010 http://srv/invoices/123 text/uri-list 12:00:00 ok ok ok 10-10-2010 http://srv/orders/pending application/atom+xml 12:00:00 ok ok ok 10-10-2010 application/rss+xml 12:00:00 - - fail 10-10-2010 http://srv/orders/2010/08 application/atom+xml 12:00:00 fail fail fail 10-10-2010 text/uri-list 12:00:00 fail fail fail
  • Take Aways •Surprising amount of things to test •REST constrains over time •Servers are rather constrained •Yet still, facilitation of change
  • Happy testing!