Author: stephenc
Date: Tue Jan 12 08:32:58 2010
New Revision: 898247
URL: http://svn.apache.org/viewvc?rev=898247&view=rev
Log:
o Reformatting to Maven style (according to
http://maven.apache.org/developers/maven-idea-codestyle.xml )
Modified:
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Modified:
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=898247&r1=898246&r2=898247&view=diff
==============================================================================
---
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
(original)
+++
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
Tue Jan 12 08:32:58 2010
@@ -19,13 +19,12 @@
* under the License.
*/
+import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
import java.io.FileOutputStream;
-import java.io.Writer;
+import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.io.BufferedOutputStream;
+import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -45,7 +44,6 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
@@ -59,6 +57,8 @@
import org.apache.maven.surefire.booter.SurefireBooter;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.booter.SurefireExecutionException;
+import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
+import
org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
import org.apache.maven.surefire.report.BriefConsoleReporter;
import org.apache.maven.surefire.report.BriefFileReporter;
import org.apache.maven.surefire.report.ConsoleReporter;
@@ -68,14 +68,8 @@
import org.apache.maven.surefire.report.XMLReporter;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
-import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.FileUtils;
-
-
-import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import
org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
-import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
+import org.codehaus.plexus.util.StringUtils;
/**
* Run integration tests using Surefire.
@@ -112,9 +106,9 @@
/**
* This old parameter is just like skipTests, but bound to the old
property maven.test.skip.exec.
*
- * @deprecated Use -DskipTests instead.
* @parameter expression="${maven.test.skip.exec}"
* @since 2.3
+ * @deprecated Use -DskipTests instead.
*/
private boolean skipExec;
@@ -239,8 +233,9 @@
/**
* List of System properties to pass to the JUnit tests.
- * @deprecated Use systemPropertyVariables instead.
+ *
* @parameter
+ * @deprecated Use systemPropertyVariables instead.
*/
private Properties systemProperties;
@@ -281,6 +276,7 @@
/**
* The summary file to write integration test results to.
+ *
* @parameter
expression="${project.build.directory}/failsafe-reports/failsafe-summary.xml"
* @required
*/
@@ -465,11 +461,12 @@
* @since 2.5
*/
private String useUnlimitedThreads;
+
/**
* (TestNG only) When you use the parallel attribute, TestNG will try to
run all your test methods in separate threads, except for
* methods that depend on each other, which will be run in the same thread
in order to respect their order of
* execution.
- *
+ * <p/>
* In JUnit 4.7 the values are classes/methods/both to run in separate
threads, as controlled by threadCount.
*
* @parameter expression="${parallel}"
@@ -545,12 +542,12 @@
private Boolean useSystemClassLoader;
/**
- * By default, Surefire forks your tests using a manifest-only jar; set
this parameter
+ * By default, Surefire forks your tests using a manifest-only JAR; set
this parameter
* to "false" to force it to launch your tests with a plain old Java
classpath.
* (See
http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
- * for a more detailed explanation of manifest-only jars and their
benefits.)
- *
- * Default value is "true". Beware, setting this to "false" may cause
your tests to
+ * for a more detailed explanation of manifest-only JARs and their
benefits.)
+ * <p/>
+ * Beware, setting this to "false" may cause your tests to
* fail on Windows if your classpath is too long.
*
* @parameter expression="${failsafe.useManifestOnlyJar}"
default-value="true"
@@ -591,7 +588,9 @@
*/
protected String encoding;
- /** @component */
+ /**
+ * @component
+ */
private ToolchainManager toolchainManager;
@@ -607,7 +606,7 @@
FailsafeSummary result = new FailsafeSummary();
try
{
- result.setResult(surefireBooter.run());
+ result.setResult( surefireBooter.run() );
}
catch ( SurefireBooterForkException e )
{
@@ -624,11 +623,13 @@
System.setProperties( originalSystemProperties );
}
- if (!summaryFile.getParentFile().isDirectory()) {
+ if ( !summaryFile.getParentFile().isDirectory() )
+ {
summaryFile.getParentFile().mkdirs();
}
- try {
+ try
+ {
String encoding;
if ( StringUtils.isEmpty( this.encoding ) )
{
@@ -636,19 +637,23 @@
"File encoding has not been set, using platform
encoding " + ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent!" );
encoding = ReaderFactory.FILE_ENCODING;
- } else {
+ }
+ else
+ {
encoding = this.encoding;
}
FileOutputStream fileOutputStream = new FileOutputStream(
summaryFile );
- BufferedOutputStream bufferedOutputStream = new
BufferedOutputStream( fileOutputStream);
+ BufferedOutputStream bufferedOutputStream = new
BufferedOutputStream( fileOutputStream );
Writer writer = new OutputStreamWriter( bufferedOutputStream,
encoding );
FailsafeSummaryXpp3Writer xpp3Writer = new
FailsafeSummaryXpp3Writer();
xpp3Writer.write( writer, result );
writer.close();
bufferedOutputStream.close();
fileOutputStream.close();
- } catch ( IOException e ) {
+ }
+ catch ( IOException e )
+ {
throw new MojoExecutionException( e.getMessage(), e );
}
}
@@ -715,10 +720,11 @@
}
}
- private boolean isAnyConcurrencySelected(){
- return this.parallel != null && this.parallel.trim().length() > 0;
+ private boolean isAnyConcurrencySelected()
+ {
+ return this.parallel != null && this.parallel.trim().length() > 0;
}
-
+
/**
* Converts old TestNG configuration parameters over to new properties
based configuration
* method. (if any are defined the old way)
@@ -740,26 +746,34 @@
}
if ( this.perCoreThreadCount != null )
{
- properties.setProperty( "perCoreThreadCount", perCoreThreadCount);
+ properties.setProperty( "perCoreThreadCount", perCoreThreadCount );
}
if ( this.useUnlimitedThreads != null )
{
- properties.setProperty( "useUnlimitedThreads",
useUnlimitedThreads);
+ properties.setProperty( "useUnlimitedThreads", useUnlimitedThreads
);
}
- Artifact configurableParallelComputer = (Artifact)
projectArtifactMap.get("org.jdogma.junit:configurable-parallel-computer");
- properties.setProperty("configurableParallelComputerPresent",
Boolean.toString(configurableParallelComputer != null));
+ Artifact configurableParallelComputer =
+ (Artifact) projectArtifactMap.get(
"org.jdogma.junit:configurable-parallel-computer" );
+ properties.setProperty( "configurableParallelComputerPresent",
+ Boolean.toString( configurableParallelComputer
!= null ) );
}
- private boolean isJunit47Compatible(Artifact artifact) throws
MojoExecutionException {
- return isWithinVersionSpec(artifact, "[4.7,)");
+ private boolean isJunit47Compatible( Artifact artifact )
+ throws MojoExecutionException
+ {
+ return isWithinVersionSpec( artifact, "[4.7,)" );
}
- private boolean isAnyJunit4(Artifact artifact) throws
MojoExecutionException {
- return isWithinVersionSpec(artifact, "[4.0,)");
+ private boolean isAnyJunit4( Artifact artifact )
+ throws MojoExecutionException
+ {
+ return isWithinVersionSpec( artifact, "[4.0,)" );
}
- private boolean isWithinVersionSpec(Artifact artifact, String versionSpec)
throws MojoExecutionException {
+ private boolean isWithinVersionSpec( Artifact artifact, String versionSpec
)
+ throws MojoExecutionException
+ {
if ( artifact == null )
{
return false;
@@ -819,11 +833,11 @@
if ( testNgArtifact != null )
{
VersionRange range = VersionRange.createFromVersionSpec(
"[4.7,)" );
- if ( !range.containsVersion( new
DefaultArtifactVersion(testNgArtifact.getVersion()) ) )
+ if ( !range.containsVersion( new DefaultArtifactVersion(
testNgArtifact.getVersion() ) ) )
{
throw new MojoFailureException(
- "TestNG support requires
version 4.7 or above. You have declared version " +
-
testNgArtifact.getVersion() );
+ "TestNG support requires version 4.7 or above. You
have declared version "
+ + testNgArtifact.getVersion() );
}
convertTestNGParameters();
@@ -838,18 +852,18 @@
// The plugin uses a JDK based profile to select the right
testng. We might be explicity using a
// different one since its based on the source level, not the
JVM. Prune using the filter.
addProvider( surefireBooter, "surefire-testng",
surefireArtifact.getBaseVersion(), testNgArtifact );
- }
+ }
else if ( junitArtifact != null && isAnyJunit4( junitArtifact ) )
{
- if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
- {
- convertJunitCoreParameters();
- addProvider( surefireBooter, "surefire-junit47",
surefireArtifact.getBaseVersion(), null );
- }
- else
- {
- addProvider( surefireBooter, "surefire-junit4",
surefireArtifact.getBaseVersion(), null );
- }
+ if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
+ {
+ convertJunitCoreParameters();
+ addProvider( surefireBooter, "surefire-junit47",
surefireArtifact.getBaseVersion(), null );
+ }
+ else
+ {
+ addProvider( surefireBooter, "surefire-junit4",
surefireArtifact.getBaseVersion(), null );
+ }
}
else
{
@@ -860,8 +874,8 @@
}
catch ( ArtifactNotFoundException e )
{
- throw new MojoExecutionException( "Unable to locate required
surefire provider dependency: " +
- e.getMessage(), e );
+ throw new MojoExecutionException(
+ "Unable to locate required surefire provider dependency: " +
e.getMessage(), e );
}
catch ( InvalidVersionSpecificationException e )
{
@@ -880,8 +894,10 @@
}
// TODO: properties should be passed in here too
- surefireBooter.addTestSuite(
"org.apache.maven.surefire.testng.TestNGXmlTestSuite", new Object[]{
- suiteXmlFiles, testSourceDirectory.getAbsolutePath(),
testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties,
reportsDirectory} );
+ surefireBooter.addTestSuite(
"org.apache.maven.surefire.testng.TestNGXmlTestSuite",
+ new Object[]{suiteXmlFiles,
testSourceDirectory.getAbsolutePath(),
+ testNgArtifact.getVersion(),
testNgArtifact.getClassifier(), properties,
+ reportsDirectory} );
}
else
{
@@ -928,8 +944,8 @@
// Have to wrap in an ArrayList as surefire expects an
ArrayList instead of a List for some reason
if ( includes == null || includes.size() == 0 )
{
- includes = new ArrayList( Arrays.asList( new
String[]{"**/IT*.java", "**/*IT.java",
- "**/*ITCase.java"} ) );
+ includes =
+ new ArrayList( Arrays.asList( new
String[]{"**/IT*.java", "**/*IT.java", "**/*ITCase.java"} ) );
}
if ( excludes == null || excludes.size() == 0 )
{
@@ -939,14 +955,15 @@
if ( testNgArtifact != null )
{
-
surefireBooter.addTestSuite("org.apache.maven.surefire.testng.TestNGDirectoryTestSuite",
new Object[]{
- testClassesDirectory, includes, excludes,
testSourceDirectory.getAbsolutePath(),
- testNgArtifact.getVersion(),
testNgArtifact.getClassifier(), properties, reportsDirectory});
+ surefireBooter.addTestSuite(
"org.apache.maven.surefire.testng.TestNGDirectoryTestSuite",
+ new
Object[]{testClassesDirectory, includes, excludes,
+
testSourceDirectory.getAbsolutePath(), testNgArtifact.getVersion(),
+
testNgArtifact.getClassifier(), properties, reportsDirectory} );
}
else
{
String junitDirectoryTestSuite;
- if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
+ if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
{
junitDirectoryTestSuite =
"org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
getLog().info( "Concurrency config is " +
properties.toString() );
@@ -977,8 +994,8 @@
// Check if we need to add configured classes/test classes directories
here.
// If they are configured, we should remove the default to avoid
conflicts.
- File projectClassesDirectory = new File (
project.getBuild().getOutputDirectory() );
- if ( ! projectClassesDirectory.equals( classesDirectory ) )
+ File projectClassesDirectory = new File(
project.getBuild().getOutputDirectory() );
+ if ( !projectClassesDirectory.equals( classesDirectory ) )
{
int indexToReplace = classpathElements.indexOf(
project.getBuild().getOutputDirectory() );
if ( indexToReplace != -1 )
@@ -1074,7 +1091,8 @@
if ( "true".equals( debugForkedProcess ) )
{
- debugForkedProcess = "-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005";
+ debugForkedProcess =
+ "-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005";
}
fork.setDebugLine( debugForkedProcess );
@@ -1147,7 +1165,8 @@
}
}
- private void addProvider( SurefireBooter surefireBooter, String provider,
String version, Artifact filteredArtifact )
+ private void addProvider( SurefireBooter surefireBooter, String provider,
String version,
+ Artifact filteredArtifact )
throws ArtifactNotFoundException, ArtifactResolutionException
{
Artifact providerArtifact = artifactFactory.createDependencyArtifact(
"org.apache.maven.surefire", provider,
@@ -1171,9 +1190,8 @@
ArtifactFilter filter = null;
if ( filteredArtifact != null )
{
- filter =
- new ExcludesArtifactFilter( Collections.singletonList(
filteredArtifact.getGroupId() + ":" +
- filteredArtifact.getArtifactId() ) );
+ filter = new ExcludesArtifactFilter(
+ Collections.singletonList( filteredArtifact.getGroupId() + ":"
+ filteredArtifact.getArtifactId() ) );
}
Artifact originatingArtifact = artifactFactory.createBuildArtifact(
"dummy", "dummy", "1.0", "jar" );
@@ -1257,9 +1275,9 @@
}
/**
- * <p>
+ * <p/>
* Adds Reporters that will generate reports with different formatting.
- * <p>
+ * <p/>
* The Reporter that will be added will be based on the value of the
parameter useFile, reportFormat, and
* printSummary.
*
@@ -1275,40 +1293,40 @@
{
if ( forking )
{
- surefireBooter.addReport(
ForkingConsoleReporter.class.getName(), new Object[] { trimStackTrace } );
+ surefireBooter.addReport(
ForkingConsoleReporter.class.getName(), new Object[]{trimStackTrace} );
}
else
{
- surefireBooter.addReport( ConsoleReporter.class.getName(),
new Object[] { trimStackTrace } );
+ surefireBooter.addReport( ConsoleReporter.class.getName(),
new Object[]{trimStackTrace} );
}
}
if ( BRIEF_REPORT_FORMAT.equals( reportFormat ) )
{
- surefireBooter.addReport( BriefFileReporter.class.getName(),
new Object[] { reportsDirectory,
- trimStackTrace } );
+ surefireBooter.addReport( BriefFileReporter.class.getName(),
+ new Object[]{reportsDirectory,
trimStackTrace} );
}
else if ( PLAIN_REPORT_FORMAT.equals( reportFormat ) )
{
surefireBooter.addReport( FileReporter.class.getName(),
- new Object[] { reportsDirectory,
trimStackTrace } );
+ new Object[]{reportsDirectory,
trimStackTrace} );
}
}
else
{
if ( BRIEF_REPORT_FORMAT.equals( reportFormat ) )
{
- surefireBooter.addReport(
BriefConsoleReporter.class.getName(), new Object[] { trimStackTrace } );
+ surefireBooter.addReport(
BriefConsoleReporter.class.getName(), new Object[]{trimStackTrace} );
}
else if ( PLAIN_REPORT_FORMAT.equals( reportFormat ) )
{
- surefireBooter.addReport(
DetailedConsoleReporter.class.getName(), new Object[] { trimStackTrace } );
+ surefireBooter.addReport(
DetailedConsoleReporter.class.getName(), new Object[]{trimStackTrace} );
}
}
if ( !disableXmlReport )
{
- surefireBooter.addReport( XMLReporter.class.getName(), new
Object[] { reportsDirectory, trimStackTrace } );
+ surefireBooter.addReport( XMLReporter.class.getName(), new
Object[]{reportsDirectory, trimStackTrace} );
}
}
@@ -1328,8 +1346,6 @@
this.skipTests = skipExec;
}
- //TODO remove the part with ToolchainManager lookup once we depend on
- //2.0.9 (have it as prerequisite). Define as regular component field then.
private Toolchain getToolchain()
{
Toolchain tc = null;
Modified:
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java?rev=898247&r1=898246&r2=898247&view=diff
==============================================================================
---
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
(original)
+++
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
Tue Jan 12 08:32:58 2010
@@ -19,55 +19,21 @@
* under the License.
*/
+import java.io.BufferedInputStream;
import java.io.File;
-import java.io.IOException;
import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.io.Reader;
+import java.io.IOException;
import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.execution.MavenSession;
+import java.io.Reader;
+
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.surefire.booter.ForkConfiguration;
import org.apache.maven.surefire.booter.SurefireBooter;
-import org.apache.maven.surefire.booter.SurefireBooterForkException;
-import org.apache.maven.surefire.booter.SurefireExecutionException;
-import org.apache.maven.surefire.report.BriefConsoleReporter;
-import
org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
-import
org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Reader;
import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
-import org.codehaus.plexus.util.StringUtils;
+import
org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Reader;
import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/**
@@ -104,9 +70,9 @@
/**
* This old parameter is just like skipTests, but bound to the old
property maven.test.skip.exec.
*
- * @deprecated Use -DskipTests instead.
* @parameter expression="${maven.test.skip.exec}"
* @since 2.3
+ * @deprecated Use -DskipTests instead.
*/
private boolean skipExec;
Modified:
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=898247&r1=898246&r2=898247&view=diff
==============================================================================
---
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Tue Jan 12 08:32:58 2010
@@ -39,7 +39,6 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
@@ -89,9 +88,9 @@
/**
* This old parameter is just like skipTests, but bound to the old
property maven.test.skip.exec.
*
- * @deprecated Use -DskipTests instead.
* @parameter expression="${maven.test.skip.exec}"
* @since 2.3
+ * @deprecated Use -DskipTests instead.
*/
private boolean skipExec;
@@ -221,8 +220,9 @@
/**
* List of System properties to pass to the JUnit tests.
- * @deprecated Use systemPropertyVariables instead.
+ *
* @parameter
+ * @deprecated Use systemPropertyVariables instead.
*/
private Properties systemProperties;
@@ -440,11 +440,12 @@
* @since 2.5
*/
private String useUnlimitedThreads;
+
/**
* (TestNG only) When you use the parallel attribute, TestNG will try to
run all your test methods in separate threads, except for
* methods that depend on each other, which will be run in the same thread
in order to respect their order of
* execution.
- *
+ * <p/>
* In JUnit 4.7 the values are classes/methods/both to run in separate
threads, as controlled by threadCount.
*
* @parameter expression="${parallel}"
@@ -524,7 +525,7 @@
* to "false" to force it to launch your tests with a plain old Java
classpath.
* (See
http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
* for a more detailed explanation of manifest-only JARs and their
benefits.)
- *
+ * <p/>
* Beware, setting this to "false" may cause your tests to
* fail on Windows if your classpath is too long.
*
@@ -559,7 +560,9 @@
*/
private String objectFactory;
- /** @component */
+ /**
+ * @component
+ */
private ToolchainManager toolchainManager;
@@ -592,18 +595,28 @@
System.setProperties( originalSystemProperties );
}
- if ( result == 0 ) return;
+ if ( result == 0 )
+ {
+ return;
+ }
String msg;
if ( result == SurefireBooter.NO_TESTS_EXIT_CODE )
{
- if ( ( failIfNoTests == null ) ||
!failIfNoTests.booleanValue() ) return;
+ if ( ( failIfNoTests == null ) ||
!failIfNoTests.booleanValue() )
+ {
+ return;
+ }
// TODO: i18n
- throw new MojoFailureException( "No tests were executed! (Set
-DfailIfNoTests=false to ignore this error.)" );
- } else {
+ throw new MojoFailureException(
+ "No tests were executed! (Set -DfailIfNoTests=false to
ignore this error.)" );
+ }
+ else
+ {
// TODO: i18n
- msg = "There are test failures.\n\nPlease refer to " +
reportsDirectory + " for the individual test results.";
+ msg = "There are test failures.\n\nPlease refer to " +
reportsDirectory
+ + " for the individual test results.";
}
@@ -679,10 +692,11 @@
}
}
- private boolean isAnyConcurrencySelected(){
- return this.parallel != null && this.parallel.trim().length() > 0;
+ private boolean isAnyConcurrencySelected()
+ {
+ return this.parallel != null && this.parallel.trim().length() > 0;
}
-
+
/**
* Converts old TestNG configuration parameters over to new properties
based configuration
* method. (if any are defined the old way)
@@ -704,26 +718,34 @@
}
if ( this.perCoreThreadCount != null )
{
- properties.setProperty( "perCoreThreadCount", perCoreThreadCount);
+ properties.setProperty( "perCoreThreadCount", perCoreThreadCount );
}
if ( this.useUnlimitedThreads != null )
{
- properties.setProperty( "useUnlimitedThreads",
useUnlimitedThreads);
+ properties.setProperty( "useUnlimitedThreads", useUnlimitedThreads
);
}
- Artifact configurableParallelComputer = (Artifact)
projectArtifactMap.get("org.jdogma.junit:configurable-parallel-computer");
- properties.setProperty("configurableParallelComputerPresent",
Boolean.toString(configurableParallelComputer != null));
+ Artifact configurableParallelComputer =
+ (Artifact) projectArtifactMap.get(
"org.jdogma.junit:configurable-parallel-computer" );
+ properties.setProperty( "configurableParallelComputerPresent",
+ Boolean.toString( configurableParallelComputer
!= null ) );
}
- private boolean isJunit47Compatible(Artifact artifact) throws
MojoExecutionException {
- return isWithinVersionSpec(artifact, "[4.7,)");
+ private boolean isJunit47Compatible( Artifact artifact )
+ throws MojoExecutionException
+ {
+ return isWithinVersionSpec( artifact, "[4.7,)" );
}
- private boolean isAnyJunit4(Artifact artifact) throws
MojoExecutionException {
- return isWithinVersionSpec(artifact, "[4.0,)");
+ private boolean isAnyJunit4( Artifact artifact )
+ throws MojoExecutionException
+ {
+ return isWithinVersionSpec( artifact, "[4.0,)" );
}
- private boolean isWithinVersionSpec(Artifact artifact, String versionSpec)
throws MojoExecutionException {
+ private boolean isWithinVersionSpec( Artifact artifact, String versionSpec
)
+ throws MojoExecutionException
+ {
if ( artifact == null )
{
return false;
@@ -783,11 +805,11 @@
if ( testNgArtifact != null )
{
VersionRange range = VersionRange.createFromVersionSpec(
"[4.7,)" );
- if ( !range.containsVersion( new
DefaultArtifactVersion(testNgArtifact.getVersion()) ) )
+ if ( !range.containsVersion( new DefaultArtifactVersion(
testNgArtifact.getVersion() ) ) )
{
throw new MojoFailureException(
- "TestNG support requires
version 4.7 or above. You have declared version " +
-
testNgArtifact.getVersion() );
+ "TestNG support requires version 4.7 or above. You
have declared version "
+ + testNgArtifact.getVersion() );
}
convertTestNGParameters();
@@ -802,18 +824,18 @@
// The plugin uses a JDK based profile to select the right
testng. We might be explicity using a
// different one since its based on the source level, not the
JVM. Prune using the filter.
addProvider( surefireBooter, "surefire-testng",
surefireArtifact.getBaseVersion(), testNgArtifact );
- }
+ }
else if ( junitArtifact != null && isAnyJunit4( junitArtifact ) )
{
- if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
- {
- convertJunitCoreParameters();
- addProvider( surefireBooter, "surefire-junit47",
surefireArtifact.getBaseVersion(), null );
- }
- else
- {
- addProvider( surefireBooter, "surefire-junit4",
surefireArtifact.getBaseVersion(), null );
- }
+ if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
+ {
+ convertJunitCoreParameters();
+ addProvider( surefireBooter, "surefire-junit47",
surefireArtifact.getBaseVersion(), null );
+ }
+ else
+ {
+ addProvider( surefireBooter, "surefire-junit4",
surefireArtifact.getBaseVersion(), null );
+ }
}
else
{
@@ -824,8 +846,8 @@
}
catch ( ArtifactNotFoundException e )
{
- throw new MojoExecutionException( "Unable to locate required
surefire provider dependency: " +
- e.getMessage(), e );
+ throw new MojoExecutionException(
+ "Unable to locate required surefire provider dependency: " +
e.getMessage(), e );
}
catch ( InvalidVersionSpecificationException e )
{
@@ -844,8 +866,10 @@
}
// TODO: properties should be passed in here too
- surefireBooter.addTestSuite(
"org.apache.maven.surefire.testng.TestNGXmlTestSuite", new Object[]{
- suiteXmlFiles, testSourceDirectory.getAbsolutePath(),
testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties,
reportsDirectory} );
+ surefireBooter.addTestSuite(
"org.apache.maven.surefire.testng.TestNGXmlTestSuite",
+ new Object[]{suiteXmlFiles,
testSourceDirectory.getAbsolutePath(),
+ testNgArtifact.getVersion(),
testNgArtifact.getClassifier(), properties,
+ reportsDirectory} );
}
else
{
@@ -892,27 +916,26 @@
// Have to wrap in an ArrayList as surefire expects an
ArrayList instead of a List for some reason
if ( includes == null || includes.size() == 0 )
{
- includes =
- new ArrayList( Arrays.asList( new String[] {
"**/Test*.java", "**/*Test.java",
- "**/*TestCase.java" } ) );
+ includes = new ArrayList(
+ Arrays.asList( new String[]{"**/Test*.java",
"**/*Test.java", "**/*TestCase.java"} ) );
}
if ( excludes == null || excludes.size() == 0 )
{
- excludes =
- new ArrayList( Arrays.asList( new String[] { "**/*$*"
} ) );
+ excludes = new ArrayList( Arrays.asList( new
String[]{"**/*$*"} ) );
}
}
if ( testNgArtifact != null )
{
-
surefireBooter.addTestSuite("org.apache.maven.surefire.testng.TestNGDirectoryTestSuite",
new Object[]{
- testClassesDirectory, includes, excludes,
testSourceDirectory.getAbsolutePath(),
- testNgArtifact.getVersion(),
testNgArtifact.getClassifier(), properties, reportsDirectory});
+ surefireBooter.addTestSuite(
"org.apache.maven.surefire.testng.TestNGDirectoryTestSuite",
+ new
Object[]{testClassesDirectory, includes, excludes,
+
testSourceDirectory.getAbsolutePath(), testNgArtifact.getVersion(),
+
testNgArtifact.getClassifier(), properties, reportsDirectory} );
}
else
{
String junitDirectoryTestSuite;
- if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
+ if ( isAnyConcurrencySelected() && isJunit47Compatible(
junitArtifact ) )
{
junitDirectoryTestSuite =
"org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
getLog().info( "Concurrency config is " +
properties.toString() );
@@ -943,8 +966,8 @@
// Check if we need to add configured classes/test classes directories
here.
// If they are configured, we should remove the default to avoid
conflicts.
- File projectClassesDirectory = new File (
project.getBuild().getOutputDirectory() );
- if ( ! projectClassesDirectory.equals( classesDirectory ) )
+ File projectClassesDirectory = new File(
project.getBuild().getOutputDirectory() );
+ if ( !projectClassesDirectory.equals( classesDirectory ) )
{
int indexToReplace = classpathElements.indexOf(
project.getBuild().getOutputDirectory() );
if ( indexToReplace != -1 )
@@ -1040,7 +1063,8 @@
if ( "true".equals( debugForkedProcess ) )
{
- debugForkedProcess = "-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005";
+ debugForkedProcess =
+ "-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005";
}
fork.setDebugLine( debugForkedProcess );
@@ -1113,7 +1137,8 @@
}
}
- private void addProvider( SurefireBooter surefireBooter, String provider,
String version, Artifact filteredArtifact )
+ private void addProvider( SurefireBooter surefireBooter, String provider,
String version,
+ Artifact filteredArtifact )
throws ArtifactNotFoundException, ArtifactResolutionException
{
Artifact providerArtifact = artifactFactory.createDependencyArtifact(
"org.apache.maven.surefire", provider,
@@ -1137,9 +1162,8 @@
ArtifactFilter filter = null;
if ( filteredArtifact != null )
{
- filter =
- new ExcludesArtifactFilter( Collections.singletonList(
filteredArtifact.getGroupId() + ":" +
- filteredArtifact.getArtifactId() ) );
+ filter = new ExcludesArtifactFilter(
+ Collections.singletonList( filteredArtifact.getGroupId() + ":"
+ filteredArtifact.getArtifactId() ) );
}
Artifact originatingArtifact = artifactFactory.createBuildArtifact(
"dummy", "dummy", "1.0", "jar" );
@@ -1223,9 +1247,9 @@
}
/**
- * <p>
+ * <p/>
* Adds Reporters that will generate reports with different formatting.
- * <p>
+ * <p/>
* The Reporter that will be added will be based on the value of the
parameter useFile, reportFormat, and
* printSummary.
*
@@ -1241,40 +1265,40 @@
{
if ( forking )
{
- surefireBooter.addReport(
ForkingConsoleReporter.class.getName(), new Object[] { trimStackTrace } );
+ surefireBooter.addReport(
ForkingConsoleReporter.class.getName(), new Object[]{trimStackTrace} );
}
else
{
- surefireBooter.addReport( ConsoleReporter.class.getName(),
new Object[] { trimStackTrace } );
+ surefireBooter.addReport( ConsoleReporter.class.getName(),
new Object[]{trimStackTrace} );
}
}
if ( BRIEF_REPORT_FORMAT.equals( reportFormat ) )
{
- surefireBooter.addReport( BriefFileReporter.class.getName(),
new Object[] { reportsDirectory,
- trimStackTrace } );
+ surefireBooter.addReport( BriefFileReporter.class.getName(),
+ new Object[]{reportsDirectory,
trimStackTrace} );
}
else if ( PLAIN_REPORT_FORMAT.equals( reportFormat ) )
{
surefireBooter.addReport( FileReporter.class.getName(),
- new Object[] { reportsDirectory,
trimStackTrace } );
+ new Object[]{reportsDirectory,
trimStackTrace} );
}
}
else
{
if ( BRIEF_REPORT_FORMAT.equals( reportFormat ) )
{
- surefireBooter.addReport(
BriefConsoleReporter.class.getName(), new Object[] { trimStackTrace } );
+ surefireBooter.addReport(
BriefConsoleReporter.class.getName(), new Object[]{trimStackTrace} );
}
else if ( PLAIN_REPORT_FORMAT.equals( reportFormat ) )
{
- surefireBooter.addReport(
DetailedConsoleReporter.class.getName(), new Object[] { trimStackTrace } );
+ surefireBooter.addReport(
DetailedConsoleReporter.class.getName(), new Object[]{trimStackTrace} );
}
}
if ( !disableXmlReport )
{
- surefireBooter.addReport( XMLReporter.class.getName(), new
Object[] { reportsDirectory, trimStackTrace } );
+ surefireBooter.addReport( XMLReporter.class.getName(), new
Object[]{reportsDirectory, trimStackTrace} );
}
}
@@ -1294,8 +1318,6 @@
this.skipTests = skipExec;
}
- //TODO remove the part with ToolchainManager lookup once we depend on
- //2.0.9 (have it as prerequisite). Define as regular component field then.
private Toolchain getToolchain()
{
Toolchain tc = null;