use of java.nio.channels.spi.AbstractSelector in project webpieces by deanhiller.
the class TestXEvaluateNIOBehavior method testNormalNio.
/**
* This test is interesting. If a Socket is registered with a Selector, and
* you close the socket, the socket cannot be closed until the select statement.
*
* NOTE: Appears to be fixed in 1.5.0_06 on windows, so we only run this on
* linux now!!!!!!!!!
*
* @throws Exception
*/
public void testNormalNio() throws Exception {
SocketChannel channel1 = SocketChannel.open();
channel1.configureBlocking(false);
channel1.socket().setReuseAddress(true);
InetAddress loopBack = InetAddress.getByName("127.0.0.1");
InetSocketAddress addr1 = new InetSocketAddress(loopBack, 0);
channel1.socket().bind(addr1);
channel1.connect(svrAddr);
channel1.finishConnect();
mockServer.expect(MockNIOServer.CONNECTED);
SelectorProvider prov = SelectorProvider.provider();
AbstractSelector sel = prov.openSelector();
log.info("about to register client");
channel1.register(sel, SelectionKey.OP_READ);
log.info("registered channel");
log.info("about to close------------------");
channel1.close();
log.info("channel is now closed-----------");
mockServer.expect(MockNIOServer.FAR_END_CLOSED);
}
Aggregations