You can use the component test wizards and the Test Suite editor
to create stubs of session beans or entity beans with either bean-managed
or container-managed persistence. Once created, the stubs are updated automatically
whenever there are modifications to the underlying stubbed components.
EJB stubs are deployed on the server at run time. In the case where
a deployed stub throws an exception, you must expect to receive an encapsulated
exception message from the server and not from the actual stub.
Note: You
cannot create stubs of EJB home methods based on EJB-QL requests.
To create stubs of your session and entity beans:
- Click and click Next.
- On the first wizard page, take one of the following actions:
- Select the test project that will contain the stub and click Next.
- Click New to create a new test project.
- On the Select the Components to be Stubbed page, select the EJB
components, libraries, or Java™ source files you want to create stubs
for and click Finish. If the stub component
already exists, the wizard prompts you to replace the existing stub. If you
select Yes or Yes to All, any
changes you have made to the existing stub will be overwritten. If you select No or No
to All, the existing files remain unchanged and a new stub is
not generated.
- In the Test Navigator view, double-click the test suite that you
want to add the stub to. This opens the Test Suite editor.
- In the Test Suite editor, click the Stubs tab,
click Add, select the stub you want to add to the test
suite, and click Finish.
Note: To create a new stub and
add it automatically to the test suite, click New and
proceed with Step 3.
To replace the stub with the real class at any time, simply remove
the stub from the test suite.