Creating behaviors for stubs

You can create behaviors to expose utility or business logic for use within IBM® Rational® Test Virtualization Server.

About this task

Before creating a behavior, do the following steps:

  • Install an Eclipse IDE with the Plug-in Development Environment (PDE). For example, Eclipse for RCP and RAP Developers, which can be downloaded from http://www.eclipse.org/.
  • Copy the com.greenhat.tester.api_<Version Number>.jar file from <Install_Directory>\plug-ins to <Eclipse IDE Installation Directory>\plug-ins on the target computer.

To create a new behavior for IBM® Rational® Test Virtualization Server, do the following steps:

Procedure

  1. Open Eclipse.

    The Eclipse application window is displayed.

  2. Click File > New > Project.

    The New Project wizard is displayed.

  3. Click Plug-in Project.
  4. Click Next.

    The first screen of the New Plug-in Project wizard is displayed.

  5. In the Project name field, enter com.example.behaviour.echo.
  6. Select the Use default location check box.
  7. Select the Create a Java project check box.
  8. In the Source folder field, enter src.
  9. In the Output folder field, enter bin.
  10. Click the Eclipse version option button.
  11. In the Eclipse version list, select the appropriate platform version.
  12. Clear the Add project to working sets check box.
  13. Click Next.

    The second screen of the New Plug-in Project wizard is displayed.

  14. In the ID field, enter com.example.behaviour.echo (if necessary).
  15. In the Version field, enter 1.0.0 qualifier (if necessary).
  16. In the Name field, enter Rational Test Virtualization Server Behaviours - Echo (or an equivalent name).
  17. In the Provider field, enter IBM Corporation.
  18. In the Execution Environment field, click JavaSE-1.6.
  19. Under Options, clear all the check boxes.
  20. Under Rick Client Application, click the No option button.
  21. Click Finish.
    Note: If a message about switching to the Eclipse Plug-in Development perspective is displayed, click Yes.

    The Manifest Editor for the plug-in is displayed.

  22. On the Manifest Editor window, click the Dependencies tab.

    The Dependencies tab is displayed.

  23. Optional: Maximize the Manifest Editor window.
  24. Under Required Plug-ins, click Add.

    The Plug-in Selection dialog is displayed.

  25. In the Select a Plug-in field, enter at least one character of the JAR files name to prompt the dialog to filter the list of plug-ins under Matching Items.
  26. Click com.greenhat.tester.api (Version Number).
  27. Click OK.
  28. On the Manifest Editor window, click the Extensions tab.

    The Extensions tab is displayed.

  29. Under All Extensions, click Add.

    The Extension Point Selection dialog is displayed.

  30. On the Extension Points tab, click com.greenhat.tester.api.behaviour.
  31. Click Finish.

    The new extension is displayed under All Extensions.

  32. Under Extension Element Details, enter the details provided in the following table.
    Field Description Suggested Value
    Name The name of the behavior. Echo Behaviour
    Short Name A short name that helps to identify the behavior. EB
    Version This is used to determine the compatibility of persisted configuration. 1.0.0
    Description Description of the purpose and capabilities of the behavior. Contributes echo functionality
    Factory Class This identifies the class within the selected plug-in that is capable of creating instances of the behavior at run time if BehaviourFactory is implemented. com.example.behaviour.echo.EchoFactory
    ID Unique identifier for the behavior. com.example.behaviour.echo
  33. Click File > Save.
  34. Define suitable interfaces for the behavior and its callback interface. (For information about this, refer to Interface definitions.)
  35. Under Extension Element Details on the Extensions tab of the Manifest Editor window, enter the name of the callback interface in the callbackClass field.

    For example: com.example.behaviour.echo.EchoListener.

    Alternatively, click the fields Browse button to select the class.

  36. In the behaviourClass field, enter the name of the behavior interface.

    For example: com.example.behaviour.echo.Echo.

    Alternatively, click the fields Browse button to select the class.

  37. Declare the exposed function and event with their parameters, and the single configuration parameter, within the echo behavior element.
  38. Click the Runtime tab.

    The Runtime tab is displayed.

  39. Ensure that the package containing the EchoFactory is exported from the bundle at run time.
  40. Click File > Save.
  41. Click File > Export.

    The Export wizard is displayed.

  42. Click Plug-in Development > Deployable plug-ins and fragments.
  43. Click Next.

    The second screen of the Export wizard is displayed.

  44. Under Available Plug-ins and Fragments, select the plug-ins check box.
  45. On the Destination tab, click the Directory option button.
  46. In the Directory field, enter a directory path.

    Alternatively, click the Browse button next to the Directory field and select the directory path.

  47. Click Finish.

    The plug-in is exported as a JAR file to a plug-ins folder in the specified directory. The name of the JAR file includes the current date and time.

  48. Copy the JAR file to <Install_Directory>\plug-ins.

    This ensures that the next time when Rational® Integration Tester is started, the echo behavior will be available within the Stub Editor.