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" );
}
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);
}
}
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;
}
Aggregations