Home

 

Testing with the Universal Test Client

Before we integrate the EJB application with the Web application, we test the session bean with the access to the JPA entities. We use the enterprise application Universal Test Client (UTC), which is contained in RAD v7.5.

In this section we describe some of the operations you can perform with the Universal Test Client. We use the test client to retrieve a customer and its accounts.

To test the session bean, do these steps:

In the Servers view, right-click the server and select Universal test client Æ Run.

Accept the certificate, and login as admin/admin (the user ID set up when installing Application Developer).

The Universal Test Client opens (Figure | 4-15).

Figure 14-15 Universal Test Client home

Select JNDI Explorer. On the right side, expand [Local EJB Beans].

Select itso.bank.service.EJBBankService. The EJBBankService appears under EJB Beans (Figure | 4-16).

Figure 14-16 UTC: JNDI Explorer

Expand EJBBankService (on the left) and select the getCustomer method. The method with its parameter opens on the right.

Type 111-11-1111 as value on the right, and click Invoke.

A Customer instance is displayed as result (Figure | 4-17).

Figure 14-17 UTC: Retrieve a customer

Click Work with Object. The customer instance appears under Objects. You can expand the object, and invoke its methods (for example, getLastName) to see the customer name.

Select the getAccounts method in the EJBBankService interface. Type 222-22-2222 as parameter value, and click Invoke. Three accounts are displayed as result.

Select the getTransactions method. Type 002-222002 as parameter value, and click Invoke. Several transaction records are displayed.

Select the OpenAccount method. Type 111-11-1111 as parameter value, and click Invoke. A new account with a random ID (for example, 001-169749) is created.

Select the deposit method. Type the new account number (001-xxxxxx) and 100.00 as parameter values, and click Invoke.

Select the getAccount method. Type the new account number (001-xxxxxx) as parameter value, and click Invoke. Click Work with Object, expand the account object, and invoke the getBalance method to verify the balance.

Select the closeAccount method. Type 111-11-1111 and the new account number (001-xxxxxx) as parameter values, and click Invoke.

Verify in the Console that the account is closed:

closed account with 1 transactions

You can play with the UTC to make sure all of the EJB methods work. When you are done, close the UTC pane.

ibm.com/redbooks