Part 6: Event-driven message distribution between several packages

../../_images/Tut_PT_Part6.png

Objective

Event-driven message distribution between several packages which were created from the same “parent” package.

Test creation

  1. Switch to “sender” in test case editor, select line 3 and insert a “Wait” test step with a delay of 500ms

  2. Switch to “main” in test case editor and choose line 4

  3. Open “react-on test step” from Test steps tab

  4. Insert a “Time event” and specify “8” as value

  5. Insert a “Message available” and specify “receiveLine” as value

  6. Insert a “Return values available” and specify “sendCountOutput” as value

  7. After that the dialog should look like in image “Test step React-On” and should be confirmed with OK

  8. Drag parallel package call of “sender” from line 2 to line 6 (AFTER 8 ms) which ensures that the package call will not end before react-on is entered into

  9. Drag lines 10-12 (read inbox, 2x write outbox) to line 7 (ON INBOX receiveLine)

  10. Remove expectation for “read from inbox” (line 8)

  11. Remove line 12 (LOOP)

  12. Select line 11 (ON VAR) and insert the test step “break”

  13. Save all packages and execute the main package

../../_images/ParalleleTests_ReactOn.png

Test step react-on

Result

At the beginning, the two receiver packages are started and then wait for messages. After 8ms the sender package is started in parallel in the react-on test step. This ensures that the sender package is not yet finished when the react-on is entered into (deadlock). Now the sender package transmits a message to the main package every 500ms. The main package waits for those messages in the react-on, reads them out and communicates them to the receiver packages. As soon as the sender package is finished, the sendCountOutput variable is engaged and the ON VAR sector is entered. The IF checks whether the same number of messages was forwarded as was received, and evaluates the result. The following break quits the react-on test step.