BPELUnit Tutorial - Testing a simple Hello BPEL Process
Remark: This tutorial has been created as part of the lecture "Development of Service-Oriented Architectures and Applications" (Entwicklung service-orientierter Architekturen und Anwendungen (SOA)).
This tutorial describes how to test a simple BPEL process with BPELUnit. It is assumed that you have already installed BPELUnit and that you know how to develop rudimentary BPEL processes and deploy them onto your BPEL engine.
This tutorial assumes ...
- that you can understand a simple BPEL process,
- that you are familiar with SOAP messages,
- that you have installed a BPEL server,
- that you have installed BPELUnit in Eclipse.
Course of Action
- Download and import the HelloBPEL process: Within this tutorial you will work with the HelloBPEL process from the first BPEL tutorial. To go ahead, download this process here. The version you can download is bundled with an Apache ODE deployment descriptor. However, the BPEL constructs used are so simple that you should be able to easily deploy this process on any server. If you are not familiar enough with BPEL, you can revisit the BPEL tutorials. After you have downloaded the archive, import it into Eclipse: Create a new project named
Importfrom the project's context menu. The process is very simple as you can see in the following picture: It just takes some input like
- Deploy the Process: Deploy the BPEL Process. If you experience difficulties and use Apache ODE, follow the instructions in this tutorial.
- Create a new Test Project: Create a new Eclipse project. The project does not need to have a special facade, therefore choose
File / New / Project / General / Projectand name the project
HelloBPELTest. Within this project, the BPELUnit test suite will be created.
- Create a new BPELUnit Test Suite: All test cases are defined in so-called Test Suites. Create a new test suite by choosing
File / New / Other / BPELUnit / BPELUnit Test Suite.
Place the suite in the suggested location. After you have successfully created the test suite, the Test Suite Editor should show up as illustrated in the following figure.
- Fill in Process Information: General information has to be entered in the test suite. The Base URL is unimportant for us now, just fill in
http://localhost:7777/ws. As the PUT (process under test) name, give
HelloBPEL. Because the BPEL process has been deployed manually beforehand, choose the
Fixed Deployeras the PUT type. The editor should now look like this:
- Specifying the BPEL WSDL: Because BPELUnit needs to call the BPEL process, the WSDL file that describes the service needs to be specified . Create a new folder
wsdlin the test project and copy the
HelloBPELArtifacts.wsdlfrom the HelloBPEL project there. Now you can choose the WSDL in the Test Suite Editor. Please be aware that the WSDL file has to contain the correct endpoint address for your process. If you have deployed the BPEL process differently (not on Apache ODE or on another host), you have to change the WSDL!
- Create a new Test Case: Because no other services are defined, leave the partners section empty and define the first test case: Choose
Add...in the Test Cases and Tracks section. Name the new Test Case
Donaldand do not alter the other settings. As you can see the test case
Donaldappears that has one partner
client. The client simulates a real client and will be responsible for calling the BPEL process.
- Send a Message to the Process: Select the
Add...but this time in the Activities section! Activities describe the test scenario. Therefore, you will add a new message exchange for the test case. Because there are a variety of possible message exchange patterns (MEPs), you have to choose how BPELUnit shall interact with the BPEL process. Because the process is a simple Receive-Reply process, choose
Send/Receive Synchronousas shown in the picture:
In the following dialog choose the port type, binding, and the operation (you only have one choice because it is a very simple process). More complicated is the XML to be sent as the payload of the SOAP message. You can inspect and define the XML namespaces by clicking on the namespaces link. BPELUnit has automatically defined
helas the prefix for the HelloBPEL process. Enter the following XML as the message payload:
<hel:HelloBPELProcessRequest> <hel:input>Donald</hel:input> </hel:HelloBPELProcessRequest>Your dialog should look like the one in the figure now:
nextfor defining the assertions for the response message. Assertitions consist of an XPath query and an expected value. Choose
//hel:resultas the XPath query and
'Hello Donald'as the expected value. Please be aware of the quotes that are necessary to denote that Donald is an XPath string. Your dialog should then look like in the following figure:
Finishto create the new activity.
- Run the Test Suite: Make sure your the HelloBPEL process is deployed and accessible and your BPELUnit Test Suite is saved. Select the
suite.bptsfile in the Project Explorer and choose
Run as / BPELUnit Test Suitefrom the context menu of the suite.bpts file. The BPELUnit view should appear, in which you can observe the progress of the test run. Like with the JUnit view, a green bar means that everything went fine and a red bar means that a test failed. If you have done everything correctly, you should see a green bar like in the picture:
In the bottom part of the BPELUnit view is an area for technical details. You can browse through the test run structure to inspect the SOAP messages, which were sent, and the assertions and their results.
Now you know the basics of testing with BPELUnit. You can experiment with your own new assertions and try some tests that fail so you can see how a failed test looks like.
Last Update: 2009-03-13 by Daniel Lübke