Hi there,

I'd like write a Junit test program for a 'state' design pattern but don't really know what to do. I've tried looking on the web/books to try and find similar examples for ideas but they are either not relevant or too advanced for my purposes.

Here's what I've done so far, which as you can see isn't much. Since it's not complete, unsurprisingly it doesn't run. I get a java.lang.NullPointerException compile time error.

Code:
package TCPProtocol;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * @author
 */
public class TCPConnectionTest {

	@Before
	public void setUp() throws Exception {
	}
	
	@Test(timeout = 4000) // fail if passed 4000ms
	public void test() {
		TCPConnection tcpconnection = new TCPConnection();
		tcpconnection.passiveOpen();
		tcpconnection.activeOpen();
		tcpconnection.synchronize();
		tcpconnection.send();
		tcpconnection.acknowledge();
		tcpconnection.close();
	}

}
Sorry if this seems like a stupid question. I'm new to this stuff and Iím really at my wits end. The above code on its own probably doesnít help much so please let me know what else you need.

Anyway, I hope you can help.

Many thanks,

C