DefaultPipeChannel implements PipeChannel { @Override public void close() throws IOException { wrappedChannel.close(); } private  DefaultPipeChannel(AsynchronousFileChannel wrappedChannel); @Override Future<Integer> read(ByteBuffer bb); @Override Future<Integer> write(ByteBuffer bb); @Override boolean isOpen(); @Override void close(); @Override int available();  }
@Test public void close() throws IOException { PipeChannel channel = DefaultPipeChannel.open(tempFile()); channel.close(); assertThatExceptionOfType(ExecutionException.class) .isThrownBy(() -> channel.write(ByteBuffer.allocate(1)).get()) .withCauseInstanceOf(ClosedChannelException.class); assertThatExceptionOfType(ExecutionException.class) .isThrownBy(() -> channel.read(ByteBuffer.allocate(1)).get()) .withCauseInstanceOf(ClosedChannelException.class); channel.close(); }