ArchiveHandler { public static byte[] getFileContent(InputStream archiveStream, String fileName, long maxMtaFileSize) throws SLException { try (InputStream moduleStream = getInputStream(archiveStream, fileName, maxMtaFileSize)) { return IOUtils.toByteArray(moduleStream); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT, fileName); } }  static Manifest getManifest(InputStream archiveStream, long maxManifestSize); static String getDescriptor(InputStream archiveStream, long maxMtaDescriptorSize); static byte[] getFileContent(InputStream archiveStream, String fileName, long maxMtaFileSize); static InputStream getInputStream(InputStream is, String entryName, long maxEntrySize); static final String MTA_DEPLOYMENT_DESCRIPTOR_NAME; }
@Test void testGetModuleContent() throws Exception { byte[] moduleContent = ArchiveHandler.getFileContent(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_MTAR), "web/web-server.zip", 2 * 1024 * 1024); InputStream entryStream = getEntryStream(moduleContent, "readme.txt"); String readmeContent = IOUtils.toString(entryStream, StandardCharsets.UTF_8); assertEquals("App router code will be packaged in this archive", readmeContent); }
@Test void testGetModuleContentExceedsSize() throws Exception { assertThrows(ContentException.class, () -> ArchiveHandler.getFileContent(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_MTAR), "web/web-server.zip", 128L)); }