MockHttpServletResponse response = new MockHttpServletResponse();
resolution.applyHeaders(response);
resolution.stream(response);
Assert.assertEquals(data, response.getOutputBytes());
ContentDisposition disposition = getContentDisposition(response);
if (attachment) {
if (filename == null) {
Assert.assertNotNull(disposition);
Assert.assertEquals("attachment", disposition.getDisposition());
Assert.assertNull(disposition.getParameter("filename"));
}
else {
Assert.assertNotNull(disposition);
Assert.assertEquals("attachment", disposition.getDisposition());
Assert.assertNotNull(disposition.getParameter("filename"));
}
}
else {
if (filename == null) {
Assert.assertNull(disposition);
}
else {
Assert.assertNotNull(disposition);
Assert.assertEquals("attachment", disposition.getDisposition());
Assert.assertNotNull(disposition.getParameter("filename"));
}
}
}