use of org.apache.archiva.configuration.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", Paths.get("target/appserver-base").toAbsolutePath().toString());
Path testConf = Paths.get("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);
CacheManager.getInstance().clearAll();
servletAuthControl = EasyMock.createControl();
servletAuth = servletAuthControl.createMock(ServletAuthenticator.class);
httpAuthControl = EasyMock.createControl();
httpAuth = httpAuthControl.createMock(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);
}
use of org.apache.archiva.configuration.ArchivaConfiguration in project archiva by apache.
the class RepositoryServletTest method testGetRepositoryAfterDelete.
@Test
public void testGetRepositoryAfterDelete() throws Exception {
RepositoryServlet servlet = RepositoryServlet.class.cast(findServlet("repository"));
assertNotNull(servlet);
ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
Configuration c = archivaConfiguration.getConfiguration();
c.removeManagedRepository(c.findManagedRepositoryById(REPOID_INTERNAL));
saveConfiguration(archivaConfiguration);
ManagedRepository repository = servlet.getRepository(REPOID_INTERNAL);
assertNull(repository);
}
use of org.apache.archiva.configuration.ArchivaConfiguration in project archiva by apache.
the class ReinitServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(req.getServletContext());
ArchivaConfiguration archivaConfiguration = applicationContext.getBean(ArchivaConfiguration.class);
archivaConfiguration.reload();
}
use of org.apache.archiva.configuration.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.ArchivaConfiguration in project archiva by apache.
the class FileMetadataRepositoryTest method createTestConfiguration.
protected static ArchivaConfiguration createTestConfiguration(Path directory) {
ArchivaConfiguration config = mock(ArchivaConfiguration.class);
Configuration configData = new Configuration();
configData.addManagedRepository(createManagedRepository(TEST_REPO_ID, directory));
configData.addManagedRepository(createManagedRepository("other-repo", directory));
when(config.getConfiguration()).thenReturn(configData);
return config;
}
Aggregations