ArchiveHandler { public static String getDescriptor(InputStream archiveStream, long maxMtaDescriptorSize) throws SLException { try (InputStream descriptorStream = getInputStream(archiveStream, MTA_DEPLOYMENT_DESCRIPTOR_NAME, maxMtaDescriptorSize)) { return IOUtils.toString(descriptorStream, StandardCharsets.UTF_8); } catch (IOException e) { throw new SLException(e, Messages.ERROR_RETRIEVING_MTA_MODULE_CONTENT); } }  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 testGetDescriptor() throws Exception { String descriptor = ArchiveHandler.getDescriptor(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_MTAR), MAX_MTA_DESCRIPTOR_SIZE); assertTrue(descriptor.contains("com.sap.mta.sample")); }
@Test void testGetDescriptorExceedsSize() throws Exception { assertThrows(ContentException.class, () -> ArchiveHandler.getDescriptor(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_MTAR), 1024L)); }
@Test void testGetDescriptorFlat() throws Exception { String descriptor = ArchiveHandler.getDescriptor(ArchiveHandlerTest.class.getResourceAsStream(SAMPLE_FLAT_MTAR), MAX_MTA_DESCRIPTOR_SIZE); assertTrue(descriptor.contains("com.sap.mta.sample")); }