111112113114115116117118119120121
line.clear(); assertTrue(inbuf.readLine(line, false)); assertEquals("Two", line.toString()); line.clear(); assertFalse(inbuf.readLine(line, false)); channel = newChannel("\r\nFour"); inbuf.fill(channel); line.clear();
117118119120121122123124125126127
channel = newChannel("\r\nFour"); inbuf.fill(channel); line.clear(); assertTrue(inbuf.readLine(line, false)); assertEquals("Three", line.toString()); inbuf.fill(channel); line.clear();
123124125126127128129130131132133
assertEquals("Three", line.toString()); inbuf.fill(channel); line.clear(); assertTrue(inbuf.readLine(line, true)); assertEquals("Four", line.toString()); line.clear(); assertFalse(inbuf.readLine(line, true)); }
127128129130131132133134135136137
line.clear(); assertTrue(inbuf.readLine(line, true)); assertEquals("Four", line.toString()); line.clear(); assertFalse(inbuf.readLine(line, true)); } public void testWriteLineChunks() throws Exception { HttpParams params = new BasicHttpParams();
143144145146147148149150151152153
inbuf.fill(inChannel); CharArrayBuffer line = new CharArrayBuffer(64); line.clear(); assertTrue(inbuf.readLine(line, false)); assertEquals("One", line.toString()); outbuf.writeLine(line); line.clear();
149150151152153154155156157158159
assertEquals("One", line.toString()); outbuf.writeLine(line); line.clear(); assertTrue(inbuf.readLine(line, false)); assertEquals("Two", line.toString()); outbuf.writeLine(line); line.clear();
155156157158159160161162163164165
assertEquals("Two", line.toString()); outbuf.writeLine(line); line.clear(); assertFalse(inbuf.readLine(line, false)); inChannel = newChannel("\r\nFour"); inbuf.fill(inChannel); line.clear();
161162163164165166167168169170171
inChannel = newChannel("\r\nFour"); inbuf.fill(inChannel); line.clear(); assertTrue(inbuf.readLine(line, false)); assertEquals("Three", line.toString()); outbuf.writeLine(line); inbuf.fill(inChannel);
169170171172173174175176177178179
outbuf.writeLine(line); inbuf.fill(inChannel); line.clear(); assertTrue(inbuf.readLine(line, true)); assertEquals("Four", line.toString()); outbuf.writeLine(line); line.clear();
175176177178179180181182183184185
assertEquals("Four", line.toString()); outbuf.writeLine(line); line.clear(); assertFalse(inbuf.readLine(line, true)); ByteArrayOutputStream outstream = new ByteArrayOutputStream(); WritableByteChannel outChannel = newChannel(outstream); outbuf.flush(outChannel);