use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class ChecksumTransferTest method testGetChecksumBadSha1BadMd5IgnoredSetting.
@Test
public void testGetChecksumBadSha1BadMd5IgnoredSetting() throws Exception {
String path = "org/apache/maven/test/get-checksum-both-bad/1.0/get-checksum-both-bad-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(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);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxied1File);
assertNoTempFiles(expectedFile);
assertChecksums(expectedFile, "invalid checksum file", "invalid checksum file");
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(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);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxied1File);
assertNoTempFiles(expectedFile);
assertChecksums(expectedFile, "1f12821c5e43e1a0b76b9564a6ddb0548ccb9486 get-default-layout-1.0.jar", "3f7341545f21226b6f49a3c2704cb9be get-default-layout-1.0.jar");
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class MetadataTransferTest method assertFetchVersioned.
/**
* Transfer the metadata file.
*
* @param requestedResource the requested resource
* @throws Exception
*/
private void assertFetchVersioned(String requestedResource) throws Exception {
Path expectedFile = managedDefaultDir.resolve(requestedResource);
ContentItem item = managedDefaultRepository.toItem(requestedResource);
if (item instanceof DataItem) {
item = managedDefaultRepository.getParent(item);
}
assertNotNull(item);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Version version = layout.adaptItem(Version.class, item);
assertNotNull(version);
String metaPath = managedDefaultRepository.toPath(layout.getMetadataItem(version));
StorageAsset downloadedFile = proxyHandler.fetchMetadataFromProxies(managedDefaultRepository.getRepository(), metaPath).getFile();
assertNotNull("Should have downloaded a file.", downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class MetadataTransferTest method assertFetchProjectOrGroupFailed.
/**
* Transfer the metadata file, not expected to succeed.
*
* @param requestedResource the requested resource
* @throws Exception
*/
private void assertFetchProjectOrGroupFailed(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();
assertNull(downloadedFile);
assertNoTempFiles(expectedFile);
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout in project archiva by apache.
the class ChecksumTransferTest method testGetChecksumBothCorrect.
@Test
public void testGetChecksumBothCorrect() throws Exception {
String path = "org/apache/maven/test/get-checksum-both-right/1.0/get-checksum-both-right-1.0.jar";
setupTestableManagedRepository(path);
Path expectedFile = managedDefaultDir.resolve(path);
BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout(BaseRepositoryContentLayout.class);
Artifact artifact = layout.getArtifact(path);
org.apache.archiva.common.utils.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);
StorageAsset downloadedFile = proxyHandler.fetchFromProxies(managedDefaultRepository.getRepository(), artifact);
Path proxied1File = Paths.get(REPOPATH_PROXIED1, path);
assertFileEquals(expectedFile, downloadedFile.getFilePath(), proxied1File);
assertNoTempFiles(expectedFile);
assertChecksums(expectedFile, "066d76e459f7782c312c31e8a11b3c0f1e3e43a7 *get-checksum-both-right-1.0.jar", "e58f30c6a150a2e843552438d18e15cb *get-checksum-both-right-1.0.jar");
}
Aggregations