DefaultFileDownloader implements FileDownloader { @Override public void download(URI downloadURI, File destination, String userName, String password) throws DownloadException { this.userName = userName; this.password = password; String oldProtocols = System.setProperty(HTTPS_PROTOCOLS, "TLSv1.2"); try { if ("file".equalsIgnoreCase(downloadURI.getScheme())) { FileUtils.copyFile(new File(downloadURI), destination); } else { downloadFile(destination, downloadURI); } } catch (IOException e) { throw new DownloadException("Could not download " + downloadURI, e); } finally { if (oldProtocols == null) { System.clearProperty(HTTPS_PROTOCOLS); } else { System.setProperty(HTTPS_PROTOCOLS, oldProtocols); } } } DefaultFileDownloader(ProxyConfig proxyConfig); @Override void download(URI downloadURI, File destination, String userName,
            String password); static final String HTTPS_PROTOCOLS; }
@Test public void installNodeFromFileSystem_NodeIsInstalledToTargetDirectory() throws IOException, DownloadException { File targetDir = new File(baseDir + "/installation"); Assert.assertFalse( "Clean test should not contain a installation folder", targetDir.exists()); File downloadDir = tmpDir.newFolder("v12.18.3"); String downloadFileName = "MyDownload.zip"; File archiveFile = new File(downloadDir, downloadFileName); archiveFile.createNewFile(); Path tempArchive = archiveFile.toPath(); DefaultFileDownloader downloader = new DefaultFileDownloader( new ProxyConfig(Collections.emptyList())); downloader.download(tempArchive.toUri(), new File(targetDir, downloadFileName), null, null); Assert.assertTrue("File was not 'downloaded' to target directory", new File(targetDir, downloadFileName).exists()); Assert.assertFalse( "File 'downloaded' was a directory event though file expected", new File(targetDir, downloadFileName).isDirectory()); }