You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2008/01/07 13:16:55 UTC
svn commit: r609582 -
/maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java
Author: vsiveton
Date: Mon Jan 7 04:16:49 2008
New Revision: 609582
URL: http://svn.apache.org/viewvc?rev=609582&view=rev
Log:
MNG-3135: Enable skipping clean:clean goal in verifier
Submitted by: Arnaud Bailly
Reviewed by: Vincent Siveton
o applied with the Maven code style
Modified:
maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java
Modified: maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java?rev=609582&r1=609581&r2=609582&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java (original)
+++ maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java Mon Jan 7 04:16:49 2008
@@ -46,6 +46,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
+import java.util.regex.Pattern;
import junit.framework.Assert;
@@ -77,6 +78,8 @@
private Properties verifierProperties = new Properties();
+ private boolean autoclean = true;
+
// TODO: needs to be configurable
private static String localRepoLayout = "default";
@@ -612,6 +615,31 @@
}
}
+ /**
+ * Check that given file's content matches an regular expression. Note this method also checks that the file exists
+ * and is readable.
+ *
+ * @param file the file to check.
+ * @param regex a regular expression.
+ * @see Pattern
+ */
+ public void assertFileMatches( String file, String regex )
+ {
+ assertFilePresent( file );
+ try
+ {
+ String content = FileUtils.fileRead( file );
+ if ( !Pattern.matches( regex, content ) )
+ {
+ Assert.fail( "Content of " + file + " does not match " + regex );
+ }
+ }
+ catch ( IOException e )
+ {
+ Assert.fail( e.getMessage() );
+ }
+ }
+
public void assertFileNotPresent( String file )
{
try
@@ -733,7 +761,7 @@
{
if ( wanted )
{
- throw new VerificationException( "Expected file was not found: " + expectedFile.getPath() );
+ throw new VerificationException( "Expected file pattern was not found: " + expectedFile.getPath() );
}
}
else
@@ -800,7 +828,7 @@
public void executeGoal( String goal, Map envVars )
throws VerificationException
{
- executeGoals( Arrays.asList( new String[]{goal} ), envVars );
+ executeGoals( Arrays.asList( new String[] { goal } ), envVars );
}
public void executeGoals( List goals )
@@ -852,7 +880,10 @@
List allGoals = new ArrayList();
- allGoals.add( "clean:clean" );
+ if ( autoclean )
+ {
+ allGoals.add( "clean:clean" );
+ }
allGoals.addAll( goals );
@@ -875,7 +906,7 @@
}
catch ( IOException e )
{
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates.
}
System.out.println();
@@ -883,7 +914,7 @@
if ( envVars.get( "JAVA_HOME" ) == null )
{
- cli.addEnvironment( "JAVA_HOME", System.getProperty( "java.home" ));
+ cli.addEnvironment( "JAVA_HOME", System.getProperty( "java.home" ) );
}
cli.setWorkingDirectory( getBasedir() );
@@ -995,8 +1026,7 @@
if ( version == null )
{
throw new VerificationException( "Illegal maven output: String 'Maven version: ' not found in the following output:\n"
- + StringUtils.join( logLines.iterator(), "\n" )
- );
+ + StringUtils.join( logLines.iterator(), "\n" ) );
}
else
{
@@ -1004,7 +1034,6 @@
}
}
-
private int runCommandLine( String mavenHome, Commandline cli, File logFile )
throws CommandLineException, IOException
{
@@ -1624,10 +1653,19 @@
this.verifierProperties = verifierProperties;
}
+ public boolean isAutoclean()
+ {
+ return autoclean;
+ }
+
+ public void setAutoclean( boolean autoclean )
+ {
+ this.autoclean = autoclean;
+ }
+
public String getBasedir()
{
return basedir;
}
-
}