Initial revision

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jvanzyl committed 2004-01-09 16:22:58 +00:00
1 parent 7e543e664f
commit 8695eb3c27
24 files changed
+2437

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
target
velocity.log
maven.log
.classpath
.project
*.ipr
*.iws
+181
View File
@@ -0,0 +1,181 @@
<?xml version="1.0"?>
<project xmlns:j="jelly:core"
xmlns:maven="jelly:maven"
xmlns:u="jelly:util"
xmlns:define="jelly:define">
<goal name="test"
description="Test the application"
prereqs="test:test"/>
<goal name="test:prepare-filesystem"
description="Create the needed directory structure">
<mkdir dir="${maven.test.dest}"/>
<mkdir dir="${maven.test.reportsDirectory}"/>
</goal>
<goal name="test:compile"
description="Compile the TestCases and TestSuites"
prereqs="java:compile,java:jar-resources,test:prepare-filesystem,test:test-resources">
<j:set var="maven.test.searchdir" value="${maven.test.dest}"/>
<j:if test="${context.getVariable('maven.test.search.classdir') == null}">
<j:set var="maven.test.searchdir" value="${pom.build.unitTestSourceDirectory}"/>
</j:if>
<j:if test="${unitTestSourcesPresent == 'true'}">
<javac
destdir="${maven.test.dest}"
excludes="**/package.html"
debug="${maven.compile.debug}"
deprecation="${maven.compile.deprecation}"
optimize="${maven.compile.optimize}">
<j:if test="${context.getVariable('maven.test.source') != null}">
<setProperty name="source" value="${maven.test.source}" />
</j:if>
<classpath>
<pathelement path="${maven.test.dest}"/>
<pathelement path="${maven.build.dest}"/>
<path refid="maven.dependency.classpath"/>
<pathelement path="${plugin.getDependencyPath('junit')}"/>
</classpath>
<src>
<path refid="maven.test.compile.src.set"/>
</src>
<j:if test="${context.getVariable('maven.compile.compilerargs') != null}">
<compilerarg line="${maven.compile.compilerargs}" />
</j:if>
<j:if test="${context.getVariable('maven.compile.encoding') != null}">
<setProperty name="encoding" value="${maven.compile.encoding}" />
</j:if>
<j:if test="${context.getVariable('maven.compile.executable') != null}">
<setProperty name="executable" value="${maven.compile.executable}" />
</j:if>
<j:if test="${context.getVariable('maven.compile.fork') != null}">
<setProperty name="fork" value="${maven.compile.fork}" />
</j:if>
<j:if test="${context.getVariable('maven.compile.source') != null}">
<setProperty name="source" value="${maven.compile.source}" />
</j:if>
<j:if test="${context.getVariable('maven.compile.verbose') != null}">
<setProperty name="verbose" value="${maven.compile.verbose}" />
</j:if>
</javac>
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No test source files to compile.</echo>
</j:if>
</goal>
<goal name="test:test"
description="Test the application"
prereqs="test:compile">
<j:if test="${unitTestSourcesPresent == 'true' and context.getVariable('maven.test.skip') != 'true'}">
<j:useBean class="org.apache.maven.test.TestRunnerBooter" var="testRunner"/>
${testRunner.setProject(pom)}
${testRunner.execute()}
<j:set var="maven.test.failure" value="${testRunner.failures()}"/>
<j:if test="${maven.test.failure}">
<j:set var="ignore__" value="${maven.test.failure.ignore}X"/>
<j:if test="${ignore__ == 'X'}">
<fail message="There were test failures."/>
</j:if>
</j:if>
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No tests to run.</echo>
</j:if>
</goal>
<goal name="test:single"
description="Execute a single test defined using the 'testcase' variable"
prereqs="test:compile">
<j:if test="${unitTestSourcesPresent == 'true'}">
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No tests to run.</echo>
</j:if>
</goal>
<goal name="test:match"
description="Execute all the tests matching the given 'testmatch' variable"
prereqs="test:compile">
<j:if test="${unitTestSourcesPresent == 'true'}">
</j:if>
<j:if test="${!unitTestSourcesPresent}">
<echo>No tests to run.</echo>
</j:if>
</goal>
<goal name="test:single-test"
description="[deprecated] please use the test:single goal instead">
<echo>[deprecated] please use the test:single goal instead</echo>
<attainGoal name="test:single"/>
</goal>
<goal name="test:match-test"
description="[deprecated] please use the test:match goal instead">
<echo>[deprecated] please use the test:match goal instead</echo>
<attainGoal name="test:match"/>
</goal>
<goal name="test:eclipse">
<echo>Used by eclipse to drag in test plugin context</echo>
</goal>
<!-- ================================================================== -->
<!-- T E S T R E S O U R C E S -->
<!-- ================================================================== -->
<goal name="test:test-resources"
description="Copy any resources that must be present for run tests"
prereqs="test:prepare-filesystem">
<j:if test="${unitTestSourcesPresent}">
<j:if test="${pom.build.unitTest != null}">
<j:if test="${!pom.build.unitTest.resources.isEmpty()}">
<maven:copy-resources
resources="${pom.build.unitTest.resources}"
todir="${maven.test.dest}"
/>
</j:if>
</j:if>
</j:if>
</goal>
<define:taglib uri="test">
<define:tag name="dependency-handle">
<!-- XXX Use this tag to allow this plugin to be loaded into another -->
</define:tag>
</define:taglib>
</project>
+14
View File
@@ -0,0 +1,14 @@
# -------------------------------------------------------------------
# P L U G I N P R O P E R T I E S
# -------------------------------------------------------------------
# JUnit test plugin.
# -------------------------------------------------------------------
maven.junit.fork = no
maven.junit.dir = ${basedir}
maven.junit.usefile = true
maven.junit.printSummary=true
maven.test.dest = ${maven.build.dir}/test-classes
maven.test.reportsDirectory = ${maven.build.dir}/test-reports
maven.test.skip = false
maven.junit.jvmargs=
+7
View File
@@ -0,0 +1,7 @@
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
maven.xdoc.date=left
## maven.xdoc.version=${pom.currentVersion}
maven.license.licenseFile=${basedir}/../../../LICENSE.txt
+47
View File
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<extend>../project.xml</extend>
<pomVersion>3</pomVersion>
<id>maven-surefire-plugin</id>
<artifactId>maven-surefire-plugin</artifactId>
<name>Maven SureFire Plug-in</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<description/>
<shortDescription>Run JUnit tests</shortDescription>
<url>http://maven.apache.org/reference/plugins/surefire/</url>
<siteDirectory>/www/maven.apache.org/reference/plugins/surefire/</siteDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/surefire/</connection>
<url>http://cvs.apache.org/viewcvs/maven/src/plugins-build/test/</url>
</repository>
<developers>
</developers>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>test-runner</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-alpha-2</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-alpha-2</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.0-beta-1</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,59 @@
package org.apache.maven.test;
import java.net.URLClassLoader;
import java.net.URL;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id: IsolatedClassLoader.java,v 1.1 2004/01/09 16:22:59 jvanzyl Exp $
*/
public class IsolatedClassLoader
extends URLClassLoader
{
private ClassLoader parent = ClassLoader.getSystemClassLoader();
public IsolatedClassLoader()
{
super( new URL[0], null );
}
public void addURL( URL url )
{
super.addURL( url );
}
public synchronized Class loadClass( String className )
throws ClassNotFoundException
{
Class c = findLoadedClass( className );
ClassNotFoundException ex = null;
if ( c == null )
{
try
{
c = findClass( className );
}
catch ( ClassNotFoundException e )
{
ex = e;
if ( parent != null )
{
c = parent.loadClass( className );
}
}
}
if ( c == null )
{
throw ex;
}
return c;
}
}
@@ -0,0 +1,109 @@
package org.apache.maven.test;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.Project;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.List;
import java.lang.reflect.Method;
/**
* A command line based tool to run tests.
* <pre>
* java junit.textui.TestRunner [-wait] TestCaseClass
* </pre>
* TestRunner expects the name of a TestCase class as argument.
* If this class defines a static <code>suite</code> method it
* will be invoked and the returned test is run. Otherwise all
* the methods starting with "test" having no arguments are run.
* <p>
* When the wait command line argument is given TestRunner
* waits until the users types RETURN.
* <p>
* TestRunner prints a trace as the tests are executed followed by a
* summary at the end.
*/
public class TestRunnerBooter
{
private Project project;
public void setProject( Project project )
{
this.project = project;
}
public void execute()
throws Exception
{
// maven.build.dest
// maven.test.dest
// maven.build.dest
// maven.test.dest
IsolatedClassLoader classLoader = new IsolatedClassLoader();
File basedir = project.getFile().getParentFile();
System.setProperty( "basedir", basedir.getPath() );
Thread.currentThread().setContextClassLoader( classLoader );
classLoader.addURL( new File ( "/home/jvanzyl/maven-repo-local/junit/jars/junit-3.8.1.jar" ).toURL() );
classLoader.addURL( new File ( "/tmp/test-runner-1.4.jar" ).toURL() );
classLoader.addURL( new File( basedir, "target/classes/" ).toURL() );
classLoader.addURL( new File( basedir, "target/test-classes/" ).toURL() );
processDependencies( project, classLoader );
Class testRunnerClass = classLoader.loadClass( "org.apache.maven.test.TestRunner" );
Object testRunner = testRunnerClass.newInstance();
Method m = testRunnerClass.getMethod( "runTestClasses", new Class[] {
File.class,
List.class,
List.class,
ClassLoader.class } );
m.invoke( testRunner, new Object[]{
basedir,
project.getBuild().getUnitTest().getIncludes(),
project.getBuild().getUnitTest().getExcludes(),
classLoader,
} );
}
// We need to deal with populating a plugin classloader with its requirements.
private void processDependencies( Project project, IsolatedClassLoader classLoader )
throws MalformedURLException
{
if ( project.getArtifacts() == null )
{
return;
}
for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
Dependency dependency = artifact.getDependency();
// Only add compile type dependencies to classloader
if ( dependency.getType().equals( "jar" ) )
{
// We have the jar and the classloader to push it into so
// lets do it!
if ( artifact.exists() )
{
classLoader.addURL( artifact.getFile().toURL() );
}
}
}
}
}
+5
View File
@@ -0,0 +1,5 @@
target
velocity.log
maven.log
.classpath
.project
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<groupId>maven</groupId>
<id>surefire-runner</id>
<artifactId>surefire-runner</artifactId>
<name>Surefire Test Runner</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<description/>
<shortDescription>Run JUnit tests</shortDescription>
<url>http://maven.apache.org/reference/plugins/surefire-runner</url>
<siteDirectory>/www/maven.apache.org/reference/plugins/surefire-runner</siteDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/surefire-runner</connection>
<url>http://cvs.apache.org/viewcvs/maven/src/plugins-build/surefire-runner</url>
</repository>
<developers>
</developers>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
</build>
</project>
@@ -0,0 +1,368 @@
package org.apache.maven.test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Enumeration;
import java.util.Vector;
/**
* A <code>TestSuite</code> is a <code>Composite</code> of Tests.
* It runs a collection of test cases. Here is an example using
* the dynamic test definition.
* <pre>
* TestSuite suite= new TestSuite();
* suite.addTest(new MathTest("testAdd"));
* suite.addTest(new MathTest("testDivideByZero"));
* </pre>
* Alternatively, a TestSuite can extract the tests to be run automatically.
* To do so you pass the class of your TestCase class to the
* TestSuite constructor.
* <pre>
* TestSuite suite= new TestSuite(MathTest.class);
* </pre>
* This constructor creates a suite with all the methods
* starting with "test" that take no arguments.
*
* @see junit.framework.Test
*/
public class MavenJUnitTestSuite
implements Test
{
private Vector fTests = new Vector( 10 );
private String fName;
private Class junitTest = null;
private Class testResultClass = null;
/**
* Constructs an empty TestSuite.
*/
public MavenJUnitTestSuite()
{
}
/**
* Constructs a TestSuite from the given class with the given name.
*/
public MavenJUnitTestSuite( Class theClass )
{
this( theClass, ClassLoader.getSystemClassLoader() );
}
/**
* Constructs a TestSuite from the given class. Adds all the methods
* starting with "test" as test cases to the suite.
* Parts of this method was written at 2337 meters in the H�ffih�tte,
* Kanton Uri
*/
public MavenJUnitTestSuite( final Class theClass, ClassLoader classLoader )
{
try
{
junitTest = classLoader.loadClass( "junit.framework.Test" );
testResultClass = classLoader.loadClass( "junit.framework.TestResult" );
}
catch ( ClassNotFoundException e )
{
}
fName = theClass.getName();
try
{
getTestConstructor( theClass ); // Avoid generating multiple error messages
}
catch ( NoSuchMethodException e )
{
addTest( warning( "Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()" ) );
return;
}
if ( !Modifier.isPublic( theClass.getModifiers() ) )
{
addTest( warning( "Class " + theClass.getName() + " is not public" ) );
return;
}
Class superClass = theClass;
Vector names = new Vector();
while ( junitTest.isAssignableFrom( superClass ) )
{
Method[] methods = superClass.getDeclaredMethods();
for ( int i = 0; i < methods.length; i++ )
{
addTestMethod( methods[i], names, theClass );
}
superClass = superClass.getSuperclass();
}
if ( fTests.size() == 0 )
{
addTest( warning( "No tests found in " + theClass.getName() ) );
}
}
/**
* Constructs an empty TestSuite.
*/
public MavenJUnitTestSuite( String name )
{
setName( name );
}
/**
* Adds a test to the suite.
*/
public void addTest( Object test )
{
fTests.addElement( test );
}
/**
* Adds the tests from the given class to the suite
*/
public void addTestSuite( Class testClass )
{
addTest( new MavenJUnitTestSuite( testClass ) );
}
private void addTestMethod( Method m, Vector names, Class theClass )
{
String name = m.getName();
if ( names.contains( name ) )
{
return;
}
if ( !isPublicTestMethod( m ) )
{
if ( isTestMethod( m ) )
{
addTest( warning( "Test method isn't public: " + m.getName() ) );
}
return;
}
names.addElement( name );
addTest( createTest( theClass, name ) );
}
/**
* ...as the moon sets over the early morning Merlin, Oregon
* mountains, our intrepid adventurers type...
*/
static public Object createTest( Class theClass, String name )
{
Constructor constructor;
try
{
constructor = getTestConstructor( theClass );
}
catch ( NoSuchMethodException e )
{
return warning( "Class " + theClass.getName() + " has no public constructor TestCase(String name) or TestCase()" );
}
Object test;
try
{
if ( constructor.getParameterTypes().length == 0 )
{
test = constructor.newInstance( new Object[0] );
if ( test instanceof TestCase )
{
( (TestCase) test ).setName( name );
}
}
else
{
test = constructor.newInstance( new Object[]{name} );
}
}
catch ( InstantiationException e )
{
return ( warning( "Cannot instantiate test case: " + name + " (" + exceptionToString( e ) + ")" ) );
}
catch ( InvocationTargetException e )
{
return ( warning( "Exception in constructor: " + name + " (" + exceptionToString( e.getTargetException() ) + ")" ) );
}
catch ( IllegalAccessException e )
{
return ( warning( "Cannot access test case: " + name + " (" + exceptionToString( e ) + ")" ) );
}
return test;
}
/**
* Converts the stack trace into a string
*/
private static String exceptionToString( Throwable t )
{
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter( stringWriter );
t.printStackTrace( writer );
return stringWriter.toString();
}
/**
* Counts the number of test cases that will be run by this test.
*/
public int countTestCases()
{
int count = 0;
for ( Enumeration e = tests(); e.hasMoreElements(); )
{
Test test = (Test) e.nextElement();
count = count + test.countTestCases();
}
return count;
}
/**
* Gets a constructor which takes a single String as
* its argument or a no arg constructor.
*/
public static Constructor getTestConstructor( Class theClass )
throws NoSuchMethodException
{
Class[] args = {String.class};
try
{
return theClass.getConstructor( args );
}
catch ( NoSuchMethodException e )
{
// fall through
}
return theClass.getConstructor( new Class[0] );
}
private boolean isPublicTestMethod( Method m )
{
return isTestMethod( m ) && Modifier.isPublic( m.getModifiers() );
}
private boolean isTestMethod( Method m )
{
String name = m.getName();
Class[] parameters = m.getParameterTypes();
Class returnType = m.getReturnType();
return parameters.length == 0 && name.startsWith( "test" ) && returnType.equals( Void.TYPE );
}
/**
* Runs the tests and collects their result in a TestResult.
*/
public void run( TestResult result )
{
for ( Enumeration e = tests(); e.hasMoreElements(); )
{
if ( result.shouldStop() )
{
break;
}
Object test = e.nextElement();
runTest( test, result );
}
}
public void runTest( Object test, TestResult result )
{
try
{
Method m = test.getClass().getMethod( "run", new Class[] { testResultClass } );
m.invoke( test, new Object[] { result } );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
/**
* Returns the test at the given index
*/
public Test testAt( int index )
{
return (Test) fTests.elementAt( index );
}
/**
* Returns the number of tests in this suite
*/
public int testCount()
{
return fTests.size();
}
/**
* Returns the tests as an enumeration
*/
public Enumeration tests()
{
return fTests.elements();
}
/**
*/
public String toString()
{
if ( getName() != null )
return getName();
return super.toString();
}
/**
* Sets the name of the suite.
* @param name The name to set
*/
public void setName( String name )
{
fName = name;
}
/**
* Returns the name of the suite. Not all
* test suites have a name and this method
* can return null.
*/
public String getName()
{
return fName;
}
/**
* Returns a test which will fail and log a warning message.
*/
private static Test warning( final String message )
{
return new TestCase( "warning" )
{
protected void runTest()
{
fail( message );
}
};
}
}
@@ -0,0 +1,33 @@
package org.apache.maven.test;
import junit.runner.TestSuiteLoader;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id: MavenTestSuiteLoader.java,v 1.1 2004/01/09 16:23:01 jvanzyl Exp $
*/
public class MavenTestSuiteLoader
implements TestSuiteLoader
{
private ClassLoader classLoader;
public MavenTestSuiteLoader( ClassLoader classLoader )
{
this.classLoader = classLoader;
}
public Class load( String className )
throws ClassNotFoundException
{
return classLoader.loadClass( className );
}
public Class reload( Class clazz )
throws ClassNotFoundException
{
return clazz;
}
}
@@ -0,0 +1,143 @@
package org.apache.maven.test;
import java.io.PrintStream;
import java.text.NumberFormat;
import java.util.Enumeration;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestFailure;
import junit.framework.TestListener;
import junit.framework.TestResult;
import junit.runner.BaseTestRunner;
public class ResultPrinter implements TestListener
{
PrintStream fWriter;
int fColumn = 0;
public ResultPrinter( PrintStream writer )
{
fWriter = writer;
}
synchronized void print( TestResult result, long runTime, String testName )
{
//printErrors( result );
//printFailures( result );
printFooter( result, runTime, testName );
}
protected void printErrors( TestResult result )
{
printDefects( result.errors(), result.errorCount(), "error" );
}
protected void printFailures( TestResult result )
{
printDefects( result.failures(), result.failureCount(), "failure" );
}
protected void printDefects( Enumeration booBoos, int count, String type )
{
if ( count == 0 )
{
return;
}
if ( count == 1 )
{
getWriter().println( "There was " + count + " " + type + ":" );
}
else
{
getWriter().println( "There were " + count + " " + type + "s:" );
}
for ( int i = 1; booBoos.hasMoreElements(); i++ )
{
printDefect( (TestFailure) booBoos.nextElement(), i );
}
}
public void printDefect( TestFailure booBoo, int count )
{ // only public for testing purposes
printDefectHeader( booBoo, count );
printDefectTrace( booBoo );
}
protected void printDefectHeader( TestFailure booBoo, int count )
{
// I feel like making this a println, then adding a line giving the throwable a chance to print something
// before we get to the stack trace.
getWriter().print( count + ") " + booBoo.failedTest() );
}
protected void printDefectTrace( TestFailure booBoo )
{
getWriter().print( BaseTestRunner.getFilteredTrace( booBoo.trace() ) );
}
protected void printFooter( TestResult result, long runtime, String testName )
{
getWriter().println( " [funit] Running " + testName );
getWriter().println( " [funit] Tests run: " + result.runCount() +
", Failures: " + result.failureCount() +
", Errors: " + result.errorCount() +
", Time elapsed: " + elapsedTimeAsString( runtime ) + " sec" );
printErrors( result );
printFailures( result );
}
/**
* Returns the formatted string of the elapsed time.
* Duplicated from BaseTestRunner. Fix it.
*/
protected String elapsedTimeAsString( long runTime )
{
return NumberFormat.getInstance().format( (double) runTime / 1000 );
}
public PrintStream getWriter()
{
return fWriter;
}
/**
* @see junit.framework.TestListener#addError(Test, Throwable)
*/
public void addError( Test test, Throwable t )
{
getWriter().print( "E" );
}
/**
* @see junit.framework.TestListener#addFailure(Test, AssertionFailedError)
*/
public void addFailure( Test test, AssertionFailedError t )
{
getWriter().print( "F" );
}
/**
* @see junit.framework.TestListener#endTest(Test)
*/
public void endTest( Test test )
{
}
/**
* @see junit.framework.TestListener#startTest(Test)
*/
public void startTest( Test test )
{
getWriter().print( "." );
if ( fColumn++ >= 40 )
{
getWriter().println();
fColumn = 0;
}
}
}
@@ -0,0 +1,215 @@
package org.apache.maven.test;
import junit.framework.Test;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import junit.runner.BaseTestRunner;
import junit.runner.TestSuiteLoader;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Iterator;
import java.util.List;
/**
* A command line based tool to run tests.
* <pre>
* java junit.textui.TestRunner [-wait] TestCaseClass
* </pre>
* TestRunner expects the name of a TestCase class as argument.
* If this class defines a static <code>suite</code> method it
* will be invoked and the returned test is run. Otherwise all
* the methods starting with "test" having no arguments are run.
* <p>
* When the wait command line argument is given TestRunner
* waits until the users types RETURN.
* <p>
* TestRunner prints a trace as the tests are executed followed by a
* summary at the end.
*/
public class TestRunner
extends BaseTestRunner
{
private ResultPrinter resultPrinter;
public static final int SUCCESS_EXIT = 0;
public static final int FAILURE_EXIT = 1;
public static final int EXCEPTION_EXIT = 2;
private static final String FS = System.getProperty( "file.separator" );
public TestRunner()
{
this( System.out );
}
public TestRunner( PrintStream writer )
{
this( new ResultPrinter( writer ) );
}
public TestRunner( ResultPrinter printer )
{
resultPrinter = printer;
}
private ClassLoader classLoader;
private List includes;
private List excludes;
private File basedir;
public void runTestClasses( File basedir, List includes, List excludes, ClassLoader classLoader )
throws Exception
{
this.basedir = basedir;
this.includes = includes;
this.excludes = excludes;
this.classLoader = classLoader;
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( new File( basedir, "target/test-classes" ) );
String[] incs = new String[includes.size()];
for ( int i = 0; i < incs.length; i++ )
{
incs[i] = StringUtils.replace( (String) includes.get( i ), "java", "class" );
}
scanner.setIncludes( incs );
String[] excls = new String[excludes.size() + 1];
for ( int i = 0; i < excls.length - 1; i++ )
{
excls[i] = StringUtils.replace( (String) excludes.get( i ), "java", "class" );
}
// Exclude inner classes
excls[excludes.size()] = "**/*$*";
scanner.setExcludes( excls );
scanner.scan();
String[] files = scanner.getIncludedFiles();
String s;
for ( int i = 0; i < files.length; i++ )
{
s = files[i];
s = s.substring( 0, s.indexOf( "." ) );
s = StringUtils.replace( s, FS, "." );
Class clazz = null;
try
{
clazz = classLoader.loadClass( s );
}
catch( ClassNotFoundException e )
{
System.out.println( "Can't find className = " + s );
continue;
}
TestResult result = run( clazz, s );
if ( result.errorCount() > 0 || result.failureCount() > 0 )
{
failures = "true";
}
}
}
private String failures = "false";
public String failures()
{
return failures;
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public TestResult run( Class testClass, String testName )
{
return run( new TestSuite( testClass ), testName );
//return run( new MavenJUnitTestSuite( testClass, classLoader ), testName );
}
public TestResult run( Test test, String testName )
{
TestRunner runner = new TestRunner();
return runner.doRun( test, testName );
}
public TestSuiteLoader getLoader()
{
return new MavenTestSuiteLoader( classLoader );
}
public void testFailed( int status, Test test, Throwable t )
{
}
public void testStarted( String testName )
{
}
public void testEnded( String testName )
{
}
protected TestResult createTestResult()
{
return new TestResult();
}
public TestResult doRun( Test suite, String testName )
{
TestResult result = createTestResult();
long startTime = System.currentTimeMillis();
suite.run( result );
long endTime = System.currentTimeMillis();
long runTime = endTime - startTime;
resultPrinter.print( result, runTime, testName );
return result;
}
protected void runFailed( String message )
{
System.err.println( message );
System.exit( FAILURE_EXIT );
}
public void setPrinter( ResultPrinter printer )
{
resultPrinter = printer;
}
}
@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="3" relativePaths="false">
<component version="2" name="ProjectRootManager">
<jdk name="java version &quot;1.4.2&quot;">
</jdk>
<projectPath>
<root type="composite">
<root url="file://$PROJECT_DIR$" type="simple">
</root>
</root>
</projectPath>
<sourcePath>
<root type="composite">
<root url="file://$PROJECT_DIR$/src/main" type="simple">
</root>
<root rootType="sourcePath" name="java version &quot;1.4.2&quot;" type="jdk">
</root>
</root>
</sourcePath>
<classPath>
<root type="composite">
<root rootType="classPath" name="java version &quot;1.4.2&quot;" type="jdk">
</root>
<root type="output">
</root>
<root url="jar:///home/jvanzyl/maven-repo-local/junit/jars/junit-3.8.1.jar!/" type="simple">
</root>
</root>
</classPath>
<javadocPath>
<root type="composite">
<root rootType="javadocPath" name="java version &quot;1.4.2&quot;" type="jdk">
</root>
</root>
</javadocPath>
<assert_keyword enabled="no">
</assert_keyword>
</component>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac">
</option>
<option name="SYNCHRONIZE_OUTPUT_DIRECTORY" value="false">
</option>
<option name="DEFAULT_OUTPUT_PATH">
</option>
<option name="OUTPUT_MODE" value="single">
</option>
<resourceExtensions>
<entry name=".+\.(properties|xml|html)">
</entry>
<entry name=".+\.(gif|png|jpeg)">
</entry>
</resourceExtensions>
</component>
<component name="JavacSettings">
<option name="DEBUGGING_INFO" value="true">
</option>
<option name="GENERATE_NO_WARNINGS" value="false">
</option>
<option name="DEPRECATION" value="true">
</option>
<option name="ADDITIONAL_OPTIONS_STRING" value="">
</option>
<option name="MAXIMUM_HEAP_SIZE" value="128">
</option>
</component>
<component name="JikesSettings">
<option name="DEBUGGING_INFO" value="true">
</option>
<option name="DEPRECATION" value="true">
</option>
<option name="GENERATE_NO_WARNINGS" value="false">
</option>
<option name="GENERATE_MAKE_FILE_DEPENDENCIES" value="false">
</option>
<option name="DO_FULL_DEPENDENCE_CHECK" value="false">
</option>
<option name="IS_INCREMENTAL_MODE" value="false">
</option>
<option name="IS_EMACS_ERRORS_MODE" value="true">
</option>
<option name="ADDITIONAL_OPTIONS_STRING" value="">
</option>
<option name="MAXIMUM_HEAP_SIZE" value="128">
</option>
</component>
<component name="AntConfiguration">
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false">
</option>
<option name="FILTER_TARGETS" value="false">
</option>
</component>
<component name="CvsManager">
</component>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY">
</option>
<option name="OPTION_SCOPE" value="protected">
</option>
<option name="OPTION_HIERARCHY" value="false">
</option>
<option name="OPTION_NAVIGATOR" value="false">
</option>
<option name="OPTION_INDEX" value="false">
</option>
<option name="OPTION_SEPARATE_INDEX" value="false">
</option>
<option name="OPTION_USE_1_1" value="false">
</option>
<option name="OPTION_DOCUMENT_TAG_USE" value="false">
</option>
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false">
</option>
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false">
</option>
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="false">
</option>
<option name="OPTION_DEPRECATED_LIST" value="false">
</option>
<option name="OTHER_OPTIONS">
</option>
<option name="HEAP_SIZE">
</option>
<option name="OPEN_IN_BROWSER" value="false">
</option>
</component>
<component name="WebManager">
<OPTION enabled="false">
</OPTION>
</component>
<component name="WebRootContainer">
</component>
<component enabled="false" name="EjbManager">
</component>
<component name="JUnitProjectSettings">
<option name="TEST_RUNNER" value="UI">
</option>
</component>
<component name="EntryPointsManager">
<entry_points>
</entry_points>
</component>
<component name="EjbActionsConfiguration">
<option name="NEW_MESSAGE_BEAN_LAST_PACKAGE" value="">
</option>
<option name="NEW_ENTITY_BEAN_LAST_PACKAGE" value="">
</option>
<option name="NEW_SESSION_BEAN_LAST_PACKAGE" value="">
</option>
</component>
<component name="ExportToHTMLSettings">
<option name="PRINT_LINE_NUMBERS" value="false">
</option>
<option name="OPEN_IN_BROWSER" value="false">
</option>
<option name="OUTPUT_DIRECTORY">
</option>
</component>
</project>
@@ -0,0 +1,704 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="3" relativePaths="false">
<component name="FileEditorManager">
<history>
</history>
<open_files>
</open_files>
</component>
<component name="ToolWindowManager">
<frame height="1004" x="1" width="1278" extended-state="0" y="1">
</frame>
<editor active="true">
</editor>
<layout>
<window_info id="Messages" auto_hide="true" order="-1" visible="false" active="false" anchor="bottom" weight="0.33" internal_type="sliding" type="sliding">
</window_info>
<window_info id="Run" auto_hide="false" order="2" visible="false" active="false" anchor="bottom" weight="0.33" internal_type="docked" type="docked">
</window_info>
<window_info id="Find" auto_hide="false" order="1" visible="false" active="false" anchor="bottom" weight="0.33" internal_type="docked" type="docked">
</window_info>
<window_info id="Project" auto_hide="false" order="0" visible="false" active="false" anchor="left" weight="0.25" internal_type="docked" type="docked">
</window_info>
<window_info id="Commander" auto_hide="false" order="0" visible="false" active="false" anchor="right" weight="0.4" internal_type="sliding" type="sliding">
</window_info>
<window_info id="TODO" auto_hide="false" order="6" visible="false" active="false" anchor="bottom" weight="0.33" internal_type="docked" type="docked">
</window_info>
<window_info id="Hierarchy" auto_hide="false" order="2" visible="false" active="false" anchor="right" weight="0.25" internal_type="docked" type="docked">
</window_info>
<window_info id="Ant Build" auto_hide="false" order="1" visible="false" active="false" anchor="right" weight="0.25" internal_type="docked" type="docked">
</window_info>
<window_info id="Inspection" auto_hide="false" order="5" visible="false" active="false" anchor="bottom" weight="0.4" internal_type="docked" type="docked">
</window_info>
<window_info id="Structure" auto_hide="false" order="1" visible="false" active="false" anchor="left" weight="0.25" internal_type="docked" type="docked">
</window_info>
<window_info id="Debug" auto_hide="false" order="3" visible="false" active="false" anchor="bottom" weight="0.4" internal_type="docked" type="docked">
</window_info>
<window_info id="EJB" auto_hide="false" order="3" visible="false" active="false" anchor="left" weight="0.25" internal_type="docked" type="docked">
</window_info>
<window_info id="Message" auto_hide="false" order="0" visible="false" active="false" anchor="bottom" weight="0.33" internal_type="docked" type="docked">
</window_info>
<window_info id="Web" auto_hide="false" order="2" visible="false" active="false" anchor="left" weight="0.25" internal_type="docked" type="docked">
</window_info>
<window_info id="Cvs" auto_hide="false" order="4" visible="false" active="false" anchor="bottom" weight="0.25" internal_type="docked" type="docked">
</window_info>
</layout>
</component>
<component name="Debugger">
<line_breakpoints>
</line_breakpoints>
<exception_breakpoints>
<breakpoint_any>
<option name="NOTIFY_CAUGHT" value="true">
</option>
<option name="NOTIFY_UNCAUGHT" value="true">
</option>
<option name="ENABLED" value="false">
</option>
<option name="SUSPEND_VM" value="true">
</option>
<option name="COUNT_FILTER_ENABLED" value="false">
</option>
<option name="COUNT_FILTER" value="0">
</option>
<option name="CONDITION_ENABLED" value="false">
</option>
<option name="CONDITION">
</option>
<option name="LOG_ENABLED" value="false">
</option>
<option name="LOG_EXPRESSION_ENABLED" value="false">
</option>
<option name="LOG_MESSAGE">
</option>
<option name="CLASS_FILTERS_ENABLED" value="false">
</option>
<option name="INVERSE_CLASS_FILLTERS" value="false">
</option>
<option name="SUSPEND_POLICY" value="SuspendAll">
</option>
</breakpoint_any>
</exception_breakpoints>
<field_breakpoints>
</field_breakpoints>
<method_breakpoints>
</method_breakpoints>
</component>
<component name="DebuggerManager">
</component>
<component name="DebuggerSettings">
<option name="TRACING_FILTERS_ENABLED" value="true">
</option>
<option name="VALUE_LOOKUP_DELAY" value="700">
</option>
<option name="DEBUGGER_TRANSPORT" value="0">
</option>
<option name="FORCE_CLASSIC_VM" value="true">
</option>
<option name="HIDE_DEBUGGER_ON_PROCESS_TERMINATION" value="false">
</option>
<option name="SKIP_SYNTHETIC_METHODS" value="true">
</option>
<option name="SKIP_CONSTRUCTORS" value="false">
</option>
<option name="STEP_THREAD_SUSPEND_POLICY" value="SuspendThread">
</option>
<default_breakpoint_settings>
<option name="NOTIFY_CAUGHT" value="true">
</option>
<option name="NOTIFY_UNCAUGHT" value="true">
</option>
<option name="WATCH_MODIFICATION" value="true">
</option>
<option name="WATCH_ACCESS" value="true">
</option>
<option name="WATCH_ENTRY" value="true">
</option>
<option name="WATCH_EXIT" value="true">
</option>
<option name="ENABLED" value="true">
</option>
<option name="SUSPEND_VM" value="true">
</option>
<option name="COUNT_FILTER_ENABLED" value="false">
</option>
<option name="COUNT_FILTER" value="0">
</option>
<option name="CONDITION_ENABLED" value="false">
</option>
<option name="CONDITION">
</option>
<option name="LOG_ENABLED" value="false">
</option>
<option name="LOG_EXPRESSION_ENABLED" value="false">
</option>
<option name="LOG_MESSAGE">
</option>
<option name="CLASS_FILTERS_ENABLED" value="false">
</option>
<option name="INVERSE_CLASS_FILLTERS" value="false">
</option>
<option name="SUSPEND_POLICY" value="SuspendAll">
</option>
</default_breakpoint_settings>
<filter>
<option name="PATTERN" value="com.sun.*">
</option>
<option name="ENABLED" value="true">
</option>
</filter>
<filter>
<option name="PATTERN" value="java.*">
</option>
<option name="ENABLED" value="true">
</option>
</filter>
<filter>
<option name="PATTERN" value="javax.*">
</option>
<option name="ENABLED" value="true">
</option>
</filter>
<filter>
<option name="PATTERN" value="org.omg.*">
</option>
<option name="ENABLED" value="true">
</option>
</filter>
<filter>
<option name="PATTERN" value="sun.*">
</option>
<option name="ENABLED" value="true">
</option>
</filter>
<filter>
<option name="PATTERN" value="junit.*">
</option>
<option name="ENABLED" value="true">
</option>
</filter>
</component>
<component name="CompilerWorkspaceConfiguration">
<option name="COMPILE_IN_BACKGROUND" value="false">
</option>
<option name="AUTO_SHOW_ERRORS_IN_EDITOR" value="true">
</option>
</component>
<component name="ErrorTreeViewConfiguration">
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false">
</option>
<option name="HIDE_WARNINGS" value="false">
</option>
</component>
<component name="DaemonCodeAnalyzer">
<disable_hints>
</disable_hints>
</component>
<component name="StructureViewFactory">
<option name="SORT_MODE" value="0">
</option>
<option name="GROUP_OVERRIDINGS" value="true">
</option>
<option name="GROUP_IMPLEMENTINGS" value="true">
</option>
<option name="AUTOSCROLL_MODE" value="true">
</option>
<option name="SHOW_METHODS" value="true">
</option>
<option name="SHOW_FIELDS" value="true">
</option>
<option name="AUTOSCROLL_FROM_SOURCE" value="false">
</option>
<option name="GROUP_GETTERS_AND_SETTERS" value="true">
</option>
</component>
<component name="CvsConfiguration">
<Checkout>
<option name="DATE_TAG" value="">
</option>
<option name="REVISION_TAG" value="">
</option>
<option name="PRUNE_EMPTY_DIRS" value="true">
</option>
<option name="RESET_STICKY_TAGS" value="false">
</option>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="CREATE_WORKING_DIR" value="">
</option>
<option name="ADDITIONAL_OPTIONS" value="">
</option>
</Checkout>
<Update>
<option name="DATE_TAG" value="">
</option>
<option name="REVISION_TAG" value="">
</option>
<option name="PRUNE_EMPTY_DIRS" value="true">
</option>
<option name="RESET_STICKY_TAGS" value="false">
</option>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="CREATE_MISSING_DIRECTORIES" value="true">
</option>
<option name="DONT_CHANGE_FILES" value="false">
</option>
<option name="QUIET_MODE" value="false">
</option>
<option name="ADDITIONAL_OPTIONS" value="">
</option>
</Update>
<Commit>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="REVISION_TAG">
</option>
<option name="LOG_MESSAGE">
</option>
<option name="ADDITIONAL_OPTIONS">
</option>
</Commit>
<Diff>
<option name="REVISION_TAG" value="HEAD">
</option>
<option name="DATE_TAG" value="">
</option>
<option name="IGNORE_WHITESPACE" value="false">
</option>
</Diff>
<Add>
<option name="ADD_AS_BINARY" value="false">
</option>
<option name="LOG_MESSAGE">
</option>
</Add>
<Status>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="INCLUDE_TAGS" value="false">
</option>
</Status>
<Edit>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="FORCE_RECURSIVE" value="false">
</option>
<option name="EDIT" value="false">
</option>
<option name="UNEDIT" value="false">
</option>
<option name="COMMIT" value="false">
</option>
<option name="ALL" value="true">
</option>
<option name="NONE" value="false">
</option>
</Edit>
<Remove>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="FORCE_RECURSIVE" value="false">
</option>
<option name="DELETE_FILE" value="false">
</option>
</Remove>
<Log>
<option name="DEFAULT_BRANCH" value="false">
</option>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="QUIET_MODE" value="true">
</option>
<option name="ADDITIONAL_OPTIONS" value="">
</option>
</Log>
<Editors>
<option name="NON_RECURSIVE" value="false">
</option>
<option name="FORCE_RECURSIVE" value="false">
</option>
</Editors>
<option name="CLIENT_PATH" value="">
</option>
<option name="EXTERNAL_DIFF_PATH">
</option>
<option name="CVS_ENABLED" value="false">
</option>
<option name="USE_EXTERNAL_DIFF" value="false">
</option>
<option name="WORKING_FILES_READONLY" value="false">
</option>
<option name="COMPRESSION_LEVEL" value="0">
</option>
<option name="ADDITIONAL_OPTIONS" value="">
</option>
<option name="BINARY_FILES_EXTENSIONS">
</option>
<option name="REUSE_LAST_LOG_MESSAGE" value="false">
</option>
<option name="PUT_FOCUS_INTO_LOG_MESSAGE" value="false">
</option>
<option name="SHOW_PROJECT_ROOTS" value="true">
</option>
<option name="SHOW_UPDATE_OPTIONS" value="true">
</option>
<option name="SHOW_COMMIT_OPTIONS" value="true">
</option>
<option name="SHOW_DIFF_OPTIONS" value="true">
</option>
<option name="SHOW_ADD_OPTIONS" value="true">
</option>
<option name="SHOW_STATUS_OPTIONS" value="true">
</option>
<option name="SHOW_EDIT_OPTIONS" value="true">
</option>
<option name="SHOW_UNEDIT_OPTIONS" value="true">
</option>
<option name="SHOW_REMOVE_OPTIONS" value="true">
</option>
<option name="SHOW_LOG_OPTIONS" value="true">
</option>
<option name="SHOW_EDITORS_OPTIONS" value="true">
</option>
<option name="HIDE_UNKNOWN_FILES" value="false">
</option>
<option name="HIDE_MISSING_FILES" value="false">
</option>
<option name="HIDE_UP_TO_DATE_FILES" value="false">
</option>
</component>
<component name="ProjectViewSettings">
<navigator flattenPackages="false" splitterProportion="0.5" autoscrollToSource="false" showMembers="false" showStructure="false" currentView="ProjectPane">
</navigator>
<view id="ProjectPane">
</view>
<view id="SourcepathPane">
</view>
<view id="ClasspathPane">
</view>
</component>
<component name="RunManager">
<option name="SHOW_SETTINGS_BEFORE_RUNNING" value="true">
</option>
<option name="COMPILE_BEFORE_RUNNING" value="true">
</option>
<activeType name="Application">
</activeType>
<configuration default="true" name="&lt;template&gt;" selected="false" type="Application">
<option name="MAIN_CLASS_NAME">
</option>
<option name="VM_PARAMETERS">
</option>
<option name="PROGRAM_PARAMETERS">
</option>
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$">
</option>
</configuration>
<configuration default="true" name="&lt;template&gt;" selected="false" type="Applet">
<option name="MAIN_CLASS_NAME">
</option>
<option name="HTML_FILE_NAME">
</option>
<option name="HTML_USED" value="false">
</option>
<option name="WIDTH" value="400">
</option>
<option name="HEIGHT" value="300">
</option>
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/config/appletviewer.policy">
</option>
<option name="VM_PARAMETERS">
</option>
</configuration>
<configuration default="true" name="&lt;template&gt;" selected="false" type="JUnit">
<option name="PACKAGE_NAME">
</option>
<option name="MAIN_CLASS_NAME">
</option>
<option name="METHOD_NAME">
</option>
<option name="TEST_OBJECT">
</option>
<option name="VM_PARAMETERS">
</option>
<option name="PARAMETERS">
</option>
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$">
</option>
</configuration>
<configuration default="true" name="&lt;template&gt;" selected="false" type="Remote">
<option name="USE_SOCKET_TRANSPORT" value="true">
</option>
<option name="SERVER_MODE" value="false">
</option>
<option name="SHMEM_ADDRESS" value="javadebug">
</option>
<option name="HOST" value="localhost">
</option>
<option name="PORT" value="5005">
</option>
</configuration>
<configuration default="true" name="&lt;template&gt;" selected="false" type="WebApp">
<WebServerIntegration>
</WebServerIntegration>
<Host>localhost</Host>
<Port>5050</Port>
</configuration>
</component>
<component name="BookmarkManager">
</component>
<component name="Commander">
<leftPanel view="Project" active="false">
</leftPanel>
<rightPanel view="Project" active="true">
</rightPanel>
<splitter proportion="0.5">
</splitter>
</component>
<component name="PropertiesComponent">
<property name="MemberChooser.showClasses" value="true">
</property>
<property name="GoToFile.includeJavaFiles" value="false">
</property>
<property name="MemberChooser.sorted" value="false">
</property>
<property name="GoToClass.includeLibraries" value="false">
</property>
<property name="MemberChooser.copyJavadoc" value="false">
</property>
<property name="GoToClass.toSaveIncludeLibraries" value="false">
</property>
</component>
<component name="SelectInManager">
</component>
<component name="VssConfiguration">
<CheckoutOptions>
<option name="COMMENT" value="">
</option>
<option name="DO_NOT_GET_LATEST_VERSION" value="false">
</option>
<option name="REPLACE_WRITABLE" value="false">
</option>
<option name="RECURSIVE" value="false">
</option>
</CheckoutOptions>
<CheckinOptions>
<option name="COMMENT" value="">
</option>
<option name="KEEP_CHECKED_OUT" value="false">
</option>
<option name="RECURSIVE" value="false">
</option>
</CheckinOptions>
<AddOptions>
<option name="COMMENT" value="">
</option>
<option name="STORE_ONLY_LATEST_VERSION" value="false">
</option>
<option name="CHECK_OUT_IMMEDIATELY" value="false">
</option>
<option name="FILE_TYPE" value="0">
</option>
</AddOptions>
<UndocheckoutOptions>
<option name="MAKE_WRITABLE" value="false">
</option>
<option name="REPLACE_LOCAL_COPY" value="0">
</option>
<option name="RECURSIVE" value="false">
</option>
</UndocheckoutOptions>
<DiffOptions>
<option name="IGNORE_WHITE_SPACE" value="false">
</option>
<option name="IGNORE_CASE" value="false">
</option>
</DiffOptions>
<GetOptions>
<option name="REPLACE_WRITABLE" value="0">
</option>
<option name="MAKE_WRITABLE" value="false">
</option>
<option name="RECURSIVE" value="false">
</option>
</GetOptions>
<option name="ENABLED" value="false">
</option>
<option name="CLIENT_PATH" value="">
</option>
<option name="SRCSAFEINI_PATH" value="">
</option>
<option name="USER_NAME" value="">
</option>
<option name="PWD" value="">
</option>
<option name="SHOW_CHECKOUT_OPTIONS" value="true">
</option>
<option name="SHOW_CHECKIN_OPTIONS" value="true">
</option>
<option name="SHOW_ADD_OPTIONS" value="true">
</option>
<option name="SHOW_UNDOCHECKOUT_OPTIONS" value="true">
</option>
<option name="SHOW_DIFF_OPTIONS" value="true">
</option>
<option name="SHOW_GET_OPTIONS" value="true">
</option>
<option name="USE_EXTERNAL_DIFF" value="false">
</option>
<option name="EXTERNAL_DIFF_PATH" value="">
</option>
<option name="REUSE_LAST_COMMENT" value="false">
</option>
<option name="PUT_FOCUS_INTO_COMMENT" value="false">
</option>
</component>
<component name="HierarchyBrowserManager">
<option name="SHOW_PACKAGES" value="false">
</option>
<option name="IS_AUTOSCROLL_TO_SOURCE" value="false">
</option>
<option name="SORT_ALPHABETICALLY" value="false">
</option>
</component>
<component name="WebViewSettings">
<webview flattenPackages="false" autoscrollToSource="false" showMembers="false">
</webview>
</component>
<component name="EjbViewSettings">
<EjbView autoscrollToSource="false" showMembers="false">
</EjbView>
</component>
<component name="LvcsConfiguration">
<option name="LOCAL_VCS_ENABLED" value="true">
</option>
<option name="LOCAL_VCS_PURGING_PERIOD" value="259200000">
</option>
<option name="ADD_LABEL_ON_PROJECT_OPEN" value="true">
</option>
<option name="ADD_LABEL_ON_PROJECT_COMPILATION" value="true">
</option>
<option name="ADD_LABEL_ON_FILE_PACKAGE_COMPILATION" value="true">
</option>
<option name="ADD_LABEL_ON_PROJECT_MAKE" value="true">
</option>
<option name="ADD_LABEL_ON_RUNNING" value="true">
</option>
<option name="ADD_LABEL_ON_DEBUGGING" value="true">
</option>
<option name="ADD_LABEL_ON_UNIT_TEST" value="true">
</option>
</component>
<component name="InspectionManager">
<option name="AUTOSCROLL_TO_SOURCE" value="false">
</option>
<option name="SPLITTER_PROPORTION" value="0.5">
</option>
<inspection_tool enabled="true" class="Unreachable declaration">
<option name="ADD_MAINS_TO_ENTRIES" value="true">
</option>
<option name="ADD_JUNIT_TO_ENTRIES" value="true">
</option>
<option name="ADD_EJB_TO_ENTRIES" value="true">
</option>
<option name="ADD_APPLET_TO_ENTRIES" value="true">
</option>
<option name="ADD_SERVLET_TO_ENTRIES" value="true">
</option>
<option name="ADD_NONJAVA_TO_ENTRIES" value="true">
</option>
</inspection_tool>
<inspection_tool enabled="true" class="Declaration access can be weaker">
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true">
</option>
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true">
</option>
<option name="SUGGEST_PRIVATE_FOR_INNERS" value="false">
</option>
</inspection_tool>
<inspection_tool enabled="true" class="Declaration can have static modifier">
</inspection_tool>
<inspection_tool enabled="true" class="Declaration can have final modifier">
<option name="REPORT_CLASSES" value="false">
</option>
<option name="REPORT_METHODS" value="false">
</option>
<option name="REPORT_FIELDS" value="true">
</option>
</inspection_tool>
<inspection_tool enabled="true" class="Unused method parameters">
</inspection_tool>
<inspection_tool enabled="true" class="Constant conditions &amp; NPEs">
</inspection_tool>
<inspection_tool enabled="true" class="Assignment is not used">
</inspection_tool>
<inspection_tool enabled="true" class="Type cast is redundant">
</inspection_tool>
<inspection_tool enabled="true" class="Declaration has javadoc problems">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="public">
</option>
<option name="REQUIRED_TAGS" value="">
</option>
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="protected">
</option>
<option name="REQUIRED_TAGS" value="">
</option>
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="protected">
</option>
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception">
</option>
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="protected">
</option>
<option name="REQUIRED_TAGS" value="">
</option>
</value>
</option>
</inspection_tool>
<inspection_tool enabled="false" class="Empty method">
</inspection_tool>
<inspection_tool enabled="false" class="Unused method return value">
</inspection_tool>
<inspection_tool enabled="false" class="Method returns the same value">
</inspection_tool>
<inspection_tool enabled="false" class="Actual method parameter is the same constant">
</inspection_tool>
</component>
<component name="TodoView" selected-index="0">
<todo-panel id="selected-file">
<are-packages-shown value="false">
</are-packages-shown>
<flattern-packages value="false">
</flattern-packages>
<is-autoscroll-to-source value="true">
</is-autoscroll-to-source>
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true">
</are-packages-shown>
<flattern-packages value="false">
</flattern-packages>
<is-autoscroll-to-source value="true">
</is-autoscroll-to-source>
</todo-panel>
</component>
<component name="VcsManagerConfiguration">
<option name="ACTIVE_VCS_NAME" value="">
</option>
</component>
</project>
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
rm -rf target
maven jar:jar
( cd ~/.maven/plugins ; rm -rf maven-test-plugin* )
rm -f ~/maven/plugins/maven-test-plugin*.jar
cp target/maven-test-plugin*.jar ~/maven/plugins
rm -f ~/.maven/plugins/*.cache
+1
View File
@@ -0,0 +1 @@
stylesheets
+50
View File
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<document>
<properties>
<title>Changes</title>
<author email="dion@multitask.com.au">dIon Gillard</author>
</properties>
<body>
<release version="1.4" date="2003-09-29">
<action dev="dion" type="update">
Apply MAVEN-309. Reorganise classpaths so that it's test, build, dependencies
and then JUnit
</action>
<action dev="jstrachan" type="fix">
You can now specify whether the source (java) or classes (class) files
are searched when using the test plugin via the property:
maven.test.search.classdir. It defaults to use (java) to preserve
backwards compatibilty. Using (class) allows you to work with alternative
languages that compile to bytecode like
<a href="http://groovy.codehaus.org/">Groovy</a>
</action>
<action dev="evenisse" type="fix">
Check if unitTest tag is present in pom before copy resources.
</action>
</release>
<release version="1.3" date="Unknown">
<action dev="evenisse" type="add">
Add jvmarg support for junit.
Add properties documentation.
</action>
</release>
<release version="1.2" date="2003-02-11">
<action dev="evenisse" type="fix">
Fixed classpath for test:ui, test:single and test:match goals.
</action>
<action dev="dion" type="fix">
Added xmlapis and xerces to project dependencies as per MAVEN-106
bug report
</action>
</release>
<release version="1.1" date="2002-10-01">
<action dev="vmassol" type="fix">
The test plugin now works again if the project has not
tests defined. The introduction of the &lt;test:test-resources&gt;
goal had broken this feature.
</action>
</release>
</body>
</document>
+52
View File
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<title>Maven test Plug-in Goals</title>
<author email="dion@apache.org">dIon Gillard</author>
</properties>
<body>
<goals>
<goal>
<name>test</name>
<description>Test the application</description>
</goal>
<goal>
<name>test:compile</name>
<description>Compile the TestCases and TestSuites</description>
</goal>
<goal>
<name>test:match</name>
<description>Execute all the tests matching the given 'testmatch' variable</description>
</goal>
<goal>
<name>test:match-test</name>
<description>[deprecated] please use the test:match goal instead</description>
</goal>
<goal>
<name>test:prepare-filesystem</name>
<description>Create the needed directory structure</description>
</goal>
<goal>
<name>test:single</name>
<description>Execute a single test defined using the 'testcase' variable</description>
</goal>
<goal>
<name>test:single-test</name>
<description>[deprecated] please use the test:single goal instead</description>
</goal>
<goal>
<name>test:test</name>
<description>Test the application</description>
</goal>
<goal>
<name>test:test-resources</name>
<description>Copy any resources that must be present for run tests</description>
</goal>
<goal>
<name>test:ui</name>
<description>Starts the Swing TestRunner front end</description>
</goal>
</goals>
</body>
</document>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<document>
<properties>
<title>Maven Test Plugin</title>
<author email="jason@zenplex.com">Jason van Zyl</author>
</properties>
<body>
<section name="Maven Test Plugin">
<p>
This plug-in provides your basic JUnit testing facilities.
</p>
</section>
</body>
</document>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Maven Test Plugin">
<title>Maven Test Plugin</title>
<body>
<links>
<item name="Maven" href="http://maven.apache.org/"/>
<item name="JUnit" href="http://junit.sourceforge.net/"/>
</links>
<menu name="Overview">
<item name="Goals" href="/goals.html"/>
<item name="Properties" href="/properties.html"/>
</menu>
</body>
</project>
+207
View File
@@ -0,0 +1,207 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<properties>
<title>Test Properties</title>
<author email="smor@apache.org">Stéphane MOR</author>
</properties>
<body>
<section name="Test Settings">
<table>
<tr><th>Property</th><th>Optional?</th><th>Description</th></tr>
<tr>
<td>maven.junit.fork</td>
<td>Yes</td>
<td>
When using Java 1.4, it may be necessary to fork the JUnit
tests to prevent XML parser issues. The default value is
<code>no</code>.
</td>
</tr>
<tr>
<td>maven.junit.dir</td>
<td>Yes</td>
<td>
The directory to invoke the VM in. (ignored if fork is disabled).
The default value is <code>${basedir}</code>.
</td>
</tr>
<tr>
<td>maven.junit.usefile</td>
<td>Yes</td>
<td>
If this value is set to false, JUnit test run details will appear on
the console as the tests are executed. If not, they are stored in
a file in the <code>test-reports</code> directory. The default value
is <code>true</code>.
</td>
</tr>
<tr>
<td>maven.junit.printSummary</td>
<td>Yes</td>
<td>
If this value is set to false, JUnit test run details will not
include test summary information for a suite. Default value is
<code>true</code>. This parameter corresponds to the JUnit Ant
task <code>printSummary</code> attribute.
</td>
</tr>
<tr>
<td>maven.test.dest</td>
<td>Yes</td>
<td>
Specifies the unit test classes directory. This is the
location where the java classes for the test source
code will be generated to. The default value is
<code>${maven.build.dir}/test-classes</code>.
</td>
</tr>
<tr>
<td>maven.test.skip</td>
<td>Yes</td>
<td>
Set this to 'true' to bypass unit tests entirely. Its use
is <b>NOT RECOMMENDED</b>, but quite convenient on occasion.
</td>
</tr>
<tr>
<td>maven.test.failure.ignore</td>
<td>Yes</td>
<td>
Set this to any value to ignore a failure during testing.
Its use is <b>NOT RECOMMENDED</b>, but quite convenient on occasion.
</td>
</tr>
<tr>
<td>maven.test.source</td>
<td>Yes</td>
<td>
<p>
Provide source compatibility with a specific release
</p>
<p>
Corresponds to the <code>source</code> attribute for the ant
<a href="http://ant.apache.org/manual/CoreTasks/javac.html">javac</a>
task.
</p>
</td>
</tr>
<tr>
<td>maven.iutest.dest</td>
<td>Yes</td>
<td>
Specifies the integration unit test classes directory.
This is the location where the java classes for the
integration unit test source code will be generated to.
The default value is
<code>${maven.build.dir}/iutest-classes</code>.
</td>
</tr>
<tr>
<td>maven.iutest.dir</td>
<td>Yes</td>
<td>
Specifies the integration unit test source directory.
This property should never be overridden as the value is
determined directly from the project descriptor. The
default value is
<code>${maven.integrationUnitTestSourceDirectory}</code>.
</td>
</tr>
<tr>
<td>maven.out.test.dir</td>
<td>Yes</td>
<td>
Specifies the directory where the integration unit testing
is run. The default value is <code>${build.dir}/iutest</code>.
</td>
</tr>
<tr>
<td>maven.webapp.dir</td>
<td>Yes</td>
<td>
Specifies the directory of the web application used to
perform integration unit testing. The default value is
<code>${iutest.dir}/testapp</code>.
</td>
</tr>
<tr>
<td>maven.conf.test.dir</td>
<td>Yes</td>
<td>
Specifies the configuration directory used to build the
web application used for integration unit testing. The
default value is <code>${iutest.dir}/cactus</code>.
</td>
</tr>
<tr>
<td>maven.tomcat.home</td>
<td>Yes</td>
<td>
Specifies your local Tomcat installation directory.
The default value is <code>${tdk.home}</code>. If
<code>${tdk.home}</code> is not specified in your
<code>${user.home}/build.properties</code>, you should set
this property. This is used for the integration unit
testing.
</td>
</tr>
<tr>
<td>maven.test.port</td>
<td>Yes</td>
<td>
Specifies the port that Tomcat will use for integration
unit testing. The default value is <code>8192</code>.
</td>
</tr>
<tr>
<td>maven.junit.jvmargs</td>
<td>Yes</td>
<td>
If fork is enabled, additional parameters may be passed to the new VM.
You can specify some args separate by space.
Each arg is describe in sub properties.
Sample :
<source><![CDATA[
maven.junit.jvmargs=-Xmx160m -verbose
]]>
</source>
</td>
</tr>
<tr>
<td>maven.junit.sysproperties</td>
<td>Yes</td>
<td>
Use this property elements to specify system properties required
by the class. These properties will be made available to the VM during
the execution of the test (either Maven's VM or the forked VM, if fork is enabled).
You can specify system properties separate by space.
Each properties is describe in sub properties.
Sample :
<source><![CDATA[
maven.junit.sysproperties=prop1 basedir
prop1=your value
basedir=${basedir}
]]>
</source>
</td>
</tr>
<tr>
<td>maven.test.search.classdir</td>
<td>Yes</td>
<td>
Use this property to specify that JUnit should search the test classes directory
rather than the source directory. This allows for test cases to be written in other
languages such as Groovy which generate bytecode that can then be used by this plugin.
Sample :
<source><![CDATA[
maven.test.search.classdir=true
]]>
</source>
</td>
</tr>
</table>
</section>
</body>
</document>