@Test void testFailToCreateZip() { String fileName = "db/"; ApplicationArchiveReader reader = new ApplicationArchiveReader(); ApplicationZipBuilder zipBuilder = new ApplicationZipBuilder(reader) { @Override protected void copy(InputStream input, OutputStream output, ApplicationArchiveContext applicationArchiveContext) throws IOException { throw new IOException(); } }; ApplicationArchiveContext applicationArchiveContext = getApplicationArchiveContext(SAMPLE_MTAR, fileName); Assertions.assertThrows(SLException.class, () -> appPath = zipBuilder.extractApplicationInNewArchive(applicationArchiveContext)); }
public Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext) { Path appPath = null; try { appPath = createTempFile(); saveAllEntries(appPath, applicationArchiveContext); return appPath; } catch (Exception e) { FileUtils.cleanUp(appPath, LOGGER); throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT, applicationArchiveContext.getModuleFileName()); } }
ApplicationZipBuilder { public Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext) { Path appPath = null; try { appPath = createTempFile(); saveAllEntries(appPath, applicationArchiveContext); return appPath; } catch (Exception e) { FileUtils.cleanUp(appPath, LOGGER); throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT, applicationArchiveContext.getModuleFileName()); } } }
ApplicationZipBuilder { public Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext) { Path appPath = null; try { appPath = createTempFile(); saveAllEntries(appPath, applicationArchiveContext); return appPath; } catch (Exception e) { FileUtils.cleanUp(appPath, LOGGER); throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT, applicationArchiveContext.getModuleFileName()); } } @Inject  ApplicationZipBuilder(ApplicationArchiveReader applicationArchiveReader); }
ApplicationZipBuilder { public Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext) { Path appPath = null; try { appPath = createTempFile(); saveAllEntries(appPath, applicationArchiveContext); return appPath; } catch (Exception e) { FileUtils.cleanUp(appPath, LOGGER); throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT, applicationArchiveContext.getModuleFileName()); } } @Inject  ApplicationZipBuilder(ApplicationArchiveReader applicationArchiveReader); Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext); }
ApplicationZipBuilder { public Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext) { Path appPath = null; try { appPath = createTempFile(); saveAllEntries(appPath, applicationArchiveContext); return appPath; } catch (Exception e) { FileUtils.cleanUp(appPath, LOGGER); throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT, applicationArchiveContext.getModuleFileName()); } } @Inject  ApplicationZipBuilder(ApplicationArchiveReader applicationArchiveReader); Path extractApplicationInNewArchive(ApplicationArchiveContext applicationArchiveContext);  }