ByteArrayDownload implements Download { public void write(HttpServletResponse response) throws IOException { download.write(response); } ByteArrayDownload(byte[] buff, String contentType, String fileName);  ByteArrayDownload(byte[] buff, String contentType, String fileName, boolean doDownload); void write(HttpServletResponse response);  }
@Test public void shouldFlushWholeStreamToHttpResponse() throws IOException { ByteArrayDownload fd = new ByteArrayDownload(bytes, "type", "x.txt"); fd.write(response); assertArrayEquals(bytes, outputStream.toByteArray()); }
@Test public void shouldUseHeadersToHttpResponse() throws IOException { ByteArrayDownload fd = new ByteArrayDownload(bytes, "type", "x.txt"); fd.write(response); verify(response, times(1)).setHeader("Content-type", "type"); assertArrayEquals(bytes, outputStream.toByteArray()); }