use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ChecksumTransferTest method testGetChecksumNoSha1CorrectMd5UsingFailSetting.
@Test
public void testGetChecksumNoSha1CorrectMd5UsingFailSetting() throws Exception {
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-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.FAIL, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
// This is a success situation. No SHA1 with a Good MD5.
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, proxied1File);
assertNoTempFiles(expectedFile);
assertChecksums(expectedFile, null, "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar");
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ChecksumTransferTest method testGetChecksumNoSha1CorrectMd5UsingFixSetting.
@Test
public void testGetChecksumNoSha1CorrectMd5UsingFixSetting() throws Exception {
String path = "org/apache/maven/test/get-checksum-md5-only/1.0/get-checksum-md5-only-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, "71f7dc3f72053a3f2d9fdd6fef9db055ef957ffb get-checksum-md5-only-1.0.jar", "f3af5201bf8da801da37db8842846e1c *get-checksum-md5-only-1.0.jar");
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresentConnectorOffline.
@Test
public void testGetDefaultLayoutNotPresentConnectorOffline() 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);
// Ensure file isn't present first.
assertNotExistsInManagedDefaultRepo(expectedFile);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ONCE, SnapshotsPolicy.ONCE, CachedFailuresPolicy.NO, true);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
assertNull("File should not have been downloaded", downloadedFile);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultTransferTest method testGetInSecondProxiedRepoFirstFails.
@Test
public void testGetInSecondProxiedRepoFirstFails() 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 Repository (usually done within archiva.xml configuration)
saveRemoteRepositoryConfig("badproxied", "Bad Proxied", "test://bad.machine.com/repo/", "default");
wagonMock.get(EasyMock.eq(path), EasyMock.anyObject(File.class));
EasyMock.expectLastCall().andThrow(new ResourceDoesNotExistException("transfer failed"));
wagonMockControl.replay();
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, "badproxied", false);
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED2, false);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
wagonMockControl.verify();
Path proxied2File = Paths.get(REPOPATH_PROXIED2, path);
assertFileEquals(expectedFile, downloadedFile, proxied2File);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultTransferTest method testGetDefaultLayoutRemoteUpdate.
/**
* The attempt here should result in file being transferred.
* <p/>
* The file exists locally, is over 6 years old, and the policy is DAILY.
*
* @throws Exception
*/
@Test
public void testGetDefaultLayoutRemoteUpdate() throws Exception {
String path = "org/apache/maven/test/get-default-layout-present/1.0/get-default-layout-present-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
assertTrue(Files.exists(expectedFile));
Files.setLastModifiedTime(expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.DAILY, SnapshotsPolicy.DAILY, CachedFailuresPolicy.NO, false);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, proxiedFile);
assertNoTempFiles(expectedFile);
}
Aggregations