private static void await(SocketChannel channel,int op) throws IOException {
  Selector selector=Selector.open();
  SelectionKey key=channel.register(selector,op);
  try {
    assertEquals(true,awaitOp(selector,key,op));
  }
  finally {
    key.cancel();
    selector.close();
  }
}

private static void await ( SocketChannel channel , int op ) throws IOException { Selector selector = Selector . open ( ) ; SelectionKey key = channel . register ( selector , op ) ; try { assertEquals ( true , awaitOp ( selector , key , op ) ) ; } finally { key . cancel ( ) ; selector . close ( ) ; } }
waits for up to 1 second for the channel to process the op
