testTarget.start();
SocketChannel channel = testTarget.getSocketChannel();
BlockingSocketChannel blockingChannel =
new BlockingSocketChannel(channel);
blockingChannel.configureBlocking(false);
TestChannelHandler testChannelHandler = new TestChannelHandler();
steppingDispatcher.registerChannel(blockingChannel, testChannelHandler);
logger.finest("close input from target");
testTarget.shutdownOutput();
logger.finest("wait until shutdown propagated through framework");
testChannelHandler.waitForInputClosed();
logger.finest(
"trigger another selection round by blocking write operation");
ChannelWriter channelWriter = testChannelHandler.getChannelWriter();
StringToByteBufferTransformer transformer =
new StringToByteBufferTransformer();
transformer.setNextForwarder(channelWriter);
transformer.forward(
"this must block and trigger another selection round");
logger.finest("push dispatcher some selection rounds forward");
// (we REALLY need two calls here as the first round does not have the
// incomplete write in its selected set...)
steppingDispatcher.continueDispatcher();
steppingDispatcher.continueDispatcher();
// test that closeCounter is still at one after the selection rounds
// above
assertEquals(1, testChannelHandler.getCloseCounter());
}