CHOReOS Web Services FISL Conference Brazil 2012
-
Upload
choreos -
Category
Technology
-
view
1.122 -
download
0
description
Transcript of CHOReOS Web Services FISL Conference Brazil 2012
![Page 1: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/1.jpg)
ChoreUnit: Testing framework for Web Services
Felipe Besson, Guilherme Nogueira, Leonardo Leite{besson, gmaio, leofl}@ime.usp.br
Porto Alegre, July 2nd, 2011
![Page 2: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/2.jpg)
Services
?
![Page 3: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/3.jpg)
Product Vs Service
![Page 4: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/4.jpg)
Product Vs Service
![Page 5: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/5.jpg)
Web Services
Message exchange standards (xml) among systems through Internet (http)
![Page 6: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/6.jpg)
Web Services - Applications● Machine-machine communication
0011110010111010
1011110111110000
![Page 7: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/7.jpg)
Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems
![Page 8: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/8.jpg)
Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automation
Comprar
Zz
z
zz
zz
Z
Z
![Page 9: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/9.jpg)
Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automation
Buy
Zz
z
zz
zz
Z
Z
Service provider
Client
![Page 10: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/10.jpg)
Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automation● Data access
WS
![Page 11: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/11.jpg)
Web Services - Applications● Machine-machine communication● Integrate heterogeneous systems● Business automation● Data access and creation (colaborative)
WS
![Page 12: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/12.jpg)
Now: billions of web pages
Future: billions of web services
![Page 13: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/13.jpg)
SOAP
![Page 14: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/14.jpg)
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>
![Page 15: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/15.jpg)
Web Services Clients in Java
● Apache Axis2● Jax-WS (Java EE API)
![Page 16: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/16.jpg)
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>...
![Page 17: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/17.jpg)
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);
}
![Page 18: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/18.jpg)
WS Client with Jax-WS
$wsimport -s src http://choreos.ime.usp.br/store?wsdl
![Page 19: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/19.jpg)
WS Client with Jax-WS
$wsimport -s src http://choreos.ime.usp.br/store?wsdl
ObjectFactory package-info StoreWSStoreWSServiceCDCustomerSearchByGenre SearchByGenreResponse SearchByTitle SearchByTitleResponseSearchByArtist SearchByArtistResponse Purchase PurchaseResponse
![Page 20: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/20.jpg)
WS Client with Jax-WS
StoreWSService service = new StoreWSService();StoreWS store = service.getStoreWSPort();
List<CD> cds = store.searchByGenre("Rock");
![Page 21: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/21.jpg)
TDD
Test-driven development
![Page 22: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/22.jpg)
TDD
Write test
Make test pass
Refactoring
![Page 23: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/23.jpg)
Our Framework
![Page 24: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/24.jpg)
Stub creation can be a problem
Process:
1. create stubs
2. add classes to project
3. understand classes
Service interfacechanged!
%$#@
Developer
![Page 25: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/25.jpg)
Problems when testing
● Tests must be almost completely rewritten
● Problem to integrate different services● How to do TDD without stubs?
%$#@
![Page 26: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/26.jpg)
Our GoalsMake 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
![Page 27: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/27.jpg)
Overview
![Page 28: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/28.jpg)
Usage (1)
WSClient – dinamic client
// criationWSClient service = new WSClient (String wsdl);
// Invoking an operationItem resposta = service.request (String operation,
Item parameters);
![Page 29: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/29.jpg)
Usage (2)
Item – recursive structure representing complex types
<ns: getProductB yN am eR esponse> <ns:return xsi:type=”ax26:I tem ”> <barcode>153</barcode> <brand>adidas</brand> <descr iption>A cleat</descr iption> <nam e>S occer cleat</nam e> <pr ice>90.0</pr ice> <spor t>soccer</spor t> </ns:return></ns:getProductB yN am eR esponse>
I tem response = w s.request( “getProductB yN am e”, “S occer cleat”);I tem response = w s.request( “getProductB yN am e”, “S occer cleat”);
I tem item = response.getChild( “return”) ;I tem .getN am e( ) ; => “return”I tem .gettagA ttr ibute( “xsi:type”) ; => “ax26:I tem ”
I tem response = w s.request( “getProductB yN am e”, “S occer cleat”);
I tem item = response.getChild( “return”) ;I tem .getN am e( ) ; => “return”I tem .gettagA ttr ibute( “xsi:type”) ; => “ax26:I tem ”
item .getChild( “barcode”) .getContent( ) ; => “153”I tem .getChild( “brand”) .getContent( ) ; => “adidas”I tem .getChild( “descr iption”) .getContent( ) ; => “A cleat”…
![Page 30: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/30.jpg)
Comparison
![Page 31: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/31.jpg)
Conclusion
WSClient code is bigger!● Is it really??● No, Jax-WS code uses stubs that were
previously generated =P
![Page 32: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/32.jpg)
Demo
![Page 33: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/33.jpg)
Next steps● Implement new features
● REST services support● Integration test
– Validate messages exchanged between services
● Experimentation
![Page 34: CHOReOS Web Services FISL Conference Brazil 2012](https://reader033.fdocuments.us/reader033/viewer/2022051323/5471cc52b4af9fa30a8b4d00/html5/thumbnails/34.jpg)
Questions?
This research has received finding from:
More Information: http://ccsl.ime.usp.br/baile/VandVRepository: https://github.com/choreos/choreos_v-v/