public void testDummy() throws Exception {
}
public void test() throws Exception {
ThreadPool tp = new ThreadPool();
tp.setKeepAliveTime(100 * 1000);
tp.setPoolSize(5);
tp.setPoolName("TP");
tp.doStart();
ClockPool cp = new ClockPool();
cp.setPoolName("CP");
cp.doStart();
SelectorManager sm = new SelectorManager();
sm.setThreadPool(tp);
sm.setThreadName("SM");
sm.doStart();
ControlServerProtocolStack templateStack = new ControlServerProtocolStack();
SocketProtocol spt = new SocketProtocol();
spt.setTimeout(10 * 1000);
spt.setSelectorManager(sm);
templateStack.push(spt);
ControlServerProtocol csp = new ControlServerProtocol();
csp.setTimeout(1 * 1000);
csp.setThreadPool(tp);
csp.setClockPool(cp);
csp.setSelectorManager(sm);
csp.setControlServerListener(new ControlServerListener() {
public void shutdown() {
log.trace("SERVER SIDE SHUTDOWN_REQ");
}
});
templateStack.push(csp);
ControlServerProtocolWaiter waiter = new ControlServerProtocolWaiter();
TestProtocol test = new TestProtocol();
test.setValue("SimpleTest");
test.setThreadPool(tp);
test.setClockPool(cp);
test.setSelectorManager(sm);
waiter.push(test);
templateStack.push(waiter);
templateStack.push(new TestCountingProtocol(completed));
ProtocolFactory pf = new ProtocolFactory();
pf.setClockPool(cp);
pf.setMaxAge(Long.MAX_VALUE);
pf.setMaxInactivity(1 * 60 * 60 * 1000);
pf.setReclaimPeriod(10 * 1000);
pf.setTemplate(templateStack);
ServerSocketAcceptor ssa = new ServerSocketAcceptor();
ssa.setSelectorManager(sm);
ssa.setTimeOut(5 * 1000);
ssa.setUri(new URI("async://localhost:0/?tcp.nodelay=true&tcp.backlog=5#"));
ssa.setAcceptorListener(pf);
ssa.startup();
ControlClientProtocolStack clientStack = new ControlClientProtocolStack();
clientStack.setClassLoader(Thread.currentThread().getContextClassLoader());
clientStack.setThreadPool(tp);
clientStack.setClockPool(cp);
clientStack.setSelectorManager(sm);
SocketProtocol sp = new SocketProtocol();
sp.setTimeout(15 * 1000);
sp.setInterface(new InetSocketAddress(ssa.getConnectURI().getHost(), 0));
sp.setAddress(new InetSocketAddress(ssa.getConnectURI().getHost(), ssa.getConnectURI().getPort()));
sp.setSelectorManager(sm);
clientStack.push(sp);
ControlClientProtocol ccp = new ControlClientProtocol();
ccp.setTimeout(15 * 1000);
clientStack.push(ccp);
clientStack.setup();
for (int i = 0; i < COUNT; i++) {
clientStack.sendDown(getDatagramPacket());
}
if (!completed.attempt(60 * 1000)) {
throw new IllegalStateException("TIMEOUT");
}
clientStack.drain();
ssa.drain();
pf.drain();
sm.doStop();
cp.doStop();
tp.doStop();
}