You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2008/07/26 18:14:55 UTC
svn commit: r680008 -
/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/
Author: jvanzyl
Date: Sat Jul 26 09:14:54 2008
New Revision: 680008
URL: http://svn.apache.org/viewvc?rev=680008&view=rev
Log:
o this will be our integration test runner, which will in turn use the invoker and embedder
Added:
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java (with props)
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java (contents, props changed)
- copied, changed from r679635, maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/VerificationException.java
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java (contents, props changed)
- copied, changed from r679948, maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Verifier.java
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java (with props)
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java (with props)
Removed:
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/VerificationException.java
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Verifier.java
Modified:
maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvoker.java
Added: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java
URL: http://svn.apache.org/viewvc/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java?rev=680008&view=auto
==============================================================================
--- maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java (added)
+++ maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java Sat Jul 26 09:14:54 2008
@@ -0,0 +1,119 @@
+package org.apache.maven.it;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public class DefaultInvocationRequest
+ implements InvocationRequest
+{
+ private List cliOptions = new ArrayList();
+ private Map envars = new HashMap();
+ private Properties systemProperties = new Properties();
+ private String basedir;
+ private String goals;
+ private boolean autoclean;
+
+ public InvocationRequest setCliOptions( List options )
+ {
+ this.cliOptions = options;
+
+ return this;
+ }
+
+ public InvocationRequest addCliOption( String option )
+ {
+ if ( cliOptions == null )
+ {
+ cliOptions = new ArrayList();
+ }
+
+ cliOptions.add( option );
+
+ return this;
+ }
+
+ public List getCliOptions()
+ {
+ return cliOptions;
+ }
+
+ public InvocationRequest addEnvar( String key, String value )
+ {
+ if ( envars == null )
+ {
+ envars = new HashMap();
+ }
+
+ envars.put( key, value );
+
+ return this;
+ }
+
+ public Map getEnvars()
+ {
+ return envars;
+ }
+
+ public InvocationRequest addSystemProperty( String key, String value )
+ {
+ if ( systemProperties == null )
+ {
+ systemProperties = new Properties();
+ }
+
+ systemProperties.setProperty( key, value );
+
+ return this;
+ }
+
+ public Properties getSystemProperties()
+ {
+ return systemProperties;
+ }
+
+ public InvocationRequest setBasedir( String basedir )
+ {
+ this.basedir = basedir;
+
+ return this;
+ }
+
+ public String getBasedir()
+ {
+ return basedir;
+ }
+
+ public InvocationRequest setGoals( String goals )
+ {
+ this.goals = goals;
+
+ return this;
+ }
+
+ public String getGoals()
+ {
+ return goals;
+ }
+
+ public InvocationRequest setEnvars( Map envars )
+ {
+ // TODO Auto-generated method stub
+ this.envars = envars;
+ return this;
+ }
+
+ public boolean getAutoclean()
+ {
+ return autoclean;
+ }
+
+ public InvocationRequest setAutoclean( boolean autoclean )
+ {
+ this.autoclean = autoclean;
+
+ return this;
+ }
+}
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvocationRequest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvoker.java
URL: http://svn.apache.org/viewvc/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvoker.java?rev=680008&r1=680007&r2=680008&view=diff
==============================================================================
--- maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvoker.java (original)
+++ maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/DefaultInvoker.java Sat Jul 26 09:14:54 2008
@@ -18,7 +18,6 @@
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.PrintStream;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
@@ -42,25 +41,22 @@
{
private static final String LOG_FILENAME = "log.txt";
public String localRepo;
- private boolean autoclean = true;
private boolean debug;
private String defaultMavenHome;
public void invoke( InvocationRequest request )
- throws VerificationException
- {
- System.out.println( "------> " + request.getGoals() ) ;
-
+ throws IntegrationTestException
+ {
List goals = Arrays.asList( StringUtils.split( request.getGoals(), "," ) );
if ( goals.size() == 0 )
{
- throw new VerificationException( "No goals specified" );
+ throw new IntegrationTestException( "No goals specified" );
}
List allGoals = new ArrayList();
- if ( autoclean )
+ if ( request.getAutoclean() )
{
allGoals.add( "clean:clean" );
}
@@ -110,35 +106,32 @@
for ( Iterator i = allGoals.iterator(); i.hasNext(); )
{
String argument = (String) i.next();
- System.out.println(argument);
cli.createArgument().setValue( argument.trim() );
}
- FileUtils.fileWrite( "/tmp/data.txt", Commandline.toString( cli.getCommandline() ) );
+ //System.out.println( "Command: " + Commandline.toString( cli.getArguments() ) );
- System.out.println( "Command: " + Commandline.toString( cli.getCommandline() ) );
-
ret = runCommandLine( System.getProperty( "maven.home" ), cli, logFile );
}
catch ( CommandLineException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
catch ( IOException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
if ( ret > 0 )
{
System.err.println( "Exit code: " + ret );
- throw new VerificationException( "Exit code was non-zero: " + ret + "; log = \n" + getLogContents( logFile ) );
+ throw new IntegrationTestException( "Exit code was non-zero: " + ret + "; log = \n" + getLogContents( logFile ) );
}
}
public String getMavenVersion()
- throws VerificationException
+ throws IntegrationTestException
{
Commandline cmd = createCommandLine();
cmd.addArguments( new String[] { "--version" } );
@@ -151,11 +144,11 @@
}
catch ( CommandLineException e )
{
- throw new VerificationException( "Error running commandline " + cmd.toString(), e );
+ throw new IntegrationTestException( "Error running commandline " + cmd.toString(), e );
}
catch ( IOException e )
{
- throw new VerificationException( "IO Error communicating with commandline " + cmd.toString(), e );
+ throw new IntegrationTestException( "IO Error communicating with commandline " + cmd.toString(), e );
}
String separator = System.getProperty( "line.separator" );
@@ -170,7 +163,7 @@
if ( version == null )
{
- throw new VerificationException( "Illegal maven output: String 'Maven version: ' not found in the following output: " + writer.toString() );
+ throw new IntegrationTestException( "Illegal maven output: String 'Maven version: ' not found in the following output: " + writer.toString() );
}
else
{
@@ -257,14 +250,4 @@
return "(Error reading log contents: " + e.getMessage() + ")";
}
}
-
- public boolean isAutoclean()
- {
- return autoclean;
- }
-
- public void setAutoclean( boolean autoclean )
- {
- this.autoclean = autoclean;
- }
}
Copied: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java (from r679635, maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/VerificationException.java)
URL: http://svn.apache.org/viewvc/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java?p2=maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java&p1=maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/VerificationException.java&r1=679635&r2=680008&rev=680008&view=diff
==============================================================================
--- maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/VerificationException.java (original)
+++ maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java Sat Jul 26 09:14:54 2008
@@ -23,24 +23,24 @@
* @author Jason van Zyl
* @version $Id$
*/
-public class VerificationException
+public class IntegrationTestException
extends Exception
{
- public VerificationException()
+ public IntegrationTestException()
{
}
- public VerificationException( String message )
+ public IntegrationTestException( String message )
{
super( message );
}
- public VerificationException( Throwable cause )
+ public IntegrationTestException( Throwable cause )
{
super( cause );
}
- public VerificationException( String message, Throwable cause )
+ public IntegrationTestException( String message, Throwable cause )
{
super( message, cause );
}
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java
------------------------------------------------------------------------------
cvs2svn:cvs-rev = 1.2
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestException.java
------------------------------------------------------------------------------
svn:mergeinfo =
Copied: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java (from r679948, maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Verifier.java)
URL: http://svn.apache.org/viewvc/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java?p2=maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java&p1=maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Verifier.java&r1=679948&r2=680008&rev=680008&view=diff
==============================================================================
--- maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Verifier.java (original)
+++ maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java Sat Jul 26 09:14:54 2008
@@ -55,40 +55,31 @@
* @todo create embedder invoker
* @todo find better way to pass in maven version
*/
-public class Verifier
+public class IntegrationTestRunner
{
private static final String LOG_FILENAME = "log.txt";
public String localRepo;
private final String basedir;
private static String localRepoLayout = "default";
- private boolean debug;
// Constructors
- public Verifier( String basedir )
- throws VerificationException
+ public IntegrationTestRunner( String basedir )
+ throws IntegrationTestException
{
- this( basedir, null );
+ this( basedir, null, false );
}
- public Verifier( String basedir, boolean debug )
- throws VerificationException
+ public IntegrationTestRunner( String basedir, boolean debug )
+ throws IntegrationTestException
{
this( basedir, null, debug );
}
- public Verifier( String basedir, String settingsFile )
- throws VerificationException
- {
- this( basedir, settingsFile, false );
- }
-
- public Verifier( String basedir, String settingsFile, boolean debug )
- throws VerificationException
+ public IntegrationTestRunner( String basedir, String settingsFile, boolean debug )
+ throws IntegrationTestException
{
this.basedir = basedir;
- this.debug = debug;
-
findLocalRepo( settingsFile );
findDefaultMavenHome();
}
@@ -98,34 +89,34 @@
Invoker invoker = new DefaultInvoker();
public void executeGoal( String goal )
- throws VerificationException
+ throws IntegrationTestException
{
InvocationRequest r = new DefaultInvocationRequest().setGoals( goal ).setBasedir( basedir );
invoker.invoke( r );
}
public void executeGoal( String goal, List cliOptions )
- throws VerificationException
+ throws IntegrationTestException
{
InvocationRequest r = new DefaultInvocationRequest().setGoals( goal ).setBasedir( basedir ).setCliOptions( cliOptions );
invoker.invoke( r );
}
public void executeGoal( String goal, Map envars )
- throws VerificationException
+ throws IntegrationTestException
{
InvocationRequest r = new DefaultInvocationRequest().setGoals( goal ).setBasedir( basedir ).setEnvars( envars );
invoker.invoke( r );
}
public void invoke( InvocationRequest request )
- throws VerificationException
+ throws IntegrationTestException
{
invoker.invoke( request );
}
public String getMavenVersion()
- throws VerificationException
+ throws IntegrationTestException
{
return invoker.getMavenVersion();
}
@@ -138,7 +129,7 @@
//
private void findDefaultMavenHome()
- throws VerificationException
+ throws IntegrationTestException
{
try
{
@@ -147,7 +138,7 @@
}
catch ( IOException e )
{
- throw new VerificationException( "Cannot read system environment variables.", e );
+ throw new IntegrationTestException( "Cannot read system environment variables.", e );
}
}
@@ -156,7 +147,7 @@
}
public void verifyErrorFreeLog()
- throws VerificationException
+ throws IntegrationTestException
{
List lines;
lines = loadFile( getBasedir(), LOG_FILENAME, false );
@@ -168,7 +159,7 @@
// A hack to keep stupid velocity resource loader errors from triggering failure
if ( line.indexOf( "[ERROR]" ) >= 0 && line.indexOf( "VM_global_library.vm" ) == -1 )
{
- throw new VerificationException( "Error in execution: " + line );
+ throw new IntegrationTestException( "Error in execution: " + line );
}
}
}
@@ -177,10 +168,10 @@
* Throws an exception if the text is not present in the log.
*
* @param text
- * @throws VerificationException
+ * @throws IntegrationTestException
*/
public void verifyTextInLog( String text )
- throws VerificationException
+ throws IntegrationTestException
{
List lines;
lines = loadFile( getBasedir(), LOG_FILENAME, false );
@@ -197,18 +188,18 @@
}
if ( !result )
{
- throw new VerificationException( "Text not found in log: " + text );
+ throw new IntegrationTestException( "Text not found in log: " + text );
}
}
public List loadFile( String basedir, String filename, boolean hasCommand )
- throws VerificationException
+ throws IntegrationTestException
{
return loadFile( new File( basedir, filename ), hasCommand );
}
public List loadFile( File file, boolean hasCommand )
- throws VerificationException
+ throws IntegrationTestException
{
List lines = new ArrayList();
@@ -235,11 +226,11 @@
}
catch ( FileNotFoundException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
catch ( IOException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
}
@@ -397,7 +388,7 @@
}
private static String retrieveLocalRepo( String settingsXmlPath )
- throws VerificationException
+ throws IntegrationTestException
{
UserModelReader userModelReader = new UserModelReader();
@@ -447,7 +438,7 @@
{
verifyExpectedResult( file, true );
}
- catch ( VerificationException e )
+ catch ( IntegrationTestException e )
{
Assert.fail( e.getMessage() );
}
@@ -484,7 +475,7 @@
{
verifyExpectedResult( file, false );
}
- catch ( VerificationException e )
+ catch ( IntegrationTestException e )
{
Assert.fail( e.getMessage() );
}
@@ -500,7 +491,7 @@
{
verifyExpectedResult( fileName, wanted );
}
- catch ( VerificationException e )
+ catch ( IntegrationTestException e )
{
Assert.fail( e.getMessage() );
}
@@ -518,7 +509,7 @@
}
private void verifyExpectedResult( String line, boolean wanted )
- throws VerificationException
+ throws IntegrationTestException
{
if ( line.indexOf( "!/" ) > 0 )
{
@@ -535,24 +526,24 @@
{
if ( wanted )
{
- throw new VerificationException( "Expected JAR resource was not found: " + line );
+ throw new IntegrationTestException( "Expected JAR resource was not found: " + line );
}
}
else
{
if ( !wanted )
{
- throw new VerificationException( "Unwanted JAR resource was found: " + line );
+ throw new IntegrationTestException( "Unwanted JAR resource was found: " + line );
}
}
}
catch ( MalformedURLException e )
{
- throw new VerificationException( "Error looking for JAR resource", e );
+ throw new IntegrationTestException( "Error looking for JAR resource", e );
}
catch ( IOException e )
{
- throw new VerificationException( "Error looking for JAR resource", e );
+ throw new IntegrationTestException( "Error looking for JAR resource", e );
}
finally
{
@@ -586,7 +577,7 @@
{
if ( wanted )
{
- throw new VerificationException( "Expected file pattern was not found: " + expectedFile.getPath() );
+ throw new IntegrationTestException( "Expected file pattern was not found: " + expectedFile.getPath() );
}
}
else
@@ -611,11 +602,11 @@
if ( !found && wanted )
{
- throw new VerificationException( "Expected file pattern was not found: " + expectedFile.getPath() );
+ throw new IntegrationTestException( "Expected file pattern was not found: " + expectedFile.getPath() );
}
else if ( found && !wanted )
{
- throw new VerificationException( "Unwanted file pattern was found: " + expectedFile.getPath() );
+ throw new IntegrationTestException( "Unwanted file pattern was found: " + expectedFile.getPath() );
}
}
}
@@ -625,14 +616,14 @@
{
if ( wanted )
{
- throw new VerificationException( "Expected file was not found: " + expectedFile.getPath() );
+ throw new IntegrationTestException( "Expected file was not found: " + expectedFile.getPath() );
}
}
else
{
if ( !wanted )
{
- throw new VerificationException( "Unwanted file was found: " + expectedFile.getPath() );
+ throw new IntegrationTestException( "Unwanted file was found: " + expectedFile.getPath() );
}
}
}
@@ -640,7 +631,7 @@
}
private void findLocalRepo( String settingsFile )
- throws VerificationException
+ throws IntegrationTestException
{
if ( localRepo == null )
{
@@ -680,7 +671,7 @@
private StringBuffer currentBody = new StringBuffer();
public void parse( File file )
- throws VerificationException
+ throws IntegrationTestException
{
try
{
@@ -694,19 +685,19 @@
}
catch ( FileNotFoundException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
catch ( IOException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
catch ( ParserConfigurationException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
catch ( SAXException e )
{
- throw new VerificationException( e );
+ throw new IntegrationTestException( e );
}
}
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java
------------------------------------------------------------------------------
cvs2svn:cvs-rev = 1.31
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/IntegrationTestRunner.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java
URL: http://svn.apache.org/viewvc/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java?rev=680008&view=auto
==============================================================================
--- maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java (added)
+++ maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java Sat Jul 26 09:14:54 2008
@@ -0,0 +1,24 @@
+package org.apache.maven.it;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+public interface InvocationRequest
+{
+ InvocationRequest setGoals( String goal );
+ InvocationRequest setBasedir( String basedir );
+ InvocationRequest addCliOption( String option );
+ InvocationRequest setCliOptions( List cliOptions );
+ InvocationRequest addSystemProperty( String key, String value );
+ InvocationRequest setEnvars( Map envars );
+ InvocationRequest addEnvar( String key, String value );
+ InvocationRequest setAutoclean( boolean autoclean );
+
+ boolean getAutoclean();
+ String getGoals();
+ String getBasedir();
+ List getCliOptions();
+ Properties getSystemProperties();
+ Map getEnvars();
+}
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/InvocationRequest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java
URL: http://svn.apache.org/viewvc/maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java?rev=680008&view=auto
==============================================================================
--- maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java (added)
+++ maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java Sat Jul 26 09:14:54 2008
@@ -0,0 +1,12 @@
+package org.apache.maven.it;
+
+public interface Invoker
+{
+ void invoke( InvocationRequest request )
+ throws IntegrationTestException;
+
+ String getExecutable();
+
+ String getMavenVersion()
+ throws IntegrationTestException;
+}
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/shared/branches/embedder-verifier/src/main/java/org/apache/maven/it/Invoker.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"