Search in sources :

Example 21 with RemoteRepository

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

the class RemoteRepositoryAdminTest method addAndDelete.

@Test
public void addAndDelete() throws Exception {
    mockAuditListener.clearEvents();
    int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
    RemoteRepository remoteRepository = getRemoteRepository();
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
    assertEquals(initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size());
    RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository("foo");
    assertNotNull(repo);
    assertEquals(getRemoteRepository().getPassword(), repo.getPassword());
    assertEquals(getRemoteRepository().getUrl(), repo.getUrl());
    assertEquals(getRemoteRepository().getUserName(), repo.getUserName());
    assertEquals(getRemoteRepository().getName(), repo.getName());
    assertEquals(getRemoteRepository().getTimeout(), repo.getTimeout());
    assertEquals(getRemoteRepository().getDescription(), repo.getDescription());
    assertEquals(1, remoteRepository.getExtraHeaders().size());
    assertEquals("wine", remoteRepository.getExtraHeaders().get("beer"));
    assertEquals(1, remoteRepository.getExtraParameters().size());
    assertEquals("bar", remoteRepository.getExtraParameters().get("foo"));
    remoteRepositoryAdmin.deleteRemoteRepository("foo", getFakeAuditInformation());
    assertEquals(initialSize, remoteRepositoryAdmin.getRemoteRepositories().size());
    repo = remoteRepositoryAdmin.getRemoteRepository("foo");
    assertNull(repo);
    assertEquals(2, mockAuditListener.getAuditEvents().size());
    assertEquals(AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get(0).getAction());
    assertEquals("root", mockAuditListener.getAuditEvents().get(0).getUserId());
    assertEquals("archiva-localhost", mockAuditListener.getAuditEvents().get(0).getRemoteIP());
    assertEquals(AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get(1).getAction());
    assertEquals("root", mockAuditListener.getAuditEvents().get(1).getUserId());
}
Also used : RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 22 with RemoteRepository

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

the class RemoteRepositoryAdminTest method addAndUpdateAndDelete.

@Test
public void addAndUpdateAndDelete() throws Exception {
    mockAuditListener.clearEvents();
    int initialSize = remoteRepositoryAdmin.getRemoteRepositories().size();
    RemoteRepository remoteRepository = getRemoteRepository();
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getFakeAuditInformation());
    assertEquals(initialSize + 1, remoteRepositoryAdmin.getRemoteRepositories().size());
    RemoteRepository repo = remoteRepositoryAdmin.getRemoteRepository("foo");
    assertNotNull(repo);
    assertEquals(getRemoteRepository().getPassword(), repo.getPassword());
    assertEquals(getRemoteRepository().getUrl(), repo.getUrl());
    assertEquals(getRemoteRepository().getUserName(), repo.getUserName());
    assertEquals(getRemoteRepository().getName(), repo.getName());
    assertEquals(getRemoteRepository().getTimeout(), repo.getTimeout());
    assertEquals(getRemoteRepository().getRemoteDownloadNetworkProxyId(), repo.getRemoteDownloadNetworkProxyId());
    repo.setUserName("foo-name-changed");
    repo.setPassword("titi");
    repo.setUrl("http://foo.com/maven-really-rocks");
    repo.setRemoteDownloadNetworkProxyId("toto");
    repo.setDescription("archiva rocks!");
    remoteRepositoryAdmin.updateRemoteRepository(repo, getFakeAuditInformation());
    repo = remoteRepositoryAdmin.getRemoteRepository("foo");
    assertEquals("foo-name-changed", repo.getUserName());
    assertEquals("titi", repo.getPassword());
    assertEquals("http://foo.com/maven-really-rocks", repo.getUrl());
    assertEquals("toto", repo.getRemoteDownloadNetworkProxyId());
    assertEquals("archiva rocks!", repo.getDescription());
    remoteRepositoryAdmin.deleteRemoteRepository("foo", getFakeAuditInformation());
    assertEquals(initialSize, remoteRepositoryAdmin.getRemoteRepositories().size());
    repo = remoteRepositoryAdmin.getRemoteRepository("foo");
    assertNull(repo);
    assertEquals(3, mockAuditListener.getAuditEvents().size());
    assertEquals(AuditEvent.ADD_REMOTE_REPO, mockAuditListener.getAuditEvents().get(0).getAction());
    assertEquals("root", mockAuditListener.getAuditEvents().get(0).getUserId());
    assertEquals("archiva-localhost", mockAuditListener.getAuditEvents().get(0).getRemoteIP());
    assertEquals(AuditEvent.MODIFY_REMOTE_REPO, mockAuditListener.getAuditEvents().get(1).getAction());
    assertEquals("root", mockAuditListener.getAuditEvents().get(1).getUserId());
    assertEquals("archiva-localhost", mockAuditListener.getAuditEvents().get(1).getRemoteIP());
    assertEquals(AuditEvent.DELETE_REMOTE_REPO, mockAuditListener.getAuditEvents().get(2).getAction());
    assertEquals("root", mockAuditListener.getAuditEvents().get(2).getUserId());
}
Also used : RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) AbstractRepositoryAdminTest(org.apache.archiva.admin.repository.AbstractRepositoryAdminTest) Test(org.junit.Test)

