use of org.apache.archiva.configuration.model.Configuration 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);
}
use of org.apache.archiva.configuration.model.Configuration 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);
repositoryRegistry.removeRepository(REPOID_INTERNAL);
org.apache.archiva.repository.ManagedRepository repository = servlet.getRepository(REPOID_INTERNAL);
assertNull(repository);
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class AbstractRepositoryServletTestCase method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
System.setProperty("appserver.base", getAppserverBase().toAbsolutePath().toString());
log.info("setUp appserverBase={}, projectBase={}, workingDir={}", getAppserverBase(), getProjectBase(), Paths.get("").toString());
repositoryRegistry.getRepositories().stream().forEach(r -> {
try {
repositoryRegistry.removeRepository(r);
} catch (RepositoryException e) {
e.printStackTrace();
}
});
org.apache.archiva.common.utils.FileUtils.deleteDirectory(getAppserverBase());
Path testConf = getProjectBase().resolve("src/test/resources/repository-archiva.xml");
Path testConfDest = getAppserverBase().resolve("conf/archiva.xml");
if (Files.exists(testConfDest)) {
org.apache.archiva.common.utils.FileUtils.deleteQuietly(testConfDest);
}
FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
repoRootInternal = getAppserverBase().resolve("data/repositories/internal");
repoRootLegacy = getAppserverBase().resolve("data/repositories/legacy");
Configuration config = archivaConfiguration.getConfiguration();
config.getManagedRepositories().clear();
config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true));
config.getProxyConnectors().clear();
config.getRemoteRepositories().clear();
saveConfiguration(archivaConfiguration);
// repositoryRegistry.reload();
// ArchivaIndexingContext ctx = repositoryRegistry.getManagedRepository( REPOID_INTERNAL ).getIndexingContext( );
// try
// {
// if (repositoryRegistry.getIndexManager(RepositoryType.MAVEN)!=null) {
// repositoryRegistry.getIndexManager(RepositoryType.MAVEN).pack(ctx);
// }
// } finally
// {
// if (ctx!=null)
// {
// ctx.close( );
// }
// }
}
use of org.apache.archiva.configuration.model.Configuration 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