### Question:
GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } }  @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long write(ByteBuffer[] byteBuffers, int offset, int length); @Override long position(); @Override FileChannel position(long offset); @Override long size(); @Override FileChannel truncate(long l); @Override void force(boolean b); @Override long transferTo(long l, long l2, WritableByteChannel writableByteChannel); @Override long transferFrom(ReadableByteChannel readableByteChannel, long l, long l2); @Override int read(ByteBuffer byteBuffer, long position); @Override int write(ByteBuffer byteBuffer, long position); @Override MappedByteBuffer map(MapMode mapMode, long l, long l2); @Override FileLock lock(long l, long l2, boolean b); @Override FileLock tryLock(long l, long l2, boolean b); static final Map<StandardOpenOption, Integer> optionMap; static final Map<PosixFilePermission, Integer> perms; }### Answer:
@Test public void testGuardClosed_whenNotClosed() throws ClosedChannelException { channel.setClosed(false); channel.guardClosed(); }
@Test(expected = ClosedChannelException.class) public void testGuardClosed_whenClosed() throws ClosedChannelException { channel.setClosed(true); channel.guardClosed(); }