ArchiveHandler { public static Manifest getManifest(InputStream archiveStream, long maxManifestSize) throws SLException { try (InputStream manifestStream = getInputStream(archiveStream, JarFile.MANIFEST_NAME, maxManifestSize)) { return new Manifest(manifestStream); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_ARCHIVE_MANIFEST); } }  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 testGetManifest() throws Exception { Manifest manifest = ArchiveHandler.getManifest(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_MTAR), MAX_MANIFEST_SIZE); Map<String, Attributes> entries = manifest.getEntries(); assertEquals(4, entries.size()); assertTrue(entries.containsKey("web/web-server.zip")); assertTrue(entries.containsKey("applogic/pricing.zip")); assertTrue(entries.containsKey("db/pricing-db.zip")); assertTrue(entries.containsKey("META-INF/mtad.yaml")); }
@Test void testGetManifestExceedsSizeLimit() throws Exception { assertThrows(ContentException.class, () -> ArchiveHandler.getManifest(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_MTAR), 512L)); }
@Test void testGetManifestFlat() throws Exception { Manifest manifest = ArchiveHandler.getManifest(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_FLAT_MTAR), MAX_MANIFEST_SIZE); Map<String, Attributes> entries = manifest.getEntries(); assertEquals(4, entries.size()); assertTrue(entries.containsKey("web/")); assertTrue(entries.containsKey("applogic/")); assertTrue(entries.containsKey("db/")); assertTrue(entries.containsKey("META-INF/mtad.yaml")); }