use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class FileMetadataRepositoryTest method setUp.
@BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
assertMaxTries = 1;
assertRetrySleepMs = 10;
Path directory = Paths.get("target/test-repositories");
if (Files.exists(directory)) {
org.apache.archiva.common.utils.FileUtils.deleteDirectory(directory);
}
ArchivaConfiguration config = createTestConfiguration(directory);
List<MetadataFacetFactory> factories = createTestMetadataFacetFactories();
MetadataService metadataService = new MetadataService();
metadataService.setMetadataFacetFactories(factories);
this.repository = new FileMetadataRepository(metadataService, config);
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class RepositoryPurgeConsumerTest method assertNotConsumed.
@SuppressWarnings("deprecation")
private void assertNotConsumed(String path) throws Exception {
ArchivaConfiguration archivaConfiguration = applicationContext.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
assertEquals(FileTypes.ARTIFACTS, fileType.getId());
fileType.addPattern("**/*.xml");
// FileTypes fileTypes = applicationContext.getBean( FileTypes.class );
for (FileTypes fileTypes : applicationContext.getBeansOfType(FileTypes.class).values()) {
fileTypes.afterConfigurationChange(null, "repositoryScanning.fileTypes", null);
}
KnownRepositoryContentConsumer repoPurgeConsumer = applicationContext.getBean("knownRepositoryContentConsumer#repository-purge", KnownRepositoryContentConsumer.class);
Path repoLocation = Paths.get("target/test-" + getName() + "/test-repo");
Path localFile = repoLocation.resolve(path);
ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate();
BaseFile baseFile = new BaseFile(repoLocation.toFile(), localFile.toFile());
predicate.setBasefile(baseFile);
assertFalse(predicate.evaluate(repoPurgeConsumer));
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class NexusIndexerConsumerTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
scheduler = new ArchivaTaskSchedulerStub();
ArchivaConfiguration configuration = applicationContext.getBean(ArchivaConfiguration.class);
FileTypes filetypes = applicationContext.getBean(FileTypes.class);
nexusIndexerConsumer = new NexusIndexerConsumer(scheduler, configuration, filetypes);
// initialize to set the file types to be processed
nexusIndexerConsumer.initialize();
repositoryConfig = BasicManagedRepository.newFilesystemInstance("test-repo", "Test Repository", Paths.get("target/test-classes").resolve("test-repo"));
repositoryConfig.setLocation(new URI("target/test-classes/test-repo"));
repositoryConfig.setLayout("default");
repositoryConfig.setScanned(true);
repositoryConfig.addActiveReleaseScheme(ReleaseScheme.RELEASE);
repositoryConfig.removeActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
repositoryRegistry.putRepository(repositoryConfig);
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class RepositoryServlet method initServers.
public void initServers(ServletConfig servletConfig) {
long start = System.currentTimeMillis();
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletConfig.getServletContext());
rwLock.writeLock().lock();
try {
configuration = wac.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
configuration.addListener(this);
repositoryRegistry = wac.getBean(ArchivaRepositoryRegistry.class);
resourceFactory = wac.getBean("davResourceFactory#archiva", DavResourceFactory.class);
locatorFactory = new ArchivaDavLocatorFactory();
ServletAuthenticator servletAuth = wac.getBean(ServletAuthenticator.class);
HttpAuthenticator httpAuth = wac.getBean("httpAuthenticator#basic", HttpAuthenticator.class);
sessionProvider = new ArchivaDavSessionProvider(servletAuth, httpAuth);
} finally {
rwLock.writeLock().unlock();
}
long end = System.currentTimeMillis();
log.debug("initServers done in {} ms", (end - start));
}
use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.
the class RepositoryServletSecurityTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
String appserverBase = System.getProperty("appserver.base", getProjectBase().resolve("target/appserver-base").toAbsolutePath().toString());
Path testConf = getProjectBase().resolve("src/test/resources/repository-archiva.xml");
Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml");
FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
Configuration config = archivaConfiguration.getConfiguration();
// clear managed repository
List<ManagedRepositoryConfiguration> f1 = new ArrayList<>(config.getManagedRepositories());
for (ManagedRepositoryConfiguration f : f1) {
config.removeManagedRepository(f);
}
assertEquals(0, config.getManagedRepositories().size());
// add internal repo
config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal.getRoot()));
saveConfiguration(archivaConfiguration);
servletAuth = mock(ServletAuthenticator.class);
httpAuth = mock(HttpAuthenticator.class);
davSessionProvider = new ArchivaDavSessionProvider(servletAuth, httpAuth);
final MockServletContext mockServletContext = new MockServletContext();
WebApplicationContext webApplicationContext = new AbstractRepositoryServletTestCase.TestWebapplicationContext(applicationContext, mockServletContext);
mockServletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);
MockServletConfig mockServletConfig = new MockServletConfig() {
@Override
public ServletContext getServletContext() {
return mockServletContext;
}
};
servlet = new RepositoryServlet();
servlet.init(mockServletConfig);
}
Aggregations