Dec 14th, 2004, 05:04 AM
I found an issue with MockHttpServletResponse that I believe can be considered as a bug.
When I obtain a PrintWriter from the MockHttpServletResponse using getWriter() method, then a new OutputStreamWriter is created and wrapped inside a PrintWriter. When I write() something to that writer and later in my test use MockHttpServletResponse.getContentAsString() then the content might not yet contain everything I wrote to that PrintWriter because either the PrintWriter or OutputStreamWriter might be buffering their content.
To resolve this I think the getContentAsString() and getContentAsByteArray() should call flushBuffer() first.