Open witherspore opened 10 years ago
Test utility classes to be used for slow-light proxy functional testing have been created and place in the com.tacitknowledge.slowlight.proxyserver.systest.util package. There are two main classes TestServer and TestClient which are used by tests, as end points, to verify slow-light proxy functionality.
All classes representing functional tests should be placed in com.tacitknowledge.slowlight.proxyserver.systest and should extend from com.tacitknowledge.slowlight.proxyserver.systest.AbstractProxyServerIT which will automatically start test server and provide few convenient methods to easily create test client and slow-light proxy server.
For more information on how to write slow-light functional tests please have a look at the following test classes: com.tacitknowledge.slowlight.proxyserver.systest.DelayProxyServerIT com.tacitknowledge.slowlight.proxyserver.systest.DiscardProxyServerIT com.tacitknowledge.slowlight.proxyserver.systest.CloseConnectionProxyServerIT com.tacitknowledge.slowlight.proxyserver.systest.RandomDataProxyServerIT
Set up some utility classes such that JUnit can easily drive remote, functional tests through the proxy server to a real server. The real server really only needs to return a stream of data that can easily be parsed and examined - it could be http such as jetty if necessary. This should be something like the below but organized well into setup and tear down methods:
InputStream streamToReturnFromRealServer; //some stream for testing Integer remotePort; //some port for the real server to service- the remote port RealServer realServer = new RealServer(streamToReturnFromRealServer, remotePort); realServer.start() //should run in its own ThreadExecutor to not block //Now wait for startup, testing to make sure it started. maybe use futures like we do with the bootstrap
//next set up proxy ServerBootstrap b = new ServerBootstrap() .group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) .childHandler(new ScenarioChannellInitializer(server.getScenarios(), server.getScenarioSelector())) .option(ChannelOption.SO_BACKLOG, 128) .option(ChannelOption.SO_KEEPALIVE, false); b.bind(server.getPort()).channel().closeFuture();
//now shut down the ports and servers by closing futures etc