@Test(expected = MojoFailureException.class) public void specifyAFileInsteadOfADirectory() throws Exception { DownloadHandler downloadTestFile = new DownloadHandler(null, File.createTempFile("foo", "bar"), 3, connectTimeout, readTimeout, null, doNotOverwriteFilesThatExist, checkFileHashes, doNotUseSystemProxy, getAllVersions); downloadTestFile.downloadFile(validFileDetails, checkFileHashes); }
protected File downloadFile(DriverDetails driverDetails, boolean shouldWeCheckFileHash) throws MojoExecutionException, IOException, URISyntaxException { URL remoteFileLocation = driverDetails.fileLocation; final String filename = FilenameUtils.getName(remoteFileLocation.getFile()); for (int retryAttempts = 1; retryAttempts <= this.fileDownloadRetryAttempts; retryAttempts++) { File downloadedFile = fileDownloader.attemptToDownload(remoteFileLocation); if (null != downloadedFile) { if (!shouldWeCheckFileHash || checkFileHash(downloadedFile, driverDetails.hash, driverDetails.hashType)) { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : true"); return downloadedFile; } else { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : false"); } } LOG.info("Problem downloading '" + filename + "'... "); if (retryAttempts < this.fileDownloadRetryAttempts) { LOG.info("Retry attempt " + (retryAttempts) + " for '" + filename + "'"); } } throw new MojoExecutionException("Unable to successfully download '" + filename + "'!"); }
DownloadHandler { protected File downloadFile(DriverDetails driverDetails, boolean shouldWeCheckFileHash) throws MojoExecutionException, IOException, URISyntaxException { URL remoteFileLocation = driverDetails.fileLocation; final String filename = FilenameUtils.getName(remoteFileLocation.getFile()); for (int retryAttempts = 1; retryAttempts <= this.fileDownloadRetryAttempts; retryAttempts++) { File downloadedFile = fileDownloader.attemptToDownload(remoteFileLocation); if (null != downloadedFile) { if (!shouldWeCheckFileHash || checkFileHash(downloadedFile, driverDetails.hash, driverDetails.hashType)) { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : true"); return downloadedFile; } else { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : false"); } } LOG.info("Problem downloading '" + filename + "'... "); if (retryAttempts < this.fileDownloadRetryAttempts) { LOG.info("Retry attempt " + (retryAttempts) + " for '" + filename + "'"); } } throw new MojoExecutionException("Unable to successfully download '" + filename + "'!"); } }
DownloadHandler { protected File downloadFile(DriverDetails driverDetails, boolean shouldWeCheckFileHash) throws MojoExecutionException, IOException, URISyntaxException { URL remoteFileLocation = driverDetails.fileLocation; final String filename = FilenameUtils.getName(remoteFileLocation.getFile()); for (int retryAttempts = 1; retryAttempts <= this.fileDownloadRetryAttempts; retryAttempts++) { File downloadedFile = fileDownloader.attemptToDownload(remoteFileLocation); if (null != downloadedFile) { if (!shouldWeCheckFileHash || checkFileHash(downloadedFile, driverDetails.hash, driverDetails.hashType)) { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : true"); return downloadedFile; } else { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : false"); } } LOG.info("Problem downloading '" + filename + "'... "); if (retryAttempts < this.fileDownloadRetryAttempts) { LOG.info("Retry attempt " + (retryAttempts) + " for '" + filename + "'"); } } throw new MojoExecutionException("Unable to successfully download '" + filename + "'!"); } DownloadHandler(File rootStandaloneServerDirectory, File downloadedZipFileDirectory, int fileDownloadRetryAttempts, int fileDownloadConnectTimeout, int fileDownloadReadTimeout, DriverMap filesToDownload, boolean overwriteFilesThatExist, boolean checkFileHash, boolean useSystemProxy, boolean onlyGetLatestVersions); }
DownloadHandler { protected File downloadFile(DriverDetails driverDetails, boolean shouldWeCheckFileHash) throws MojoExecutionException, IOException, URISyntaxException { URL remoteFileLocation = driverDetails.fileLocation; final String filename = FilenameUtils.getName(remoteFileLocation.getFile()); for (int retryAttempts = 1; retryAttempts <= this.fileDownloadRetryAttempts; retryAttempts++) { File downloadedFile = fileDownloader.attemptToDownload(remoteFileLocation); if (null != downloadedFile) { if (!shouldWeCheckFileHash || checkFileHash(downloadedFile, driverDetails.hash, driverDetails.hashType)) { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : true"); return downloadedFile; } else { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : false"); } } LOG.info("Problem downloading '" + filename + "'... "); if (retryAttempts < this.fileDownloadRetryAttempts) { LOG.info("Retry attempt " + (retryAttempts) + " for '" + filename + "'"); } } throw new MojoExecutionException("Unable to successfully download '" + filename + "'!"); } DownloadHandler(File rootStandaloneServerDirectory, File downloadedZipFileDirectory, int fileDownloadRetryAttempts, int fileDownloadConnectTimeout, int fileDownloadReadTimeout, DriverMap filesToDownload, boolean overwriteFilesThatExist, boolean checkFileHash, boolean useSystemProxy, boolean onlyGetLatestVersions); DriverMap ensureStandaloneExecutableFilesExist(); }
DownloadHandler { protected File downloadFile(DriverDetails driverDetails, boolean shouldWeCheckFileHash) throws MojoExecutionException, IOException, URISyntaxException { URL remoteFileLocation = driverDetails.fileLocation; final String filename = FilenameUtils.getName(remoteFileLocation.getFile()); for (int retryAttempts = 1; retryAttempts <= this.fileDownloadRetryAttempts; retryAttempts++) { File downloadedFile = fileDownloader.attemptToDownload(remoteFileLocation); if (null != downloadedFile) { if (!shouldWeCheckFileHash || checkFileHash(downloadedFile, driverDetails.hash, driverDetails.hashType)) { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : true"); return downloadedFile; } else { LOG.info("Archive file '" + downloadedFile.getName() + "' is valid : false"); } } LOG.info("Problem downloading '" + filename + "'... "); if (retryAttempts < this.fileDownloadRetryAttempts) { LOG.info("Retry attempt " + (retryAttempts) + " for '" + filename + "'"); } } throw new MojoExecutionException("Unable to successfully download '" + filename + "'!"); } DownloadHandler(File rootStandaloneServerDirectory, File downloadedZipFileDirectory, int fileDownloadRetryAttempts, int fileDownloadConnectTimeout, int fileDownloadReadTimeout, DriverMap filesToDownload, boolean overwriteFilesThatExist, boolean checkFileHash, boolean useSystemProxy, boolean onlyGetLatestVersions); DriverMap ensureStandaloneExecutableFilesExist();  }