### Question:
Helper { public static String extractSignature(String file, int index) throws IOException { try (ZipFile zipFile = new ZipFile(file)) { String signatureFileName = "META-INF/signatures" + index + ".xml"; ZipEntry entry = zipFile.getEntry(signatureFileName); if (entry == null) throw new IOException(signatureFileName + " does not exists in archive: " + file); try (InputStream inputStream = zipFile.getInputStream(entry)) { return IOUtils.toString(inputStream, "UTF-8"); } } } private  Helper(); static File[] getFilesFromPath(Path path); static File[] getFilesFromPath(Path path, FileFilter filter); static File[] getFilesFromResourcePath(Path path); static File[] getFilesFromResourcePath(Path path, FileFilter filter); static byte[] generateRandomBytes(int length); static boolean isZipFile(InputStream stream); static boolean isZipFile(File file); static boolean isXMLFile(File file); static void deleteFile(String file); static String extractSignature(String file, int index); static void serialize(T object, File file); static void serialize(T object, String filename); static T deserializer(File file); static T deserializer(String filename); static OutputStream bufferedOutputStream(File file); static X509Certificate loadCertificate(String filePath); static boolean hasSpecialCharacters(String fileName); static String getIdentifier(String identifier); static SignaturePolicyProvider getBdocSignaturePolicyProvider(DSSDocument signature); static List<byte[]> getAllFilesFromContainerAsBytes(Container container); static List<byte[]> getAllFilesFromContainerPathAsBytes(String pathFrom); static void saveAllFilesFromContainerToFolder(Container container, String path); static void saveAllFilesFromContainerPathToFolder(String pathFrom, String pathTo); static void deleteTmpFiles(); static boolean isPdfFile(String file); static String bytesToHex(byte[] bytes, int maxLen); static void printWarningSection(Logger logger, String warningMessage); static void printErrorSection(Logger logger, String errorMessage); static final String SPECIAL_CHARACTERS; }### Answer:
@Test public void extractSignatureS0() throws Exception { Assert.assertEquals("A", Helper.extractSignature(this.createZIPFile(), 0)); }
@Test public void extractSignatureS1() throws Exception { Assert.assertEquals("B", Helper.extractSignature(this.createZIPFile(), 1)); }
@Test(expected = IOException.class) public void extractSignatureThrowsErrorWhenSignatureIsNotFound() throws Exception { String file = this.getFileBy("zip"); try ( FileOutputStream fileStream = new FileOutputStream(file); ZipOutputStream zipStream = new ZipOutputStream(fileStream)) { ZipEntry zipEntry = new ZipEntry("test"); zipStream.putNextEntry(zipEntry); zipStream.write(0x42); zipStream.closeEntry(); } Helper.extractSignature(file, 0); }