use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ChecksumTransferTest method testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting.
@Test
public void testGetAlwaysBadChecksumPresentLocallyAbsentRemoteUsingIgnoredSetting() throws Exception {
String path = "org/apache/maven/test/get-bad-local-checksum/1.0/get-bad-local-checksum-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
setManagedOlderThanRemote(expectedFile, remoteFile);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, proxied1File);
assertNoTempFiles(expectedFile);
// There are no hashcodes on the proxy side to download, hence the local ones should remain invalid.
assertChecksums(expectedFile, "invalid checksum file", "invalid checksum file");
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ChecksumTransferTest method testGetWithNoChecksumsUsingFixSetting.
@Test
public void testGetWithNoChecksumsUsingFixSetting() throws Exception {
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
FileUtils.deleteDirectory(expectedFile.getParent());
assertFalse(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, proxied1File);
assertNoTempFiles(expectedFile);
assertChecksums(expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486 get-default-layout-1.0.jar", "3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar");
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ChecksumTransferTest method testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting.
@Test
public void testGetChecksumCorrectSha1BadMd5UsingIgnoredSetting() throws Exception {
String path = "org/apache/maven/test/get-checksum-sha1-bad-md5/1.0/get-checksum-sha1-bad-md5-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
FileUtils.deleteDirectory(expectedFile.getParent());
assertFalse(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, proxied1File);
assertNoTempFiles(expectedFile);
assertChecksums(expectedFile, "3dd1a3a57b807d3ef3fbc6013d926c891cbb8670 *get-checksum-sha1-bad-md5-1.0.jar", "invalid checksum file");
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class HttpProxyTransferTest method testGetOverHttpProxy.
@Test
public void testGetOverHttpProxy() throws Exception {
Assertions.assertThat(System.getProperty("http.proxyHost")).isEmpty();
Assertions.assertThat(System.getProperty("http.proxyPort")).isEmpty();
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar";
// Configure Connector (usually done within archiva.xml configuration)
addConnector();
Path expectedFile = Paths.get(managedDefaultRepository.getRepoRoot()).resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path sourceFile = Paths.get(PROXIED_BASEDIR, path);
assertNotNull("Expected File should not be null.", expectedFile);
assertNotNull("Actual File should not be null.", downloadedFile);
assertTrue("Check actual file exists.", Files.exists(downloadedFile));
assertTrue("Check filename path is appropriate.", Files.isSameFile(expectedFile, downloadedFile));
assertTrue("Check file path matches.", Files.isSameFile(expectedFile, downloadedFile));
String expectedContents = FileUtils.readFileToString(sourceFile.toFile(), Charset.defaultCharset());
String actualContents = FileUtils.readFileToString(downloadedFile.toFile(), Charset.defaultCharset());
assertEquals("Check file contents.", expectedContents, actualContents);
Assertions.assertThat(System.getProperty("http.proxyHost")).isEmpty();
Assertions.assertThat(System.getProperty("http.proxyPort")).isEmpty();
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultTransferTest method testGetInSecondProxiedRepo.
@Test
public void testGetInSecondProxiedRepo() throws Exception {
String path = "org/apache/maven/test/get-in-second-proxy/1.0/get-in-second-proxy-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
assertNotExistsInManagedDefaultRepo(expectedFile);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED2, false);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path proxied2File = Paths.get(REPOPATH_PROXIED2, path);
assertFileEquals(expectedFile, downloadedFile, proxied2File);
assertNoTempFiles(expectedFile);
}
Aggregations