use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresent.
@Test
public void testGetDefaultLayoutNotPresent() 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, false);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path sourceFile = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, sourceFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class ManagedDefaultTransferTest method testGetDefaultLayoutAlreadyPresentNewerThanRemotePolicyIgnored.
/**
* <p>
* Request a file, that exists locally, and remotely.
* </p>
* <p>
* All policies are set to IGNORE.
* </p>
* <p>
* Managed file is newer than remote file.
* </p>
* <p>
* Transfer should not have occured, as managed file is newer.
* </p>
*
* @throws Exception
*/
@Test
public void testGetDefaultLayoutAlreadyPresentNewerThanRemotePolicyIgnored() 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);
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
// Set the managed File to be newer than local.
setManagedNewerThanRemote(expectedFile, remoteFile);
long originalModificationTime = Files.getLastModifiedTime(expectedFile).toMillis();
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
assertTrue(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO, false);
// Attempt the proxy fetch.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
assertNotDownloaded(downloadedFile);
assertNotModified(expectedFile, originalModificationTime);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class SnapshotTransferTest method testOlderTimestampDrivenSnapshotOnFirstRepo.
@Test
public void testOlderTimestampDrivenSnapshotOnFirstRepo() throws Exception {
String path = "org/apache/maven/test/get-present-timestamped-snapshot/1.0-SNAPSHOT/get-present-timestamped-snapshot-1.0-SNAPSHOT.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
Path remoteFile = Paths.get(REPOPATH_PROXIED1, path);
setManagedNewerThanRemote(expectedFile, remoteFile);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
// Attempt to download.
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
// Should not have downloaded as managed is newer than remote.
assertNotDownloaded(downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class SnapshotTransferTest method testTimestampDrivenSnapshotNotPresentAlready.
@Test
public void testTimestampDrivenSnapshotNotPresentAlready() throws Exception {
String path = "org/apache/maven/test/get-timestamped-snapshot/1.0-SNAPSHOT/get-timestamped-snapshot-1.0-SNAPSHOT.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
Files.deleteIfExists(expectedFile);
assertFalse(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile, proxiedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.model.ArtifactReference in project archiva by apache.
the class SnapshotTransferTest method testSnapshotNonExistant.
@Test
public void testSnapshotNonExistant() throws Exception {
String path = "org/apache/maven/test/does-not-exist/1.0-SNAPSHOT/does-not-exist-1.0-SNAPSHOT.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
ArtifactReference artifact = managedDefaultRepository.toArtifactReference(path);
Files.deleteIfExists(expectedFile);
assertFalse(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
Path downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository, artifact);
assertNotDownloaded(downloadedFile);
assertNoTempFiles(expectedFile);
}
Aggregations