Search in sources :

Example 6 with ProxyConnector

use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.

the class ProxyConnectorAdminTest method updateProxyConnector.

@Test
public void updateProxyConnector() throws Exception {
    mockAuditListener.clearEvents();
    ProxyConnector proxyConnector = proxyConnectorAdmin.getProxyConnector("internal", "central");
    assertNotNull(proxyConnector);
    proxyConnector.setDisabled(false);
    proxyConnectorAdmin.updateProxyConnector(proxyConnector, getFakeAuditInformation());
    proxyConnector = proxyConnectorAdmin.getProxyConnector("internal", "central");
    assertFalse(proxyConnector.isDisabled());
    proxyConnector.setDisabled(true);
    proxyConnectorAdmin.updateProxyConnector(proxyConnector, getFakeAuditInformation());
    proxyConnector = proxyConnectorAdmin.getProxyConnector("internal", "central");
    assertTrue(proxyConnector.isDisabled());
    proxyConnector.setOrder(4);
    proxyConnectorAdmin.updateProxyConnector(proxyConnector, getFakeAuditInformation());
    proxyConnector = proxyConnectorAdmin.getProxyConnector("internal", "central");
    assertEquals(4, proxyConnector.getOrder());
    mockAuditListener.clearEvents();
}
Also used : ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 7 with ProxyConnector

use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.

the class ProxyConnectorRuleAdminTest method addProxyConnectorRule.

@Test
public void addProxyConnectorRule() throws Exception {
    ProxyConnector proxyConnector = new ProxyConnector();
    proxyConnector.setSourceRepoId("snapshots");
    proxyConnector.setTargetRepoId("central");
    ProxyConnectorRule rule = null;
    try {
        int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
        assertEquals(0, size);
        proxyConnectorAdmin.addProxyConnector(proxyConnector, getFakeAuditInformation());
        rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector));
        proxyConnectorRuleAdmin.addProxyConnectorRule(rule, getFakeAuditInformation());
        assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
        rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
        assertEquals("org/apache/maven", rule.getPattern());
        assertEquals(1, rule.getProxyConnectors().size());
        assertEquals("snapshots", rule.getProxyConnectors().get(0).getSourceRepoId());
        assertEquals("central", rule.getProxyConnectors().get(0).getTargetRepoId());
        assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
    } finally {
        proxyConnectorRuleAdmin.deleteProxyConnectorRule(rule, getFakeAuditInformation());
        proxyConnectorAdmin.deleteProxyConnector(proxyConnector, getFakeAuditInformation());
    }
}
Also used : ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 8 with ProxyConnector

use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.

the class ProxyConnectorRuleAdminTest method addProxyConnectorRuleWithTwoProxyConnectors.

@Test
public void addProxyConnectorRuleWithTwoProxyConnectors() throws Exception {
    RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
    remoteRepository.setId("archiva");
    remoteRepository.setName("archiva rocks");
    remoteRepository.setUrl("http://wine.org");
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
    int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
    assertEquals(0, size);
    ProxyConnector proxyConnector1 = new ProxyConnector();
    proxyConnector1.setSourceRepoId("snapshots");
    proxyConnector1.setTargetRepoId("central");
    proxyConnectorAdmin.addProxyConnector(proxyConnector1, getFakeAuditInformation());
    ProxyConnector proxyConnector2 = new ProxyConnector();
    proxyConnector2.setSourceRepoId("snapshots");
    proxyConnector2.setTargetRepoId("archiva");
    proxyConnectorAdmin.addProxyConnector(proxyConnector2, getFakeAuditInformation());
    ProxyConnectorRule rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector1, proxyConnector2));
    try {
        proxyConnectorRuleAdmin.addProxyConnectorRule(rule, getFakeAuditInformation());
        assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
        rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
        assertEquals("org/apache/maven", rule.getPattern());
        assertEquals(2, rule.getProxyConnectors().size());
        assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
    } finally {
        proxyConnectorRuleAdmin.deleteProxyConnectorRule(rule, getFakeAuditInformation());
        proxyConnectorAdmin.deleteProxyConnector(proxyConnector1, getFakeAuditInformation());
        proxyConnectorAdmin.deleteProxyConnector(proxyConnector2, getFakeAuditInformation());
        remoteRepositoryAdmin.deleteRemoteRepository(remoteRepository.getId(), getFakeAuditInformation());
    }
}
Also used : ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 9 with ProxyConnector

use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.

the class ProxyConnectorRuleAdminTest method updateProxyConnectorRuleWithTwoProxyConnectors.

