@Test public void testLookup() throws ArtifactDescriptorException { StubArtifact art = new StubArtifact("gid:aid:ext:ver"); ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(art, null, ""); ArtifactDescriptorResult description = reader.readArtifactDescriptor(session, request); assertEquals(request, description.getRequest()); assertEquals(art, description.getArtifact()); assertEquals(1, description.getRelocations().size()); Artifact artifact = description.getRelocations().get(0); assertEquals("gid", artifact.getGroupId()); assertEquals("aid", artifact.getArtifactId()); assertEquals("ver", artifact.getVersion()); assertEquals("ext", artifact.getExtension()); assertEquals(1, description.getRepositories().size()); RemoteRepository repo = description.getRepositories().get(0); assertEquals("id", repo.getId()); assertEquals("type", repo.getContentType()); assertEquals("protocol://some/url?for=testing", repo.getUrl()); assertDependencies(description.getDependencies()); assertDependencies(description.getManagedDependencies()); }
@Test public void testCreateSimpleRepo() { String plainUrl = "http://some.repo.url/somepath"; RemoteRepository repository = createRemoteRepository(plainUrl); assertNotNull(repository); assertNotNull(repository.getId()); assertNull(repository.getAuthentication()); }
@Test public void testCreateRepWithCredentials() { String plainUrl = "http://*****:*****@some.repo.url/somepath"; RemoteRepository repository = createRemoteRepository(plainUrl); assertNotNull(repository); assertNotNull(repository.getId()); assertNotNull(repository.getAuthentication()); assertEquals("user", repository.getAuthentication().getUsername()); assertEquals("password", repository.getAuthentication().getPassword()); assertEquals("http://some.repo.url/somepath", repository.getUrl()); }
/** * Create an {@link org.sonatype.aether.connector.async.AsyncRepositoryConnector} instance which * connect to the {@link RemoteRepository} * * @param repository the remote repository * @param session the {@link RepositorySystemSession} * @param logger the logger. * @throws NoRepositoryConnectorException */ public AsyncRepositoryConnector( RemoteRepository repository, RepositorySystemSession session, FileProcessor fileProcessor, Logger logger) throws NoRepositoryConnectorException { this.logger = logger; this.repository = repository; this.listener = session.getTransferListener(); this.fileProcessor = fileProcessor; this.session = session; if (!"default".equals(repository.getContentType())) { throw new NoRepositoryConnectorException(repository); } if (!repository.getProtocol().regionMatches(true, 0, "http", 0, "http".length()) && !repository.getProtocol().regionMatches(true, 0, "dav", 0, "dav".length())) { throw new NoRepositoryConnectorException(repository); } AsyncHttpClientConfig config = createConfig(session, repository, true); httpClient = new AsyncHttpClient(new NettyAsyncHttpProvider(config)); checksumAlgos = new LinkedHashMap<String, String>(); checksumAlgos.put("SHA-1", ".sha1"); checksumAlgos.put("MD5", ".md5"); disableResumeSupport = ConfigUtils.getBoolean(session, false, "aether.connector.ahc.disableResumable"); maxIOExceptionRetry = ConfigUtils.getInteger(session, 3, "aether.connector.ahc.resumeRetry"); this.headers = new FluentCaseInsensitiveStringsMap(); Map<?, ?> headers = ConfigUtils.getMap( session, null, ConfigurationProperties.HTTP_HEADERS + "." + repository.getId(), ConfigurationProperties.HTTP_HEADERS); if (headers != null) { for (Map.Entry<?, ?> entry : headers.entrySet()) { if (entry.getKey() instanceof String && entry.getValue() instanceof String) { this.headers.add(entry.getKey().toString(), entry.getValue().toString()); } } } }