Search in sources :

Example 6 with RemoteRepositoriesService

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;
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) JacksonJaxbJsonProvider(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)

Example 7 with RemoteRepositoriesService

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");
    }
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) Test(org.junit.Test)

Example 8 with RemoteRepositoriesService

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();
    }
}
Also used : Path(java.nio.file.Path) ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) Test(org.junit.Test)

Example 9 with RemoteRepositoriesService

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());
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) Test(org.junit.Test)

Example 10 with RemoteRepositoriesService

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"));
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) Test(org.junit.Test)

Aggregations

RemoteRepositoriesService (org.apache.archiva.rest.api.services.RemoteRepositoriesService)10 Test (org.junit.Test)9 RemoteRepository (org.apache.archiva.admin.model.beans.RemoteRepository)5 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)2 Server (org.eclipse.jetty.server.Server)2 ServerConnector (org.eclipse.jetty.server.ServerConnector)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 Path (java.nio.file.Path)1