PronomSignatureService implements SignatureUpdateService { @Override public SignatureFileInfo importSignatureFile(final Path targetDir) throws SignatureServiceException { final Element sigFile = pronomService.getSignatureFileV1().getElement(); final int version = Integer.valueOf(sigFile.getAttribute("Version")); final boolean deprecated = Boolean .valueOf(sigFile.getAttribute("Deprecated")); final SignatureFileInfo sigInfo = new SignatureFileInfo(version, deprecated, SignatureType.BINARY); final String fileName = String.format(filenamePattern, version); final Path outputFile = targetDir.resolve(fileName); try (final Writer writer = Files.newBufferedWriter(outputFile, UTF_8)) { final XMLSerializer serializer = new XMLSerializer(writer, new OutputFormat(Method.XML, "UTF-8", true)); serializer.serialize(sigFile); sigInfo.setFile(outputFile); } catch (final IOException e) { throw new SignatureServiceException(e); } return sigInfo; } PronomSignatureService();  PronomSignatureService(PronomService pronomService, String filenamePattern); @Override SignatureFileInfo importSignatureFile(final Path targetDir); void setPronomService(PronomService pronomService); void setFilenamePattern(String filenamePattern); @Override SignatureFileInfo getLatestVersion(int currentVersion); @Override void configurationChanged(ConfigurationEvent evt); @Override void onProxyChange(ProxySettings proxySettings); @Override void init(DroidGlobalConfig config);  }
@Test public void testGetSigFileFromRemoteWebServiceSavesFileLocally() throws SignatureServiceException, IOException { List<Path> sigFiles = FileUtil.listFiles(sigFileDir, false, (DirectoryStream.Filter)null); assertEquals(0, sigFiles.size()); SignatureFileInfo info = importer.importSignatureFile(sigFileDir); sigFiles = FileUtil.listFiles(sigFileDir, false, (DirectoryStream.Filter)null); assertEquals(1, sigFiles.size()); assertTrue(info.getVersion() > 0); assertEquals(false, info.isDeprecated()); assertEquals(SignatureType.BINARY, info.getType()); }