// This is testing the Rest end points, we should instead be testing the underlying functionality // in unit tests @Test public void testBrowserDownload() { final String text = "abcdefg"; // mock converters map StreamConverter streamConverter = new StreamConverter(repo); Map<String, Converter> converterMap = new HashMap<String, Converter>(); converterMap.put("txt", streamConverter); // stub DefaultExportProcessor DefaultExportHandler defaultExportHandler = new DefaultExportHandler(); defaultExportHandler.setConverters(converterMap); defaultExportHandler.setRepository(repo); loginAsRepositoryAdmin(); ITenant systemTenant = tenantManager.createTenant( null, ServerRepositoryPaths.getPentahoRootFolderName(), adminAuthorityName, authenticatedAuthorityName, "Anonymous"); userRoleDao.createUser( systemTenant, sysAdminUserName, "password", "", new String[] {adminAuthorityName}); login( sysAdminUserName, systemTenant, new String[] {adminAuthorityName, authenticatedAuthorityName}); ITenant mainTenant_1 = tenantManager.createTenant( systemTenant, MAIN_TENANT_1, adminAuthorityName, authenticatedAuthorityName, "Anonymous"); userRoleDao.createUser( mainTenant_1, "admin", "password", "", new String[] {adminAuthorityName}); try { login("admin", mainTenant_1, new String[] {authenticatedAuthorityName, adminAuthorityName}); mp.defineInstance(IUnifiedRepository.class, repo); mp.defineInstance(DefaultExportHandler.class, defaultExportHandler); final String fileName = "file.txt"; createTestFile("/public".replaceAll("/", ":") + ":" + fileName, text); // test download of file WebResource webResource = resource(); webResource.path("repo/files/public:file.txt/download").get(ClientResponse.class); // test download of dir as a zip file ClientResponse r2 = webResource.path("repo/files/public:file.txt/download").get(ClientResponse.class); assertResponse(r2, Status.OK); JerseyTestUtil.assertResponseIsZip(r2); } catch (Throwable ex) { TestCase.fail(); } finally { cleanupUserAndRoles(mainTenant_1); cleanupUserAndRoles(systemTenant); } }