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.
ChoreUnit: Testing framework for
Web Services
Felipe Besson, Guilherme Nogueira, Leonardo Leite
{besson, gmaio, leofl}@ime...
Services
?
Product Vs Service
Product Vs Service
Web Services
Message exchange standards (xml)
among systems through Internet (http)
Web Services - Applications
● Machine-machine communication
00111100
10111010
10111101
11110000
Web Services - Applications
● Machine-machine communication
● Integrate heterogeneous systems
Web Services - Applications
● Machine-machine communication
● Integrate heterogeneous systems
● Business automation
Compra...
Web Services - Applications
● Machine-machine communication
● Integrate heterogeneous systems
● Business automation
Buy
Z
...
Web Services - Applications
● Machine-machine communication
● Integrate heterogeneous systems
● Business automation
● Data...
Web Services - Applications
● Machine-machine communication
● Integrate heterogeneous systems
● Business automation
● Data...
Now: billions of web pages
Future: billions of web services
SOAP
WSDL
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="htt...
Web Services Clients in Java
● Apache Axis2
● Jax-WS (Java EE API)
WS Client with Jax-WS
...
<portType name="StoreWS">
<operation name="searchByArtist">
<input message="tns:searchByArtist"/...
WS Client with Jax-WS
public interface Store {
List<CD> searchByArtist(String artist);
List<CD> searchByGenre(String genre...
WS Client with Jax-WS
$wsimport -s src http://choreos.ime.usp.br/store?wsdl
WS Client with Jax-WS
$wsimport -s src http://choreos.ime.usp.br/store?wsdl
ObjectFactory  
package­info   
StoreWS
StoreW...
WS Client with Jax-WS
StoreWSService service = new StoreWSService();
StoreWS store = service.getStoreWSPort();
List<CD> cd...
TDD
Test-driven development
TDD
Write test
Make test pass
Refactoring
Our Framework
Stub creation can be a problem
Process:
1. create stubs
2. add classes to
project
3. understand classes
Service interface
...
Problems when testing
● Tests must be almost completely
rewritten
● Problem to integrate different services
● How to do TD...
Our Goals
Make testing web services easy
● Interact with web services without stubs
● Easily validate the operation's resp...
Overview
Usage (1)
WSClient – dinamic client
// criation
WSClient service = new WSClient (String wsdl);
// Invoking an operation
It...
Usage (2)
Item – recursive structure representing
complex types
<ns: getProductByNameResponse>
<ns:return xsi:type=”ax26:I...
Comparison
Conclusion
WSClient code is bigger!
● Is it really??
● No, Jax-WS code uses stubs that were
previously generated =P
Demo
Next steps
● Implement new features
● REST services support
● Integration test
– Validate messages exchanged
between servi...
Questions?
This research has received finding from:
More Information: http://ccsl.ime.usp.br/baile/VandV
Repository: https...
Upcoming SlideShare
Loading in …5
×

ChorUnit Fisl 12

304 views

Published on

A tool for testing web services

Published in: Science
  • Be the first to comment

  • Be the first to like this

ChorUnit Fisl 12

  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 automation Comprar Z z z z z zz Z Z
  9. 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. 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 pages Future: 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-WS public 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        PurchaseResponse        
  20. 20. WS Client with Jax-WS StoreWSService service = new StoreWSService(); StoreWS store = service.getStoreWSPort(); List<CD> cds = store.searchByGenre("Rock");
  21. 21. TDD Test-driven development
  22. 22. TDD Write test Make test pass Refactoring
  23. 23. Our Framework
  24. 24. Stub creation can be a problem Process: 1. create stubs 2. add classes to project 3. understand classes Service interface changed! %$#@ Developer
  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 operation's 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 // criation WSClient service = new WSClient (String wsdl); // Invoking an operation Item resposta = service.request (String operation, Item parameters);
  29. 29. Usage (2) Item – recursive structure representing complex types <ns: getProductByNameResponse> <ns:return xsi:type=”ax26:Item”> <barcode>153</barcode> <brand>adidas</brand> <description>A cleat</description> <name>Soccer cleat</name> <price>90.0</price> <sport>soccer</sport> </ns:return> </ns:getProductByNameResponse> 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. 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/

×