Class TravelAgencyWSTest { BASE_URL = “localhost:9881/travelagency”; private RESTClient client;...

1
class TravelAgencyWSTest { BASE_URL = “localhost:9881/travelagency”; private RESTClient client; @BeforeClass public static void publishWS() { Bash.deployService(“travelAgency”); client = new RESTClient(); client.setBaseURL(BASE_URL);} @Test public void shouldRetriveCreditCardNumber() { body = “John|421543-2”; client.POST(“/users”, body); response = client.GET(“/users?name=John”); assertEquals(“421543-2”, response); } … Introduction Supporting Test-Driven Development of Web Service Supporting Test-Driven Development of Web Service Choreographies Choreographies Felipe Besson, Pedro Leal, Fabio Kon and Alfredo Goldman {besson, pedrombl, fabio.kon, gold}@ime.usp.br Department of Computer Science - IME - University of São Paulo Deja Milojicic - [email protected] Hewlett Packard Laboratories Unit Testing Ongoing work Goals Integration Testing Acknowledgments References Inherent characteristics of Service-Oriented Architecture (SOA) such as dynamicity, lack of observability of the service code and structure, difficulties in interoperability, and third party participants makes traditional testing techniques inappropriate [1]. We aim to develop a testing framework for supporting Test-Driven Development (TDD) [2] of choreographies. During the development, the framework will provide features for automated testing of: Isolated services; Messages exchanged within the choreography; The entire choreography. Also, the testing framework shall provide mechanisms for enacting (starting) and stopping the choreography automatically on a cloud environment, e.g., Open Cirrus or Amazon EC2 [1] G. Canfora and M. Di Penta. Service-oriented architectures testing: A survey. In A. De Lucia and F. Ferrucci, editors, Software Engineering, volume 5413 of LNCS, pages 78–105. Springer, 2009. [2] Kent Beck. Test Driven Development: By Example. Addison-Wesley Professional, 2002. [3] OMG. Business Process Model and Notation. Available on: http://www.bpmn.org/. [4] OpenKnowledge Project. Available on: http://www.openk.org/ This work represents our first efforts to achieve our goals. Our prototype consists of: Ad hoc bash scripts for the Book Trip choreography deployment and enactment on a distributed environment (using OpenKnowledge [4]); A set of JUnit test cases for automated testing of this choreography (see the tests below); Every operation of each service participating in the choreography is tested: 1. Developer activates the choreography, invoking service A; 2. Messages are exchanged between services A and B; 3. Output messages from B are intercepted; 4. Messages are stored in a queue; 5. Collected data is validated. We are extending our prototype by providing features for: Generating web service clients dynamically; Manipulating the elements (roles, messages, services) of a choreography more easily; Mocking third-party services and choreography parts; Improving the interception and validation of exchanged messages. Automating the deployment and enactment of choreographies on a cloud environment Acceptance Testing The choreography is tested from the user perspective. In this context, the choreography is accessible as an atomic service, and each test exercises an entire conversation as a unit. Before the acceptance testing execution, the prototype deploys and enacts the choreography in a distributed environment. The steps of testing More information: http://ccsl.ime.usp.br/baile/VandV This research is funded by: Code Example Our Prototype class AirlineWSTest { private AirlineWSClient stub; @BeforeClass public static void publishWS() { Bash.deployService(“airline”); } @Test public void shouldFindFlight() { flight = airlineWS.getFlight(“Moscow”, …); assertEquals(“3810”, flight.getId()); assertEquals(“Moscow”, flight.getDest()); assertEquals(“06-01-11”, flight.getDate()); assertEquals(“09:15”, flight.getTime()); } … SOAP Service REST Service each service messages exchanged entire choreography Testing code of example above: A global view of a choreography in BPMN2 [3] for planning and booking a trip. Book Trip Choreography Global View Integration Test Example This example shows a situation where only integration tests would find the bug in the system. In this case, the acquirer service only works with dollar amounts. When it receives the message with the content in the Brazilian currency, it mistakenly interprets the value as dollar. Integration testing code that discover the error above: Overhead Evaluation The integration testing approach must collect the messages exchanged among the services. Such procedure might cause an overhead in the choreography execution. Here, we present a quantitative assessment to evaluate possible overheads: •We compared the execution time of a choreography functionality using and not using our approach •We used a simple interaction operation (orderTrip operation with 4 messages exchanged) •It was executed in a cluster. Each web service was allocated on a dedicated node •Execution time for 1, 2, 4, 8, and 16 sequential executions •30 samples for each one Results The overhead is smaller than the standard deviation (between parentheses). Thus, the overhead is negligible. Since we do not net need to store the entire XML- Soap message but only its content, the message monitoring process is relatively fast. AStub.sendMessageToC(“x”, “Hello!”); String actualContent = queue.get(“B”, “C”, “x’”); assertEquals(“Hello!”, actualContent); travelerStub.bookReserve(reserve); String expected = queue.get(“airline”, “travelagency”, “value_paid”); assertEquals(“BRL 2000”, expected); Web service choreographies have been proposed as a decentralized, scalable way of composing services.

Transcript of Class TravelAgencyWSTest { BASE_URL = “localhost:9881/travelagency”; private RESTClient client;...

Page 1: Class TravelAgencyWSTest { BASE_URL = “localhost:9881/travelagency”; private RESTClient client; @BeforeClass public static void publishWS() { Bash.deployService(“travelAgency”);

class TravelAgencyWSTest {

BASE_URL = “localhost:9881/travelagency”;private RESTClient client;

@BeforeClasspublic static void publishWS() {

Bash.deployService(“travelAgency”);client = new RESTClient();client.setBaseURL(BASE_URL);}

…@Testpublic void shouldRetriveCreditCardNumber() {

body = “John|421543-2”;client.POST(“/users”, body);response = client.GET(“/users?name=John”);assertEquals(“421543-2”, response);

} …

Introduction

Supporting Test-Driven Development of Web Service Supporting Test-Driven Development of Web Service ChoreographiesChoreographies

Felipe Besson, Pedro Leal, Fabio Kon and Alfredo Goldman {besson, pedrombl, fabio.kon, gold}@ime.usp.br

Department of Computer Science - IME - University of São PauloDeja Milojicic - [email protected]

Hewlett Packard Laboratories

Unit Testing

Ongoing work

Goals Integration Testing

AcknowledgmentsReferences

Inherent characteristics of Service-Oriented Architecture (SOA) such as dynamicity, lack of observability of the service code and structure, difficulties in interoperability, and third party participants makes traditional testing techniques inappropriate [1].

We aim to develop a testing framework for supporting Test-Driven Development (TDD) [2] of choreographies. During the development, the framework will provide features for automated testing of:

Isolated services; Messages exchanged within the choreography; The entire choreography.

Also, the testing framework shall provide mechanisms for enacting (starting) and stopping the choreography automatically on a cloud environment, e.g., Open Cirrus or Amazon EC2

[1] G. Canfora and M. Di Penta. Service-oriented architectures testing: A survey. In A. De Lucia and F. Ferrucci, editors, Software Engineering, volume 5413 of LNCS, pages 78–105. Springer, 2009. [2] Kent Beck. Test Driven Development: By Example. Addison-Wesley Professional, 2002.[3] OMG. Business Process Model and Notation. Available on: http://www.bpmn.org/.[4] OpenKnowledge Project. Available on: http://www.openk.org/

This work represents our first efforts to achieve our goals. Our prototype consists of:Ad hoc bash scripts for the Book Trip choreography

deployment and enactment on a distributed environment (using OpenKnowledge [4]);

A set of JUnit test cases for automated testing of this choreography (see the tests below);

Every operation of each service participating in the choreography is tested:

1. Developer activates the choreography, invoking service A;2. Messages are exchanged between services A and B;3. Output messages from B are intercepted;4. Messages are stored in a queue;5. Collected data is validated.

We are extending our prototype by providing features for: Generating web service clients dynamically; Manipulating the elements (roles, messages, services) of a choreography more

easily; Mocking third-party services and choreography parts; Improving the interception and validation of exchanged messages. Automating the deployment and enactment of choreographies on a cloud

environment

Acceptance TestingThe choreography is tested from the user perspective. In this context, the choreography is accessible as an atomic service, and each test exercises an entire conversation as a unit.

Before the acceptance testing execution, the prototype deploys and enacts the choreography in a distributed environment.

The steps of testing

More information: http://ccsl.ime.usp.br/baile/VandV

This research is funded by:

Code Example

Our Prototype

class AirlineWSTest {

private AirlineWSClient stub;

@BeforeClasspublic static void publishWS() {

Bash.deployService(“airline”); }…@Testpublic void shouldFindFlight() {

flight = airlineWS.getFlight(“Moscow”, …);assertEquals(“3810”, flight.getId());assertEquals(“Moscow”, flight.getDest());assertEquals(“06-01-11”, flight.getDate());assertEquals(“09:15”, flight.getTime());

} …

SOAP ServiceREST Service

each service messages exchanged entire choreography

Testing code of example above:

A global view of a choreography in BPMN2 [3] for planning and booking a trip.

Book Trip Choreography

Global View

Integration Test ExampleThis example shows a situation where only integration tests would find the bug in the system. In this case, the acquirer service only works with dollar amounts. When it receives the message with the content in the Brazilian currency, it mistakenly interprets the value as dollar.

Integration testing code that discover the error above:

Overhead EvaluationThe integration testing approach must collect the messages exchanged among the services. Such procedure might cause an overhead in the choreography execution. Here, we present a quantitative assessment to evaluate possible overheads:

•We compared the execution time of a choreography functionality using and not using our approach•We used a simple interaction operation (orderTrip operation with 4 messages exchanged)•It was executed in a cluster. Each web service was allocated on a dedicated node•Execution time for 1, 2, 4, 8, and 16 sequential executions•30 samples for each one

Results

The overhead is smaller than the standard deviation (between parentheses). Thus, the overhead is negligible. Since we do not net need to store the entire XML-Soap message but only its content, the message monitoring process is relatively fast.

AStub.sendMessageToC(“x”, “Hello!”);

String actualContent = queue.get(“B”, “C”, “x’”);assertEquals(“Hello!”, actualContent);

travelerStub.bookReserve(reserve);

String expected = queue.get(“airline”, “travelagency”,

“value_paid”);assertEquals(“BRL 2000”, expected);

Web service choreographies have been proposed as a decentralized, scalable way of composing services.