use of org.apache.maven.model.building.SimpleProblemCollector in project maven by apache.
the class AbstractModelInterpolatorTest method testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression.
@Test
public void testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression() throws Exception {
Model model = new Model();
Scm scm = new Scm();
scm.setConnection("${test}/somepath");
model.setScm(scm);
model.addProperty("test", "test");
ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel(model, new File("."), createModelBuildingRequest(context), collector);
assertProblemFree(collector);
assertEquals("test/somepath", out.getScm().getConnection());
}
use of org.apache.maven.model.building.SimpleProblemCollector in project maven by apache.
the class AbstractModelInterpolatorTest method testShouldNotInterpolateDependencyVersionWithInvalidReference.
@Test
public void testShouldNotInterpolateDependencyVersionWithInvalidReference() throws Exception {
Model model = new Model();
model.setVersion("3.8.1");
Dependency dep = new Dependency();
dep.setVersion("${something}");
model.addDependency(dep);
/*
// This is the desired behaviour, however there are too many crappy poms in the repo and an issue with the
// timing of executing the interpolation
try
{
new RegexBasedModelInterpolator().interpolate( model, context );
fail( "Should have failed to interpolate with invalid reference" );
}
catch ( ModelInterpolationException expected )
{
assertTrue( true );
}
*/
ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel(model, new File("."), createModelBuildingRequest(context), collector);
assertProblemFree(collector);
assertEquals("${something}", (out.getDependencies().get(0)).getVersion());
}
use of org.apache.maven.model.building.SimpleProblemCollector in project maven by apache.
the class AbstractModelInterpolatorTest method shouldInterpolateOrganizationNameCorrectly.
@Test
public void shouldInterpolateOrganizationNameCorrectly() throws Exception {
String orgName = "MyCo";
Model model = new Model();
model.setName("${project.organization.name} Tools");
Organization org = new Organization();
org.setName(orgName);
model.setOrganization(org);
ModelInterpolator interpolator = createInterpolator();
Model out = interpolator.interpolateModel(model, new File("."), createModelBuildingRequest(context), new SimpleProblemCollector());
assertEquals(orgName + " Tools", out.getName());
}
use of org.apache.maven.model.building.SimpleProblemCollector in project maven by apache.
the class AbstractModelInterpolatorTest method testShouldThrowExceptionOnRecursiveScmConnectionReference.
@Test
public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws Exception {
Model model = new Model();
Scm scm = new Scm();
scm.setConnection("${project.scm.connection}/somepath");
model.setScm(scm);
ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector();
interpolator.interpolateModel(model, null, createModelBuildingRequest(context), collector);
assertCollectorState(0, 1, 0, collector);
}
use of org.apache.maven.model.building.SimpleProblemCollector in project maven by apache.
the class AbstractModelInterpolatorTest method testTwoReferences.
@Test
public void testTwoReferences() throws Exception {
Model model = new Model();
model.setVersion("3.8.1");
model.setArtifactId("foo");
Dependency dep = new Dependency();
dep.setVersion("${artifactId}-${version}");
model.addDependency(dep);
ModelInterpolator interpolator = createInterpolator();
final SimpleProblemCollector collector = new SimpleProblemCollector();
Model out = interpolator.interpolateModel(model, new File("."), createModelBuildingRequest(context), collector);
assertCollectorState(0, 0, 2, collector);
assertEquals("foo-3.8.1", (out.getDependencies().get(0)).getVersion());
}
Aggregations