Search in sources :

Example 16 with Transfer

use of org.commonjava.maven.galley.model.Transfer in project galley by Commonjava.

the class HttpListTest method simpleCentralListing_Missing.

@Test
public void simpleCentralListing_Missing() throws Exception {
    final String dir = "central-missing/";
    final String fname = dir + "index.html";
    final String listingFname = dir + ".listing.txt";
    final String url = fixture.formatUrl(fname);
    final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
    final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
    final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
    final ListingResult result = listing.call();
    assertThat(result, nullValue());
    assertThat(listing.getError(), nullValue());
}
Also used : SimpleHttpLocation(org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) ListingResult(org.commonjava.maven.galley.model.ListingResult) Test(org.junit.Test)

Example 17 with Transfer

use of org.commonjava.maven.galley.model.Transfer in project galley by Commonjava.

the class HttpListTest method simpleNexusListing.

@Test
public void simpleNexusListing() throws Exception {
    final String dir = "nexus-switchyard/";
    final String fname = dir + "index.html";
    final String listingFname = dir + ".listing.txt";
    final String url = fixture.formatUrl(fname);
    final String body = getBody(fname);
    fixture.getServer().expect(url, 200, body);
    final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
    final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
    final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
    final ListingResult result = listing.call();
    assertThat(listing.getError(), nullValue());
    assertThat(result, notNullValue());
    assertThat(result.getListing(), notNullValue());
    assertTrue(Arrays.equals(nexusswitchyard, result.getListing()));
}
Also used : SimpleHttpLocation(org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) ListingResult(org.commonjava.maven.galley.model.ListingResult) Test(org.junit.Test)

Example 18 with Transfer

use of org.commonjava.maven.galley.model.Transfer in project galley by Commonjava.

the class HttpListTest method simpleCentralListing_WriteListingFile.

@Test
public void simpleCentralListing_WriteListingFile() throws Exception {
    final String dir = "central-btm/";
    final String fname = dir + "index.html";
    final String listingFname = dir + ".listing.txt";
    final String url = fixture.formatUrl(fname);
    final String body = getBody(fname);
    fixture.getServer().expect(url, 200, body);
    final SimpleHttpLocation location = new SimpleHttpLocation("test", url, true, true, true, true, null);
    final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, listingFname));
    final HttpListing listing = new HttpListing(url, new ConcreteResource(location, fname), fixture.getHttp());
    final ListingResult result = listing.call();
    assertThat(listing.getError(), nullValue());
    assertThat(result, notNullValue());
    assertThat(result.getListing(), notNullValue());
    assertTrue(Arrays.equals(centralbtm, result.getListing()));
    final List<String> lines = IOUtils.readLines(transfer.openInputStream());
    assertTrue("Listing file written incorrectly!", lines.equals(Arrays.asList(centralbtm)));
}
Also used : SimpleHttpLocation(org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) ListingResult(org.commonjava.maven.galley.model.ListingResult) Test(org.junit.Test)

Example 19 with Transfer

use of org.commonjava.maven.galley.model.Transfer in project galley by Commonjava.

the class MavenModelProcessorTest method resolveExpressionsBothInDepAndProfile.

@Test
public void resolveExpressionsBothInDepAndProfile() throws Exception {
    final URI src = new URI("http://nowhere.com/path/to/repo");
    final ProjectVersionRef childRef = new SimpleProjectVersionRef("org.test", "test-pom", "1.0");
    final LinkedHashMap<ProjectVersionRef, String> lineage = new LinkedHashMap<ProjectVersionRef, String>();
    lineage.put(childRef, "test-pom-1.0.pom.xml");
    final Location location = new SimpleLocation("test", src.toString(), false, true, true, false, true, false);
    final String base = PROJ_BASE + "resolve-expression-in-a-profile/";
    for (final Entry<ProjectVersionRef, String> entry : lineage.entrySet()) {
        final ProjectVersionRef ref = entry.getKey();
        final String filename = entry.getValue();
        final String path = ArtifactPathUtils.formatArtifactPath(ref.asPomArtifact(), fixture.getTypeMapper());
        fixture.getTransport().registerDownload(new ConcreteResource(location, path), new TestDownload(base + filename));
    }
    final Transfer transfer = fixture.getArtifactManager().retrieve(location, childRef.asPomArtifact());
    final MavenPomView pomView = fixture.getPomReader().read(childRef, transfer, Collections.singletonList(location));
    String url = pomView.resolveExpressions("${repo.url}", "test.oracle");
    assertThat(url, equalTo("http://test.oracle.repository"));
    List<DependencyView> dvs = pomView.getAllDirectDependencies();
    assertThat(dvs.get(0).getVersion(), equalTo("2.5"));
    String version = pomView.resolveExpressions("${commons.lang.value}");
    assertThat(version, equalTo("2.5"));
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) URI(java.net.URI) PluginDependencyView(org.commonjava.maven.galley.maven.model.view.PluginDependencyView) DependencyView(org.commonjava.maven.galley.maven.model.view.DependencyView) LinkedHashMap(java.util.LinkedHashMap) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) MavenPomView(org.commonjava.maven.galley.maven.model.view.MavenPomView) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Example 20 with Transfer

