DefaultExportExecutor implements ExportExecutor { protected void prepareResponse(final HttpServletRequest request, final HttpServletResponse response, final File attachment) { response.setContentType(WebUtils.APPLICATION_OCTET_STREAM); response.setHeader(WebUtils.CONTENT_DISPOSITION_HEADER, "attachment; filename=\"" + EncodingUtils.encodeFilename(attachment.getName(), request.getHeader("USER-AGENT")) + "\""); } DefaultExportExecutor(final ConfigDirectory configDirectory); @Override UUID submit(final MultipleEntriesCommand command, final SVNConnection connection, final long pegRevision); @Override int getProgress(final UUID uuid); @Override void delete(final UUID uuid); @Override void downloadByUUID(final UUID uuid, final HttpServletRequest request, final HttpServletResponse response); @Autowired void setRepositoryService(final RepositoryService repositoryService); void setArchiveFileCharset(final String archiveFileCharset); static final String FALLBACK_CHARSET; }
@Test public void testPrepareResponse() throws Exception { final ConfigDirectory configDirectoryMock = createMock(ConfigDirectory.class); final DefaultExportExecutor exportExecutor = new DefaultExportExecutor(configDirectoryMock); final MockHttpServletRequest request = new MockHttpServletRequest(); final MockHttpServletResponse response = new MockHttpServletResponse(); assertEquals(0, response.getHeaderNames().size()); assertNull(response.getContentType()); exportExecutor.prepareResponse(request, response, new File("testfile")); assertEquals(1, response.getHeaderNames().size()); assertEquals("attachment; filename=\"testfile\"", response.getHeader(WebUtils.CONTENT_DISPOSITION_HEADER)); assertEquals(WebUtils.APPLICATION_OCTET_STREAM, response.getContentType()); }