use of org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.ArtifactMetaData in project build-info by JFrogDev.
the class DownloadTest method testDownloadArtifact.
@Test(dataProvider = "testDownloadFilesProvider")
public void testDownloadArtifact(Map<String, String> uploadedChecksum, String fileName, long fileSize) throws Exception {
DependenciesDownloaderHelper dependenciesDownloaderHelper = new DependenciesDownloaderHelper(artifactoryManager, ".", log);
String repoUrl = localRepo1 + "/" + TEST_REPO_PATH;
String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "download" + File.separatorChar;
String url = repoUrl + "/" + fileName;
ArtifactMetaData artifactMetaData = dependenciesDownloaderHelper.downloadArtifactMetaData(url);
Assert.assertEquals(artifactMetaData.getMd5(), uploadedChecksum.get(MD5_ALGORITHM));
Assert.assertEquals(artifactMetaData.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM));
Assert.assertEquals(artifactMetaData.getSize(), fileSize);
DownloadableArtifact downloadableArtifact = new DownloadableArtifact(repoUrl, targetDirPath, fileName, "", fileName, PatternType.NORMAL);
Dependency dependency = dependenciesDownloaderHelper.downloadArtifact(downloadableArtifact, artifactMetaData, url, fileName);
Assert.assertEquals(dependency.getId(), fileName);
Assert.assertEquals(dependency.getMd5(), uploadedChecksum.get(MD5_ALGORITHM));
Assert.assertEquals(dependency.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM));
Assert.assertEquals((new File(targetDirPath + fileName)).length(), fileSize);
}
use of org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.ArtifactMetaData in project build-info by JFrogDev.
the class DownloadTest method testBulkAndConcurrentDownload.
/**
* Tests download of files - both bulk and concurrently.
*
* @param uploadedChecksum - checksums of the artifact uploaded to Artifactory, used to compare with the downloaded artifact.
* @param fileName - artifact name to download.
* @param fileSize - artifact size to download.
*/
@Test(dataProvider = "testDownloadFilesProvider")
public void testBulkAndConcurrentDownload(Map<String, String> uploadedChecksum, String fileName, long fileSize) throws Exception {
String uriWithParams = localRepo1 + "/" + TEST_REPO_PATH + "/" + fileName;
String fileDestination = tempWorkspace.getPath() + File.separatorChar + "download" + File.separatorChar + fileName;
DependenciesDownloaderHelper helper = new DependenciesDownloaderHelper(artifactoryManager, tempWorkspace.getPath(), log);
DependenciesDownloaderHelper.ArtifactMetaData artifactMetaData = helper.downloadArtifactMetaData(uriWithParams);
Assert.assertEquals(artifactMetaData.getSize(), fileSize);
Map<String, String> downloadedChecksum;
if (fileSize >= MIN_SIZE_FOR_CONCURRENT_DOWNLOAD && artifactMetaData.isAcceptRange()) {
// Perform concurrent download.
downloadedChecksum = helper.downloadFileConcurrently(uriWithParams, fileSize, fileDestination, fileName);
} else {
// Perform bulk download.
downloadedChecksum = helper.downloadFile(uriWithParams, fileDestination);
}
// Verify the downloaded file.
Assert.assertEquals(uploadedChecksum.get(MD5_ALGORITHM), downloadedChecksum.get(MD5_ALGORITHM));
Assert.assertEquals(uploadedChecksum.get(SHA1_ALGORITHM), downloadedChecksum.get(SHA1_ALGORITHM));
}
use of org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.ArtifactMetaData in project build-info by JFrogDev.
the class DownloadTest method testDownloadArtifactWithoutContentLength.
@Test(dataProvider = "testDownloadFilesProvider")
public void testDownloadArtifactWithoutContentLength(Map<String, String> uploadedChecksum, String fileName, long fileSize) throws Exception {
DependenciesDownloaderHelper dependenciesDownloaderHelper = new DependenciesDownloaderHelper(artifactoryManager, ".", log);
String repoUrl = localRepo1 + "/" + TEST_REPO_PATH;
String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "download" + File.separatorChar;
String url = repoUrl + "/" + fileName;
ArtifactMetaData artifactMetaData = dependenciesDownloaderHelper.downloadArtifactMetaData(url);
Assert.assertEquals(artifactMetaData.getMd5(), uploadedChecksum.get(MD5_ALGORITHM));
Assert.assertEquals(artifactMetaData.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM));
Assert.assertEquals(artifactMetaData.getSize(), fileSize);
// When content-length is missing
artifactMetaData.setSize(0);
DownloadableArtifact downloadableArtifact = new DownloadableArtifact(repoUrl, targetDirPath, fileName, "", fileName, PatternType.NORMAL);
Dependency dependency = dependenciesDownloaderHelper.downloadArtifact(downloadableArtifact, artifactMetaData, url, fileName);
Assert.assertEquals(dependency.getId(), fileName);
Assert.assertEquals(dependency.getMd5(), uploadedChecksum.get(MD5_ALGORITHM));
Assert.assertEquals(dependency.getSha1(), uploadedChecksum.get(SHA1_ALGORITHM));
Assert.assertEquals((new File(targetDirPath + fileName)).length(), fileSize);
}
Aggregations