ExportController extends AbstractTemplateController { @Override protected ModelAndView svnHandle(final SVNConnection connection, final BaseCommand cmd, final long headRevision, final UserRepositoryContext userRepositoryContext, final HttpServletRequest request, final HttpServletResponse response, final BindException exception) throws Exception { final MultipleEntriesCommand command = (MultipleEntriesCommand) cmd; final long pegRevision = command.hasPegRevision() ? command.getPegRevision().getNumber() : command.getRevisionNumber(); if (userRepositoryContext.getIsWaitingForExport()) { throw new IllegalStateException("Export already in progress"); } final UUID uuid = exportExecutor.submit(command, connection, pegRevision); userRepositoryContext.setExportUuid(uuid); userRepositoryContext.setIsWaitingForExport(true); final Map<String, String> model = new HashMap<String, String>(); model.put("revision", command.getRevision().toString()); return new ModelAndView(new RedirectView(command.createListUrl(), true), model); } ExportController(final ExportExecutor exportExecutor);   }
@Test public void testExport() throws Exception { final File tempFile = File.createTempFile("sventon-", "-test"); tempFile.deleteOnExit(); final MockHttpServletRequest request = new MockHttpServletRequest(); final MockHttpServletResponse response = new MockHttpServletResponse(); final UserRepositoryContext context = new UserRepositoryContext(); final MultipleEntriesCommand command = new MultipleEntriesCommand(); final PathRevision[] entriesToExport = new PathRevision[]{ new PathRevision("/trunk/file1", Revision.create(100)), new PathRevision("/tags/test/file2", Revision.create(101)) }; command.setName(new RepositoryName("test")); command.setEntries(entriesToExport); assertFalse(context.getIsWaitingForExport()); assertNull(context.getExportUuid()); final ExportController ctrl = new ExportController(new ExportExecutor() { public UUID submit(MultipleEntriesCommand command, SVNConnection connection, long pegRevision) { return UUID.fromString(UUID_STRING); } public void downloadByUUID(UUID uuid, HttpServletRequest request, HttpServletResponse response) throws IOException { } public void delete(UUID uuid) { } public int getProgress(UUID uuid) { return 1; } }); final ModelAndView modelAndView = ctrl.svnHandle(null, command, 123, context, request, response, null); assertNotNull(modelAndView); assertTrue(context.getIsWaitingForExport()); assertEquals(UUID_STRING, context.getExportUuid().toString()); }