use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.
the class AbstractDownloadTest method getRemoteRepositoriesService.
protected RemoteRepositoriesService getRemoteRepositoriesService() {
RemoteRepositoriesService service = JAXRSClientFactory.create(getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", RemoteRepositoriesService.class, Collections.singletonList(new JacksonJaxbJsonProvider()));
WebClient.client(service).header("Authorization", authorizationHeader);
WebClient.client(service).header("Referer", "http://localhost:" + port);
WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(300000L);
return service;
}
use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.
the class RemoteRepositoryConnectivityCheckTest method checkRemoteConnectivityFail.
@Test
public void checkRemoteConnectivityFail() throws Exception {
RemoteRepositoriesService service = getRemoteRepositoriesService();
WebClient.client(service).header("Authorization", authorizationHeader);
try {
RemoteRepository repo = getRemoteRepository();
repo.setUrl("http://localhost:8956");
service.addRemoteRepository(repo);
assertThat(service.checkRemoteConnectivity(repo.getId())).isFalse();
} finally {
service.deleteRemoteRepository("id-new");
}
}
use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.
the class RemoteRepositoryConnectivityCheckTest method checkRemoteConnectivityEmptyRemote.
@Test
public void checkRemoteConnectivityEmptyRemote() throws Exception {
Path tmpDir = Files.createTempDirectory("test");
Server repoServer = buildStaticServer(tmpDir);
ServerConnector serverConnector = new ServerConnector(repoServer, new HttpConnectionFactory());
repoServer.addConnector(serverConnector);
repoServer.start();
RemoteRepositoriesService service = getRemoteRepositoriesService();
WebClient.client(service).header("Authorization", authorizationHeader);
try {
int repoServerPort = serverConnector.getLocalPort();
RemoteRepository repo = getRemoteRepository();
repo.setUrl("http://localhost:" + repoServerPort);
service.addRemoteRepository(repo);
assertThat(service.checkRemoteConnectivity(repo.getId())).isTrue();
} finally {
service.deleteRemoteRepository("id-new");
org.apache.archiva.common.utils.FileUtils.deleteQuietly(tmpDir);
repoServer.stop();
}
}
use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.
the class RemoteRepositoriesServiceTest method addAndUpdateAndDeleteRemoteRepository.
@Test
public void addAndUpdateAndDeleteRemoteRepository() throws Exception {
RemoteRepositoriesService service = getRemoteRepositoriesService();
WebClient.client(service).header("Authorization", authorizationHeader);
int initialSize = service.getRemoteRepositories().size();
service.addRemoteRepository(getRemoteRepository());
assertNotNull(service.getRemoteRepository("id-new"));
assertEquals(getRemoteRepository().getName(), service.getRemoteRepository("id-new").getName());
assertEquals(getRemoteRepository().getUrl(), service.getRemoteRepository("id-new").getUrl());
assertEquals(getRemoteRepository().getLayout(), service.getRemoteRepository("id-new").getLayout());
assertEquals(getRemoteRepository().getUserName(), service.getRemoteRepository("id-new").getUserName());
assertEquals(getRemoteRepository().getPassword(), service.getRemoteRepository("id-new").getPassword());
assertEquals(getRemoteRepository().getTimeout(), service.getRemoteRepository("id-new").getTimeout());
assertEquals(initialSize + 1, service.getRemoteRepositories().size());
RemoteRepository repo = getRemoteRepository();
repo.setName("name changed");
repo.setPassword("new password");
repo.setUserName("new username");
repo.setUrl("http://foo.new.org");
repo.setDescription("foo bar");
service.updateRemoteRepository(repo);
assertEquals(repo.getName(), service.getRemoteRepository("id-new").getName());
assertEquals(repo.getUrl(), service.getRemoteRepository("id-new").getUrl());
assertEquals(repo.getLayout(), service.getRemoteRepository("id-new").getLayout());
assertEquals(repo.getUserName(), service.getRemoteRepository("id-new").getUserName());
assertEquals(repo.getPassword(), service.getRemoteRepository("id-new").getPassword());
assertEquals(repo.getTimeout(), service.getRemoteRepository("id-new").getTimeout());
assertEquals(repo.getDescription(), service.getRemoteRepository("id-new").getDescription());
service.deleteRemoteRepository("id-new");
assertNull(service.getRemoteRepository("id-new"));
assertEquals(initialSize, service.getRemoteRepositories().size());
}
use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.
the class RemoteRepositoriesServiceTest method checkRemoteConnectivity.
@Test
public void checkRemoteConnectivity() throws Exception {
RemoteRepositoriesService service = getRemoteRepositoriesService();
WebClient.client(service).header("Authorization", authorizationHeader);
int initialSize = service.getRemoteRepositories().size();
service.addRemoteRepository(getRemoteRepository());
assertTrue(service.checkRemoteConnectivity("id-new"));
}
Aggregations