Search in sources :

Example 1 with Mirror

use of org.apache.maven.settings.Mirror in project indy by Commonjava.

the class SettingsGeneratedForRemoteRepoTest method generateSettingsXml.

@Test
public void generateSettingsXml() throws Exception {
    final IndyClientHttp http = getHttp();
    // all mavdav requests are siblings of the default base-url suffix '/api/'
    final String url = getDotMavenUrl("settings/remote/settings-central.xml");
    System.out.println("Requesting: " + url);
    final HttpResources resources = http.getRaw(new HttpGet(url));
    InputStream stream = null;
    Settings settings = null;
    try {
        stream = resources.getResponseStream();
        settings = new SettingsXpp3Reader().read(stream);
    } finally {
        closeQuietly(stream);
        closeQuietly(resources);
    }
    assertThat(settings.getLocalRepository(), equalTo("${user.home}/.m2/repo-remote-central"));
    assertThat(settings.getMirrors(), notNullValue());
    assertThat(settings.getMirrors().size(), equalTo(1));
    final Mirror mirror = settings.getMirrors().get(0);
    assertThat(mirror.getUrl(), equalTo(http.toIndyUrl("remote/central")));
}
Also used : InputStream(java.io.InputStream) IndyClientHttp(org.commonjava.indy.client.core.IndyClientHttp) HttpResources(org.commonjava.indy.client.core.helper.HttpResources) HttpGet(org.apache.http.client.methods.HttpGet) SettingsXpp3Reader(org.apache.maven.settings.io.xpp3.SettingsXpp3Reader) Mirror(org.apache.maven.settings.Mirror) Settings(org.apache.maven.settings.Settings) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 HttpGet (org.apache.http.client.methods.HttpGet)1 Mirror (org.apache.maven.settings.Mirror)1 Settings (org.apache.maven.settings.Settings)1 SettingsXpp3Reader (org.apache.maven.settings.io.xpp3.SettingsXpp3Reader)1 IndyClientHttp (org.commonjava.indy.client.core.IndyClientHttp)1 HttpResources (org.commonjava.indy.client.core.helper.HttpResources)1 Test (org.junit.Test)1