Monday, January 12, 2009

Automate your BPEL Testing

BPEL Test Suite is part of Oracle's SOA Suite. You can use it to automate your BPEL Testing.

Here is the summary of steps you need to create and deploy BPEL Test Suite for your project.

1) Create and Deploy your BPEL Project. (For example BPELTestSuiteCaseExample
2) Create Baseline

In the Applications Navigator tab, right-click BPELTestSuiteCallHelloWS.bpel and select Test -> Create Test Suite. In the dialog box that appears, name the test suite logicSuite (or whatever name you want to give to your test suite).





  • Go to BPEL Console and select the the domain where you have deployed the BPEL Process
  • Select the Dashboard tab.
  • Click on your BPEL Process. This will take you to the Initiate Tab. Enter all inputs and click on the POST button.
  • Once you process is completed, click on Instances tab(from upper right corner of the BPEL console)
  • Select the last instance of your process, and then got to "Test" tab.
  • Click Save as unit test (.xml) to save this instance as a unit test case. Save the generated XML, using the filename baseline.xml on your local file system, into the bpel/testsuites/logicSuite/includes subdirectory of the you project directory ((in our case "BPELTestSuiteCallHelloWS"). Note that this file must appear in the includes subdirectory to be used as a baseline case.
  • Import the baseline test into Oracle JDeveloper, by selecting the logicSuite test suite in the Applications Navigator tab and selecting Refresh from the View menu. The baseline.xml test case should now appear in the Includes directory in the tree
3. Design the Test Case
The next task is to design the test cases that will be used to test the BPEL process. Oracle BPEL Process Manager test cases contain several key components:

  • Initiate action: Every test case starts with an initiate action that calls the BPEL process and defines the initial payload
  • Emulations: When executing a BPEL process, the test cases don't actually call the partner services included in the process definition. Instead, the test cases in our example emulate the services' activity. As part of the emulation, the test cases also specify the data to be returned by each service being emulated.
  • Assertions: Assertions are used to validate a variable or an entire XML document at any point during a BPEL process execution. Three types of assertions are available. Simple Value Assert checks the value of a variable, XML Assert compares the elements of an entire XML document with their expected values, and Activity Executed Assert checks the number of times an activity is invoked
Now Let's create a test case.
  • In the Application Navigation, right click the logicSuite test suite (the one we created in "Create BaseLine" step.) and select Create BPEL Test. In the dialog box that appears, enter the name of test case (for example "testReturnDinesh" ) and click OK.





  • Make sure the Diagram view is open for testReturnDinesh.xml, and click the Included BPEL Tests button in the upper left corner of the edit pane. In the dialog box that appears, click Add and select baseline.xml to add it to the set of included BPEL tests.


  • Now let's override the Invoke activity (by providing emulation).
    NOTE: This steps provides emulation of the web service invoke so if you are really interesting the out come of the Web Service Invoked, you may skip this step.

    1. Double click the InvokeMyHelloWorld icon. Select the Emulate tab.
    2. Check "Override Included Emulation" box.
    3. Select "Enter Manually" radio button. and enter following XML fragment ..

    Greeting Dinesh




  • 3. Click OK.

    Now let's add Assert Value to AssignOutput Activity
    1. Double Click on the the AssignOutput activity icon and click on the Create Magic wand.
    2. Enter values of dialog box as shown



Deploy and test
Deploy the test suite:At this moment I do not have auto deploy for BPEL Test Suite so I am going to use the Jdeveloper method to deploy it.
  1. Right Click on Test Suite and select BPEL Test Deployer..
  2. Uncheck and check the the top left button (the one next to "servers to deploy into:")
  3. Select the server and Domain (for example Fable and "Platform") and Process Version from the right side pane of the BPEL Test Deployer.
Testing the Test Suite
Testing the Test Suite

  1. Log on to the BPEL Console and select your Domain where you have deployed the process.
  2. Select the Process and click on it. Navigate to "Test Suite" Tab.
  3. Select the Test Name and click on the Execute Test button.


4. Verify the Result on the BPEL Test Report Page.