Search in sources :

Example 41 with RemoteRepositoryConfiguration

use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration 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 42 with RemoteRepositoryConfiguration

use of org.apache.archiva.configuration.model.RemoteRepositoryConfiguration 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 43 with RemoteRepositoryConfiguration

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

the class MavenRepositoryProviderTest method createRemoteInstance.

@Test
public void createRemoteInstance() throws Exception {
    RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration();
    repo.setUsername("testuser001");
    repo.setPassword("pwd0000abc");
    repo.setCheckPath("test/check.html");
    repo.setTimeout(50);
    repo.setUrl("https://repo.maven.apache.org/maven2/test");
    repo.setDownloadRemoteIndex(true);
    repo.setDownloadRemoteIndexOnStartup(true);
    Map<String, String> header = new HashMap<>();
    header.put("header1", "value1");
    header.put("header2", "value2");
    repo.setExtraHeaders(header);
    Map<String, String> params = new HashMap<>();
    params.put("param1", "pval1");
    params.put("param2", "pval2");
    repo.setExtraParameters(params);
    repo.setRefreshCronExpression("0 1 07 ? * MON");
    repo.setRemoteDownloadTimeout(333);
    repo.setRemoteIndexUrl("testremote/.index");
    repo.setDescription("This is a test");
    repo.setId("test001");
    repo.setName("Remote Test Repo 001");
    repo.setIndexDir("testindex/.index");
    repo.setLayout("maven2");
    repo.setType(RepositoryType.MAVEN.toString());
    repo.setIndexDir("local/.index");
    RemoteRepository mr = provider.createRemoteInstance(repo);
    assertEquals("test001", mr.getId());
    assertEquals("This is a test", mr.getDescription());
    assertNotNull(mr.getLocation());
    assertEquals("https://repo.maven.apache.org/maven2/test", mr.getLocation().toString());
    assertEquals("Remote Test Repo 001", mr.getName());
    assertEquals("test001", mr.getId());
    assertEquals("0 1 07 ? * MON", mr.getSchedulingDefinition());
    assertEquals(50, mr.getTimeout().get(ChronoUnit.SECONDS));
    assertTrue(mr.isScanned());
    assertNotNull(mr.getLoginCredentials());
    assertTrue(mr.getLoginCredentials() instanceof PasswordCredentials);
    PasswordCredentials creds = (PasswordCredentials) mr.getLoginCredentials();
    assertEquals("testuser001", creds.getUsername());
    assertEquals("pwd0000abc", new String(creds.getPassword()));
    assertEquals("value1", mr.getExtraHeaders().get("header1"));
    assertEquals("pval2", mr.getExtraParameters().get("param2"));
    assertEquals("maven2", mr.getLayout());
    try {
        ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature(ArtifactCleanupFeature.class);
        throw new Exception("artifactCleanupFeature should not be available");
    } catch (UnsupportedFeatureException e) {
    // correct
    }
    IndexCreationFeature indexCreationFeature = mr.getFeature(IndexCreationFeature.class);
    assertEquals("local/.index", indexCreationFeature.getIndexPath().toString());
    try {
        StagingRepositoryFeature stagingRepositoryFeature = mr.getFeature(StagingRepositoryFeature.class);
        throw new Exception("stagingRepositoryFeature should not be available");
    } catch (UnsupportedFeatureException e) {
    // correct
    }
    RemoteIndexFeature remoteIndexFeature = mr.getFeature(RemoteIndexFeature.class);
    assertNull(remoteIndexFeature.getProxyId());
}
Also used : PasswordCredentials(org.apache.archiva.repository.base.PasswordCredentials) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) UnsupportedFeatureException(org.apache.archiva.repository.UnsupportedFeatureException) HashMap(java.util.HashMap) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) RemoteRepository(org.apache.archiva.repository.RemoteRepository) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) UnsupportedFeatureException(org.apache.archiva.repository.UnsupportedFeatureException) URISyntaxException(java.net.URISyntaxException) RepositoryException(org.apache.archiva.repository.RepositoryException) IOException(java.io.IOException) Test(org.junit.Test)

Example 44 with RemoteRepositoryConfiguration

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

the class MavenRepositoryProviderTest method getRemoteConfiguration.

