Search in sources :

Example 46 with ManagedRepositoryConfiguration

use of org.apache.archiva.configuration.ManagedRepositoryConfiguration 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

ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)46 Configuration (org.apache.archiva.configuration.Configuration)17 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)14 Path (java.nio.file.Path)9 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)9 Before (org.junit.Before)9 ContextConfiguration (org.springframework.test.context.ContextConfiguration)9 Test (org.junit.Test)8 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)7 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)7 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)7 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)7 ArrayList (java.util.ArrayList)6 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)5 IndexUpdateFailedException (org.apache.archiva.indexer.IndexUpdateFailedException)5 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)5 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)5 IOException (java.io.IOException)4 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)4 RepositoryException (org.apache.archiva.repository.RepositoryException)4