use of org.apache.archiva.repository.storage.StorageAsset 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.storage.StorageAsset 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.storage.StorageAsset in project archiva by apache.
the class ManagedDefaultTransferTest method testGetDefaultLayoutNotPresentPassthrough.
@Test
public void testGetDefaultLayoutNotPresentPassthrough() throws Exception {
String path = "org/apache/maven/test/get-default-layout/1.0/get-default-layout-1.0.jar.asc";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(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.
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), path);
Path sourceFile = Paths.get(REPOPATH_PROXIED1, path);
assertNotNull(downloadedFile);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), sourceFile);
assertFalse(Files.exists(downloadedFile.getParent().getFilePath().resolve(downloadedFile.getName() + ".sha1")));
assertFalse(Files.exists(downloadedFile.getParent().getFilePath().resolve(downloadedFile.getName() + ".md5")));
assertFalse(Files.exists(downloadedFile.getParent().getFilePath().resolve(downloadedFile.getName() + ".sha256")));
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class MetadataTransferTest method assertFetchVersionedFailed.
/**
* Transfer the metadata file, not expected to succeed.
*
* @param requestedResource the requested resource
* @throws Exception
*/
private void assertFetchVersionedFailed(String requestedResource) throws Exception {
Path expectedFile = managedDefaultDir.resolve(requestedResource);
ContentItem item = managedDefaultRepository.toItem(requestedResource);
assertNotNull(item);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Version version = layout.adaptItem(Version.class, item);
assertNotNull(version);
String metaPath = managedDefaultRepository.toPath(layout.getMetadataItem(version));
assertNotNull(metaPath);
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository.getRepository(), metaPath).getFile();
assertNull(downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.storage.StorageAsset in project archiva by apache.
the class MetadataTransferTest method assertFetchProjectOrGroup.
/**
* Transfer the metadata file.
*
* @param requestedResource the requested resource
* @throws Exception
*/
private void assertFetchProjectOrGroup(String requestedResource) throws Exception {
Path expectedFile = managedDefaultDir.resolve(requestedResource);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
ContentItem metaItem = managedDefaultRepository.toItem(requestedResource);
Project project = layout.adaptItem(Project.class, managedDefaultRepository.getParent(metaItem));
assertNotNull(project);
String metaPath = managedDefaultRepository.toPath(layout.getMetadataItem(project));
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository.getRepository(), metaPath).getFile();
assertNotNull("Should have downloaded a file.", downloadedFile);
assertNoTempFiles(expectedFile);
}
Aggregations