use of org.apache.archiva.repository.RepositoryContentProvider in project archiva by apache.
the class RepositoryRequestTest method createManagedRepositoryContent.
protected ManagedRepositoryContent createManagedRepositoryContent(String id, String name, Path location, String layout) throws Exception {
MavenManagedRepository repo = new MavenManagedRepository(id, name, archivaConfiguration.getRepositoryBaseDir());
repo.setLocation(location.toAbsolutePath().toUri());
repo.setLayout(layout);
RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
ManagedRepositoryContent repoContent = provider.createManagedContent(repo);
return repoContent;
}
use of org.apache.archiva.repository.RepositoryContentProvider in project archiva by apache.
the class MetadataToolsTest method createTestRepoContent.
private ManagedRepositoryContent createTestRepoContent() throws Exception {
Path repoRoot = Paths.get("target/metadata-tests/" + name.getMethodName());
if (Files.exists(repoRoot)) {
org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRoot);
}
Files.createDirectories(repoRoot);
MavenManagedRepository repoConfig = createRepository("test-repo", "Test Repository: " + name.getMethodName(), repoRoot);
RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
ManagedRepositoryContent repoContent = provider.createManagedContent(repoConfig);
return repoContent;
}
use of org.apache.archiva.repository.RepositoryContentProvider in project archiva by apache.
the class MetadataToolsTest method assertSnapshotVersions.
private void assertSnapshotVersions(String artifactId, String version, String[] expectedVersions) throws Exception {
Path repoRootDir = Paths.get("src/test/repositories/metadata-repository");
VersionedReference reference = new VersionedReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
reference.setVersion(version);
MavenManagedRepository repo = createRepository("test-repo", "Test Repository: " + name.getMethodName(), repoRootDir);
RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
ManagedRepositoryContent repoContent = provider.createManagedContent(repo);
Set<String> testedVersionSet = tools.gatherSnapshotVersions(repoContent, reference);
// Sort the list (for asserts)
List<String> testedVersions = new ArrayList<>();
testedVersions.addAll(testedVersionSet);
Collections.sort(testedVersions, new VersionComparator());
// Test the expected array of versions, to the actual tested versions
assertEquals("Assert Snapshot Versions: length/size", expectedVersions.length, testedVersions.size());
for (int i = 0; i < expectedVersions.length; i++) {
String actualVersion = testedVersions.get(i);
assertEquals("Snapshot Versions[" + i + "]", expectedVersions[i], actualVersion);
}
}
use of org.apache.archiva.repository.RepositoryContentProvider in project archiva by apache.
the class AbstractRepositoryPurgeTest method getRepository.
public ManagedRepositoryContent getRepository() throws Exception {
if (repo == null) {
org.apache.archiva.repository.ManagedRepository repoCfg = getRepoConfiguration(TEST_REPO_ID, TEST_REPO_NAME);
RepositoryContentProvider provider = applicationContext.getBean("repositoryContentProvider#maven", RepositoryContentProvider.class);
repo = provider.createManagedContent(repoCfg);
}
return repo;
}
use of org.apache.archiva.repository.RepositoryContentProvider in project archiva by apache.
the class ArchivaDavResourceFactoryTest method testRequestMetadataRepoIsLegacy.
@Test
public void testRequestMetadataRepoIsLegacy() throws Exception {
ManagedRepositoryContent legacyRepo = createManagedRepositoryContent(LEGACY_REPO);
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory();
RepositoryContentProvider provider = createRepositoryContentProvider(legacyRepo);
beanFactory.registerSingleton("repositoryContentProvider#legacy", provider);
RepositoryContentFactory repoContentFactory = applicationContext.getBean("repositoryContentFactory#default", RepositoryContentFactory.class);
repoContentFactory.getRepositoryContentProviders().add(provider);
defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(LEGACY_REPO, Paths.get("target/test-classes/" + LEGACY_REPO).toString(), "legacy"), false, null);
DavResourceLocator locator = new ArchivaDavResourceLocator("", "/repository/" + LEGACY_REPO + "/eclipse/maven-metadata.xml", LEGACY_REPO, new ArchivaDavLocatorFactory());
// use actual object (this performs the isMetadata, isDefault and isSupportFile check!)
RepositoryRequest repoRequest = new RepositoryRequest();
resourceFactory.setRepositoryRequest(repoRequest);
try {
archivaConfigurationControl.reset();
expect(archivaConfiguration.getConfiguration()).andReturn(config).times(2);
expect(repoFactory.getManagedRepositoryContent(LEGACY_REPO)).andReturn(legacyRepo);
expect(request.getMethod()).andReturn("GET").times(3);
expect(request.getRemoteAddr()).andReturn("http://localhost:8080").times(3);
expect(request.getDavSession()).andReturn(new ArchivaDavSession()).times(2);
expect(request.getContextPath()).andReturn("").times(2);
archivaConfigurationControl.replay();
repoContentFactoryControl.replay();
requestControl.replay();
resourceFactory.createResource(locator, request, response);
archivaConfigurationControl.verify();
repoContentFactoryControl.verify();
requestControl.verify();
fail("A 404 error should have been thrown!");
} catch (DavException e) {
assertEquals(404, e.getErrorCode());
}
}
Aggregations