Designer > BPEL Unit Testing > Editing a B-unit File
  

Editing a B-unit File

You can design your own B-unit tests with the help of the B-unit editor. Double-click a B-unit file in Project Explorer to open the B-unit editor.
The B-unit editor displays the Design tab, containing an Outline pane and a Details pane. The Outline displays different sections of a B-unit file that you can select to edit in the Details pane.
The following is a description of each node in the B-unit Outline. For more details, select the node name.

BPEL Unit (Root)

Open a B-unit file in the B-unit editor, and select BPEL Unit from the Outline view.
The detail view displays the BPEL, WSDL and other resources used in the B-unit test.
To add resources, specify name, location and type URI. If you are using an XQuery module, the type URI is:
http://modules.active-endpoints.com/2009/07/xquery
At the bottom of the panel is the Trace selection. You can turn trace on or off to control console logging output.
The child elements of BPEL Unit are:
To add a child element, right-mouse click on BPEL Unit, and select Add.
See also, Editing a B-unit File.

Extensions and Extension Activities

Open a B-unit file in the B-unit editor, and select Extensions or Extension Activities from the Outline view. To add an extension, right-mouse click on BPEL Unit.
Extensions
Extensions specify context information required to run a B-unit that are typically defined in a process deployment description. Currently, extensions specify Logical People Groups that are WS-HT Extensions, and can be used within People activities.
You can define the value for a Logical People Group exactly as you define it in the People tab of the Process Deployment Descriptor Editor. For details about static, dynamic and People Query values.
Extension Activities
Extension Activities refer to People activities. You can assert what goes into a People activity and also to specify a response from the People activity if it includes a task (and not a notification).
You can define a People activity for a B-unit test as follows:
  1. 1. Select or add an Extension Activity (a People activity). If this activity is within a loop (for example, a For Each), you can specify a Count for the expected number of times to execute the activity.
  2. 2. Add at least one iteration that is the Default iteration. This is the default for how each iteration should run.
  3. 3. For each iteration, add the Response type that is the outcome of a task:
  4. 4. Add Asserts
See also, Editing a B-unit File and Tips on Using Parameterized XSL for Input and Assert Data.

Invokes

Open a B-unit file in the B-unit editor, and select Invokes from the Outline view. To add an invoke, right-mouse click on BPEL Unit.
A common use case for an invoke is to provide a simulated response for a service that your process is invoking. When an invoke activity within the process executes, the B-unit engine looks for a matching invoke element within the B-unit file. If found, this invoke element provides the ability to do assertions on the input data passed to the invoke as well as provide a message that simulates the response from the service invoke.
B-unit invoke elements can be configured for one-way and two-way service invokes. Both styles of invokes can have assertions on the input data but only two-way service invokes are allowed to have a response.
You can define an invoke for a B-unit test as follows:
  1. 1. Select or add an Invoke. Add an Invoke by right-mouse clicking on BPEL Unit.
  2. 2. Specify the Name or Location Path of the invoke. If this activity is within a loop (for example, a For Each), you can specify a Count for the expected number of times to execute the activity. Specify a Delay if you want to delay before returning the response. The delay allows for better handling of onEvent and onAlarm events.
  3. 3. Add a default iteration.
  4. 4. Add the Response type expected:
  5. 5. Add Asserts.
About Message Part Data
Some information about a message and its associated parts are generated automatically in the B-unit editor when you perform certain actions including:
See also, Editing a B-unit File, Tips on Using Assertions, and Tips on Using Parameterized XSL for Input and Assert Data.

Alarms

Open a B-unit file in the B-unit editor, and select Alarms from the Outline view. To add an alarm, right-mouse click on BPEL Unit.
Alarms refer to the wait activity and the onAlarm events in picks and event handlers. You can assert on an alarm deadline or duration.
You can define an alarm for a B-unit test as follows:
  1. 1. Select or add an alarm. Add an alarm by right-mouse clicking on BPEL Unit.
  2. 2. Specify the Process and Location Path of the alarm-based activity.
  3. 3. Add a default alarm, and add the duration for the B-unit test to use.
  4. 4. Add an Assert.
  5. 5. Add an assert iteration, if desired. If the alarm-based activity is within a loop, add an Index for this iteration. The index is the nth iteration within the count, specified for the alarm.
See also Editing a B-unit File and Editing a B-unit FileTips on Using Assertions

Commands

Open a B-unit file in the B-unit editor, and select Commands from the Outline view. To add a command, right-mouse click on BPEL Unit.
Commands send messages to the B-unit test engine to execute the test logic.
The commands you can add are as follows:
Command
Description
Send Message
Sends WSDL messages to the test engine.
Select an Operation for the specified partner link.
Delivery Options.
  • - Async. Controls whether or not two receives can execute in a row, without waiting for the reply associated with the first receive to complete
  • - Delay. Wait value that the B-unit waits before starting to check the Timeout.
  • - Timeout. Sets a value for the how long the test engine should wait for process completion. This setting ensures that the invokes complete with the correct count.
  • - Message Context. Optionally specify the meta-data for the incoming message, including the authenticated principal, and other message header data.
Wait Until
Checks for the execution completion of the process.
  • - Delay. Wait value that the B-unit waits before starting to check the Timeout.
  • - Timeout. Sets a value for the how long the test engine should wait for process completion. This setting ensures that the invokes complete with the correct count.
  • - Fail on Timeout. Enable this check box to fail the test if the process does not complete within the timeout value.
Terminate Process
Terminates a process instance for one of the processes in the B-unit test, if you are running more than one process.
Assert Process State
Asserts the execution state of the process that you specify.
  • - Process State. Running, suspended, complete, faulted, final. Select final to assert completed and faulted states.
  • - Process Id. Used only if you are running the test on multiple BPEL files.
  • - Delay. Wait value that the B-unit waits before starting to check the Timeout.
  • - Wait for Async. If you have Async selected in a Send Message command for the same process, this property allows you to wait to assert the process state until all asynchronous activities have completed.
See also, Editing a B-unit File.