use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class ProjectInheritanceTest method testVerifyProjectVersion.
@Test
public void testVerifyProjectVersion() throws Exception {
final ManipulationSession session = new ManipulationSession();
final File projectroot = new File(TestUtils.resolveFileResource(RESOURCE_BASE, "").getParentFile().getParentFile().getParentFile().getParentFile(), "integration-test/src/it/project-inheritance/pom.xml");
PomIO pomIO = new PomIO();
List<Project> projects = pomIO.parseProject(projectroot);
for (Project p : projects) {
if (p.getPom().equals(projectroot)) {
HashMap<ArtifactRef, Dependency> deps = p.getResolvedManagedDependencies(session);
for (ArtifactRef a : deps.keySet()) {
assertFalse(a.getVersionString().contains("project.version"));
}
deps = p.getResolvedDependencies(session);
assertTrue(deps.size() == 1);
for (ArtifactRef a : deps.keySet()) {
assertFalse(a.getVersionString().contains("project.version"));
}
assertFalse(deps.containsKey("org.mockito:mockito-all:jar:*"));
deps = p.getAllResolvedDependencies(session);
assertTrue(deps.size() == 3);
for (ArtifactRef a : deps.keySet()) {
assertFalse(a.getVersionString().contains("project.version"));
if (a.getGroupId().equals("org.mockito")) {
assertTrue(a.getVersionString().contains("*"));
}
}
assertTrue(deps.containsKey(SimpleArtifactRef.parse("org.mockito:mockito-all:jar:*")));
}
}
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class PropertyInterpolatorTest method testInteropolateProperties.
@Test
public void testInteropolateProperties() throws Exception {
final Model model = TestUtils.resolveModelResource(RESOURCE_BASE, "infinispan-bom-8.2.0.Final.pom");
Project p = new Project(model);
Properties props = p.getModel().getProperties();
boolean containsProperty = false;
for (Object o : props.values()) {
if (((String) o).contains("${")) {
containsProperty = true;
}
}
assertTrue(containsProperty);
PropertyInterpolator pi = new PropertyInterpolator(props, p);
assertTrue(pi.interp("${version.hibernate.osgi}").equals("5.0.4.Final"));
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class PropertyInterpolatorTest method testResolveProjectDependencies.
@Test
public void testResolveProjectDependencies() throws Exception {
final Model model = TestUtils.resolveModelResource(RESOURCE_BASE, "infinispan-bom-8.2.0.Final.pom");
final Project project = new Project(model);
HashMap<ArtifactRef, Dependency> deps = project.getResolvedManagedDependencies(new ManipulationSession());
assertTrue(deps.size() == 66);
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class XMLManipulatorTest method testNotFound.
@Test(expected = ManipulationException.class)
public void testNotFound() throws Exception {
String path = "//include[starts-with(.,'i-do-not-exist')]";
File target = tf.newFile();
FileUtils.copyFile(xmlFile, target);
Project p = new Project(null, target, null);
xmlManipulator.internalApplyChanges(p, new XMLState.XMLOperation(target.getName(), path, null));
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class XMLManipulatorTest method alterFile.
@Test
public void alterFile() throws Exception {
String replacementGA = "com.rebuild:servlet-api";
String tomcatPath = "//include[starts-with(.,'org.apache.tomcat')]";
File target = tf.newFile();
FileUtils.copyFile(xmlFile, target);
Project project = new Project(null, target, null);
xmlManipulator.internalApplyChanges(project, new XMLState.XMLOperation(target.getName(), tomcatPath, replacementGA));
Diff diff = DiffBuilder.compare(fromFile(xmlFile)).withTest(fromFile(target)).build();
assertTrue(diff.toString(), diff.hasDifferences());
String xpathForHamcrest = "/*/*/*/*/*[starts-with(.,'com.rebuild') and local-name() = 'include']";
Iterable<Node> i = new JAXPXPathEngine().selectNodes(xpathForHamcrest, fromFile(target).build());
int count = 0;
for (Node anI : i) {
count++;
assertTrue(anI.getTextContent().startsWith("com.rebuild:servlet-api"));
}
assertEquals(1, count);
}
Aggregations