@Test
public void updateProxyConnectorRuleWithTwoProxyConnectors() throws Exception {
    RemoteRepository remoteRepository = new RemoteRepository(Locale.getDefault());
    remoteRepository.setId("archiva");
    remoteRepository.setName("archiva rocks");
    remoteRepository.setUrl("http://wine.org");
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
    int size = proxyConnectorRuleAdmin.getProxyConnectorRules().size();
    assertEquals(0, size);
    ProxyConnector proxyConnector1 = new ProxyConnector();
    proxyConnector1.setSourceRepoId("snapshots");
    proxyConnector1.setTargetRepoId("central");
    proxyConnectorAdmin.addProxyConnector(proxyConnector1, getFakeAuditInformation());
    ProxyConnector proxyConnector2 = new ProxyConnector();
    proxyConnector2.setSourceRepoId("snapshots");
    proxyConnector2.setTargetRepoId("archiva");
    proxyConnectorAdmin.addProxyConnector(proxyConnector2, getFakeAuditInformation());
    ProxyConnectorRule rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector1, proxyConnector2));
    try {
        proxyConnectorRuleAdmin.addProxyConnectorRule(rule, getFakeAuditInformation());
        assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
        rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
        assertEquals("org/apache/maven", rule.getPattern());
        assertEquals(2, rule.getProxyConnectors().size());
        // assertEquals( "snapshots", rule.getProxyConnectors().get( 0 ).getSourceRepoId() );
        // assertEquals( "central", rule.getProxyConnectors().get( 0 ).getTargetRepoId() );
        assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
        rule.setProxyConnectors(Arrays.asList(proxyConnector1));
        proxyConnectorRuleAdmin.updateProxyConnectorRule(rule, getFakeAuditInformation());
        assertEquals(size + 1, proxyConnectorRuleAdmin.getProxyConnectorRules().size());
        rule = proxyConnectorRuleAdmin.getProxyConnectorRules().get(0);
        assertEquals("org/apache/maven", rule.getPattern());
        assertEquals(1, rule.getProxyConnectors().size());
        assertEquals("snapshots", rule.getProxyConnectors().get(0).getSourceRepoId());
        assertEquals("central", rule.getProxyConnectors().get(0).getTargetRepoId());
    } finally {
        proxyConnectorRuleAdmin.deleteProxyConnectorRule(rule, getFakeAuditInformation());
        proxyConnectorAdmin.deleteProxyConnector(proxyConnector1, getFakeAuditInformation());
        proxyConnectorAdmin.deleteProxyConnector(proxyConnector2, getFakeAuditInformation());
        remoteRepositoryAdmin.deleteRemoteRepository(remoteRepository.getId(), getFakeAuditInformation());
    }
}
Also used : ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 10 with ProxyConnector

use of org.apache.archiva.admin.model.beans.ProxyConnector in project archiva by apache.

the class ProxyConnectorRuleServiceTest method addProxyConnectorRule.

@Test
public void addProxyConnectorRule() throws Exception {
    ProxyConnector proxyConnector = new ProxyConnector();
    proxyConnector.setSourceRepoId("snapshots");
    proxyConnector.setTargetRepoId("central");
    ProxyConnectorRuleService service = getProxyConnectorRuleService(authorizationHeader);
    ProxyConnectorRule rule = null;
    try {
        int size = service.getProxyConnectorRules().size();
        assertEquals(0, size);
        getProxyConnectorService().addProxyConnector(proxyConnector);
        rule = new ProxyConnectorRule("org/apache/maven", ProxyConnectorRuleType.BLACK_LIST, Arrays.asList(proxyConnector));
        service.addProxyConnectorRule(rule);
        assertEquals(size + 1, service.getProxyConnectorRules().size());
        rule = service.getProxyConnectorRules().get(0);
        assertEquals("org/apache/maven", rule.getPattern());
        assertEquals(1, rule.getProxyConnectors().size());
        assertEquals("snapshots", rule.getProxyConnectors().get(0).getSourceRepoId());
        assertEquals("central", rule.getProxyConnectors().get(0).getTargetRepoId());
        assertEquals(ProxyConnectorRuleType.BLACK_LIST, rule.getProxyConnectorRuleType());
    } finally {
        service.deleteProxyConnectorRule(rule);
        getProxyConnectorService().deleteProxyConnector(proxyConnector);
    }
}
Also used : ProxyConnectorRule(org.apache.archiva.admin.model.beans.ProxyConnectorRule) ProxyConnector(org.apache.archiva.admin.model.beans.ProxyConnector) ProxyConnectorRuleService(org.apache.archiva.rest.api.services.ProxyConnectorRuleService) Test(org.junit.Test)

Aggregations

ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)20 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 AbstractRepositoryAdminTest (org.apache.archiva.admin.repository.AbstractRepositoryAdminTest)7 RemoteRepository (org.apache.archiva.admin.model.beans.RemoteRepository)6 HashMap (java.util.HashMap)5 List (java.util.List)5 ProxyConnectorRule (org.apache.archiva.admin.model.beans.ProxyConnectorRule)5 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)4 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)4 Path (java.nio.file.Path)3 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)3 ProxyConnectorRuleConfiguration (org.apache.archiva.configuration.ProxyConnectorRuleConfiguration)3 NetworkProxy (org.apache.archiva.admin.model.beans.NetworkProxy)2 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)2 Configuration (org.apache.archiva.configuration.Configuration)2 Artifact (org.apache.archiva.maven2.model.Artifact)2 RemoteRepository (org.apache.archiva.repository.RemoteRepository)2 SearchRequest (org.apache.archiva.rest.api.model.SearchRequest)2 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)2