SOA 11g Tutorial: Unit Testing Composite App

This is part of the Oracle SOA11g hands on tutorials.

Overview

Testing Steps

* Use JDev to define
– Tests
– Assertions
– Emulations
* Use EM console or Ant to
– Run tests
* Use EM console or JUnit report to
– Review test results

Test Case Components

* Initiation defines:
– Test service
– Test operation
– Test data
* Emulation defines:
– Response message
– Fault message
* Assertion
– Compare response message with expected message

Creating Unit Test

* Open POProcessing project in JDev
* Right click testsuite folder under SOA Content
– Select Create Test Suite
* On the pop up dialog, enter
– Name: test1
– Click OK
* On Create Composite Test dialog, enter
– Name: TestDelivery
– Click OK

Setting Inbound Message

* Open TestDelivery.xml file
* Right click receivePO component and select Create Initiate Messages
* In the Initiate Messages dialog, paste the following message into the Value panel

<PurchaseOrder xmlns="http://xmlns.oracle.com/ns/order">
  <CustID>1111</CustID>
  <ID>1112</ID>
  <productName>TV-LCD</productName>
  <itemType>Electronics</itemType>
  <price>1260</price>
  <quantity>1</quantity>
  <status>Initial</status>
  <ccType>Mastercard</ccType>
  <ccNumber>8765-8765-8765-8765</ccNumber>
</PurchaseOrder>

* Click OK

Setting Simulated Message

* Open TestDelivery.xml file.
* Double click the wire between approvelargeOrder BPEL process and getCreditCardStatus web service to bring up the Wire Actions dialog.
– Click Emulates tab.
– Click green plus sign to bring up the Create Emulate dialog.
~ Click Generate Sample button to auto generate a sample response.
~ Change response value to VALID to simulate valid credit card.

<creditcardStatus xmlns="http://www.globalcompany.com/ns/CCAuthorizationService">VALID</creditcardStatus>

~ Click OK on Create Emulate dialog.
– Click OK on Wire Actions dialog.
* Notice that
– Wire has changed to a dashed line
– A message arrow indicating service return value
* Save all

Setting the Assertion for Success

* Double click the wire between routePO and WriteApprovalResults to bring up the Wire Actions dialog.
* On Asserts tab, click green plus sign to add an new assertion.
– Click Browse button to the right of Assert Target. We want to assert only one field.
~ On Select Assert Target dialog, select imp1:status and click OK button.
– Back on Create Assert dialog, enter approved in the Assert Value field.
– Click OK buttons on both dialogs.
* Notice that
– Wire has changed to a dashed line
– A message arrow indicating service assertion
* Save all

Setting the Assertion for Failure

* Double click the wire between approveLargeOrder and FulfillmentProcess to bring up the Wire Actions dialog.
* On Asserts tab, click green plus sign to add an new assertion.
– Click Browse button to the right of Assert Target. We want to assert only one field.
~ On Select Assert Target dialog, select ns1:customerId and click OK button.
– Back on Create Assert dialog, enter 9999 in the Assert Value field.
– Click OK buttons on both dialogs.
* Notice that
– Wire has changed to a dashed line
– A message arrow indicating service assertion
* Save all

Test

Redeploy POProcessing Application

* Redeploy POProcessing application as usual.

Test TestDelivery.xml

* Login EM
* Click on POProcessing application
* Click Unit Test tab
* Select checkbox for TestDelivery.xml and click Execute button.
* On Details of test run dialog, enter:
– Test Run Name: Run1
– Click OK

View Test Result

* Wait until test run is completed.
* On Test Runs tab, click Search button if Run1 is not shown.
* Check that
– Run1 has a overall status of Failed.
– approveLargeOrder/Ful has a status of False
– routePO/WriteApprovalResults has status of True

This entry was posted in soa11g. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.