use of org.apache.archiva.repository.EditableManagedRepository in project archiva by apache.
the class RepositoryScannerTest method createLegacyRepository.
private ManagedRepository createLegacyRepository() {
Path repoDir = Paths.get(System.getProperty("basedir"), "src/test/repositories/legacy-repository");
assertTrue("Legacy Test Repository should exist.", Files.exists(repoDir) && Files.isDirectory(repoDir));
EditableManagedRepository repo = createRepository("testLegacyRepo", "Test Legacy Repository", repoDir);
repo.setLayout("legacy");
return repo;
}
use of org.apache.archiva.repository.EditableManagedRepository in project archiva by apache.
the class ArchivaDavResourceFactoryTest method createManagedRepositoryContent.
private ManagedRepositoryContent createManagedRepositoryContent(String repoId) throws RepositoryAdminException {
ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent(artifactMappingProviders, fileTypes);
org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository(repoId);
repoContent.setRepository(repo);
if (repo != null && repo instanceof EditableManagedRepository) {
((EditableManagedRepository) repo).setContent(repoContent);
}
return repoContent;
}
use of org.apache.archiva.repository.EditableManagedRepository in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method assertVersions.
private void assertVersions(String artifactId, String version, String[] expectedVersions) throws Exception {
VersionedReference reference = new VersionedReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
reference.setVersion(version);
// Use the test metadata-repository, which is already setup for
// These kind of version tests.
Path repoDir = Paths.get("src/test/repositories/metadata-repository");
((EditableManagedRepository) repoContent.getRepository()).setLocation(repoDir.toAbsolutePath().toUri());
// Request the versions.
Set<String> testedVersionSet = repoContent.getVersions(reference);
// Sort the list (for asserts later)
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 Versions: length/size", expectedVersions.length, testedVersions.size());
for (int i = 0; i < expectedVersions.length; i++) {
String actualVersion = testedVersions.get(i);
assertEquals("Versions[" + i + "]", expectedVersions[i], actualVersion);
}
}
use of org.apache.archiva.repository.EditableManagedRepository in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method assertGetVersions.
private void assertGetVersions(String artifactId, List<String> expectedVersions) throws Exception {
ProjectReference reference = new ProjectReference();
reference.setGroupId("org.apache.archiva.metadata.tests");
reference.setArtifactId(artifactId);
// Use the test metadata-repository, which is already setup for
// These kind of version tests.
Path repoDir = Paths.get("src/test/repositories/metadata-repository");
((EditableManagedRepository) repoContent.getRepository()).setLocation(repoDir.toAbsolutePath().toUri());
// Request the versions.
Set<String> testedVersionSet = repoContent.getVersions(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("available versions", expectedVersions, testedVersions);
}
Aggregations