@Override
    public int read() throws IOException {
        if (!ensureDataInBuffer()) {
            return -1;
        }
        return buf[position++] & BYTE_MASK;
    }
@Test
    public void readByteByByte() throws Exception {
        for (byte b : mockInput) {
            assertEquals(b, (byte) in.read());
        }
        assertEquals(-1, in.read());
    }