import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;

import java.net.Socket;

public class TestCompressor extends TestCase {
    public void setUp() throws Exception {
    }

    public void testConnectToCompressorServer() throws Exception {
	CompressorServer server = new CompressorServer(4444);
	server.startServer();
        Thread.sleep(100);
	Socket client = new Socket("localhost", 4444);
	assertEquals(true, server.isRunning());
	assertTrue(client != null);
	Thread.sleep(100);
	server.stopServer();
	Thread.sleep(100); //let server stop running
	assertEquals(false, server.isRunning());
    }

    public static Test suite() { 
	TestSuite suite= new TestSuite(TestCompressor.class);
	return suite;
    }

    public static void main(String args[]) { 
	junit.textui.TestRunner.run(suite());
	System.exit(0);
    }
}
