ContainerSignatureHttpService implements SignatureUpdateService { @Override public SignatureFileInfo importSignatureFile(final Path targetDir) throws SignatureServiceException { final GetMethod get = new GetMethod(endpointUrl); try { final int statusCode = client.executeMethod(get); if (statusCode == HttpStatus.SC_NOT_FOUND) { throw new SignatureServiceException( String.format(FILE_NOT_FOUND_404, endpointUrl)); } else if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NOT_MODIFIED) { throw new SignatureServiceException( String.format(ERROR_MESSAGE_PATTERN, endpointUrl, statusCode)); } final int version = getVersion(get); final SignatureFileInfo signatureFileInfo = new SignatureFileInfo(version, false, SignatureType.CONTAINER); final String fileName = String.format(FILENAME_PATTERN, version); final Path targetFile = targetDir.resolve(fileName); Files.copy(get.getResponseBodyAsStream(), targetFile); signatureFileInfo.setFile(targetFile); return signatureFileInfo; } catch (final UnknownHostException e) { throw new SignatureServiceException( String.format(COULD_NOT_FIND_SERVER, endpointUrl)); } catch (final IOException | DateParseException e) { throw new SignatureServiceException(e); } finally { get.releaseConnection(); } } ContainerSignatureHttpService();  ContainerSignatureHttpService(String endpointUrl); @Override SignatureFileInfo getLatestVersion(int currentVersion); @Override SignatureFileInfo importSignatureFile(final Path targetDir); @Override void configurationChanged(ConfigurationEvent evt); @Override void onProxyChange(ProxySettings proxySettings); @Override void init(DroidGlobalConfig config);  }
@Test public void testImportSignatureFile() throws IOException { when(proxySettings.isEnabled()).thenReturn(false); httpService.onProxyChange(proxySettings); final File tmpDir = temporaryFolder.newFolder("testImportSignatureFileEmptyFolder"); tmpDir.mkdir(); SignatureFileInfo sigFileInfo; try { sigFileInfo = httpService.importSignatureFile(tmpDir.toPath()); assertEquals(false, sigFileInfo.isDeprecated()); assertTrue(sigFileInfo.getVersion() > 20110114); } catch (SignatureServiceException e) { e.printStackTrace(); } assertEquals(1, tmpDir.list().length); }