Unit Testing


To test the File Download application:

  1. 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; 
  1. 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; 
  1. Copy the FileRemote.java, FileRemoteImpl.java, FileInfo.java, FileServer.java, FileClient.java, and ProgressTest.java files to a folder on your computer. On the command prompt, use the cd command to move to the folder where you have copied the Java files. Compile the files using the following javac command:

     javac *.java 
  1. Generate the stub and skeleton files for the File Download application using the following command:

     rmic FileRemoteImpl 
  1. Start the RMI registry using the following command:

     start rmiregistry 
  1. Copy the FileRemote.class, FileRemoteImpl.class, FileInfo.class, FileServer.class, FileRemoteImpl_Stub.class, and FileRemoteImpl_Skel.class files to the folder, named Server, where your server machine is hosted. On the command prompt, use the cd command to move to the folder where you have copied the class files.

  2. Run the server of the File Download application using the following command at the command prompt:

     java FileServer 
  1. Copy the FileRemoteImpl.class, FileInfo.class, FileRemoteImpl_Stub.class, FileClient.class, and ProgressTest.class files to the folder, named Client, where your client machine is hosted. On the command prompt, use the cd command to move to the folder where you have copied the class files.

  2. Create a java.policy file to authenticate the client to access the remote object using the following command:

     Policytool 
  1. Run the client of the File Download application. You need to specify the IP address of the server on the command line. To execute the client, specify the following command at the command prompt:

     java FileClient 192.168.0.36 
  1. Click the Get File List button on the File Download Application window to display the list of files that are available for download. The File Download Application window with the file list appears, as shown in Figure 3-4:

    click to expand: this figure shows the list of files that are stored on the server. the list displays the file names and sizes in bytes. the end user can select one row at a time for download.
    Figure 3-4: Displaying File Download Application

  1. Click the Download the File button without selecting any file from the table. An error message appears, as shown in Figure 3-5:

    this figure shows the error dialog box.
    Figure 3-5: Error Dialog Box

  1. Select a file that you want to download.

  2. Click the Download the File button to start the file download process. A Confirm dialog box appears, as shown in Figure 3-6:

    this figure shows the confirm dialog box that allows end users to confirm whether they want to download the file.
    Figure 3-6: Confirm Dialog Box

  1. Click OK in the Confirm dialog box. A Save dialog box opens, as shown in Figure 3-7:

    click to expand: this figure shows a save dialog box that allows the end user to save the file at a specified location.
    Figure 3-7: Save Dialog Box

  1. Click the Save button of the Save dialog box. A Download Status dialog box opens, as shown in Figure 3-8:

    this figure shows the download status dialog box that displays the file downloading status and a progress bar.
    Figure 3-8: Download Status Dialog Box

    To stop the download, the end user can click Cancel. After download, a Download Complete dialog box opens, as shown in Figure 3-9:

    this figure shows the download complete dialog box.
    Figure 3-9: Download Complete Dialog Box




Java InstantCode. Developing Applications Using Java NIO
Java InstantCode. Developing Applications Using Java NIO
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 55

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