Search in sources :

Example 1 with RepositoryScanningConfiguration

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);
}
Also used : WagonFactoryRequest(org.apache.archiva.proxy.common.WagonFactoryRequest) RepositoryScanningConfiguration(org.apache.archiva.configuration.RepositoryScanningConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) RepositoryScanningConfiguration(org.apache.archiva.configuration.RepositoryScanningConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.ProxyConnectorConfiguration) WagonFactory(org.apache.archiva.proxy.common.WagonFactory) Wagon(org.apache.maven.wagon.Wagon) Before(org.junit.Before)

Example 2 with RepositoryScanningConfiguration

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);
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RepositoryScanningConfiguration(org.apache.archiva.configuration.RepositoryScanningConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) RepositoryScanningConfiguration(org.apache.archiva.configuration.RepositoryScanningConfiguration) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Test(org.junit.Test)

Example 3 with RepositoryScanningConfiguration

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));
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) RepositoryScanningConfiguration(org.apache.archiva.configuration.RepositoryScanningConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) RepositoryScanningConfiguration(org.apache.archiva.configuration.RepositoryScanningConfiguration) Test(org.junit.Test)

Aggregations

ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)3 Configuration (org.apache.archiva.configuration.Configuration)3 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)3 RepositoryScanningConfiguration (org.apache.archiva.configuration.RepositoryScanningConfiguration)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)1 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)1 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)1 WagonFactory (org.apache.archiva.proxy.common.WagonFactory)1 WagonFactoryRequest (org.apache.archiva.proxy.common.WagonFactoryRequest)1 Wagon (org.apache.maven.wagon.Wagon)1 Before (org.junit.Before)1