### Question:
GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position((int)read); return (int) read; }  @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(expected = ClosedChannelException.class) public void testRead3Arg_whenClosed() throws IOException { channel.setClosed(true); ByteBuffer[] buffers = new ByteBuffer[2]; buffers[0] = mockBuffer; buffers[1] = mockBuffer; int offset = 0; int length = 2; channel.read(buffers, offset, length); }
@Test(expected = ClosedChannelException.class) public void testRead2Arg_whenClosed() throws IOException { long position = 5L; channel.setClosed(true); channel.read(mockBuffer, position); }