Search in sources :

Example 1 with MirrorSelector

use of org.eclipse.aether.repository.MirrorSelector in project wildfly-swarm by wildfly-swarm.

the class MavenArtifactResolvingHelperTest method propagateRepositoryPolicies.

@Test
public // SWARM-1173: swarm-plugin trying to download SNAPSHOTs from Maven Central
void propagateRepositoryPolicies() {
    RepositorySystemSession sessionMock = Mockito.mock(RepositorySystemSession.class);
    MirrorSelector mirrorSelectorMock = Mockito.mock(MirrorSelector.class);
    Mockito.when(sessionMock.getMirrorSelector()).thenReturn(mirrorSelectorMock);
    ProxySelector proxySelectorMock = Mockito.mock(ProxySelector.class);
    Mockito.when(sessionMock.getProxySelector()).thenReturn(proxySelectorMock);
    MavenArtifactResolvingHelper artifactResolverHelper = new MavenArtifactResolvingHelper(null, null, sessionMock, null);
    ArtifactRepositoryPolicy testSnapshotPolicy = new ArtifactRepositoryPolicy(false, "hourly", "warn");
    ArtifactRepositoryPolicy testReleasesPolicy = new ArtifactRepositoryPolicy(true, "never", "warn");
    ArtifactRepository testingRepo = new MavenArtifactRepository("testing-repo", "http://testing-repo.org", new DefaultRepositoryLayout(), testSnapshotPolicy, testReleasesPolicy);
    artifactResolverHelper.remoteRepository(testingRepo);
    List<RemoteRepository> remoteRepos = artifactResolverHelper.getRemoteRepositories();
    Assert.assertTrue("Remote repositories " + remoteRepos + " do not contain expected testing repo " + testingRepo, remoteRepos.stream().anyMatch(remoteRepo -> {
        RepositoryPolicy snapshotsPolicy = remoteRepo.getPolicy(true);
        RepositoryPolicy releasesPolicy = remoteRepo.getPolicy(false);
        return remoteRepo.getId().equals(testingRepo.getId()) && !snapshotsPolicy.isEnabled() && snapshotsPolicy.getUpdatePolicy().equals(testSnapshotPolicy.getUpdatePolicy()) && snapshotsPolicy.getChecksumPolicy().equals(testSnapshotPolicy.getChecksumPolicy()) && releasesPolicy.isEnabled() && releasesPolicy.getUpdatePolicy().equals(testReleasesPolicy.getUpdatePolicy()) && releasesPolicy.getChecksumPolicy().equals(testReleasesPolicy.getChecksumPolicy());
    }));
}
Also used : ProxySelector(org.eclipse.aether.repository.ProxySelector) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) ProxySelector(org.eclipse.aether.repository.ProxySelector) Test(org.junit.Test) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Mockito(org.mockito.Mockito) List(java.util.List) MirrorSelector(org.eclipse.aether.repository.MirrorSelector) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Assert(org.junit.Assert) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MirrorSelector(org.eclipse.aether.repository.MirrorSelector) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Test(org.junit.Test)

Aggregations

List (java.util.List)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 ArtifactRepositoryPolicy (org.apache.maven.artifact.repository.ArtifactRepositoryPolicy)1 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)1 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)1 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)1 MirrorSelector (org.eclipse.aether.repository.MirrorSelector)1 ProxySelector (org.eclipse.aether.repository.ProxySelector)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 RepositoryPolicy (org.eclipse.aether.repository.RepositoryPolicy)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 Mockito (org.mockito.Mockito)1