### Question:
ChunkInputStream extends InputStream implements Seekable { @Override public synchronized void seek(long pos) throws IOException { if (pos < 0 || pos >= length) { if (pos == 0) { return; } throw new EOFException("EOF encountered at pos: " + pos + " for chunk: " + chunkInfo.getChunkName()); } if (buffersHavePosition(pos)) { adjustBufferPosition(pos - bufferOffset); } else { chunkPosition = pos; } } ChunkInputStream(ChunkInfo chunkInfo, BlockID blockId,
          XceiverClientSpi xceiverClient, boolean verifyChecksum); synchronized long getRemaining(); @Override synchronized int read(); @Override synchronized int read(byte[] b, int off, int len); @Override synchronized void seek(long pos); @Override synchronized long getPos(); @Override boolean seekToNewSource(long targetPos); @Override synchronized void close();  }### Answer:
@Test public void testSeek() throws Exception { seekAndVerify(0); try { seekAndVerify(CHUNK_SIZE); Assert.fail("Seeking to Chunk Length should fail."); } catch (EOFException e) { GenericTestUtils.assertExceptionContains("EOF encountered at pos: " + CHUNK_SIZE + " for chunk: " + CHUNK_NAME, e); } seekAndVerify(25); Assert.assertEquals(25, chunkStream.getChunkPosition()); byte[] b = new byte[30]; chunkStream.read(b, 0, 30); matchWithInputData(b, 25, 30); matchWithInputData(chunkStream.getReadByteBuffers().get(0).toByteArray(), 20, 40); Assert.assertEquals(-1, chunkStream.getChunkPosition()); seekAndVerify(35); Assert.assertEquals(-1, chunkStream.getChunkPosition()); seekAndVerify(75); Assert.assertEquals(75, chunkStream.getChunkPosition()); }