Search in sources :

Example 1 with RemoteRepositoriesService

use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.

the class RemoteRepositoriesServiceTest method listRemoteRepositoriesKarma.

@Test
public void listRemoteRepositoriesKarma() throws Exception {
    RemoteRepositoriesService service = getRemoteRepositoriesService();
    WebClient.client(service).header("Authorization", authorizationHeader);
    WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(300000);
    List<RemoteRepository> repos = service.getRemoteRepositories();
    assertFalse(repos.isEmpty());
    log.info("repos {}", repos);
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) RemoteRepository(org.apache.archiva.admin.model.beans.RemoteRepository) Test(org.junit.Test)

Example 2 with RemoteRepositoriesService

use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.

the class RemoteRepositoriesServiceTest method checkRemoteConnectivity2.

/*
     * Check maven repository
     */
@Test
public void checkRemoteConnectivity2() throws Exception {
    RemoteRepositoriesService service = getRemoteRepositoriesService();
    WebClient.client(service).header("Authorization", authorizationHeader);
    int initialSize = service.getRemoteRepositories().size();
    service.addRemoteRepository(getRemoteMavenRepository());
    assertTrue(service.checkRemoteConnectivity("id-maven1"));
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) Test(org.junit.Test)

Example 3 with RemoteRepositoriesService

use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.

the class RemoteRepositoriesServiceTest method checkRemoteConnectivity3.

/*
     *  Check oracle repository that allows not browsing (MRM-1933)
     */
@Test
public void checkRemoteConnectivity3() throws Exception {
    RemoteRepositoriesService service = getRemoteRepositoriesService();
    WebClient.client(service).header("Authorization", authorizationHeader);
    WebClient.client(service).accept("application/json");
    int initialSize = service.getRemoteRepositories().size();
    service.addRemoteRepository(getRemoteOracleRepository());
    assertTrue(service.checkRemoteConnectivity("id-oracle"));
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) Test(org.junit.Test)

Example 4 with RemoteRepositoriesService

use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.

the class RemoteRepositoriesServiceTest method addAndDeleteRemoteRepository.

@Test
public void addAndDeleteRemoteRepository() 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(getRemoteRepository().getDescription(), service.getRemoteRepository("id-new").getDescription());
    assertEquals(initialSize + 1, service.getRemoteRepositories().size());
    service.deleteRemoteRepository("id-new");
    assertNull(service.getRemoteRepository("id-new"));
    assertEquals(initialSize, service.getRemoteRepositories().size());
}
Also used : RemoteRepositoriesService(org.apache.archiva.rest.api.services.RemoteRepositoriesService) Test(org.junit.Test)

Example 5 with RemoteRepositoriesService

use of org.apache.archiva.rest.api.services.RemoteRepositoriesService in project archiva by apache.

the class RemoteRepositoryConnectivityCheckTest method checkRemoteConnectivity.

@Test
public void checkRemoteConnectivity() throws Exception {
    Server repoServer = buildStaticServer(Paths.get(System.getProperty("basedir"), "src/test/repositories/test-repo"));
    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");
        repoServer.stop();
    }
}
Also used : 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)

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