use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class RepositoryPurgeConsumerTest method cleanupFileTypes.
private void cleanupFileTypes() {
ArchivaConfiguration archivaConfiguration = applicationContext.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
fileType.removePattern("**/*.xml");
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration 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());
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class RepositoryServletTest method testGetRepositoryAfterAdd.
@Test
public void testGetRepositoryAfterAdd() throws Exception {
RepositoryServlet servlet = RepositoryServlet.class.cast(findServlet("repository"));
assertNotNull(servlet);
ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
Configuration c = archivaConfiguration.getConfiguration();
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
repo.setId(NEW_REPOSITORY_ID);
repo.setName(NEW_REPOSITORY_NAME);
Path repoRoot = Paths.get("target/test-repository-root");
if (!Files.exists(repoRoot)) {
Files.createDirectories(repoRoot);
}
repo.setLocation(repoRoot.toAbsolutePath().toString());
c.addManagedRepository(repo);
saveConfiguration(archivaConfiguration);
ManagedRepository repository = servlet.getRepository(NEW_REPOSITORY_ID);
assertNotNull(repository);
assertEquals(NEW_REPOSITORY_NAME, repository.getName());
// check other is still intact
assertRepositoryValid(servlet, REPOID_INTERNAL);
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class CleanupReleasedSnapshotsRepositoryPurgeTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
RepositoryContentFactory factory = applicationContext.getBean("repositoryContentFactory#cleanup-released-snapshots", RepositoryContentFactory.class);
archivaConfiguration = applicationContext.getBean("archivaConfiguration#cleanup-released-snapshots", ArchivaConfiguration.class);
listener = mock(RepositoryListener.class);
List<RepositoryListener> listeners = Collections.singletonList(listener);
Mockito.when(sessionFactory.createSession()).thenReturn(repositorySession);
Mockito.when(repositorySession.getRepository()).thenReturn(metadataRepository);
repositorySession.save();
repoPurge = new CleanupReleasedSnapshotsRepositoryPurge(getRepository(), metadataTools, applicationContext.getBean(ArchivaRepositoryRegistry.class), repositorySession, listeners);
((DefaultManagedRepositoryAdmin) applicationContext.getBean(ManagedRepositoryAdmin.class)).setArchivaConfiguration(archivaConfiguration);
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class RepositoryContentConsumersTest method lookupRepositoryConsumers.
private RepositoryContentConsumers lookupRepositoryConsumers() throws Exception {
ArchivaConfiguration configuration = applicationContext.getBean("archivaConfiguration#test-conf", ArchivaConfiguration.class);
ArchivaAdministrationStub administrationStub = new ArchivaAdministrationStub(configuration);
RepositoryContentConsumers consumerUtilStub = new RepositoryContentConsumersStub(administrationStub);
RepositoryContentConsumers consumerUtil = applicationContext.getBean("repositoryContentConsumers#test", RepositoryContentConsumers.class);
ApplicationContext context = new //
MockApplicationContext(//
consumerUtil.getAvailableKnownConsumers(), consumerUtil.getAvailableInvalidConsumers());
consumerUtilStub.setApplicationContext(context);
consumerUtilStub.setSelectedInvalidConsumers(consumerUtil.getSelectedInvalidConsumers());
consumerUtilStub.setSelectedKnownConsumers(consumerUtil.getSelectedKnownConsumers());
consumerUtilStub.setArchivaAdministration(administrationStub);
assertNotNull("RepositoryContentConsumers should not be null.", consumerUtilStub);
return consumerUtilStub;
}
Aggregations