use of org.apache.archiva.configuration.RepositoryScanningConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
c.setVersion("2.0");
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(true);
c.addManagedRepository(testRepo);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
RepositoryScanningConfiguration scCfg = new RepositoryScanningConfiguration();
c.setRepositoryScanning(scCfg);
configuration.save(c);
assertFalse(configuration.isDefaulted());
repositoryRegistry.reload();
assertTrue(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
use of org.apache.archiva.configuration.RepositoryScanningConfiguration in project archiva by apache.
the class Maven2RepositoryMergerTest method testMergeWithOutConflictArtifacts.
@Test
public void testMergeWithOutConflictArtifacts() throws Exception {
String sourceRepoId = "source-repo";
ArtifactMetadata artifact1 = new ArtifactMetadata();
artifact1.setNamespace("org.testng");
artifact1.setProject("testng");
artifact1.setVersion("5.8");
artifact1.setProjectVersion("5.8");
artifact1.setId("testng-5.8-jdk15.jar");
artifact1.setRepositoryId(sourceRepoId);
List<ArtifactMetadata> sourceRepoArtifactsList = getArtifacts();
sourceRepoArtifactsList.add(artifact1);
List<ArtifactMetadata> targetRepoArtifactsList = getArtifacts();
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation("target/test-repository");
String sourceRepo = "src/test/resources/test-repository-with-conflict-artifacts";
ManagedRepositoryConfiguration testRepoWithConflicts = new ManagedRepositoryConfiguration();
testRepoWithConflicts.setId(sourceRepoId);
testRepoWithConflicts.setLocation(sourceRepo);
RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
List<String> knownContentConsumers = new ArrayList<>();
knownContentConsumers.add("metadata-updater");
repoScanConfig.setKnownContentConsumers(knownContentConsumers);
c.setRepositoryScanning(repoScanConfig);
c.addManagedRepository(testRepo);
c.addManagedRepository(testRepoWithConflicts);
configuration.save(c);
Path targetRepoFile = Paths.get("/target/test-repository/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar");
targetRepoFile.toFile().setReadOnly();
when(metadataRepository.getArtifacts(sourceRepoId)).thenReturn(sourceRepoArtifactsList);
when(metadataRepository.getArtifacts(TEST_REPO_ID)).thenReturn(targetRepoArtifactsList);
assertEquals(1, repositoryMerger.getConflictingArtifacts(metadataRepository, sourceRepoId, TEST_REPO_ID).size());
verify(metadataRepository).getArtifacts(TEST_REPO_ID);
}
use of org.apache.archiva.configuration.RepositoryScanningConfiguration in project archiva by apache.
the class Maven2RepositoryMergerTest method testMerge.
@Test
public void testMerge() throws Exception {
String targetRepoPath = "target/test-repository-target";
Path mergedArtifact = Paths.get(targetRepoPath, "com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar");
Path mavenMetadata = Paths.get(targetRepoPath, "com/example/test/test-artifact/maven-metadata.xml");
Path pom = Paths.get(targetRepoPath, "com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.pom");
assertFalse(Files.exists(mergedArtifact));
assertFalse(Files.exists(mavenMetadata));
assertFalse(Files.exists(pom));
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation("target/test-repository");
RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
List<String> knownContentConsumers = new ArrayList<>();
knownContentConsumers.add("metadata-updater12");
repoScanConfig.setKnownContentConsumers(knownContentConsumers);
c.setRepositoryScanning(repoScanConfig);
ManagedRepositoryConfiguration targetRepo = new ManagedRepositoryConfiguration();
targetRepo.setId("target-rep");
targetRepo.setLocation(targetRepoPath);
c.addManagedRepository(testRepo);
c.addManagedRepository(targetRepo);
configuration.save(c);
when(metadataRepository.getArtifacts(TEST_REPO_ID)).thenReturn(getArtifacts());
repositoryMerger.merge(metadataRepository, TEST_REPO_ID, "target-rep");
verify(metadataRepository).getArtifacts(TEST_REPO_ID);
assertTrue(Files.exists(mergedArtifact));
assertTrue(Files.exists(mavenMetadata));
assertTrue(Files.exists(pom));
}
Aggregations