Search in sources :

Example 1 with EditableManagedRepository

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;
}
Also used : Path(java.nio.file.Path) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository)

Example 2 with EditableManagedRepository

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;
}
Also used : EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) ManagedDefaultRepositoryContent(org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent)

Example 3 with EditableManagedRepository

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);
    }
}
Also used : Path(java.nio.file.Path) VersionedReference(org.apache.archiva.model.VersionedReference) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ArrayList(java.util.ArrayList) VersionComparator(org.apache.archiva.common.utils.VersionComparator)

Example 4 with EditableManagedRepository

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);
}
Also used : Path(java.nio.file.Path) ProjectReference(org.apache.archiva.model.ProjectReference) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ArrayList(java.util.ArrayList) VersionComparator(org.apache.archiva.common.utils.VersionComparator)

Aggregations

EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)4 Path (java.nio.file.Path)3 ArrayList (java.util.ArrayList)2 VersionComparator (org.apache.archiva.common.utils.VersionComparator)2 ProjectReference (org.apache.archiva.model.ProjectReference)1 VersionedReference (org.apache.archiva.model.VersionedReference)1 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)1 ManagedDefaultRepositoryContent (org.apache.archiva.repository.content.maven2.ManagedDefaultRepositoryContent)1