use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef 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);
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"));
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project indy by Commonjava.
the class MavenMetadataGeneratorTest method generateFileContent_SnapshotMetadataWith2Versions.
@Test
public void generateFileContent_SnapshotMetadataWith2Versions() throws Exception {
final StoreResource resource = setupSnapshotDirWith2Snapshots();
final EventMetadata emd = new EventMetadata();
final Transfer transfer = generator.generateFileContent(stores.getArtifactStore(resource.getStoreKey()), resource.getChild("maven-metadata.xml").getPath(), emd);
assertThat(transfer, notNullValue());
final MavenMetadataView metadata = metadataReader.readMetadata(new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT"), Collections.singletonList(transfer), emd);
assertThat(metadata, notNullValue());
final VersioningView versioning = metadata.getVersioning();
final LatestSnapshotView latestSnapshot = versioning.getLatestSnapshot();
assertThat(latestSnapshot.isLocalCopy(), equalTo(false));
assertThat(latestSnapshot.getTimestamp(), equalTo(SnapshotUtils.parseSnapshotTimestamp("20140828.225800")));
assertThat(latestSnapshot.getBuildNumber(), equalTo(1));
final List<SnapshotArtifactView> snapshots = versioning.getSnapshotArtifacts();
assertThat(snapshots.size(), equalTo(4));
for (final SnapshotArtifactView snap : snapshots) {
final String extension = snap.getExtension();
assertThat(extension.equals("jar") || extension.equals("pom"), equalTo(true));
final String version = snap.getVersion();
System.out.println(version);
final SingleVersion parsed = VersionUtils.createSingleVersion(version);
assertThat(parsed.isSnapshot(), equalTo(true));
assertThat(parsed.isLocalSnapshot(), equalTo(false));
final SnapshotPart part = parsed.getSnapshotPart();
final String tstamp = SnapshotUtils.generateSnapshotTimestamp(part.getTimestamp());
assertThat(tstamp.equals("20140828.225800") || tstamp.equals("20140828.221400"), equalTo(true));
}
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project indy by Commonjava.
the class MavenMetadataGeneratorTest method generateFileContent_VersionsMetadataWith2Versions.
@Test
public void generateFileContent_VersionsMetadataWith2Versions() throws Exception {
final StoreResource resource = setupVersionsStructureWith2Versions();
final ConcreteResource metadataFile = resource.getChild("maven-metadata.xml");
final Transfer transfer = generator.generateFileContent(stores.getArtifactStore(resource.getStoreKey()), metadataFile.getPath(), new EventMetadata());
assertThat(transfer, notNullValue());
final MavenMetadataView metadata = metadataReader.readMetadata(new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT"), Collections.singletonList(transfer), new EventMetadata());
assertThat(metadata, notNullValue());
final VersioningView versioning = metadata.getVersioning();
final List<SingleVersion> versions = versioning.getVersions();
assertThat(versions, notNullValue());
assertThat(versions.get(0).renderStandard(), equalTo("1.0"));
assertThat(versions.get(1).renderStandard(), equalTo("1.1"));
assertThat(versioning.getReleaseVersion().renderStandard(), equalTo("1.1"));
assertThat(versioning.getLatestVersion().renderStandard(), equalTo("1.1"));
}
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"));
}
use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project galley by Commonjava.
the class VersionResolverImplTest method resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy.
@Test
public void resolveSnapshot_FirstMatch_SingletonLocationList_SingletonSnapshotList_LatestVersionStrategy() throws Exception {
final String testResource = "single-snapshot/single-snapshot.xml";
final ProjectVersionRef ref = new SimpleProjectVersionRef("org.group", "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.101244-1"));
}
Aggregations