}
public void testComplexReadWriteLine() throws Exception {
HttpParams params = new BasicHttpParams();
SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, params);
outbuf.write(ByteBuffer.wrap(new byte[] {'a', '\n'}));
outbuf.write(ByteBuffer.wrap(new byte[] {'\r', '\n'}));
outbuf.write(ByteBuffer.wrap(new byte[] {'\r', '\r', '\n'}));
outbuf.write(ByteBuffer.wrap(new byte[] {'\n'}));
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 14; i++) {
buffer.append("a");
}
String s1 = buffer.toString();
buffer.append("\r\n");
outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes("US-ASCII")));
buffer.setLength(0);
for (int i = 0; i < 15; i++) {
buffer.append("a");
}
String s2 = buffer.toString();
buffer.append("\r\n");
outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes("US-ASCII")));
buffer.setLength(0);
for (int i = 0; i < 16; i++) {
buffer.append("a");
}
String s3 = buffer.toString();
buffer.append("\r\n");
outbuf.write(ByteBuffer.wrap(buffer.toString().getBytes("US-ASCII")));
outbuf.write(ByteBuffer.wrap(new byte[] {'a'}));
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
WritableByteChannel outChannel = newChannel(outstream);
outbuf.flush(outChannel);
ReadableByteChannel channel = newChannel(outstream.toByteArray());
SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 16, params);
inbuf.fill(channel);