* @author Jerome Louvel
*/
public class BufferTestCase extends RestletTestCase {
public void testFlip() throws IOException {
Buffer buffer = new Buffer(8192);
buffer.fill("abcdefghijklm");
buffer.flip();
for (int i = 0; i < 4; i++) {
// Drain first characters
buffer.drain();
}
buffer.flip();
buffer.fill("nopqrst");
buffer.flip();
for (int i = 0; i < 4; i++) {
// Drain first characters
buffer.drain();
}
buffer.flip();
buffer.fill("uvwxyz");
buffer.flip();
StringBuilder sb = new StringBuilder();
buffer.drain(sb, BufferState.FILLING);
assertEquals("Remaining buffer", "ijklmnopqrstuvwxyz", sb.toString());
}