Unit Testing


To test the Chat 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 ChatServer.java, UAServer_Socket.java, PRServer_Socket.java, AppendUserList.java, Msgbroadcast.java, and SocketCallback.java files to a folder on the server 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. Copy the ChatLogin.java, ChatClient.java, CClient.java, and Messager.java files to a folder on the client computer. Compile the files using the following javac command:

     javac *.java 
  1. Run the Chat application server using the following command at the command prompt:

     java ChatServer 
  1. Run the Chat application login window using the following command at the command prompt:

     java ChatLogin 

    The Chat Login window appears, as shown in Figure 2-2.

  1. Specify the server IP address, user name , and password. Click the Connect button. The Chat Application - user1 window appears, as shown in Figure 2-4:

    click to expand: this figure shows the chat application window for user1 that displays a welcome message in the text pane.
    Figure 2-4: Welcome Message in the Chat Application - user1 Window

    An Error dialog box appears, if the process to establish a connection between the client and the server fails, as shown in Figure 2-5:

    this figure shows an error dialog box.
    Figure 2-5: The Error Dialog Box

  1. Run the Chat application login window using the following command at the command prompt from another client computer:

     java ChatLogin 

    The Chat Login window appears, as shown in Figure 2-2.

  1. Specify the server IP address, user name, and password. Click the Connect button. The Chat Application - user2 window appears, as shown in Figure 2-6:

    click to expand: this figure shows the chat application window for user2. the user list pane displays the names of two users, user1 and user2, who are connected to the chat session.
    Figure 2-6: The Chat Application - user2 Window with List of Users

    When user2 joins the chat session, a message, user2 has joined the chat session appears in the text pane of the user1 chat window, as shown in Figure 2-7:

    click to expand: this figure shows the user2 has joined the chat session message.
    Figure 2-7: The Chat Application - user1 Window with user2 in Chat Session

  1. Type Hi all in the text box of the Chat application window of user1 and click the Send button. The message is broadcasted to all the users, as shown in Figure 2-8:

    click to expand: this figure shows the message received on the user1 chat application window.
    Figure 2-8: Receiving Message in the Chat Application - user2 Window

    Figure 2-9 shows the broadcast message that appears in the user2 client window:

    click to expand: this figure shows the message received in the user2 chat application window.
    Figure 2-9: Receiving Message in the Chat Application - user2 Window

  1. Type Hi user2! in the text box of the user1 Chat application window, select user2 from the User List, and click the Private Message button. The message is sent to the user2 only, as shown in Figure 2-10:

    click to expand: this figure shows the message received on the user1 chat application window.
    Figure 2-10: Receiving Message in the Chat Application - user1 Window

    Figure 2-11 shows the private message that appears in the user2 client window:

    click to expand: this figure shows the message received on the user2 chat application window.
    Figure 2-11: Private Message in the Chat Application - user2 Window

  1. Click the Logout button of the Chat Application - user2 window. A Confirm dialog box appears, as shown in Figure 2-12:

    this figure shows the confirm dialog box to logout from the chat session.
    Figure 2-12: The Confirm Dialog Box

  1. Click Yes on the Confirm dialog box. A message, user2 has left the chat session appears in the text pane of all the chat users, as shown in Figure 2-13:

    click to expand: this figure shows the logout message of user2 in the user1 chat application window.
    Figure 2-13: The Chat Application - user1 Window




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