You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/04/06 14:47:21 UTC

svn commit: r391974 - in /maven/components/branches/maven-2.0.x/maven-project/src: main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java

Author: jdcasey
Date: Thu Apr  6 05:47:20 2006
New Revision: 391974

URL: http://svn.apache.org/viewcvs?rev=391974&view=rev
Log:
Fixing integration tests...bad string comparison when looking for self-referencing expressions during interpolation.

Modified:
    maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
    maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java

Modified: maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java?rev=391974&r1=391973&r2=391974&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java Thu Apr  6 05:47:20 2006
@@ -164,7 +164,7 @@
             }
 
             // 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." );
             }

Modified: maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java?rev=391974&r1=391973&r2=391974&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java (original)
+++ maven/components/branches/maven-2.0.x/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java Thu Apr  6 05:47:20 2006
@@ -45,26 +45,59 @@
 
         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();
+
         Scm scm = new Scm();
         scm.setConnection( "${project.scm.connection}/somepath" );
-        
+
         model.setScm( scm );
-        
+
         try
         {
             Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-            
+
             fail( "The interpolator should not allow self-referencing expressions in POM." );
         }
         catch ( ModelInterpolationException e )
         {
-            
+
         }
+    }
+
+    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()