use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.
the class EmbeddableCDI_HTTPArtifactDownload_Test method resolveArtifactViaHttp.
@Test
public void resolveArtifactViaHttp() throws Exception {
String path = "/group/artifact/1/artifact-1.pom";
String content = "this is a test.";
server.expect(path, 200, content);
Transfer transfer = transfers.retrieve(new SimpleLocation(server.getBaseUri()), new SimpleProjectVersionRef("group", "artifact", "1").asPomArtifact());
assertThat(transfer, notNullValue());
InputStream stream = null;
try {
stream = transfer.openInputStream();
assertThat(IOUtils.toString(stream), equalTo(content));
} finally {
IOUtils.closeQuietly(stream);
}
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.
the class XMLInfrastructure method getProjectVersionRef.
public ProjectVersionRef getProjectVersionRef(final Document doc) throws GalleyMavenXMLException {
final Element project = doc.getDocumentElement();
String gid = getChildText("groupId", project);
final String aid = getChildText("artifactId", project);
String ver = getChildText("version", project);
if (isEmpty(gid) || isEmpty(ver)) {
final NodeList nl = project.getElementsByTagName("parent");
if (nl == null || nl.getLength() < 1) {
logger.debug("No parent declaration.");
return null;
}
final Element parent = (Element) nl.item(0);
gid = getChildText("groupId", parent);
ver = getChildText("version", parent);
}
if (isEmpty(gid) || isEmpty(aid) || isEmpty(ver)) {
throw new GalleyMavenXMLException("Project GAV is invalid! (g=%s, a=%s, v=%s)", gid, aid, ver);
}
return new SimpleProjectVersionRef(gid, aid, ver);
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.
the class MavenPomViewTest method buildExtension.
@Test
public void buildExtension() throws Exception {
MavenPomView pomView = loadPoms("pom-with-build-ext.xml");
List<ExtensionView> extensions = pomView.getBuildExtensions();
assertThat(extensions, notNullValue());
assertThat(extensions.size(), equalTo(1));
assertThat(extensions.get(0).asProjectVersionRef(), equalTo((ProjectVersionRef) new SimpleProjectVersionRef("ext.group", "ext-artifact", "1.0")));
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.
the class MavenPomViewTest method profileBuildExtension.
@Test
public void profileBuildExtension() throws Exception {
MavenPomView pomView = loadPoms(new String[] { "test" }, "pom-with-profile-build-ext.xml");
List<ExtensionView> extensions = pomView.getBuildExtensions();
assertThat(extensions, notNullValue());
assertThat(extensions.size(), equalTo(1));
assertThat(extensions.get(0).asProjectVersionRef(), equalTo((ProjectVersionRef) new SimpleProjectVersionRef("ext.group", "ext-artifact", "1.0")));
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.
the class ArtifactManagerImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_TwoSnapshotList_LatestVersionStrategy() throws Exception {
final String base = "2-snapshots-1-location/";
final String testResource = base + "two-snapshots.xml";
final String testPomResource = base + "two-snapshots-pom.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group2", "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.102909-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.102909-1"));
}
Aggregations