use of org.apache.archiva.configuration.model.Configuration 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(session, sourceRepoId)).thenReturn(sourceRepoArtifactsList);
when(metadataRepository.getArtifacts(session, TEST_REPO_ID)).thenReturn(targetRepoArtifactsList);
assertEquals(1, repositoryMerger.getConflictingArtifacts(metadataRepository, sourceRepoId, TEST_REPO_ID).size());
verify(metadataRepository).getArtifacts(session, TEST_REPO_ID);
}
use of org.apache.archiva.configuration.model.Configuration 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");
for (Path testArtifact : new Path[] { mergedArtifact, mavenMetadata, pom }) {
Files.deleteIfExists(testArtifact);
}
assertFalse("Artifact file exists already", Files.exists(mergedArtifact));
assertFalse("Metadata file exists already", Files.exists(mavenMetadata));
assertFalse("Pom File exists already", 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(session, TEST_REPO_ID)).thenReturn(getArtifacts());
repositoryMerger.merge(metadataRepository, TEST_REPO_ID, "target-rep");
verify(metadataRepository).getArtifacts(session, TEST_REPO_ID);
assertTrue(Files.exists(mergedArtifact));
assertTrue(Files.exists(mavenMetadata));
assertTrue(Files.exists(pom));
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class DefaultRemoteRepositoryAdmin method updateRemoteRepository.
@Override
public Boolean updateRemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository, AuditInformation auditInformation) throws RepositoryAdminException {
String repositoryId = remoteRepository.getId();
triggerAuditEvent(repositoryId, null, AuditEvent.MODIFY_REMOTE_REPO, auditInformation);
// update means : remove and add
Configuration configuration = getArchivaConfiguration().getConfiguration();
RemoteRepositoryConfiguration remoteRepositoryConfiguration = getRepositoryConfiguration(remoteRepository);
try {
repositoryRegistry.putRepository(remoteRepositoryConfiguration);
} catch (RepositoryException e) {
log.error("Could not update remote repository {}: {}", remoteRepositoryConfiguration.getId(), e.getMessage(), e);
throw new RepositoryAdminException("Update of remote repository failed" + (e.getMessage() == null ? "" : ": " + e.getMessage()));
}
return Boolean.TRUE;
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class DefaultRedbackRuntimeConfigurationAdmin method updateRedbackRuntimeConfiguration.
@Override
public void updateRedbackRuntimeConfiguration(RedbackRuntimeConfiguration redbackRuntimeConfiguration) throws RepositoryAdminException {
org.apache.archiva.configuration.model.RedbackRuntimeConfiguration runtimeConfiguration = build(redbackRuntimeConfiguration);
Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setRedbackRuntimeConfiguration(runtimeConfiguration);
try {
archivaConfiguration.save(configuration);
} catch (RegistryException e) {
throw new RepositoryAdminException(e.getMessage(), e);
} catch (IndeterminateConfigurationException e) {
throw new RepositoryAdminException(e.getMessage(), e);
}
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class ArchivaDavResourceFactoryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
request = mock(DavServletRequest.class);
response = mock(DavServletResponse.class);
// responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
archivaConfiguration = mock(ArchivaConfiguration.class);
config = new Configuration();
when(archivaConfiguration.getConfiguration()).thenReturn(config);
when(archivaConfiguration.getDefaultLocale()).thenReturn(Locale.getDefault());
archivaConfiguration.addListener(any());
archivaConfiguration.save(eq(config));
archivaConfiguration.save(eq(config), anyString());
defaultManagedRepositoryAdmin.setArchivaConfiguration(archivaConfiguration);
repositoryRegistry.setArchivaConfiguration(archivaConfiguration);
repositoryRegistry.reload();
((DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator()).setArchivaConfiguration(archivaConfiguration);
if (defaultManagedRepositoryAdmin.getManagedRepository(RELEASES_REPO) == null) {
defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(RELEASES_REPO, getProjectBase().resolve("target/test-classes/" + RELEASES_REPO).toString(), "default"), false, null);
}
if (defaultManagedRepositoryAdmin.getManagedRepository(INTERNAL_REPO) == null) {
defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(INTERNAL_REPO, getProjectBase().resolve("target/test-classes/" + INTERNAL_REPO).toString(), "default"), false, null);
}
RepositoryGroup repoGroupConfig = new RepositoryGroup();
repoGroupConfig.setId(LOCAL_REPO_GROUP);
repoGroupConfig.addRepository(RELEASES_REPO);
repoGroupConfig.addRepository(INTERNAL_REPO);
defaultRepositoryGroupAdmin.setArchivaConfiguration(archivaConfiguration);
if (defaultManagedRepositoryAdmin.getManagedRepository(LOCAL_REPO_GROUP) == null) {
defaultRepositoryGroupAdmin.addRepositoryGroup(repoGroupConfig, null);
}
repoFactory = mock(RepositoryContentFactory.class);
repoRequest = mock(MavenRepositoryRequestInfo.class);
resourceFactory = new OverridingArchivaDavResourceFactory(applicationContext, archivaConfiguration);
resourceFactory.setArchivaConfiguration(archivaConfiguration);
proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).clear();
proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).add(new OverridingRepositoryProxyHandler(this));
resourceFactory.setProxyRegistry(proxyRegistry);
resourceFactory.setRemoteRepositoryAdmin(remoteRepositoryAdmin);
resourceFactory.setManagedRepositoryAdmin(defaultManagedRepositoryAdmin);
resourceFactory.setRepositoryRegistry(repositoryRegistry);
verify(archivaConfiguration, atLeast(2)).getConfiguration();
verify(archivaConfiguration, atMost(25)).getConfiguration();
verify(archivaConfiguration, atMost(4)).addListener(any());
verify(archivaConfiguration, atMost(5)).save(eq(config));
verify(archivaConfiguration, atMost(5)).save(eq(config), anyString());
}
Aggregations