SimpleDualPortServer dualPortServer = new SimpleDualPortServer(0, 0);
new Thread(dualPortServer).start();
QAUtil.sleep(1000);
INonBlockingConnection nbc1 = new NonBlockingConnection("localhost", dualPortServer.getTcpServerListenPort(), new EchoDataHandler());
nbc1.write((int) 55);
INonBlockingConnection nbc2 = new NonBlockingConnection("localhost", dualPortServer.getTcpServerListenPort(), new EchoDataHandler());
nbc2.write((int) 55);
INonBlockingConnection nbc3 = new NonBlockingConnection("localhost", dualPortServer.getTcpServerListenPort(), new EchoDataHandler());
nbc3.write((int) 66);
QAUtil.sleep(1000);
HttpClient httpClient = new HttpClient();
IHttpResponse response = httpClient.call(new PostRequest("http://localhost:" + dualPortServer.getHttpServerListenPort() + "/66", "text/plain", "hello you"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("hello you", response.getBody().readString());
response = httpClient.call(new PostRequest("http://localhost:" + dualPortServer.getHttpServerListenPort() + "/66", "text/plain", "hello you2"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("hello you2", response.getBody().readString());
response = httpClient.call(new PostRequest("http://localhost:" + dualPortServer.getHttpServerListenPort() + "/55", "text/plain", "hello you3"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("hello you3", response.getBody().readString());
httpClient.close();
nbc1.close();
nbc2.close();
nbc3.close();
dualPortServer.close();
}