Search in sources :

Example 86 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class AbstractMavenRepositorySearch method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    FileUtils.deleteDirectory(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer"));
    assertFalse(Files.exists(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer")));
    Files.createDirectories(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer"));
    FileUtils.deleteDirectory(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer"));
    assertFalse(Files.exists(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer")));
    Files.createDirectories(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer"));
    archivaConfig = mock(ArchivaConfiguration.class);
    repositoryRegistry.setArchivaConfiguration(archivaConfig);
    search = new MavenRepositorySearch(indexer, repositoryRegistry, proxyRegistry, queryCreator);
    assertNotNull(repositoryRegistry);
    config = new Configuration();
    config.addManagedRepository(createRepositoryConfig(TEST_REPO_1));
    config.addManagedRepository(createRepositoryConfig(TEST_REPO_2));
    config.addManagedRepository(createRepositoryConfig(REPO_RELEASE));
    when(archivaConfig.getDefaultLocale()).thenReturn(Locale.getDefault());
    when(archivaConfig.getConfiguration()).thenReturn(config);
    archivaConfig.save(any(Configuration.class), anyString());
    repositoryRegistry.reload();
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) Before(org.junit.Before)

Example 87 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411RepoGroupTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    c = new Configuration();
    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId(TEST_REPO_ID);
    testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
    testRepo.setReleases(true);
    testRepo.setSnapshots(false);
    c.addManagedRepository(testRepo);
    testRepoS = new ManagedRepositoryConfiguration();
    testRepoS.setId(TEST_SNAP_REPO_ID);
    testRepoS.setLocation(Paths.get("target/test-repositorys").toAbsolutePath().toString());
    testRepoS.setReleases(false);
    testRepoS.setSnapshots(true);
    c.addManagedRepository(testRepoS);
    RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
    testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
    testRemoteRepo.setLayout("default");
    testRemoteRepo.setName("Central Repository");
    testRemoteRepo.setUrl("http://central.repo.com/maven2");
    testRemoteRepo.setTimeout(10);
    c.addRemoteRepository(testRemoteRepo);
    ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
    proxyConnector.setSourceRepoId(TEST_REPO_ID);
    proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
    proxyConnector.setDisabled(false);
    c.addProxyConnector(proxyConnector);
    ProxyConnectorConfiguration proxyConnectors = new ProxyConnectorConfiguration();
    proxyConnectors.setSourceRepoId(TEST_SNAP_REPO_ID);
    proxyConnectors.setTargetRepoId(TEST_REMOTE_REPO_ID);
    proxyConnectors.setDisabled(false);
    c.addProxyConnector(proxyConnectors);
    List<String> repos = new ArrayList<>();
    repos.add(TEST_REPO_ID);
    repos.add(TEST_SNAP_REPO_ID);
    RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
    repoGroup.setId(TEST_REPO_GROUP_ID);
    repoGroup.setRepositories(repos);
    c.addRepositoryGroup(repoGroup);
    configuration.save(c);
    repositoryRegistry.reload();
    assertFalse(c.getManagedRepositories().get(0).isSnapshots());
    assertTrue(c.getManagedRepositories().get(0).isReleases());
    assertTrue(c.getManagedRepositories().get(1).isSnapshots());
    assertFalse(c.getManagedRepositories().get(1).isReleases());
    wagonFactory = mock(WagonFactory.class);
    storage.setWagonFactory(wagonFactory);
    Wagon wagon = new MockWagon();
    when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) WagonFactoryRequest(org.apache.archiva.maven.common.proxy.WagonFactoryRequest) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) WagonFactory(org.apache.archiva.maven.common.proxy.WagonFactory) Wagon(org.apache.maven.wagon.Wagon) Before(org.junit.Before)

Example 88 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411Test method testGetProjectVersionMetadataWithParentNoRemoteReposConfigured.

@Test
public void testGetProjectVersionMetadataWithParentNoRemoteReposConfigured() throws Exception {
    assertNotNull(storage);
    // remove configuration
    Configuration config = configuration.getConfiguration();
    RemoteRepositoryConfiguration remoteRepo = config.findRemoteRepositoryById(TEST_REMOTE_REPO_ID);
    config.removeRemoteRepository(remoteRepo);
    configuration.save(config);
    assertNotNull(storage);
    copyTestArtifactWithParent("target/test-classes/com/example/test/test-artifact-module-a", "target/test-repository/com/example/test/test-artifact-module-a");
    ProjectVersionMetadata metadata = storage.readProjectVersionMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact-module-a", "1.0"));
    assertEquals("1.0", metadata.getId());
    MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet(MavenProjectFacet.FACET_ID);
    assertNotNull(facet);
    assertEquals("com.example.test", facet.getGroupId());
    assertEquals("test-artifact-module-a", facet.getArtifactId());
    assertEquals("jar", facet.getPackaging());
    List<String> paths = new ArrayList<>();
    paths.add("target/test-repository/com/example/test/test-artifact-module-a");
    paths.add("target/test-repository/com/example/test/test-artifact-parent");
    paths.add("target/test-repository/com/example/test/test-artifact-root");
    deleteTestArtifactWithParent(paths);
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) ArrayList(java.util.ArrayList) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) Test(org.junit.Test)

Example 89 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class Maven2RepositoryMetadataResolverMRM1411Test method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    c = new Configuration();
    testRepo = new ManagedRepositoryConfiguration();
    testRepo.setId(TEST_REPO_ID);
    testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
    testRepo.setReleases(true);
    testRepo.setSnapshots(true);
    c.addManagedRepository(testRepo);
    RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
    testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
    testRemoteRepo.setLayout("default");
    testRemoteRepo.setName("Central Repository");
    testRemoteRepo.setUrl("http://central.repo.com/maven2");
    testRemoteRepo.setTimeout(10);
    c.addRemoteRepository(testRemoteRepo);
    ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
    proxyConnector.setSourceRepoId(TEST_REPO_ID);
    proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
    proxyConnector.setDisabled(false);
    c.addProxyConnector(proxyConnector);
    configuration.save(c);
    repositoryRegistry.reload();
    assertTrue(c.getManagedRepositories().get(0).isSnapshots());
    assertTrue(c.getManagedRepositories().get(0).isReleases());
    wagonFactory = mock(WagonFactory.class);
    assertNotNull(storage);
    storage.setWagonFactory(wagonFactory);
    Wagon wagon = new MockWagon();
    when(wagonFactory.getWagon(new WagonFactoryRequest("wagon#http", new HashMap<String, String>()))).thenReturn(wagon);
}
Also used : WagonFactoryRequest(org.apache.archiva.maven.common.proxy.WagonFactoryRequest) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) HashMap(java.util.HashMap) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) WagonFactory(org.apache.archiva.maven.common.proxy.WagonFactory) Wagon(org.apache.maven.wagon.Wagon) Before(org.junit.Before)

Example 90 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class RepositoryServletRepositoryGroupTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String appserverBase = getAppserverBase().toAbsolutePath().toString();
    log.debug("Appserver Base {}", appserverBase);
    Configuration configuration = archivaConfiguration.getConfiguration();
    repoRootFirst = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_FIRST);
    repoRootLast = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_LAST);
    configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
    configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
    List<String> managedRepoIds = new ArrayList<>();
    managedRepoIds.add(MANAGED_REPO_FIRST);
    managedRepoIds.add(MANAGED_REPO_LAST);
    configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_VALID_REPOS, managedRepoIds));
    // Create the repository group with an invalid managed repository
    repoRootInvalid = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_INVALID);
    ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository(MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true);
    configuration.addManagedRepository(managedRepositoryConfiguration);
    List<String> invalidManagedRepoIds = new ArrayList<>();
    invalidManagedRepoIds.add(MANAGED_REPO_FIRST);
    invalidManagedRepoIds.add(MANAGED_REPO_INVALID);
    invalidManagedRepoIds.add(MANAGED_REPO_LAST);
    configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds));
    configuration.removeManagedRepository(managedRepositoryConfiguration);
    org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRootInvalid);
    repositoryRegistry.reload();
    saveConfiguration(archivaConfiguration);
    startRepository();
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) Before(org.junit.Before)

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