public class PartialBufferOutputStream2Test extends TestCase {
public void testFlushOnClose() throws IOException {
MockHttpServletResponse mockResponse = new MockHttpServletResponse();
PartialBufferedOutputStream2 pbos = new PartialBufferedOutputStream2(mockResponse);
PrintStream ps = new PrintStream(pbos);
ps.print("Hello world!");
ps.close();
// check the in memory buffer has been flushed to the target output stream