use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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.content.BaseRepositoryContentLayout 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);
}
use of org.apache.archiva.repository.content.BaseRepositoryContentLayout 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.BaseRepositoryContentLayout 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.BaseRepositoryContentLayout 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