ChorUnit Fisl 12

download ChorUnit Fisl 12

If you can't read please download the document

Transcript of ChorUnit Fisl 12

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. Services ? 3. Product Vs Service 4. Product Vs Service 5. Web Services Message exchange standards (xml) among systems through Internet (http) 6. Web Services - Applications Machine-machine communication 00111100 10111010 10111101 11110000 7. Web Services - Applications Machine-machine communication Integrate heterogeneous systems 8. Web Services - Applications Machine-machine communication Integrate heterogeneous systems Business automation Comprar Z z z z z zz Z Z 9. Web Services - Applications Machine-machine communication Integrate heterogeneous systems Business automation Buy Z z z z z zz Z Z Service provider Client 10. Web Services - Applications Machine-machine communication Integrate heterogeneous systems Business automation Data access WS 11. Web Services - Applications Machine-machine communication Integrate heterogeneous systems Business automation Data access and creation (colaborative) WS 12. Now: billions of web pages Future: billions of web services 13. SOAP 14. WSDL 15. Web Services Clients in Java Apache Axis2 Jax-WS (Java EE API) 16. WS Client with Jax-WS ... ... 17. WS Client with Jax-WS public interface Store { List searchByArtist(String artist); List searchByGenre(String genre); List searchByTitle(String title); Boolean purchase(CD cd, Customer customer); } 18. WS Client with Jax-WS $wsimport -s src http://choreos.ime.usp.br/store?wsdl 19. WS Client with Jax-WS $wsimport -s src http://choreos.ime.usp.br/store?wsdl ObjectFactory packageinfo StoreWS StoreWSService CD Customer SearchByGenre SearchByGenreResponse SearchByTitle SearchByTitleResponse SearchByArtist SearchByArtistResponse Purchase PurchaseResponse 20. WS Client with Jax-WS StoreWSService service = new StoreWSService(); StoreWS store = service.getStoreWSPort(); List cds = store.searchByGenre("Rock"); 21. TDD Test-driven development 22. TDD Write test Make test pass Refactoring 23. Our Framework 24. Stub creation can be a problem Process: 1. create stubs 2. add classes to project 3. understand classes Service interface changed! %$#@ Developer 25. Problems when testing Tests must be almost completely rewritten Problem to integrate different services How to do TDD without stubs? %$#@ 26. Our Goals Make testing web services easy Interact with web services without stubs Easily validate the operation's responses Writing tests before the actual implementation Integrate tests and framework to the development environment 27. Overview 28. Usage (1) WSClient dinamic client // criation WSClient service = new WSClient (String wsdl); // Invoking an operation Item resposta = service.request (String operation, Item parameters); 29. Usage (2) Item recursive structure representing complex types 153adidasA cleatSoccer cleat90.0soccer Item response = ws.request(getProductByName, Soccer cleat); Item response = ws.request(getProductByName, Soccer cleat); Item item = response.getChild(return); Item.getName(); => return Item.gettagAttribute(xsi:type); => ax26:Item Item response = ws.request(getProductByName, Soccer cleat); Item item = response.getChild(return); Item.getName(); => return Item.gettagAttribute(xsi:type); => ax26:Item item.getChild(barcode).getContent(); => 153 Item.getChild(brand).getContent(); => adidas Item.getChild(description).getContent(); => A cleat 30. Comparison 31. Conclusion WSClient code is bigger! Is it really?? No, Jax-WS code uses stubs that were previously generated =P 32. Demo 33. Next steps Implement new features REST services support Integration test Validate messages exchanged between services Experimentation 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/