### Question:
ByteArrayWrapper extends ByteArrayInputStream implements PositionedReadable, Seekable, Closeable { public synchronized void seek(long position) throws IOException { if (position < 0 || position >= count) { throw new IOException("cannot seek position " + position + " as it is out of bounds"); } pos = (int) position; } ByteArrayWrapper(byte[] buf); synchronized void seek(long position); synchronized long getPos(); boolean seekToNewSource(long targetPos); synchronized int read(long position, byte[] buffer, int offset, int length); synchronized void readFully(long position, byte[] buffer, int offset, int length); synchronized void readFully(long position, byte[] buffer);  }### Answer:
@Test public void testSeek() throws IOException { ByteArrayWrapper wrapper = createInstance(16); final int position = 4; wrapper.seek(position); assertEquals(4, wrapper.getPos()); wrapper.close(); }
@Test(expected=IOException.class) public void testSeekNegative() throws IOException { ByteArrayWrapper wrapper = createInstance(16); wrapper.seek(-2); wrapper.close(); }
@Test(expected=IOException.class) public void testSeekOutOfBounds() throws IOException { ByteArrayWrapper wrapper = createInstance(16); wrapper.seek(20); wrapper.close(); }