use of org.apache.archiva.configuration.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.ArchivaConfiguration in project archiva by apache.
the class FileMetadataRepositoryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
Path directory = Paths.get("target/test-repositories");
if (Files.exists(directory)) {
org.apache.archiva.common.utils.FileUtils.deleteDirectory(directory);
}
ArchivaConfiguration config = createTestConfiguration(directory);
Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
this.repository = new FileMetadataRepository(factories, config);
}
use of org.apache.archiva.configuration.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);
listenerControl = EasyMock.createControl();
listener = listenerControl.createMock(RepositoryListener.class);
List<RepositoryListener> listeners = Collections.singletonList(listener);
repoPurge = new CleanupReleasedSnapshotsRepositoryPurge(getRepository(), metadataTools, applicationContext.getBean(RepositoryRegistry.class), repositorySession, listeners);
((DefaultManagedRepositoryAdmin) applicationContext.getBean(ManagedRepositoryAdmin.class)).setArchivaConfiguration(archivaConfiguration);
}
use of org.apache.archiva.configuration.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.ArchivaConfiguration in project archiva by apache.
the class ArchivaDavResourceFactoryTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
requestControl = createControl();
request = requestControl.createMock(DavServletRequest.class);
responseControl = createControl();
response = responseControl.createMock(DavServletResponse.class);
// responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
archivaConfigurationControl = createControl();
archivaConfiguration = archivaConfigurationControl.createMock(ArchivaConfiguration.class);
config = new Configuration();
expect(archivaConfiguration.getConfiguration()).andReturn(config).times(2, 20);
expect(archivaConfiguration.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
archivaConfiguration.addListener(EasyMock.anyObject());
expectLastCall().times(0, 4);
archivaConfiguration.save(config);
expectLastCall().times(0, 4);
archivaConfigurationControl.replay();
defaultManagedRepositoryAdmin.setArchivaConfiguration(archivaConfiguration);
repositoryRegistry.setArchivaConfiguration(archivaConfiguration);
repositoryRegistry.reload();
((DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator()).setArchivaConfiguration(archivaConfiguration);
if (defaultManagedRepositoryAdmin.getManagedRepository(RELEASES_REPO) == null) {
defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(RELEASES_REPO, Paths.get("target/test-classes/" + RELEASES_REPO).toString(), "default"), false, null);
}
if (defaultManagedRepositoryAdmin.getManagedRepository(INTERNAL_REPO) == null) {
defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(INTERNAL_REPO, Paths.get("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);
}
repoContentFactoryControl = createControl();
repoFactory = repoContentFactoryControl.createMock(RepositoryContentFactory.class);
repoRequestControl = createControl();
repoRequest = repoRequestControl.createMock(RepositoryRequest.class);
resourceFactory = new OverridingArchivaDavResourceFactory(applicationContext, plexusSisuBridge, archivaConfiguration);
resourceFactory.setArchivaConfiguration(archivaConfiguration);
resourceFactory.setRepositoryFactory(repoFactory);
resourceFactory.setRepositoryRequest(repoRequest);
resourceFactory.setConnectors(new OverridingRepositoryProxyConnectors());
resourceFactory.setRemoteRepositoryAdmin(remoteRepositoryAdmin);
resourceFactory.setManagedRepositoryAdmin(defaultManagedRepositoryAdmin);
resourceFactory.setRepositoryRegistry(repositoryRegistry);
}
Aggregations