Search in sources :

Example 1 with ArtifactDescriptorReader

use of org.sonatype.aether.impl.ArtifactDescriptorReader in project sonatype-aether by sonatype.

the class DefaultDependencyCollectorTest method testArtifactDescriptorResolutionNotRestrictedToRepoHostingSelectedVersion.

@Test
public void testArtifactDescriptorResolutionNotRestrictedToRepoHostingSelectedVersion() throws Exception {
    RemoteRepository repo2 = new RemoteRepository("test", "default", "file:///");
    final List<RemoteRepository> repos = new ArrayList<RemoteRepository>();
    collector.setArtifactDescriptorReader(new ArtifactDescriptorReader() {

        public ArtifactDescriptorResult readArtifactDescriptor(RepositorySystemSession session, ArtifactDescriptorRequest request) throws ArtifactDescriptorException {
            repos.addAll(request.getRepositories());
            return new ArtifactDescriptorResult(request);
        }
    });
    DependencyNode root = parser.parseLiteral("verrange:parent:jar:[1,):compile");
    List<Dependency> dependencies = Arrays.asList(root.getDependency());
    CollectRequest request = new CollectRequest(dependencies, null, Arrays.asList(repository, repo2));
    CollectResult result = collector.collectDependencies(session, request);
    assertEquals(0, result.getExceptions().size());
    assertEquals(2, repos.size());
    assertEquals("id", repos.get(0).getId());
    assertEquals("test", repos.get(1).getId());
}
Also used : RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) CollectResult(org.sonatype.aether.collection.CollectResult) ArrayList(java.util.ArrayList) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) DependencyNode(org.sonatype.aether.graph.DependencyNode) ArtifactDescriptorException(org.sonatype.aether.resolution.ArtifactDescriptorException) ArtifactDescriptorResult(org.sonatype.aether.resolution.ArtifactDescriptorResult) ArtifactDescriptorRequest(org.sonatype.aether.resolution.ArtifactDescriptorRequest) ArtifactDescriptorReader(org.sonatype.aether.impl.ArtifactDescriptorReader) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)1 CollectRequest (org.sonatype.aether.collection.CollectRequest)1 CollectResult (org.sonatype.aether.collection.CollectResult)1 Dependency (org.sonatype.aether.graph.Dependency)1 DependencyNode (org.sonatype.aether.graph.DependencyNode)1 ArtifactDescriptorReader (org.sonatype.aether.impl.ArtifactDescriptorReader)1 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)1 ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)1 ArtifactDescriptorRequest (org.sonatype.aether.resolution.ArtifactDescriptorRequest)1 ArtifactDescriptorResult (org.sonatype.aether.resolution.ArtifactDescriptorResult)1 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)1