Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

CHOReOS Web Services FISL Conference Brazil 2012

1,238 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

CHOReOS Web Services FISL Conference Brazil 2012

  1. 1. ChoreUnit: Testing framework for Web Services Felipe Besson, Guilherme Nogueira, Leonardo Leite {besson, gmaio, leofl}@ime.usp.br Porto Alegre, July 2nd, 2011
  2. 2. Services ?
  3. 3. Product Vs Service
  4. 4. Product Vs Service
  5. 5. Web Services Message exchange standards (xml)among systems through Internet (http)
  6. 6. Web Services - Applications● Machine-machine communication 00111100 10111010 10111101 11110000
  7. 7. Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems
  8. 8. Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automationZ z z z z z z Z Z Comprar
  9. 9. Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automationZ z Service provider z z z z z Client Z Z Buy
  10. 10. Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automation● Data access WS
  11. 11. Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automation● Data access and creation (colaborative) WS
  12. 12. Now: billions of web pagesFuture: billions of web services
  13. 13. SOAP
  14. 14. WSDL<?xml version="1.0" encoding="UTF-8"?><definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="http://hello/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://hello/"name="HelloWorldService"><types> <xsd:schema> <xsd:import namespace="http://hello/" schemaLocation="http://localhost:8080/hello?xsd=1"></xsd:import> </xsd:schema></types><message name="sayHelloTo"> <part name="parameter" element="tns:sayHelloTo"></part></message><message name="sayHelloToResponse"> <part name="parameter" element="tns:sayHelloToResponse"></part></message><portType name="HelloWorld"> <operation name="sayHelloTo"> <input message="tns:sayHelloTo"></input> <output message="tns:sayHelloToResponse"></output> </operation></portType>
  15. 15. Web Services Clients in Java● Apache Axis2● Jax-WS (Java EE API)
  16. 16. WS Client with Jax-WS...<portType name="StoreWS"> <operation name="searchByArtist"> <input message="tns:searchByArtist"/> <output message="tns:searchByArtistResponse"/> </operation> <operation name="searchByGenre"> <input message="tns:searchByGenre"/> <output message="tns:searchByGenreResponse"/> </operation> <operation name="searchByTitle"> <input message="tns:searchByTitle"/> <output message="tns:searchByTitleResponse"/> </operation> <operation name="purchase"> <input message="tns:purchase"/> <output message="tns:purchaseResponse"/> </operation></portType>...
  17. 17. WS Client with Jax-WSpublic interface Store { List<CD> searchByArtist(String artist); List<CD> searchByGenre(String genre); List<CD> searchByTitle(String title); Boolean purchase(CD cd, Customer customer);}
  18. 18. WS Client with Jax-WS$wsimport -s src http://choreos.ime.usp.br/store?wsdl
  19. 19. WS Client with Jax-WS$wsimport -s src http://choreos.ime.usp.br/store?wsdl ObjectFactory package-info StoreWS StoreWSService CD Customer SearchByGenre SearchByGenreResponse SearchByTitle SearchByTitleResponse SearchByArtist SearchByArtistResponse Purchase
  20. 20. WS Client with Jax-WSStoreWSService service = new StoreWSService();StoreWS store = service.getStoreWSPort();List<CD> cds = store.searchByGenre("Rock");
  21. 21. TDDTest-driven development
  22. 22. TDD Make test passWrite test Refactoring
  23. 23. Our Framework
  24. 24. Stub creation can be a problemProcess: %$#@ 1. create stubs 2. add classes to project 3. understand classes Developer Service interface changed!
  25. 25. Problems when testing ● Tests must be almost completely rewritten ● Problem to integrate different services ● How to do TDD without stubs? %$#@
  26. 26. Our Goals Make testing web services easy ● Interact with web services without stubs ● Easily validate the operations responses ● Writing tests before the actual implementation ● Integrate tests and framework to the development environment
  27. 27. Overview
  28. 28. Usage (1)WSClient – dinamic client// criationWSClient service = new WSClient (String wsdl);// Invoking an operationItem resposta = service.request (String operation, Item parameters);
  29. 29. Usage (2)Item – recursive structure representing complextypes<n s: g etP r od u ctB y N am eR esp on se> <n s:r Ietu rrn xsi:ty p e=”ax26:I tem od u ctB y N am e”, “S occer tem esp on se = w s.r equ est( “g etP r ”> <bar cod e>153</ bar cod e> cleat”); <br an d >ad id as</ br an d > <d escr ip tionr>A on se.g etC h ild ( “r etution;> I tem item = esp cleat</ d escr ip r n ”) I tem .g etN am e( ) ; => “r etu r n ” <n am e>S occer cleat</ n ame”) ; => “ax26:I tem ” I tem .g ettag A ttr ibu te( “xsi:ty p e> <p r ice>90.0</ p r ice> <spitem .g etC h ild( </ sp or t>.g etC on ten t( ) ; => “153” or t>soccer “bar code”) I tem .g etC h ild( “br an d ”) .g etC on ten t( ) ; => “adid as” </ n s:rtem .gretC h ild( “descr ip tion ”) .g etC on ten t( ) ; => “A cleat” I etu n ></ n s:g etP r od u ctB y N am eR esp on se> …
  30. 30. Comparison
  31. 31. Conclusion WSClient code is bigger! ● Is it really?? ● No, Jax-WS code uses stubs that were previously generated =P
  32. 32. Demo
  33. 33. Next steps● Implement new features ● REST services support ● Integration test – Validate messages exchanged between services● Experimentation
  34. 34. Questions? This research has received finding from: More Information: http://ccsl.ime.usp.br/baile/VandV Repository: https://github.com/choreos/choreos_v-v/

×