With the release of Soa Suite 11g you can make a unit tests to test your Soa Composite Application. In this blog I will show all the steps you have to do, to make a successfull unit test. For this I made a simple Composite application which retrieves the last name of an employee. The Composite application with an exposed BPEL process has EmployeeId as input and BPEL invokes a database adapter to get the Employee’s lastname and return this as response.
First we start by making a XML schema with a input and response element
Add a BPEL process to the Composite xml and use the above XML schema as input and output and expose this BPEL as a webservice. After this I created a Database adapter which has employeeId as input and returns the lastname of the employee. Add a wire between the BPEL process and the Database adapter so I can invoke this adapter in the BPEL process
Open the BPEL process and add the invoke operation. I use an assign operation to fill the input variable of the database adapter and an other assign operation to retrieve the lastname and add this to the response of the BPEL process
The employee Composite application is finished and now I can create a new Test Suite.
The Test Suite creates a copy of the Composite xml.
Select the Exposed Service where we can create a new input request
In this dialog I can generate a sample xml and change the EmployeeId with a real value
Select the wire of the database adapter where we add a input and output assertion so the unit test can compare this to the adapter values
First we create the input assert, use the generate Sample button and change the employeeId value
Do the same for the output of the Database adapter.
Do the same for the exposed Service and the BPEL process
In this wire I want to compare the output of the BPEL process with the Callback Assert.
Now we only have to deploy the whole composite application. The just created Test Suite is part of this deployment.
To test this unit test I have to go to the new improved EM website of the Soa Suite server where I can select the Employee Composite
Select the Unit Test tab of the Employee Composite and select the testcase and press the Execute Button
Take a look at the Test Runs to see the results of the test.
We can see the test4 is successfull and the assertions are succesfull too.
Finally we can compare the expected and actual Value by selecting an assertion