use of org.apache.archiva.repository.content.Artifact 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);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(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.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
assertNull("File should not have been downloaded", downloadedFile);
}
use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class ManagedDefaultTransferTest method testNotFoundInAnyProxies.
@Test
public void testNotFoundInAnyProxies() throws Exception {
String path = "org/apache/maven/test/does-not-exist/1.0/does-not-exist-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(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.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
assertNull("File returned was: " + downloadedFile + "; should have got a not found exception", downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class SnapshotTransferTest method testMetadataDrivenSnapshotNotPresentAlready.
@Test
public void testMetadataDrivenSnapshotNotPresentAlready() throws Exception {
String path = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-metadata-snapshot-1.0-20050831.101112-1.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
Files.deleteIfExists(expectedFile);
assertFalse(Files.exists(expectedFile));
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
assertNotNull(downloadedFile);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxiedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class SnapshotTransferTest method testTimestampDrivenSnapshotNotUpdated.
@Test
public void testTimestampDrivenSnapshotNotUpdated() 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, 12000000);
long expectedTimestamp = Files.getLastModifiedTime(expectedFile).toMillis();
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
// Configure Connector (usually done within archiva.xml configuration)
saveConnector(ID_DEFAULT_MANAGED, ID_PROXIED1, false);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
assertNotDownloaded(downloadedFile);
assertNotModified(expectedFile, expectedTimestamp);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class SnapshotTransferTest method testNewerTimestampDrivenSnapshotOnFirstRepo.
@Test
public void testNewerTimestampDrivenSnapshotOnFirstRepo() 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);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(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, false);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
Path proxiedFile = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxiedFile);
assertNoTempFiles(expectedFile);
}
Aggregations