use of org.eclipse.aether.repository.RemoteRepository in project kie-soup by kiegroup.
the class AetherTest method shouldUseWagonClass.
@Test
public void shouldUseWagonClass() throws ArtifactResolutionException {
final RepositoryPolicy repositoryPolicy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_NEVER, RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
final RemoteRepository s3repository = new RemoteRepository.Builder("central", "default", "s3://amazon-s3-repository-bucket/").setPolicy(repositoryPolicy).build();
final List<RemoteRepository> remoteRepositories = Collections.singletonList(s3repository);
final MavenProject mavenProject = mock(MavenProject.class);
when(mavenProject.getRemoteProjectRepositories()).thenReturn(remoteRepositories);
final ArtifactRequest request = new ArtifactRequest(new DefaultArtifact("org.test:fake:0.0.1"), remoteRepositories, null);
try {
System.setProperty(Aether.S3_WAGON_CLASS, "org.appformer.maven.integration.S3WagonMock");
final File tmpDirectory = IoUtils.getTmpDirectory();
MavenSettings.getSettings().setLocalRepository(tmpDirectory.getAbsolutePath());
final Aether aether = new Aether(mavenProject);
final RepositorySystemSession session = aether.getSession();
final ArtifactResult artifactResult = aether.getSystem().resolveArtifact(session, request);
assertTrue(artifactResult.isResolved());
assertTrue(S3WagonMock.wasUsed());
} finally {
System.clearProperty(Aether.S3_WAGON_CLASS);
MavenSettings.reinitSettings();
}
}
use of org.eclipse.aether.repository.RemoteRepository in project kie-soup by kiegroup.
the class AetherTest method testNotOffline.
@Test
public void testNotOffline() {
final RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
final MavenProject mavenProject = mock(MavenProject.class);
when(mavenProject.getRemoteProjectRepositories()).thenReturn(Collections.singletonList(central));
final Aether aether = new Aether(mavenProject) {
@Override
boolean isForcedOffline() {
return false;
}
};
assertThat(aether.getRepositories()).contains(central);
}
use of org.eclipse.aether.repository.RemoteRepository in project kie-soup by kiegroup.
the class AetherTest method testForcedOffline.
@Test
public void testForcedOffline() {
final RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
final MavenProject mavenProject = mock(MavenProject.class);
when(mavenProject.getRemoteProjectRepositories()).thenReturn(Collections.singletonList(central));
final Aether aether = new Aether(mavenProject) {
@Override
boolean isForcedOffline() {
return true;
}
};
assertThat(aether.getRepositories()).doesNotContain(central);
}
use of org.eclipse.aether.repository.RemoteRepository in project kie-soup by kiegroup.
the class AetherTest method testProxies.
@Test
public void testProxies() {
String oldSettingsXmlPath = System.getProperty(CUSTOM_SETTINGS_PROPERTY);
try {
if (oldSettingsXmlPath != null) {
System.clearProperty(CUSTOM_SETTINGS_PROPERTY);
}
MavenSettings.reinitSettingsFromString(SETTINGS_WITH_PROXY);
Aether aether = Aether.getAether();
RemoteRepository remoteRepository = new RemoteRepository.Builder("local", "default", "http://myserver.com").build();
Proxy proxy = aether.getSession().getProxySelector().getProxy(remoteRepository);
assertEquals("http", proxy.getType());
assertEquals("localhost", proxy.getHost());
assertEquals(8888, proxy.getPort());
} finally {
if (oldSettingsXmlPath != null) {
System.setProperty(CUSTOM_SETTINGS_PROPERTY, oldSettingsXmlPath);
}
MavenSettings.reinitSettings();
}
}
use of org.eclipse.aether.repository.RemoteRepository in project kie-soup by kiegroup.
the class MavenRepositoryTest method testMirrors.
@Test
public void testMirrors() {
MavenRepositoryMock.setCustomSettingsFileName("settings_with_mirror.xml");
final MavenRepository repo = new MavenRepositoryMock(Aether.getAether());
final Collection<RemoteRepository> remoteRepos = repo.getRemoteRepositoriesForRequest();
assertEquals(2, remoteRepos.size());
for (final RemoteRepository remoteRepo : remoteRepos) {
assertTrue(remoteRepo.getId().equals("qa") || remoteRepo.getId().equals("foo"));
}
}
Aggregations