Example 23 with RemoteRepository

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

the class DownloadRemoteIndexTaskTest method downloadAndMergeRemoteIndexInEmptyIndex.

@Test
public void downloadAndMergeRemoteIndexInEmptyIndex() throws Exception {
    RemoteRepository remoteRepository = getRemoteRepository();
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, null);
    downloadRemoteIndexScheduler.startup();
    downloadRemoteIndexScheduler.scheduleDownloadRemote("test-repo-re", true, true);
    ((ThreadPoolTaskScheduler) downloadRemoteIndexScheduler.getTaskScheduler()).getScheduledExecutor().awaitTermination(10, TimeUnit.SECONDS);
    remoteRepositoryAdmin.deleteRemoteRepository("test-repo-re", null);
    // search
    BooleanQuery.Builder iQuery = new BooleanQuery.Builder();
    iQuery.add(indexer.constructQuery(MAVEN.GROUP_ID, new StringSearchExpression("commons-logging")), BooleanClause.Occur.SHOULD);
    remoteRepositoryAdmin.addRemoteRepository(remoteRepository, null);
    FlatSearchRequest rq = new FlatSearchRequest(iQuery.build());
    rq.setContexts(Arrays.asList(repositoryRegistry.getRemoteRepository(remoteRepository.getId()).getIndexingContext().getBaseContext(IndexingContext.class)));
    FlatSearchResponse response = indexer.searchFlat(rq);
    log.info("returned hit count:{}", response.getReturnedHitsCount());
    assertThat(response.getReturnedHitsCount()).isEqualTo(8);
}
Also used : BooleanQuery(org.apache.maven.index_shaded.lucene.search.BooleanQuery) FlatSearchResponse(org.apache.maven.index.FlatSearchResponse) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) FlatSearchRequest(org.apache.maven.index.FlatSearchRequest) StringSearchExpression(org.apache.maven.index.expr.StringSearchExpression) Test(org.junit.Test)

Aggregations

RemoteRepository (org.apache.archiva.admin.model.beans.RemoteRepository)23 Test (org.junit.Test)16 AbstractRepositoryAdminTest (org.apache.archiva.admin.repository.AbstractRepositoryAdminTest)7 Path (java.nio.file.Path)6 ProxyConnector (org.apache.archiva.admin.model.beans.ProxyConnector)6 RemoteRepositoriesService (org.apache.archiva.rest.api.services.RemoteRepositoriesService)5 ArrayList (java.util.ArrayList)3 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)3 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)3 NetworkProxy (org.apache.archiva.admin.model.beans.NetworkProxy)3 HashMap (java.util.HashMap)2 ProxyConnectorRule (org.apache.archiva.admin.model.beans.ProxyConnectorRule)2 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)2 Artifact (org.apache.archiva.maven2.model.Artifact)2 SearchRequest (org.apache.archiva.rest.api.model.SearchRequest)2 ManagedRepositoriesService (org.apache.archiva.rest.api.services.ManagedRepositoriesService)2 ProxyConnectorService (org.apache.archiva.rest.api.services.ProxyConnectorService)2 RepositoriesService (org.apache.archiva.rest.api.services.RepositoriesService)2 RepositoryGroupService (org.apache.archiva.rest.api.services.RepositoryGroupService)2 SearchService (org.apache.archiva.rest.api.services.SearchService)2