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();