Search in sources :

Example 91 with Configuration

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);
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) MockServletConfig(org.springframework.mock.web.MockServletConfig) HttpAuthenticator(org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator) MockServletContext(org.springframework.mock.web.MockServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext) ServletAuthenticator(org.apache.archiva.security.ServletAuthenticator) Before(org.junit.Before)

Example 92 with Configuration

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);
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepository(org.apache.archiva.repository.ManagedRepository) Test(org.junit.Test)

Example 93 with Configuration

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( );
// }
// }
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) Before(org.junit.Before)

Example 94 with Configuration

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;
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Aggregations

Configuration (org.apache.archiva.configuration.model.Configuration)94 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)56 ContextConfiguration (org.springframework.test.context.ContextConfiguration)45 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)42 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)34 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)34 WebappConfiguration (org.apache.archiva.configuration.model.WebappConfiguration)32 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)29 Path (java.nio.file.Path)27 Test (org.junit.Test)26 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)23 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)23 RepositoryException (org.apache.archiva.repository.RepositoryException)22 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)14 ManagedRepository (org.apache.archiva.repository.ManagedRepository)13 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)12 RemoteRepository (org.apache.archiva.repository.RemoteRepository)12 Test (org.junit.jupiter.api.Test)12 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)11