Computer Programming Capstone Source Code and Documentation Package
3
Juliet Mercado
COP 2939
Unit Test Suite
Skeleton code facilitates a top-down design approach, where a partially working system with comprehensive high-level structures is designed and coded, and this system is then progressively extended to fulfill the requirements of the system. Below is the skeleton code for the java classes that will be implemented in the broadcast chat server:
Client.java
public class Client extends Panel implements Runnable {
/**
* It sets up the client interface, initiates the connection with the server host using the socket,
* When user enters a message it delivers the message by writing to the OutPutStream object.
//.. Constructor
public Client (String host, int port){
}
private void processMessage (String message){
}
//Background thread runs this: show messages from other window
public void run() {
}
}
Server.java
/*
* This is the listener class, a server, a stand-alone application.
*/
public class Server {
private void listen(int port) throws java.io.IOException {// ...create a new server socket}// send message to all the clientsvoidsentToAll(String message) {}/** Remove a socket, and its corresponding output stream, from our list.* This is usually called by a connection thread that has discovered the* connection to the client is dead.*/voidremoveConnection(Socket S) {}public static void main(String[] args) throws Exception {}}
ServerThread.java
public class ServerThread extends Thread {publicServerThread(Server server, Socket socket) {}/** The run method starts running in a separate thread when start() is called* in the constructor* The following code does the actual chat work*/public void run() {}}
ClientApplet.java
public class ClientApplet extends Applet {/*** Web deployable client applet*/public void init(){}}
Testing
Software unit tests help the developer to confirm that the logic of a piece of the program is accurate. Running tests automatically assists in distinguishing software regressions introduced by variations in the source code. Having high test coverage of the code allows one to continue developing features without having to undertake lots of manual tests. A unit test is a portion of code written by a developer that executes a precise functionality in the code to be tested and asserts a specific behavior or state. The classes in this case were tested and the results are described below:
i. Client.java:the test pass for this class fails and this is because the class generates one error since it cannot find the symbol class Panel
ii. Server.java:the test pass for this class fails and this is because it cannot find the symbol class Socket
iii. ClientApplet.java: the test pass for this class fails and this is because it cannot find the symbol class Applet