|
7 | 7 | import org.jfrog.build.api.dependency.pattern.PatternType;
|
8 | 8 | import org.jfrog.build.api.util.FileChecksumCalculator;
|
9 | 9 | import org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails;
|
| 10 | +import org.jfrog.filespecs.FileSpec; |
| 11 | +import org.jfrog.filespecs.entities.FilesGroup; |
10 | 12 | import org.testng.Assert;
|
11 | 13 | import org.testng.annotations.AfterClass;
|
12 | 14 | import org.testng.annotations.BeforeClass;
|
|
18 | 20 | import java.io.RandomAccessFile;
|
19 | 21 | import java.security.NoSuchAlgorithmException;
|
20 | 22 | import java.util.HashMap;
|
| 23 | +import java.util.List; |
21 | 24 | import java.util.Map;
|
22 | 25 |
|
23 |
| -import static org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.*; |
| 26 | +import static org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.ArtifactMetaData; |
| 27 | +import static org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.MD5_ALGORITHM_NAME; |
| 28 | +import static org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.MIN_SIZE_FOR_CONCURRENT_DOWNLOAD; |
| 29 | +import static org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloaderHelper.SHA1_ALGORITHM_NAME; |
24 | 30 |
|
25 | 31 | /**
|
26 | 32 | * Integration tests for the DependenciesDownloader classes.
|
@@ -112,6 +118,36 @@ public void testDownloadArtifactWithoutContentLength(Map<String, String> uploade
|
112 | 118 | Assert.assertEquals((new File(targetDirPath + fileName)).length(), fileSize);
|
113 | 119 | }
|
114 | 120 |
|
| 121 | + public void testDownloadArtifactFromDifferentPath() throws IOException { |
| 122 | + String targetDirPath = tempWorkspace.getPath() + File.separatorChar + "testDownloaddupArtifactFromDifferentPath" + File.separatorChar; |
| 123 | + FileSpec fileSpec = new FileSpec(); |
| 124 | + // Upload one file to different locations in Artifactory. |
| 125 | + try { |
| 126 | + File file = createRandomFile(tempWorkspace.getPath() + File.pathSeparatorChar + "file", 1); |
| 127 | + for (int i = 0; i < 3; i++) { |
| 128 | + String filePath = TEST_REPO_PATH + "/" + i + "/file"; |
| 129 | + DeployDetails deployDetails = new DeployDetails.Builder() |
| 130 | + .file(file) |
| 131 | + .artifactPath(filePath) |
| 132 | + .targetRepository(localRepo1) |
| 133 | + .explode(false) |
| 134 | + .packageType(DeployDetails.PackageType.GENERIC) |
| 135 | + .build(); |
| 136 | + FilesGroup fg = new FilesGroup(); |
| 137 | + fg.setPattern(localRepo1 + "/" + filePath); |
| 138 | + fg.setTarget(targetDirPath); |
| 139 | + fileSpec.addFilesGroup(fg); |
| 140 | + // Upload artifact |
| 141 | + artifactoryManager.upload(deployDetails); |
| 142 | + } |
| 143 | + DependenciesDownloaderHelper helper = new DependenciesDownloaderHelper(artifactoryManager, tempWorkspace.getPath(), log); |
| 144 | + List<Dependency> dependencies = helper.downloadDependencies(fileSpec); |
| 145 | + Assert.assertEquals(dependencies.size(), 3); |
| 146 | + } finally { |
| 147 | + FileUtils.deleteDirectory(tempWorkspace); |
| 148 | + } |
| 149 | + } |
| 150 | + |
115 | 151 | /**
|
116 | 152 | * Create and upload files to Artifactory.
|
117 | 153 | * The test files are created according to the data provided in testFilesMap
|
|
0 commit comments