Introducing the built-in testing framework
Oracle SOA Suite 11g provides a testing framework that allows you to:
- Define tests, assertions, and emulations using JDeveloper
- Run these tests either from the EM console or on the command line using ANT
- Review the test results from the EM console or as a JUnit report
There are three parts to a test case:
- An Initiation of a composite defines the service and operation invoked along with the test data.
defines the message or fault returned from a reference or component
invoked through a synchronous response or a callback without executing
the component or referenced service.
- An Assertion compares the message or part of the message over an SCA wire against the expected data.
A single test includes definitions of the initiation,
emulations, and assertions. The test suite is defined in the composite
project and is deployed along with the composite to the server, so it
can be initiated from the EM console.
Tutorial: Automated unit testing
The best way to learn how to build and execute a unit test is to try an example.
Modify POProcessing to add a unit test, which sets the inbound
message, the simulation message, and two assertions. The inbound
message is a valid order with a valid credit card and order total
between 1000 and 5000. This triggers the approveLargeOrder process but
not the human task.
The simulated message is the message returned from the credit validation service as a VALID response.
The first assertion is on the data being passed to the WriteFile
service, checking that the value of status = 'approved', which is the
expected value for this input data.
The second assertion is on the data being passed to
FulfillmentProcess, checking that the customer ID is 9999—since the
customer ID is actually 1111, this test will always fail. This last
assertion shows what happens when the data being checked is not the
Use JDeveloper to create a unit test for POProcessing.
- Open the POProcessing project in JDeveloper. In the Application navigator expand the SOA Content folder and right-click on the test suites folder.
- Select Create Test Suite.
- Name the test suite logicTest.
- Click on OK.
- Name the test TestDelivery.
- Click on OK.
Notice that the composite view changes slightly to show you
are in Unit Test creation mode now. The swim lanes on the left and
right are yellow. You can return to the normal composite editor by
selecting the Return to SOA composite diagram button at the top of the window.