String s3 = "Like hello and stuff";
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setHttpElementCharset(params, "UTF-8");
SessionOutputBufferMockup outbuffer = new SessionOutputBufferMockup(params);
CharArrayBuffer chbuffer = new CharArrayBuffer(16);
for (int i = 0; i < 10; i++) {
chbuffer.clear();
chbuffer.append(s1);
outbuffer.writeLine(chbuffer);
chbuffer.clear();
chbuffer.append(s2);
outbuffer.writeLine(chbuffer);
chbuffer.clear();
chbuffer.append(s3);
outbuffer.writeLine(chbuffer);
}
outbuffer.flush();
long bytesWritten = outbuffer.getMetrics().getBytesTransferred();
long expected = ((s1.toString().getBytes("UTF-8").length + 2)+
(s2.toString().getBytes("UTF-8").length + 2) +
(s3.toString().getBytes("UTF-8").length + 2)) * 10;
assertEquals(expected, bytesWritten);
SessionInputBufferMockup inbuffer = new SessionInputBufferMockup(
outbuffer.getData(), params);
for (int i = 0; i < 10; i++) {
assertEquals(s1, inbuffer.readLine());
assertEquals(s2, inbuffer.readLine());
assertEquals(s3, inbuffer.readLine());