import java.net.DatagramSocket;
import java.net.SocketException;


public class TestClient {
	MessageQueue toSendMsgs = new MessageQueue();
	MessageQueue receivedMsgs = new MessageQueue();
	ClientReceiver cr;
	ClientSender cs;
	public TestClient(String IPAddress, int port) {
		DatagramSocket socket;
		try {
			socket = new DatagramSocket();
		} catch (SocketException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		cs = new ClientSender();
		cr = new ClientReceiver();
		cs.start();
		cr.start();

		try {
			cs.join();
			cr.join();
		} catch (InterruptedException e) {
			System.out.println("An unexpected interrupt exception occurred!");
			e.printStackTrace();
		}
	}

	public void runAllTests() {
		toSendMsgs.add("up");
		System.out.println("TODO: Add tests here.");
	}
}

@@ -460,16 +460,34 @@
 tSender(
+toSendMsgs, socket
 );%0A%09%09cr 
@@ -745,33 +745,214 @@
 s() 
-%7B%0A%09%09toSendMsgs.add(%22up%22);
+throws InterruptedException %7B%0A%09%09toSendMsgs.add(%22up%22);%0A%09%09synchronized(receivedMsgs) %7B%0A%09%09%09while(receivedMsgs.isEmpty()) %7B%0A%09%09%09%09receivedMsgs.wait();%0A%09%09%09%7D%0A%09%09%09// check that the message received is correct%0A%09%09%09%0A%09%09%7D
 %0A%09%09S

Add testclient wait