@Test
public void limitsInputLength() throws IOException {

  OngoingStubbing bufferedReaderStubbing = when(bufferedReaderMock.read());
  for (int i = 0; i < 300; i++) {
    bufferedReaderStubbing = bufferedReaderStubbing.thenReturn(42);
  }
  try {
    testSubject.readRequest();
    Assert.fail("Should have thrown exception");
  } catch (IOException e) {
    Assert.assertEquals(e.getMessage(), "input too long");
  }
}