Use EJB Test Client wizard

This is a feature of JBuilder Enterprise.

The Use EJB Test Client wizard adds a declaration of a test client class to the active class in the code editor. If you don't have an EJB test client yet or want to create another, you can use the wizard to create one for you.

To use the wizard, open the class you want to add the declaration to in JBuilder's code editor, then choose Wizards|EJB|Use EJB Test Client.



Select EJB Test Client Class To Use

EJB Test Client Class Already Exists

If the EJB test client already exists, check this option and then click Next. The wizard takes you to the next step where you specify the test client to use. If you don't check this option, when you click Next, you are taken to another page where you create an EJB test client.



Select Class And Field Names

There are two steps if you have an existing EJB test client already.

Class

Specify the existing test client class by entering its name or by navigating to it.

Field

Specify a variable name that will hold an instance of the test client class. Click Finish when you are done, and the wizard generates the declaration.



Enter New EJB Test Client Details

This page appears if you haven't specified an existing EJB test client in the previous step. Use it to specify which EJB you want to test.

EJB Name

Select the enterprise bean from the drop-down list. Before you use the list, however, select either the From Project or From JAR Or Directory options to determine what appears in this drop-down list. If you select From Project, the list displays all EJBs in the current project. If you select From JAR Or Directory, you must navigate to the JAR or directory where the bean exists, then you can select the bean from this drop-down list.

From Project

If you EJB is in your current project, select this option and use the EJB Name drop-down list to select the bean. From the drop-down list, select the enterprise bean you want to create a test client for. The list displays all enterprise beans in the current project.

From JAR Or Directory

Select From JAR Or Directory if your bean is not in the current project, but exists elsewhere in a JAR file or if it's not in a JAR, but just in another directory. Use the ... button to navigate to where the JAR or the bean is located and select the JAR or directory, then use the drop-down list to select the bean. This option is not available for EJBs targeting WebSphere 3.5.

Package

From the drop-down list, select the package you want the test client to be in or type in the name of the package you want to use. The drop-down list displays all currently opened projects.

Class

Enter a name for your new EJB test client. JBuilder suggests a default name based on the name of the enterprise bean you are building the test client for. You can accept this name or enter another.

Base Class

If you want the test client based on a class, specify the base class name by typing it in or use the class tool to navigate to where the base class resides and select it.

Generate Method For Testing Remote Interface Calls With Default Arguments

Adds a testRemoteCallsWithDefaultArguments() method that tests the remote interface calls with default argument values. See "Testing an enterprise bean" for more information about calling testRemoteCallsWithDeaultArguments() to test your bean's remote methods.

Generate Logging Messages

If this option is checked, the wizard generates code that declares and implements a method in the test client for each method in the home and remote interface. Each of these implemented methods calls a corresponding method in the home or remote interface. Each of these implemented methods reports its success in invoking the home or remote method and how long the method took to execute.

Generate Main Function

Check this option to add a main() function to the test client. You can then call the bean's methods from the main() function. You do this by first calling either a create or find method, and, if a remote reference is returned, by using that remote reference to call the bean's business methods. Or, because the wizard declares a client object in the main() function, you can use that client object to call the methods declared in the test client that call the bean's remote methods.

Generate Header Comments

If checked, this option adds JavaDoc header comments such as Title and Author to the top of the EJB test client.



Select Field Name

Field

Enter a field you want to use to identify the EJB test client object instance. If you don't specify one, a default name will be generated for you.