Merging 391974 from branch to fix IT errors introduced when attempting to fix the case where a resolved POM expression contains a substring referencing that POM element. Two-expression cycles are still possible.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@391988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2006-04-06 14:04:08 +00:00
parent 39132c3e37
commit ea8e24b1fb
2 changed files with 41 additions and 8 deletions

View File

@ -164,7 +164,7 @@ public class RegexBasedModelInterpolator
}
// if the expression refers to itself, skip it.
if ( String.valueOf( value ).indexOf( realExpr ) > -1 )
if ( String.valueOf( value ).indexOf( wholeExpr ) > -1 )
{
throw new ModelInterpolationException( wholeExpr, model.getId() + " references itself." );
}

View File

@ -46,7 +46,23 @@ public class RegexBasedModelInterpolatorTest
context = Collections.singletonMap( "basedir", "myBasedir" );
}
public void testShouldThrowExceptionOnRecursiveScmConnectionReference() throws IOException
public void testShouldNotThrowExceptionOnReferenceToNonExistentValue()
throws IOException, ModelInterpolationException
{
Model model = new Model();
Scm scm = new Scm();
scm.setConnection( "${test}/somepath" );
model.setScm( scm );
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
assertEquals( "${test}/somepath", out.getScm().getConnection() );
}
public void testShouldThrowExceptionOnRecursiveScmConnectionReference()
throws IOException
{
Model model = new Model();
@ -67,6 +83,23 @@ public class RegexBasedModelInterpolatorTest
}
}
public void testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression()
throws IOException, ModelInterpolationException
{
Model model = new Model();
Scm scm = new Scm();
scm.setConnection( "${test}/somepath" );
model.setScm( scm );
model.addProperty( "test", "test" );
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
assertEquals( "test/somepath", out.getScm().getConnection() );
}
public void testShouldInterpolateOrganizationNameCorrectly()
throws Exception
{