}
}
@Test
public void testWriteLineChunks() throws Exception {
final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(16, 16, null, this.allocator);
final SessionInputBuffer inbuf = new SessionInputBufferImpl(16, 16, null, this.allocator);
ReadableByteChannel inChannel = newChannel("One\r\nTwo\r\nThree");
inbuf.fill(inChannel);
final CharArrayBuffer line = new CharArrayBuffer(64);
line.clear();
Assert.assertTrue(inbuf.readLine(line, false));
Assert.assertEquals("One", line.toString());
outbuf.writeLine(line);
line.clear();
Assert.assertTrue(inbuf.readLine(line, false));
Assert.assertEquals("Two", line.toString());
outbuf.writeLine(line);
line.clear();
Assert.assertFalse(inbuf.readLine(line, false));
inChannel = newChannel("\r\nFour");
inbuf.fill(inChannel);
line.clear();
Assert.assertTrue(inbuf.readLine(line, false));
Assert.assertEquals("Three", line.toString());
outbuf.writeLine(line);
inbuf.fill(inChannel);
line.clear();
Assert.assertTrue(inbuf.readLine(line, true));
Assert.assertEquals("Four", line.toString());
outbuf.writeLine(line);
line.clear();
Assert.assertFalse(inbuf.readLine(line, true));
final ByteArrayOutputStream outstream = new ByteArrayOutputStream();
final WritableByteChannel outChannel = newChannel(outstream);
outbuf.flush(outChannel);
final String s = new String(outstream.toByteArray(), "US-ASCII");
Assert.assertEquals("One\r\nTwo\r\nThree\r\nFour\r\n", s);
}