Search in sources :

Example 11 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManagerTest method testMirrorAuthentication.

@Test
public void testMirrorAuthentication() {
    final RemoteRepository repo = newRepo("a", "http://", false, "", "");
    final RemoteRepository mirror = newRepo("a", "http://", false, "", "");
    mirror.setAuthentication(new Authentication("username", "password"));
    session.setMirrorSelector(new MirrorSelector() {

        public RemoteRepository getMirror(RemoteRepository repository) {
            return mirror;
        }
    });
    List<RemoteRepository> result = manager.aggregateRepositories(session, Collections.<RemoteRepository>emptyList(), Arrays.asList(repo), true);
    assertEquals(1, result.size());
    assertEquals("username", result.get(0).getAuthentication().getUsername());
    assertEquals("password", result.get(0).getAuthentication().getPassword());
}
Also used : Authentication(org.sonatype.aether.repository.Authentication) MirrorSelector(org.sonatype.aether.repository.MirrorSelector) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Test(org.junit.Test)

Example 12 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManagerTest method testProxySelector.

@Test
public void testProxySelector() {
    final RemoteRepository repo = newRepo("a", "http://", false, "", "");
    final Proxy proxy = new Proxy("http", "host", 2011, null);
    session.setProxySelector(new ProxySelector() {

        public Proxy getProxy(RemoteRepository repository) {
            return proxy;
        }
    });
    session.setMirrorSelector(new MirrorSelector() {

        public RemoteRepository getMirror(RemoteRepository repository) {
            return null;
        }
    });
    List<RemoteRepository> result = manager.aggregateRepositories(session, Collections.<RemoteRepository>emptyList(), Arrays.asList(repo), true);
    assertEquals(1, result.size());
    assertEquals("http", result.get(0).getProxy().getType());
    assertEquals("host", result.get(0).getProxy().getHost());
    assertEquals(2011, result.get(0).getProxy().getPort());
}
Also used : ProxySelector(org.sonatype.aether.repository.ProxySelector) Proxy(org.sonatype.aether.repository.Proxy) MirrorSelector(org.sonatype.aether.repository.MirrorSelector) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Test(org.junit.Test)

Example 13 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManagerTest method testAggregateMirrorRepos_DominantMirrorIncomplete.

@Test
public void testAggregateMirrorRepos_DominantMirrorIncomplete() {
    RemoteRepository dominant1 = newRepo("a", "http://", false, "", "");
    RemoteRepository dominantMirror1 = newRepo("x", "file://", false, "", "");
    dominantMirror1.setMirroredRepositories(Arrays.asList(dominant1));
    RemoteRepository recessive1 = newRepo("a", "https://", true, "", "");
    RemoteRepository recessive2 = newRepo("b", "https://", true, "", "");
    RemoteRepository recessiveMirror1 = newRepo("x", "http://", true, "", "");
    recessiveMirror1.setMirroredRepositories(Arrays.asList(recessive1, recessive2));
    List<RemoteRepository> result = manager.aggregateRepositories(session, Arrays.asList(dominantMirror1), Arrays.asList(recessiveMirror1), false);
    assertEquals(1, result.size());
    assertEqual(newRepo("x", "file://", true, "", ""), result.get(0));
    assertEquals(2, result.get(0).getMirroredRepositories().size());
    assertEquals(dominant1, result.get(0).getMirroredRepositories().get(0));
    assertEquals(recessive2, result.get(0).getMirroredRepositories().get(1));
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Test(org.junit.Test)

Example 14 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManagerTest method testMirrorProxy.

@Test
public void testMirrorProxy() {
    final RemoteRepository repo = newRepo("a", "http://", false, "", "");
    final RemoteRepository mirror = newRepo("a", "http://", false, "", "");
    mirror.setProxy(new Proxy("http", "host", 2011, null));
    session.setMirrorSelector(new MirrorSelector() {

        public RemoteRepository getMirror(RemoteRepository repository) {
            return mirror;
        }
    });
    List<RemoteRepository> result = manager.aggregateRepositories(session, Collections.<RemoteRepository>emptyList(), Arrays.asList(repo), true);
    assertEquals(1, result.size());
    assertEquals("http", result.get(0).getProxy().getType());
    assertEquals("host", result.get(0).getProxy().getHost());
    assertEquals(2011, result.get(0).getProxy().getPort());
}
Also used : Proxy(org.sonatype.aether.repository.Proxy) MirrorSelector(org.sonatype.aether.repository.MirrorSelector) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Test(org.junit.Test)

Example 15 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManagerTest method testAggregateMirrorRepos_DominantMirrorComplete.

@Test
public void testAggregateMirrorRepos_DominantMirrorComplete() {
    RemoteRepository dominant1 = newRepo("a", "http://", false, "", "");
    RemoteRepository dominantMirror1 = newRepo("x", "file://", false, "", "");
    dominantMirror1.setMirroredRepositories(Arrays.asList(dominant1));
    RemoteRepository recessive1 = newRepo("a", "https://", true, "", "");
    RemoteRepository recessiveMirror1 = newRepo("x", "http://", true, "", "");
    recessiveMirror1.setMirroredRepositories(Arrays.asList(recessive1));
    List<RemoteRepository> result = manager.aggregateRepositories(session, Arrays.asList(dominantMirror1), Arrays.asList(recessiveMirror1), false);
    assertEquals(1, result.size());
    assertEqual(dominantMirror1, result.get(0));
    assertEquals(1, result.get(0).getMirroredRepositories().size());
    assertEquals(dominant1, result.get(0).getMirroredRepositories().get(0));
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Test(org.junit.Test)

Aggregations

RemoteRepository (org.sonatype.aether.repository.RemoteRepository)71 Artifact (org.sonatype.aether.artifact.Artifact)30 Test (org.junit.Test)27 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)18 File (java.io.File)15 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)15 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)13 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)13 Dependency (org.sonatype.aether.graph.Dependency)12 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)12 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)12 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)11 CollectRequest (org.sonatype.aether.collection.CollectRequest)10 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)10 ArrayList (java.util.ArrayList)8 RepositorySystem (org.sonatype.aether.RepositorySystem)8 IOException (java.io.IOException)7 Before (org.junit.Before)7 Metadata (org.sonatype.aether.metadata.Metadata)7 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)7