Unit Testing


To test the Port Information application:

  1. Download the JCA, which is available in a zip format with the name Javacomm20-win32.zip. The JCA can be downloaded from the following URL: http://java.sun.com/products/javacomm/downloads/index.html

  2. Unzip the zip file downloaded from the above URL.

  3. Copy the win32com.dll from the unzipped file to jre\bin directory where the J2SDK is installed.

  4. Copy the comm.jar from the unzipped file to the jre\lib\ext directory where the J2SDK is installed.

  5. Copy the javax.comm.properties from the unzipped file to the jre\lib directory where the J2SDK is installed.

  6. Set the path of the bin directory of J2SDK by executing the following command at the command prompt:

     set path = %path%;D:\j2sdk1.4.0_02\bin; 
  7. Set the classpath of the lib directory of J2SDK by executing the following command at the command prompt:

     set classpath = %classpath%;d:\j2sdk1.4.0_02\lib; d:\j2sdk1.4.0_02\jre\lib\ext\comm.jar; 

  8. Copy the PortDescription.java and ShowDescriptionWindow.java files to a folder on your computer. On the command prompt, use the cd command to move to that folder where you have copied the Java files. Next, compile the files using the javac command as follows:

     javac *.java 
  9. To run the Port Information application, specify the following command at the command prompt:

     java PortDescription 
  10. Click the List Serial Ports button on the Port Information application window to list all the serial ports attached to a computer. The Serial Ports list box displays the serial ports, as shown in Figure 2-3:

    click to expand: this figure shows the list of serial ports attached to a computer in the serial ports list box.
    Figure 2-3: Displaying the List of Serial Ports

  11. Click the List Parallel Ports button to list the parallel ports attached to a computer. The Parallel Ports list box displays a list of parallel ports, as shown in Figure 2-4:

    click to expand: this figure shows the list of parallel ports attached to a computer in the parallel ports list box.
    Figure 2-4: Displaying the List of Parallel Ports

  12. Select a port from the list of ports and click the Port Description button. The description of the selected port appears, as shown in Figure 2-5:

    this figure shows the description of the selected port, which includes the type, name, mode, status and owner name of the port.
    Figure 2-5: Displaying the Port Description

  13. Click the OK button to close the Port Description window.

  14. Select a port from the list of ports and click the Open Port button. The selected port opens and a confirmation message appears, as shown in Figure 2-6:

    click to expand: this figure shows the confirmation message displayed to the end user after the application successfully opens the selected parallel port.
    Figure 2-6: The Open Port Window

  15. Click the Yes button to close the port. If you clicked the No button and again try to open the same port. The error message appears, as shown in Figure 2-7:

    this figure shows the error message when the port is already open.
    Figure 2-7: An Error Message




Developing Applications Using JCA
Developing Applications Using JCA
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 43

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net