Monday, August 4, 2008

Testing Applications with IBM Rational Application Developer on WTE WebSphere Test Environment

Testing Your Applications

Once you have created your JSP files, coded your action, and configured your web project to support struts, you are ready to test your application.

To test a JSP or a Servlet, it is usually as simple as right-clicking on the Servlet or JSP in question and selecting 'Run on Server.' With out Struts application, we won't be blessed with as simple a deployment option.

To test your application, perform the following steps:

1. Perform a File à Save All to ensure all editors are saved.

2. Perform a File à Close All to close all open editors.

3. Open the Server Perspective Windows à Open Perspective à Server

4. From the ‘Server Configuration’ window in the lower left corner of the Server perspective, right click and select New à Server and Server Configurations

5. Name the new server ‘PulpJava Test Server’

6. Make sure the Server Type is configured to be a WebSphere 5 Test Environment

7. Click ‘Finish’ to create the server

8. In the ‘Server Configuration’ view, open the Servers folder and notice that the ‘PulpJava Test Server’ has been created.

9. In the Navigator view of the Server perspective, notice that a new folder named ‘Servers’ has been added. This folder contains all of the configuration information for your test server.

Associating an Enterprise Project with a Server

1. From the Server Configuration window in the Servers perspective, open the Servers folder and right-click on the ‘PulpJava Test Server’

2. Click ‘Add and remove projects’ from the context menu.

Your PulpJava project should appear as an available project on the left hand side of the ‘Add or Remove Projects’ wizard.

3. Highlight your PulpJava project on the left hand side and click the Add > button.

After clicking Add >, your PulpJava project should move to the right hand side under ‘Configured Projects’.

4. Click ‘Finish’ to have your PulpJava project associated with your ‘PulpJava Test Server’

In the ‘Server Configuration’ view, the PulpJava enterprise application and the PulpJavaWeb web module should appear as branches under the ‘PulpJava Test Server’ tree.

Starting a Test Server

1. Make sure all editors are saved: File à Save All

2. Make sure all editors are closed: File à Close All

3. From the Servers view, right-click on the ‘PulpJava Test Server’ and select ‘Start’ from the context menu.

4. When the console window reports that ‘server1 open for e-business,’ your test server has successfully started.

NOTE: closing all open editors, especially an editor for the configuring the server, is not a trivial matter. Having an open editor with unsaved changes in may stop a server from starting properly.

Stopping a Test Server

1. From the Servers view, right-click on the ‘PulpJava Test Server’ and select ‘Stop’ from the context menu.

2. The server has terminated when the console reports ‘Server server1 stopped.’

Testing Your Application

Once your test server has been created, your PulpJava project has been associated with your test server, and your test server has been started, testing your application is very simple.

  1. Make sure your test server is started.
  2. Open a web browser such as Internet Explorer or Netscape Navigator
  3. Enter the following url:


4. Your internationalized (English?) message should appear

To test the Spanish message, change the preferred language of your browser. For Internet Explorer:

5.From the IE menu select ToolsàInternet Options

6. In the lower right hand corner of the General tab of the Internet Options page, click ‘Language’

7. In the Language Preference window that appears, take a trip to beautiful Quebec by clicking the Add button and scrolling down until you find "French (Canada) [fr_ca]. Click ‘OK’

8. Move French (Canada) to the top of your preference list using the ‘Move Up’ button and then click ‘OK’

9. Click ‘Apply’ and the ‘OK’ to leave the ‘Internet Options’ window and return to Internet Explorer.

10. Close and then open a new Internet Explorer browser and re-test your application.

Go through the same steps again and take a trip to Argentina by choosing "Spanish (Argentina) [es-ar]" as another preferred language.

Move Spanish up above English and French in the Preferred Languages window and then retest your application. You may need to close Internet Explorer and start it up again to get the change to take effect.

Clearing your cache or doing a CTRL+R to properly refresh your page isn't a bad idea either.

If french is at the top of your preferred language list, you should get the frenchspeaker.jsp page displayed. If you choose Spanish as your preferred language, you should see the spanishspeaker.jsp page displayed. If you choose Swahili as your preferred language, you will run into some problems. I'll leave it up to you to provide your own support for your Swahili users.

Congratulations. You have just created and tested a round trip struts application.

Hibernate Tutorials

Sun Certified Java Associate Mock Exams and Tutorials

No comments: