// expected
}
}
public void testReusableStringReader() throws Exception {
ReusableStringReader reader = new ReusableStringReader();
assertEquals(-1, reader.read());
assertEquals(-1, reader.read(new char[1]));
assertEquals(-1, reader.read(new char[2], 1, 1));
assertEquals(-1, reader.read(CharBuffer.wrap(new char[2])));
reader.setValue("foobar");
char[] buf = new char[4];
assertEquals(4, reader.read(buf));
assertEquals("foob", new String(buf));
assertEquals(2, reader.read(buf));
assertEquals("ar", new String(buf, 0, 2));
assertEquals(-1, reader.read(buf));
reader.close();
reader.setValue("foobar");
assertEquals(0, reader.read(buf, 1, 0));
assertEquals(3, reader.read(buf, 1, 3));
assertEquals("foo", new String(buf, 1, 3));
assertEquals(2, reader.read(CharBuffer.wrap(buf, 2, 2)));
assertEquals("ba", new String(buf, 2, 2));
assertEquals('r', (char) reader.read());
assertEquals(-1, reader.read(buf));
reader.close();
reader.setValue("foobar");
StringBuilder sb = new StringBuilder();
int ch;
while ((ch = reader.read()) != -1) {
sb.append((char) ch);
}
reader.close();
assertEquals("foobar", sb.toString());
}