@Test public void testRandomReads() throws Exception { Random random = new Random(); int length = random.nextInt(SIZE); byte[] data = new byte[length]; random.nextBytes(data); Input in = new InputBytes(data); for (int i = 0; i < COUNT; i++) { int p = random.nextInt(length); int l = Math.min(random.nextInt(SIZE/10), length-p); byte[] buffer = new byte[l]; in.read(p, buffer, 0, l); Assert.assertArrayEquals(Arrays.copyOfRange(data, p, p+l), buffer); } }
@Override public synchronized int read(long pos, byte[] b, int start, int len) throws IOException { this.pos = (int)pos; return read(b, start, len); }
InputBytes extends ByteArrayInputStream implements Input { @Override public synchronized int read(long pos, byte[] b, int start, int len) throws IOException { this.pos = (int)pos; return read(b, start, len); } }
InputBytes extends ByteArrayInputStream implements Input { @Override public synchronized int read(long pos, byte[] b, int start, int len) throws IOException { this.pos = (int)pos; return read(b, start, len); } InputBytes(byte[] data);  InputBytes(ByteBuffer data); }
InputBytes extends ByteArrayInputStream implements Input { @Override public synchronized int read(long pos, byte[] b, int start, int len) throws IOException { this.pos = (int)pos; return read(b, start, len); } InputBytes(byte[] data);  InputBytes(ByteBuffer data); @Override long length(); @Override synchronized int read(long pos, byte[] b, int start, int len); }
InputBytes extends ByteArrayInputStream implements Input { @Override public synchronized int read(long pos, byte[] b, int start, int len) throws IOException { this.pos = (int)pos; return read(b, start, len); } InputBytes(byte[] data);  InputBytes(ByteBuffer data); @Override long length(); @Override synchronized int read(long pos, byte[] b, int start, int len);  }