@Test public void testWillContinueToLoadOnException() throws Exception { final IPlatformImporter importer = mock(IPlatformImporter.class); final FileInputStream inputStream = mock(FileInputStream.class); final ArchiveLoader loader = createArchiveLoader(importer, inputStream); final File directory = mock(File.class); final File jobs = mock(File.class); String jobsName = "jobs.zip"; when(jobs.getName()).thenReturn(jobsName); final File reports = mock(File.class); when(jobs.getPath()).thenReturn("/root/path/" + jobsName); String reportsName = "reports.zip"; when(reports.getName()).thenReturn(reportsName); when(reports.getPath()).thenReturn("/root/path/" + reportsName); when(directory.listFiles(ZIPS_FILTER)).thenReturn(new File[] {jobs, reports}); Exception exception = new RuntimeException("exception thrown on purpose from testWillContinueToLoadOnException"); doThrow(exception).when(importer).importFile(argThat(bundleMatcher(jobsName, inputStream))); IRepositoryImportLogger logger = mock(IRepositoryImportLogger.class); when(importer.getRepositoryImportLogger()).thenReturn(logger); loader.loadAll(directory, ZIPS_FILTER); verify(importer).importFile(argThat(bundleMatcher(jobsName, inputStream))); verify(importer).importFile(argThat(bundleMatcher(reportsName, inputStream))); verify(jobs).renameTo(argThat(fileMatcher(jobs))); verify(reports).renameTo(argThat(fileMatcher(reports))); }