LiveContentRetrieverController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) throws Exception { LiveContentRetrieverCommand cmd = (LiveContentRetrieverCommand) comm; File f = downloadTemporaryFile(cmd.getUrl()); AttachmentView v = new AttachmentView(cmd.getContentFileName(), f, true); return new ModelAndView(v); } LiveContentRetrieverController();   }
@Test @Ignore public final void testHandle() { try { MockHttpServletRequest aReq = new MockHttpServletRequest(); MockHttpServletResponse aResp = new MockHttpServletResponse(); LiveContentRetrieverCommand aCmd = new LiveContentRetrieverCommand(); aCmd.setUrl("http: aCmd.setContentFileName("test.html"); BindException aErrors = new BindException(aCmd, "LiveContentRetrieverCommand"); ModelAndView mav = testInstance.handle(aReq, aResp, aCmd, aErrors); assertTrue(mav != null); assertEquals(mav.getModel().size(), 0); assertTrue(mav.getView() instanceof AttachmentView); AttachmentView view = (AttachmentView)mav.getView(); view.render(null, aReq, aResp); assertTrue(aResp.getHeader("Content-Disposition").toString().endsWith("test.html")); assertTrue(aResp.getContentAsString().contains("British Library")); assertFalse(aErrors.hasErrors()); } catch(Exception e) { fail(e.getMessage()); } }