@Test
public void getRemoteConfiguration() throws Exception {
    MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance("test01", "My Test repo", Paths.get("target/remotes"));
    repo.setLocation(new URI("https://this.is/a/test"));
    repo.setScanned(true);
    repo.setDescription(repo.getPrimaryLocale(), "This is a description");
    repo.setLayout("maven2");
    repo.setName(repo.getPrimaryLocale(), "test0003");
    repo.setSchedulingDefinition("0 0 05 ? * WED");
    RemoteIndexFeature remoteIndexFeature = repo.getFeature(RemoteIndexFeature.class);
    remoteIndexFeature.setProxyId("proxyabc");
    remoteIndexFeature.setDownloadTimeout(Duration.ofSeconds(54));
    remoteIndexFeature.setDownloadRemoteIndex(false);
    remoteIndexFeature.setIndexUri(new URI("/this/remote/.index"));
    remoteIndexFeature.setDownloadRemoteIndexOnStartup(true);
    IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class);
    indexCreationFeature.setIndexPath(new URI("/this/local/.index"));
    RemoteRepositoryConfiguration cfg = provider.getRemoteConfiguration(repo);
    assertEquals("https://this.is/a/test", cfg.getUrl());
    assertEquals("This is a description", cfg.getDescription());
    assertEquals("maven2", cfg.getLayout());
    assertEquals("test0003", cfg.getName());
    assertEquals("0 0 05 ? * WED", cfg.getRefreshCronExpression());
    assertEquals("/this/remote/.index", cfg.getRemoteIndexUrl());
    assertEquals("proxyabc", cfg.getRemoteDownloadNetworkProxyId());
    assertEquals(54, cfg.getRemoteDownloadTimeout());
    assertFalse(cfg.isDownloadRemoteIndex());
    assertTrue(cfg.isDownloadRemoteIndexOnStartup());
    assertEquals("/this/local/.index", cfg.getIndexDir());
}
Also used : IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) RemoteIndexFeature(org.apache.archiva.repository.features.RemoteIndexFeature) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) URI(java.net.URI) Test(org.junit.Test)

Example 45 with RemoteRepositoryConfiguration

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

the class MockRepoAdmin method getRemoteRepositories.

@Override
public List<RemoteRepository> getRemoteRepositories() throws RepositoryAdminException {
    List<RemoteRepository> remoteRepositories = new ArrayList<>(archivaConfiguration.getConfiguration().getRemoteRepositories().size());
    for (RemoteRepositoryConfiguration repositoryConfiguration : archivaConfiguration.getConfiguration().getRemoteRepositories()) {
        RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault(), repositoryConfiguration.getId(), repositoryConfiguration.getName(), repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(), repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(), repositoryConfiguration.getTimeout());
        remoteRepository.setDownloadRemoteIndex(repositoryConfiguration.isDownloadRemoteIndex());
        remoteRepository.setRemoteIndexUrl(repositoryConfiguration.getRemoteIndexUrl());
        remoteRepository.setCronExpression(repositoryConfiguration.getRefreshCronExpression());
        remoteRepository.setIndexDirectory(repositoryConfiguration.getIndexDir());
        remoteRepository.setRemoteDownloadNetworkProxyId(repositoryConfiguration.getRemoteDownloadNetworkProxyId());
        remoteRepository.setRemoteDownloadTimeout(repositoryConfiguration.getRemoteDownloadTimeout());
        remoteRepository.setDownloadRemoteIndexOnStartup(repositoryConfiguration.isDownloadRemoteIndexOnStartup());
        remoteRepositories.add(remoteRepository);
    }
    return remoteRepositories;
}
Also used : ArrayList(java.util.ArrayList) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository)

Aggregations

RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)46 Configuration (org.apache.archiva.configuration.model.Configuration)17 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)14 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)14 RemoteRepository (org.apache.archiva.repository.RemoteRepository)12 ContextConfiguration (org.springframework.test.context.ContextConfiguration)11 ArrayList (java.util.ArrayList)9 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)9 EditableRemoteRepository (org.apache.archiva.repository.EditableRemoteRepository)9 RepositoryException (org.apache.archiva.repository.RepositoryException)8 Test (org.junit.Test)8 Path (java.nio.file.Path)7 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)7 RemoteIndexFeature (org.apache.archiva.repository.features.RemoteIndexFeature)7 Test (org.junit.jupiter.api.Test)7 HashMap (java.util.HashMap)6 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)6 PasswordCredentials (org.apache.archiva.repository.base.PasswordCredentials)6 Iterator (java.util.Iterator)5 List (java.util.List)5