tp.setKeepAliveTime(1 * 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.setTimeout(500);
sm.doStart();
SocketProtocol spt = new SocketProtocol();
spt.setUpProtocol(new TestCountingProtocol(completed));
spt.setTimeout(10 * 1000);
spt.setSelectorManager(sm);
ProtocolFactory pf = new ProtocolFactory();
pf.setClockPool(cp);
pf.setMaxAge(Long.MAX_VALUE);
pf.setMaxInactivity(1 * 60 * 60 * 1000);
pf.setReclaimPeriod(10 * 1000);
pf.setTemplate(spt);
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();
SocketProtocol sp = new SocketProtocol();
sp.setUpProtocol(new Protocol() {
public Protocol getUpProtocol() {
throw new NoSuchMethodError();
}
public void setUpProtocol(Protocol up) {
throw new NoSuchMethodError();
}
public Protocol getDownProtocol() {
throw new NoSuchMethodError();
}
public void setDownProtocol(Protocol down) {
throw new NoSuchMethodError();
}
public void clearLinks() {
}
public Protocol cloneProtocol() throws CloneNotSupportedException {
return (Protocol) super.clone();
}
public void setup() {
}
public void drain() {
}
public void teardown() {
}
public void sendUp(UpPacket packet) {
}
public void sendDown(DownPacket packet) {
}
public void flush() {
}
});
sp.setTimeout(10 * 1000);
sp.setInterface(new InetSocketAddress(ssa.getConnectURI().getHost(), 0));
sp.setAddress(new InetSocketAddress(ssa.getConnectURI().getHost(), ssa.getConnectURI().getPort()));
sp.setSelectorManager(sm);
sp.setup();
for (int i = 0; i < COUNT; i++) {
sp.sendDown(getDatagramPacket());
}
if (!completed.attempt(60 * 1000)) {
throw new IllegalStateException("TIMEOUT");
}
sp.drain();
ssa.drain();
pf.drain();
spt.drain();
sm.doStop();
cp.doStop();
tp.doStop();
}