use of org.commonjava.maven.galley.model.Transfer in project galley by Commonjava.

the class MavenModelProcessorTest method resolvePluginVersionFromManagementExpression.

@Test
public void resolvePluginVersionFromManagementExpression() throws Exception {
    final URI src = new URI("http://nowhere.com/path/to/repo");
    final ProjectVersionRef childRef = new SimpleProjectVersionRef("org.test", "test-child", "1.0");
    final LinkedHashMap<ProjectVersionRef, String> lineage = new LinkedHashMap<ProjectVersionRef, String>();
    lineage.put(childRef, "child.pom.xml");
    lineage.put(new SimpleProjectVersionRef("org.test", "test-parent", "1.0"), "parent.pom.xml");
    final Location location = new SimpleLocation("test", src.toString(), false, true, true, false, true, false);
    final String base = PROJ_BASE + "version-expression-managed-parent-plugin/";
    for (final Entry<ProjectVersionRef, String> entry : lineage.entrySet()) {
        final ProjectVersionRef ref = entry.getKey();
        final String filename = entry.getValue();
        final String path = ArtifactPathUtils.formatArtifactPath(ref.asPomArtifact(), fixture.getTypeMapper());
        fixture.getTransport().registerDownload(new ConcreteResource(location, path), new TestDownload(base + filename));
    }
    final Transfer transfer = fixture.getArtifactManager().retrieve(location, childRef.asPomArtifact());
    final MavenPomView pomView = fixture.getPomReader().read(childRef, transfer, Collections.singletonList(location));
    final List<PluginView> buildPlugins = pomView.getAllBuildPlugins();
    assertThat(buildPlugins, notNullValue());
    assertThat(buildPlugins.size(), equalTo(1));
    final PluginView pv = buildPlugins.get(0);
    assertThat(pv, notNullValue());
    assertThat(pv.getVersion(), equalTo("1.0"));
    final ModelProcessorConfig discoveryConfig = new ModelProcessorConfig();
    discoveryConfig.setIncludeManagedDependencies(true);
    discoveryConfig.setIncludeBuildSection(true);
    discoveryConfig.setIncludeManagedPlugins(false);
    EProjectDirectRelationships result = fixture.getModelProcessor().readRelationships(pomView, src, discoveryConfig);
    final Set<ProjectRelationship<?, ?>> rels = result.getExactAllRelationships();
    logger.info("Found {} relationships:\n\n  {}", rels.size(), new JoinString("\n  ", rels));
    boolean seen = false;
    for (final ProjectRelationship<?, ?> rel : rels) {
        if (rel.getType() == RelationshipType.PLUGIN && !rel.isManaged()) {
            if (seen) {
                fail("Multiple plugins found!");
            }
            seen = true;
            assertThat(rel.getTarget().getVersionString(), equalTo("1.0"));
        }
    }
    if (!seen) {
        fail("Plugin relationship not found!");
    }
}
Also used : TestDownload(org.commonjava.maven.galley.testing.core.transport.job.TestDownload) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) URI(java.net.URI) LinkedHashMap(java.util.LinkedHashMap) JoinString(org.commonjava.maven.atlas.ident.util.JoinString) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ProjectRelationship(org.commonjava.maven.atlas.graph.rel.ProjectRelationship) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) EProjectDirectRelationships(org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships) PluginView(org.commonjava.maven.galley.maven.model.view.PluginView) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) MavenPomView(org.commonjava.maven.galley.maven.model.view.MavenPomView) SimpleLocation(org.commonjava.maven.galley.model.SimpleLocation) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Aggregations

Transfer (org.commonjava.maven.galley.model.Transfer)218 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)89 Test (org.junit.Test)80 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)64 IOException (java.io.IOException)63 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)59 InputStream (java.io.InputStream)43 StoreKey (org.commonjava.indy.model.core.StoreKey)43 Logger (org.slf4j.Logger)34 ArrayList (java.util.ArrayList)33 OutputStream (java.io.OutputStream)31 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)31 HostedRepository (org.commonjava.indy.model.core.HostedRepository)29 IndyDataException (org.commonjava.indy.data.IndyDataException)28 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)28 Group (org.commonjava.indy.model.core.Group)26 Measure (org.commonjava.o11yphant.metrics.annotation.Measure)23 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)21 TransferException (org.commonjava.maven.galley.TransferException)20 Location (org.commonjava.maven.galley.model.Location)19