Search in sources :

Example 6 with MavenManagedRepository

use of org.apache.archiva.maven.repository.MavenManagedRepository in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method setUp.

@Before
public void setUp() throws Exception {
    Path repoDir = getRepositoryPath("default-repository");
    MavenManagedRepository repository = createRepository("testRepo", "Unit Test Repo", repoDir);
    FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
    fileType.addPattern("**/*.xml");
    assertEquals(FileTypes.ARTIFACTS, fileType.getId());
    fileTypes.afterConfigurationChange(null, "fileType", null);
    repoContent = new ManagedDefaultRepositoryContent(repository, fileTypes, fileLockManager);
    repoContent.setMavenContentHelper(contentHelper);
    repoContent.setMetadataReader(metadataReader);
    repoContent.setPathTranslator(pathTranslator);
    repoContent.setArtifactMappingProviders(artifactMappingProviders);
// repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, "default" );
}
Also used : Path(java.nio.file.Path) FileType(org.apache.archiva.configuration.model.FileType) MavenManagedRepository(org.apache.archiva.maven.repository.MavenManagedRepository) Before(org.junit.Before)

Example 7 with MavenManagedRepository

use of org.apache.archiva.maven.repository.MavenManagedRepository in project archiva by apache.

the class MetadataToolsTest method assertSnapshotVersions.

private void assertSnapshotVersions(String artifactId, String version, String[] expectedVersions) throws Exception {
    Path repoRootDir = getRepositoryPath("metadata-repository");
    ItemSelector reference = ArchivaItemSelector.builder().withNamespace("org.apache.archiva.metadata.tests").withArtifactId(artifactId).withProjectId(artifactId).withVersion(version).build();
    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);
    }
}
Also used : Path(java.nio.file.Path) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) RepositoryContentProvider(org.apache.archiva.repository.RepositoryContentProvider) MavenManagedRepository(org.apache.archiva.maven.repository.MavenManagedRepository) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) ArrayList(java.util.ArrayList) VersionComparator(org.apache.archiva.common.utils.VersionComparator)

Example 8 with MavenManagedRepository

use of org.apache.archiva.maven.repository.MavenManagedRepository in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method setupRepoCopy.

private Path setupRepoCopy(String source, String target) throws IOException {
    Path defaultRepo = getRepositoryPath(source);
    Path newRepo = defaultRepo.getParent().resolve(target);
    FileUtils.copyDirectory(defaultRepo.toFile(), newRepo.toFile());
    MavenManagedRepository repository = createRepository("testRepo", "Unit Test Repo", newRepo);
    FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
    fileType.addPattern("**/*.xml");
    assertEquals(FileTypes.ARTIFACTS, fileType.getId());
    fileTypes.afterConfigurationChange(null, "fileType", null);
    repoContent = new ManagedDefaultRepositoryContent(repository, fileTypes, fileLockManager);
    return newRepo;
}
Also used : Path(java.nio.file.Path) FileType(org.apache.archiva.configuration.model.FileType) MavenManagedRepository(org.apache.archiva.maven.repository.MavenManagedRepository)

Aggregations

MavenManagedRepository (org.apache.archiva.maven.repository.MavenManagedRepository)8 Path (java.nio.file.Path)6 FileType (org.apache.archiva.configuration.model.FileType)3 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)3 RepositoryContentProvider (org.apache.archiva.repository.RepositoryContentProvider)3 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 VersionComparator (org.apache.archiva.common.utils.VersionComparator)1 ItemSelector (org.apache.archiva.repository.content.ItemSelector)1 ArchivaItemSelector (org.apache.archiva.repository.content.base.ArchivaItemSelector)1