Creating tests for an EJB session facade
You can use the EJB session facade testing pattern to test the implementation of the session facade design pattern. This design pattern is used to provide a higher level business logic interface, to hide the complexity of the application from the client, and to improve performance. The session facade testing pattern generates tests for an EJB session facade and for the subsystem behind the facade.
To create a test for testing the implementation of the session facade design pattern of the EJB under test:
- Click File > New > Other > Component Test > EJB > EJB Component Test and click Next.
This starts the Create Test for EJB wizard.
- On the first wizard page, do one of the following:
- Select the test project that will contain the test and click Next.
- Or click New to start the process of creating a new test project.
At this point, a static analysis is performed on the EJBs associated with the test project. These files were selected during the creation of the test project and serve to define the scope of the test. (The list of files in the project can be updated by modifying the test project's Test Scope properties.)
When the analysis is complete, you will see a list of components in a table format and sorted according to the computed metrics. You can use the guidance that these metrics provide to help you decide which EJB components are most important for you to test. Components with highlighted values or high numerical values are considered high-priority test candidates. For testing a session facade, it is especially useful to test components with a high Fan Out value.
- On the Select the components under test page, select the components you want to include in the test and click Next.
- On the Select a test pattern page, select EJB session facade testing and click Next.
- On the Select the EJB interfaces page, select the interfaces (local or remote) you want to use to perform the test.
- On the Select the methods under test page, select the create method that creates the EJB session facade under test. Then, select the individual methods to be tested and click Next.
- On the Select the methods behind the facade page, select the methods to be tested from the EJB behind the session facade.
The end result is a test behavior script and a test suite with one test case for the entire scenario. The test behavior script contains code for testing the session facade under test as well as the methods behind the facade.
- Click on a particular method to display which EJB it belongs to. If the method you have selected belongs to the Local or Remote interface of the EJB, you can also choose the method to create the EJB instance on which this method will be applied.
- When you have selected the methods to be tested, click Finish.
After you create the test, be sure to populate the test data table with test data. To display a test data table, do one of the following:
- Open the test behavior script and position the cursor within a test method.
- Click a method in the Outline view.
Related concepts
Test patterns for Enterprise JavaBeans
Static metrics
Related tasks
Creating new component test projects