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());
}
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());
}
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);
}
Aggregations