@Test public void shouldSetMd5AndSSLPortHeaders() throws Exception { ServerBinaryDownloader downloader = new ServerBinaryDownloader(ServerUrlGeneratorMother.generatorFor("localhost", server.getPort()), null, SslVerificationMode.NONE); downloader.downloadIfNecessary(DownloadableFile.AGENT); MessageDigest digester = MessageDigest.getInstance("MD5"); try (BufferedInputStream stream = new BufferedInputStream(new FileInputStream(DownloadableFile.AGENT.getLocalFile()))) { try (DigestInputStream digest = new DigestInputStream(stream, digester)) { IOUtils.copy(digest, new NullOutputStream()); } assertThat(downloader.getMd5(), is(Hex.encodeHexString(digester.digest()).toLowerCase())); } assertThat(downloader.getSslPort(), is(String.valueOf(server.getSecurePort()))); }
agentDownloader.downloadIfNecessary(DownloadableFile.AGENT); pluginZipDownloader.downloadIfNecessary(DownloadableFile.AGENT_PLUGINS); tfsImplDownloader.downloadIfNecessary(DownloadableFile.TFS_IMPL);
if (launcherDownloader.downloadIfNecessary(DownloadableFile.LAUNCHER)) { return LAUNCHER_NOT_UP_TO_DATE; agentDownloader.downloadIfNecessary(DownloadableFile.AGENT);
@Test public void shouldReturnTrueIfTheFileIsDownloaded() { ServerBinaryDownloader downloader = new ServerBinaryDownloader(ServerUrlGeneratorMother.generatorFor("localhost", server.getPort()), null, SslVerificationMode.NONE); assertThat(downloader.downloadIfNecessary(DownloadableFile.AGENT), is(true)); }
@Test public void shouldDownloadAgentJarFile() { ServerBinaryDownloader downloader = new ServerBinaryDownloader(ServerUrlGeneratorMother.generatorFor("localhost", server.getPort()), null, SslVerificationMode.NONE); assertThat(DownloadableFile.AGENT.doesNotExist(), is(true)); downloader.downloadIfNecessary(DownloadableFile.AGENT); assertThat(DownloadableFile.AGENT.getLocalFile().exists(), is(true)); }
private void assertExtraProperties(String valueToSet, Map<String, String> expectedValue) { ServerBinaryDownloader downloader = new ServerBinaryDownloader(ServerUrlGeneratorMother.generatorFor("localhost", server.getPort()), null, SslVerificationMode.NONE); try { server.setExtraPropertiesHeaderValue(valueToSet); downloader.downloadIfNecessary(DownloadableFile.AGENT); assertThat(downloader.getExtraProperties(), is(expectedValue)); } finally { server.setExtraPropertiesHeaderValue(null); } } }