use of org.commonjava.maven.galley.testing.core.transport.job.TestDownload in project galley by Commonjava.
the class MavenModelProcessorTest method resolvePluginDependencyFromManagedInfo.
@Test
public void resolvePluginDependencyFromManagedInfo() 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);
final String base = PROJ_BASE + "dependency-in-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());
final List<PluginDependencyView> deps = pv.getLocalPluginDependencies();
assertThat(deps, notNullValue());
assertThat(deps.size(), equalTo(1));
final PluginDependencyView pdv = deps.get(0);
assertThat(pdv, notNullValue());
assertThat(pdv.asArtifactRef().getVersionString(), 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_DEP && !rel.isManaged()) {
if (seen) {
fail("Multiple plugin dependencies found!");
}
seen = true;
assertThat(rel.getTarget().getVersionString(), equalTo("1.0"));
}
}
if (!seen) {
fail("Plugin-dependency relationship not found!");
}
}
use of org.commonjava.maven.galley.testing.core.transport.job.TestDownload in project galley by Commonjava.
the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
final String base = "single-snapshot/";
final String testResource = base + "single-snapshot.xml";
final String testPomResource = base + "single-snapshot-pom.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT");
final ConcreteResource metadataResource = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
final ConcreteResource pomResource = new ConcreteResource(LOCATION, fixture.pomPath(ref.selectVersion("1.0-20140604.101244-1").asPomArtifact()));
fixture.getTransport().registerDownload(metadataResource, new TestDownload(ROOT + testResource));
fixture.getTransport().registerDownload(pomResource, new TestDownload(ROOT + testPomResource));
final Transfer retrieved = fixture.getArtifactManager().retrieve(LOCATION, ref.asPomArtifact(), new EventMetadata());
final Document document = fixture.getXml().parse(retrieved, new EventMetadata());
final ProjectVersionRef result = fixture.getXml().getProjectVersionRef(document);
System.out.println(result);
// assertThat( result, notNullValue() );
// assertThat( result.getVersionString(), equalTo( "1.0-20140604.101244-1" ) );
}
use of org.commonjava.maven.galley.testing.core.transport.job.TestDownload in project galley by Commonjava.
the class VersionResolverImplTest method resolveSnapshot_FirstMatch_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy() throws Exception {
final String testResource = "2-snapshots-2-locations/maven-metadata-1.xml";
final String testResource2 = "2-snapshots-2-locations/maven-metadata-2.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
final String path = fixture.snapshotMetadataPath(ref);
fixture.getTransport().registerDownload(new ConcreteResource(LOCATION, path), new TestDownload(ROOT + testResource));
fixture.getTransport().registerDownload(new ConcreteResource(LOCATION2, path), new TestDownload(ROOT + testResource2));
final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(TWO_LOCATIONS, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
assertThat(result, notNullValue());
// newest snapshot is in the SECOND location, but we're using first-match semantics here.
assertThat(result.getVersionString(), equalTo("1.0-20140604.101244-1"));
}
use of org.commonjava.maven.galley.testing.core.transport.job.TestDownload in project galley by Commonjava.
the class VersionResolverImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy() throws Exception {
final String testResource = "2-snapshots-1-location/two-snapshots.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
final ConcreteResource cr = new ConcreteResource(LOCATION, fixture.snapshotMetadataPath(ref));
final TestDownload download = new TestDownload(ROOT + testResource);
fixture.getTransport().registerDownload(cr, download);
final ProjectVersionRef result = fixture.getVersionResolver().resolveFirstMatchVariableVersion(ONE_LOCATION, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
assertThat(result, notNullValue());
assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
use of org.commonjava.maven.galley.testing.core.transport.job.TestDownload in project galley by Commonjava.
the class VersionResolverImplTest method resolveSnapshot_Latest_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_Latest_TwoLocationList_TwoSingletonSnapshotList_LatestVersionStrategy() throws Exception {
final String testResource = "2-snapshots-2-locations/maven-metadata-1.xml";
final String testResource2 = "2-snapshots-2-locations/maven-metadata-2.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "artifact", "1.0-SNAPSHOT");
final String path = fixture.snapshotMetadataPath(ref);
fixture.getTransport().registerDownload(new ConcreteResource(LOCATION, path), new TestDownload(ROOT + testResource));
fixture.getTransport().registerDownload(new ConcreteResource(LOCATION2, path), new TestDownload(ROOT + testResource2));
final ProjectVersionRef result = fixture.getVersionResolver().resolveLatestVariableVersion(TWO_LOCATIONS, ref, LatestVersionSelectionStrategy.INSTANCE, new EventMetadata());
assertThat(result, notNullValue());
// newest snapshot is in the SECOND location.
assertThat(result.getVersionString(), equalTo("1.0-20140604.102909-1"));
}
Aggregations