title: Reading mocked ServletOutputStream from println
body: <p>I have an HttpServlet that I'm trying to write tests for and have mocked the ServletOutputStream: <code>ServletOutputStream outputStream = mock(ServletOutputStream.class);</code>. I need to get what's written to outputStream in the servlet that used <code>println</code>. ie, in the servlet, I have code like:</p>
  
  <pre><code>ServletOutputStream out = response.getOutpuStream();
  out.println("foo");
  </code></pre>
  
  <p>So, I would want to test for "foo." I've tried to say <code>when(outputStream.println()).then...</code>, but this doesn't work since println() is a void method. I've also investigated HttpServletResponseWrappers, but have been unable to find a solution there. Ideas? I'm using Mockito.</p>