Saturday, October 31, 2009

Unit Testing













Unit Testing

The online technical support application is deployed and tested on the Sun Java System Application Server Platform Edition 8. You can download this application server from:



http://java.sun.com/j2ee/1.4/download.html








Note�

To install Sun Java System Application Server Platform Edition 8, you need to install Java 2 Standard Edition (J2SE) 1.4.2 on the computer.



To deploy the online technical support application:




  1. Select Programs->Sun Microsystems->J2EE 1.4 SDK ->Start Default Server from the Start menu to start the application server.




  2. Select Programs->Sun Microsystems->J2EE 1.4 SDK ->Deploytool from the Start menu to open the Deployment Tool window.




  3. Select New->Application from the File menu of the Deployment Tool window. The New Application dialog box appears.




  4. Click Browse in the New Application dialog box to display another New Application dialog box.




  5. Select the directory where you want to save the .ear file in the Look In combo box.




  6. Enter the name of the .ear file as OnlineTechnicalSupportApp in the File Name text box, as shown in Figure 4-8:






    Figure 4-8: The New Application Dialog Box




  7. Click the New Application button to return to the previous New Application dialog box.




  8. Click OK to create the new application.




  9. Select New->Web Component from the File menu of the Deployment Tool window. The New Web Application Wizard-Introduction dialog box appears.




  10. Click Next. The New Web Application Wizard-WAR File dialog box appears.




  11. Click Edit Contents in the New Web Application Wizard-WAR File dialog box. The Edit Contents of WebApp dialog box appears.




  12. Select all the JSP files, the QueryXMLGenerator.class file, and the path.properties file of the application from the Available Files pane and click Add. Select the xml directory as well from the Available Files pane and click Add. The Contents of WebApp pane of the Edit Contents of WebApp dialog box displays the added files, as shown in Figure 4-9:






    Figure 4-9: The Edit Contents of WebApp Dialog Box




  13. Click OK to add the files to the Web application Web Archive (WAR) file.




  14. Click Next in the New Web Application Wizard-WAR File dialog box. The New Web Application Wizard-Choose Component Type dialog box appears.




  15. Select the JSP Page radio button and click Next. The New Web Application Wizard-Component General Properties dialog box appears.




  16. Select Logon.jsp from the JSP Filename drop-down list. The remaining fields get automatically populated with values. Figure 4-10 shows the New Web Application Wizard-Component General Properties dialog box:






    Figure 4-10: The New Web Application Wizard-Component General Properties Dialog Box




  17. Click Finish.




  18. In the Deployment Tool window, specify/fourth as the context root of your application in the Context Root text field, as shown in Figure 4-11:






    Figure 4-11: The Deployment Tool Window




  19. Select Save from the File menu of the Deployment Tool window to save the application.




  20. Select Deploy from the Tools menu. The Deploy Module OnlineTechnicalSupportApp dialog box appears.




  21. Specify the application server user name and password in the User Name and Password fields and click OK.




  22. The Distribute Module dialog box appears. It indicates the successful deployment of the application.





To test the deployed application:




  1. Specify the following URL in the address bar of the browser:



    http://localhost:8080/fourth/Logon.jsp




  2. In the Logon JSP page, specify Peter in the Logon ID field and peter in the Password field, as shown in Figure 4-12:






    Figure 4-12: The Logon JSP Page




  3. Click the Logon button. The DoLogon Page appears which displays the Logout and Go to main page hyperlinks.




  4. Select the Go to main page hyperlink. The User Options page appears, as shown in Figure 4-13:






    Figure 4-13: The User Options Page Containing Hyperlinks




  5. Select the Post a new query hyperlink. The New Query page appears.




  6. Specify a query to post, as shown in Figure 4-14:






    Figure 4-14: Posting a Query




  7. Click the Submit Query button to post the query.




  8. Check the querylist.xml file to ensure that your query has been added to the file.




  9. Select the Logout hyperlink in the New Query page. The Logon JSP page appears.




  10. Specify admin in the User ID and Password fields and click Logon. The Administrator Options page appears, as shown in Figure 4-15:






    Figure 4-15: The Administrator Options Page Containing Hyperlinks




  11. Select the Post reply to query hyperlink. The Query Reply page appears.




  12. Select the title of the query you posted using steps 5 through 7 from the Query title drop-down list. Specify the date of reply and the reply in the Date and Reply fields, as shown in Figure 4-16:






    Figure 4-16: Posting a Reply




  13. Click the Post Reply button.




  14. Check the querylist.xml file to ensure that the reply has been added to the file.




  15. Select the Go to main page hyperlink in the Query Reply page.




  16. Select the View query list hyperlink in the Administrator Options page. The View Query page appears.





  17. Select the title of the query you added in the user module from the Query title drop-down list. Select View query in XML from the Output drop-down list, as shown in Figure 4-17:






    Figure 4-17: Selecting a Query Format




  18. Click the View Query button. The browser displays the dynamically generated XML content that contains the query information, as shown in Figure 4-18:






    Figure 4-18: Dynamically Generated XML Content




  19. Click the Back button of the browser to return to the View Query page.




  20. In the View Query page, select View query in HTML from the Output drop-down list and click View Query.




  21. The style sheet of the application displays the XML content in HTML format, as shown in Figure 4-19:






    Figure 4-19: Query in HTML Format




  22. In the View Query page, select Download query from the Output drop-down list and click View Query.




  23. The File Download dialog box appears, as shown in Figure 4-20:






    Figure 4-20: The File Download Dialog Box




  24. Click the Save button to save the content as an XML file. The Save As dialog box appears. From the Save in drop-down list, select the directory in which you want to save the XML file, as shown in Figure 4-21:






    Figure 4-21: The Save As Dialog Box




  25. Click Save to save the content as an XML file.




  26. Select Logout in the View Query page to logout from the application.













No comments: