UnsyncBufferedReader extends Reader { @Override public int read() throws IOException { if (_reader == null) { throw new IOException("Reader is null"); } if (_index >= _firstInvalidIndex) { _fillInBuffer(); if (_index >= _firstInvalidIndex) { return -1; } } return _buffer[_index++]; } UnsyncBufferedReader(Reader reader);  UnsyncBufferedReader(Reader reader, int size); @Override void close(); @Override void mark(int markLimit); @Override boolean markSupported(); @Override int read(); @Override int read(char[] chars); @Override int read(char[] chars, int offset, int length); String readLine(); @Override boolean ready(); @Override void reset(); @Override long skip(long skip);  }
@Override @Test public void testRead() throws Exception { UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader( new StringReader("ab\r\nef"), 3); char[] buffer = (char[])_bufferField.get(unsyncBufferedReader); Assert.assertEquals(Arrays.toString(buffer), 3, buffer.length); Assert.assertEquals(0, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals('a', unsyncBufferedReader.read()); Assert.assertEquals(1, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals('b', unsyncBufferedReader.read()); Assert.assertEquals(2, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals('\r', unsyncBufferedReader.read()); Assert.assertEquals(3, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals('\n', unsyncBufferedReader.read()); Assert.assertEquals(1, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals('e', unsyncBufferedReader.read()); Assert.assertEquals(2, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals('f', unsyncBufferedReader.read()); Assert.assertEquals(3, _indexField.getInt(unsyncBufferedReader)); Assert.assertEquals(-1, unsyncBufferedReader.read()); }