assertNull(receiver.readLine());
assertNull(receiver.readLine());
}
public void testComplexReadWriteLine() throws Exception {
HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup();
transmitter.write(new byte[] {'a', '\n'});
transmitter.write(new byte[] {'\r', '\n'});
transmitter.write(new byte[] {'\r', '\r', '\n'});
transmitter.write(new byte[] {'\n'});
//these write operations should have no effect
transmitter.write(null);
transmitter.write(null, 0, 12);
transmitter.flush();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 14; i++) {
buffer.append("a");
}
String s1 = buffer.toString();
buffer.append("\r\n");
transmitter.write(buffer.toString().getBytes("US-ASCII"));
transmitter.flush();
buffer.setLength(0);
for (int i = 0; i < 15; i++) {
buffer.append("a");
}
String s2 = buffer.toString();
buffer.append("\r\n");
transmitter.write(buffer.toString().getBytes("US-ASCII"));
transmitter.flush();
buffer.setLength(0);
for (int i = 0; i < 16; i++) {
buffer.append("a");
}
String s3 = buffer.toString();
buffer.append("\r\n");
transmitter.write(buffer.toString().getBytes("US-ASCII"));
transmitter.flush();
transmitter.write(new byte[] {'a'});
transmitter.flush();
HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
transmitter.getData());
assertEquals("a", receiver.readLine());
assertEquals("", receiver.readLine());
assertEquals("\r", receiver.readLine());
assertEquals("", receiver.readLine());