Author: jdcasey
Date: Wed Jan 16 15:50:50 2008
New Revision: 612645

URL: http://svn.apache.org/viewvc?rev=612645&view=rev
Log:
Trying to make the FileProfileActivator unit test more resilient to alternative 
local repository locations.

Modified:
    
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
    
maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java

Modified: 
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java?rev=612645&r1=612644&r2=612645&view=diff
==============================================================================
--- 
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
 (original)
+++ 
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
 Wed Jan 16 15:50:50 2008
@@ -69,13 +69,14 @@
             {
                 fileString = StringUtils.replace( interpolator.interpolate( 
fileString, "" ), "\\", "/" );
 
-                System.out.println( "FileProfileActivator: Checking file 
existence for: " + fileString + ". Result: " + FileUtils.fileExists( fileString 
) );
+                boolean result = FileUtils.fileExists( fileString );
+
                 if ( logger != null )
                 {
-                    logger.info( "FileProfileActivator: Checking file 
existence for: " + fileString );
+                    logger.debug( "FileProfileActivator: Checking file 
existence for: " + fileString + ". Result: " + result );
                 }
 
-                return FileUtils.fileExists( fileString );
+                return result;
             }
 
             // check if the file is missing, if it is then the profile will be 
active
@@ -85,21 +86,21 @@
             {
                 fileString = StringUtils.replace( interpolator.interpolate( 
fileString, "" ), "\\", "/" );
 
-                System.out.println( "FileProfileActivator: Checking file is 
missing for: " + fileString + ". Result: " + (!FileUtils.fileExists( fileString 
)) );
+                boolean result = !FileUtils.fileExists( fileString );
+
                 if ( logger != null )
                 {
-                    logger.info( "FileProfileActivator: Checking file is 
missing for: " + fileString );
+                    logger.debug( "FileProfileActivator: Checking file is 
missing for: " + fileString + ". Result: " + result );
                 }
 
-                return !FileUtils.fileExists( fileString );
+                return result;
             }
         }
         else
         {
-            System.out.println( "FileProfileActivator: no file specified. 
Skipping activation." );
             if ( logger != null )
             {
-                logger.info( "FileProfileActivator: no file specified. 
Skipping activation." );
+                logger.debug( "FileProfileActivator: no file specified. 
Skipping activation." );
             }
         }
 

Modified: 
maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java?rev=612645&r1=612644&r2=612645&view=diff
==============================================================================
--- 
maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java
 (original)
+++ 
maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/FileProfileActivatorTest.java
 Wed Jan 16 15:50:50 2008
@@ -19,13 +19,13 @@
  * under the License.
  */
 
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.Profile;
+
 import java.util.Properties;
 
 import junit.framework.TestCase;
 
-import org.apache.maven.model.Activation;
-import org.apache.maven.model.Profile;
-
 /**
  * Test case for the [EMAIL PROTECTED] FileProfileActivator}.
  *
@@ -41,8 +41,18 @@
         throws ProfileActivationException
     {
         org.apache.maven.model.ActivationFile activationFile = new 
org.apache.maven.model.ActivationFile();
+
+        // make an educated guess at the repository location...
+        String repoLocation = System.getProperty( "maven.repo.local", 
"${user.home}/.m2/repository" );
+
+        repoLocation = repoLocation.replace( '\\', '/' );
+        if ( repoLocation.endsWith( "/" ) )
+        {
+            repoLocation = repoLocation.substring( 0, repoLocation.length() - 
1 );
+        }
+
         // Assume that junit exists
-        activationFile.setExists( 
"${user.home}/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar" );
+        activationFile.setExists( repoLocation + 
"/junit/junit/3.8.1/junit-3.8.1.jar" );
 
         Activation fileActivation = new Activation();
         fileActivation.setFile( activationFile );


Reply via email to