Unit Testing


To test the Serial Communication application:

  1. Download the Javacomm20-win32 JCA, which is availabel in zip format at:

    http://java.sun.com/products/javacomm/downloads/index.html

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

  3. Copy win32com.dll from the unzipped file to the jre\bin directory where Java 2 Software Development Kit (J2SDK) is installed.

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

  5. Copy javax.comm.properties from the unzipped file to the jre\lib directory where 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 PortCommunication.java and PortPropertyPage.java files to a folder on your computer. Use the cd command at the command prompt to move to that folder. Compile the files using the javac command, as follows:

     javac *.java 
  9. Copy the PortCommunication.java and PortPropertyPage.java files to another computer on the network. Compile these files using the command specified in Step 8.

  10. Connect the two computers that contain the PortCommunication.java and PortPropertyPage.java files using a null modem wire.

  11. Run the Serial Communication application on both the computers connected by a null modem wire using the following command at the command prompt:

     java PortCommunication 
  12. Click the Open Port button in the Serial Communication window of both computers. This opens the currently selected port in the Port Property Page window for communication.

  13. Click File->Properties in the Serial Communication window on both the computers connected by a null modem wire. This opens the Port Property page.

  14. Select the port connected by the null modem wire in the Port Property Page window on both computers. You can set communication properties for the communicating ports in the Port Property Page window.

  15. Click the OK button in the Port Property Page window to set the communication properties.

  16. Type the data to be sent using the Serial Communication application. The data is specified in the upper text pane of the user interface of the Serial Communication window. Press Enter, as shown in Figure 5-5:

    click to expand: this figure shows the message, hello, in the upper pane of the serial communication window.
    Figure 5-5: Sending Data Using the Serial Communication Application

The data is received in the lower pane of the Serial Communication interface on the other computer, as shown in Figure 5-6:

click to expand: this figure shows the message, hello, in the lower pane of the serial communication window.
Figure 5-6: Receiving Data using the Serial Communication Application




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