You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/08/09 18:28:00 UTC
svn commit: r1371299 - in /maven/surefire/trunk:
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/
maven-surefire-common/src/test/java/org/apache/mav...
Author: krosenvold
Date: Thu Aug 9 16:27:59 2012
New Revision: 1371299
URL: http://svn.apache.org/viewvc?rev=1371299&view=rev
Log:
o Refactored & simplified mutable state mess
Modified:
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SummaryTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java
maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Thu Aug 9 16:27:59 2012
@@ -554,9 +554,9 @@ public abstract class AbstractSurefireMo
@Component
protected ToolchainManager toolchainManager;
- // common field getters/setters
+ private Artifact surefireBooterArtifact;
- // common code
+ private Toolchain toolchain;
protected abstract String getPluginName();
@@ -565,6 +565,9 @@ public abstract class AbstractSurefireMo
public void execute()
throws MojoExecutionException, MojoFailureException
{
+ // Stuff that should have been final
+ setupStuff();
+
if ( verifyParameters() && !hasExecutedBefore() )
{
DefaultScanResult scan = scanDirectories();
@@ -582,6 +585,13 @@ public abstract class AbstractSurefireMo
}
}
+ private void setupStuff()
+ {
+ createDependencyResolver();
+ surefireBooterArtifact = getSurefireBooterArtifact();
+ toolchain = getToolchain();
+ }
+
private DefaultScanResult scanDirectories()
{
return new DirectoryScanner( getTestClassesDirectory(), getIncludeList(), getExcludeList(),
@@ -598,6 +608,16 @@ public abstract class AbstractSurefireMo
return false;
}
+ String jvmToUse = getJvm();
+ if ( toolchain != null )
+ {
+ getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + toolchain );
+ if ( jvmToUse != null )
+ {
+ getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + jvmToUse );
+ }
+ }
+
if ( !getTestClassesDirectory().exists() )
{
if ( Boolean.TRUE.equals( getFailIfNoTests() ) )
@@ -620,14 +640,12 @@ public abstract class AbstractSurefireMo
protected void executeAfterPreconditionsChecked( DefaultScanResult scanResult )
throws MojoExecutionException, MojoFailureException
{
- createDependencyResolver();
Summary summary = executeAllProviders( scanResult );
handleSummary( summary );
}
- private Artifact surefireBooterArtifact;
private void createDependencyResolver()
{
@@ -692,9 +710,8 @@ public abstract class AbstractSurefireMo
throws MojoExecutionException, MojoFailureException
{
SurefireProperties effectiveProperties = setupProperties();
- ForkConfiguration forkConfiguration = getForkConfiguration();
- summary.reportForkConfiguration( forkConfiguration );
- ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration( forkConfiguration );
+ summary.reportForkConfiguration( isForking() );
+ ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration( isForking() );
try
{
@@ -702,26 +719,28 @@ public abstract class AbstractSurefireMo
new RunOrderParameters( getRunOrder(), getStatisticsFileName( getConfigChecksum() ) );
final RunResult result;
- if ( ForkConfiguration.FORK_NEVER.equals( forkConfiguration.getForkMode() ) )
+ if ( isForkModeNever() )
{
effectiveProperties.copyToSystemProperties();
InPluginVMSurefireStarter surefireStarter =
- createInprocessStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters );
+ createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters );
result = surefireStarter.runSuitesInProcess( scanResult );
}
else
{
+ ForkConfiguration forkConfiguration = getForkConfiguration();
Properties originalSystemProperties = (Properties) System.getProperties().clone();
try
{
ForkStarter forkStarter =
createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters,
effectiveProperties );
- result = forkStarter.run( scanResult );
+ result = forkStarter.run( scanResult, getEffectiveForkMode() );
}
finally
{
System.setProperties( originalSystemProperties );
+ cleanupForkConfiguration( forkConfiguration );
}
}
summary.registerRunResult( result );
@@ -734,10 +753,6 @@ public abstract class AbstractSurefireMo
{
summary.registerException( e );
}
- finally
- {
- cleanupForkConfiguration( forkConfiguration );
- }
}
protected void cleanupForkConfiguration( ForkConfiguration forkConfiguration )
@@ -860,7 +875,24 @@ public abstract class AbstractSurefireMo
boolean isForkModeNever()
{
- return ForkConfiguration.FORK_NEVER.equals( getForkMode() );
+ return ForkConfiguration.FORK_NEVER.equals( getEffectiveForkMode() );
+ }
+
+ boolean isForking()
+ {
+ return !isForkModeNever();
+ }
+
+ private String getEffectiveForkMode()
+ {
+ String forkMode1 = getForkMode();
+
+ if ( toolchain != null && isForkModeNever() )
+ {
+ return ForkConfiguration.FORK_ONCE;
+ }
+
+ return ForkConfiguration.getEffectiveForkMode( forkMode1 );
}
private List<RunOrder> getRunOrders()
@@ -937,7 +969,7 @@ public abstract class AbstractSurefireMo
if ( isSpecificTestSpecified() )
{
failIfNoTests = getEffectiveFailIfNoTests();
- setFailIfNoTests( Boolean.valueOf( failIfNoTests ) );
+ setFailIfNoTests( failIfNoTests );
}
else
{
@@ -966,7 +998,7 @@ public abstract class AbstractSurefireMo
}
- StartupConfiguration createStartupConfiguration( ForkConfiguration forkConfiguration, ProviderInfo provider,
+ StartupConfiguration createStartupConfiguration( ProviderInfo provider,
ClassLoaderConfiguration classLoaderConfiguration )
throws MojoExecutionException, MojoFailureException
{
@@ -989,7 +1021,7 @@ public abstract class AbstractSurefireMo
isChildDelegation() );
return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration,
- forkConfiguration.getForkMode(), false );
+ isForking(), false );
}
catch ( ArtifactResolutionException e )
{
@@ -1173,8 +1205,7 @@ public abstract class AbstractSurefireMo
SurefireProperties effectiveSystemProperties )
throws MojoExecutionException, MojoFailureException
{
- StartupConfiguration startupConfiguration =
- createStartupConfiguration( forkConfiguration, provider, classLoaderConfiguration );
+ StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration );
String configChecksum = getConfigChecksum();
StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum );
ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters );
@@ -1184,13 +1215,11 @@ public abstract class AbstractSurefireMo
}
protected InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider,
- ForkConfiguration forkConfiguration,
ClassLoaderConfiguration classLoaderConfiguration,
RunOrderParameters runOrderParameters )
throws MojoExecutionException, MojoFailureException
{
- StartupConfiguration startupConfiguration =
- createStartupConfiguration( forkConfiguration, provider, classLoaderConfiguration );
+ StartupConfiguration startupConfiguration = createStartupConfiguration( provider, classLoaderConfiguration );
String configChecksum = getConfigChecksum();
StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum );
ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters );
@@ -1206,101 +1235,88 @@ public abstract class AbstractSurefireMo
Artifact shadeFire = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-shadefire" );
- surefireBooterArtifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" );
- if ( surefireBooterArtifact == null )
- {
- throw new RuntimeException( "Unable to locate surefire-booter in the list of plugin artifacts" );
- }
-
- surefireBooterArtifact.isSnapshot(); // MNG-2961: before Maven 2.0.8, fixes getBaseVersion to be -SNAPSHOT if needed
-
final Classpath bootClasspathConfiguration =
getArtifactClasspath( shadeFire != null ? shadeFire : surefireBooterArtifact );
- ForkConfiguration fork = new ForkConfiguration( bootClasspathConfiguration, getForkMode(), tmpDir );
+ ForkConfiguration fork = new ForkConfiguration( bootClasspathConfiguration, tmpDir );
- fork.setTempDirectory( tmpDir );
+ setUseSystemClassLoader( isUseSystemClassLoader() );
- Toolchain tc = getToolchain();
+ fork.setDebugLine( getEffectiveDebugForkedProcess() );
- String jvmToUse = getJvm();
- if ( tc != null )
- {
- getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + tc );
- if ( isForkModeNever() )
- {
- setForkMode( ForkConfiguration.FORK_ONCE );
- }
- if ( jvmToUse != null )
- {
- getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + jvmToUse );
- }
- else
- {
- jvmToUse = tc.findTool( "java" ); //NOI18N
- }
- }
+ fork.setJvmExecutable( getEffectiveJvm() );
- if ( fork.isForking() )
- {
- setUseSystemClassLoader( isUseSystemClassLoader() );
+ fork.setWorkingDirectory( getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir() );
- if ( "true".equals( getDebugForkedProcess() ) )
- {
- setDebugForkedProcess(
- "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" );
- }
+ fork.setArgLine( getArgLine() );
- fork.setDebugLine( getDebugForkedProcess() );
+ fork.setEnvironmentVariables( getEnvironmentVariables() );
- if ( ( jvmToUse == null || "".equals( jvmToUse ) ) )
- {
- // use the same JVM as the one used to run Maven (the "java.home" one)
- jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java";
- getLog().debug( "Using JVM: " + jvmToUse );
- }
+ if ( getLog().isDebugEnabled() )
+ {
+ showMap( getEnvironmentVariables(), "environment variable" );
- fork.setJvmExecutable( jvmToUse );
+ fork.setDebug( true );
+ }
- if ( getWorkingDirectory() != null )
- {
- fork.setWorkingDirectory( getWorkingDirectory() );
- }
- else
+ if ( getArgLine() != null )
+ {
+ List<String> args = Arrays.asList( getArgLine().split( " " ) );
+ if ( args.contains( "-da" ) || args.contains( "-disableassertions" ) )
{
- fork.setWorkingDirectory( getBasedir() );
+ setEnableAssertions( false );
}
+ }
- fork.setArgLine( getArgLine() );
+ if ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() ) )
+ {
+ fork.setThreadCount( getThreadCount() );
+ }
+ else
+ {
+ fork.setThreadCount( 1 );
+ }
+ return fork;
+ }
- fork.setEnvironmentVariables( getEnvironmentVariables() );
+ private String getEffectiveDebugForkedProcess()
+ {
+ String debugForkedProcess = getDebugForkedProcess();
+ if ( "true".equals( debugForkedProcess ) )
+ {
+ return "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005";
+ }
+ return debugForkedProcess;
+ }
- if ( getLog().isDebugEnabled() )
- {
- showMap( getEnvironmentVariables(), "environment variable" );
+ private String getEffectiveJvm()
+ {
+ String jvmToUse = getJvm();
+ if ( toolchain != null && jvmToUse == null )
+ {
+ jvmToUse = toolchain.findTool( "java" ); //NOI18N
+ }
- fork.setDebug( true );
- }
+ if ( StringUtils.isEmpty( jvmToUse ) )
+ {
+ // use the same JVM as the one used to run Maven (the "java.home" one)
+ jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java";
+ getLog().debug( "Using JVM: " + jvmToUse );
+ }
- if ( getArgLine() != null )
- {
- List<String> args = Arrays.asList( getArgLine().split( " " ) );
- if ( args.contains( "-da" ) || args.contains( "-disableassertions" ) )
- {
- setEnableAssertions( false );
- }
- }
+ return jvmToUse;
+ }
- if ( fork.getForkMode().equals( ForkConfiguration.FORK_PERTHREAD ) )
- {
- fork.setThreadCount( getThreadCount() );
- }
- else
- {
- fork.setThreadCount( 1 );
- }
+
+ private Artifact getSurefireBooterArtifact()
+ {
+ Artifact artifact = getPluginArtifactMap().get( "org.apache.maven.surefire:surefire-booter" );
+ if ( artifact == null )
+ {
+ throw new RuntimeException( "Unable to locate surefire-booter in the list of plugin artifacts" );
}
- return fork;
+ artifact.isSnapshot(); // MNG-2961: before Maven 2.0.8, fixes getBaseVersion to be -SNAPSHOT if needed
+ return artifact;
}
@@ -1314,6 +1330,11 @@ public abstract class AbstractSurefireMo
return new File( getReportsDirectory().getParentFile(), "surefire" );
}
+ /**
+ * Operates on raw plugin paramenters, not the "effective" values.
+ *
+ * @return The checksum
+ */
private String getConfigChecksum()
{
ChecksumCalculator checksum = new ChecksumCalculator();
@@ -1392,9 +1413,9 @@ public abstract class AbstractSurefireMo
return false;
}
- protected ClassLoaderConfiguration getClassLoaderConfiguration( ForkConfiguration fork )
+ protected ClassLoaderConfiguration getClassLoaderConfiguration( boolean isForking )
{
- return fork.isForking()
+ return isForking
? new ClassLoaderConfiguration( isUseSystemClassLoader(), isUseManifestOnlyJar() )
: new ClassLoaderConfiguration( false, false );
}
@@ -1865,9 +1886,7 @@ public abstract class AbstractSurefireMo
return systemProperties;
}
- /**
- * @noinspection deprecation
- */
+ @SuppressWarnings( { "UnusedDeclaration", "deprecation" } )
public void setSystemProperties( Properties systemProperties )
{
this.systemProperties = systemProperties;
@@ -1878,6 +1897,7 @@ public abstract class AbstractSurefireMo
return systemPropertyVariables;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setSystemPropertyVariables( Map<String, String> systemPropertyVariables )
{
this.systemPropertyVariables = systemPropertyVariables;
@@ -1888,6 +1908,7 @@ public abstract class AbstractSurefireMo
return systemPropertiesFile;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setSystemPropertiesFile( File systemPropertiesFile )
{
this.systemPropertiesFile = systemPropertiesFile;
@@ -1908,6 +1929,7 @@ public abstract class AbstractSurefireMo
return pluginArtifactMap;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setPluginArtifactMap( Map<String, Artifact> pluginArtifactMap )
{
this.pluginArtifactMap = pluginArtifactMap;
@@ -1918,6 +1940,7 @@ public abstract class AbstractSurefireMo
return projectArtifactMap;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setProjectArtifactMap( Map<String, Artifact> projectArtifactMap )
{
this.projectArtifactMap = projectArtifactMap;
@@ -1929,6 +1952,7 @@ public abstract class AbstractSurefireMo
return reportNameSuffix;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setReportNameSuffix( String reportNameSuffix )
{
this.reportNameSuffix = reportNameSuffix;
@@ -1940,6 +1964,7 @@ public abstract class AbstractSurefireMo
return redirectTestOutputToFile;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
{
this.redirectTestOutputToFile = redirectTestOutputToFile;
@@ -1961,6 +1986,7 @@ public abstract class AbstractSurefireMo
return forkMode;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setForkMode( String forkMode )
{
this.forkMode = forkMode;
@@ -1976,6 +2002,7 @@ public abstract class AbstractSurefireMo
return argLine;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setArgLine( String argLine )
{
this.argLine = argLine;
@@ -1987,6 +2014,7 @@ public abstract class AbstractSurefireMo
return environmentVariables;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setEnvironmentVariables( Map<String, String> environmentVariables )
{
this.environmentVariables = environmentVariables;
@@ -1997,6 +2025,7 @@ public abstract class AbstractSurefireMo
return workingDirectory;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setWorkingDirectory( File workingDirectory )
{
this.workingDirectory = workingDirectory;
@@ -2007,6 +2036,7 @@ public abstract class AbstractSurefireMo
return childDelegation;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setChildDelegation( boolean childDelegation )
{
this.childDelegation = childDelegation;
@@ -2017,6 +2047,7 @@ public abstract class AbstractSurefireMo
return groups;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setGroups( String groups )
{
this.groups = groups;
@@ -2027,6 +2058,7 @@ public abstract class AbstractSurefireMo
return excludedGroups;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setExcludedGroups( String excludedGroups )
{
this.excludedGroups = excludedGroups;
@@ -2037,6 +2069,7 @@ public abstract class AbstractSurefireMo
return suiteXmlFiles;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setSuiteXmlFiles( File[] suiteXmlFiles )
{
this.suiteXmlFiles = suiteXmlFiles;
@@ -2047,6 +2080,7 @@ public abstract class AbstractSurefireMo
return junitArtifactName;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setJunitArtifactName( String junitArtifactName )
{
this.junitArtifactName = junitArtifactName;
@@ -2057,6 +2091,7 @@ public abstract class AbstractSurefireMo
return testNGArtifactName;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setTestNGArtifactName( String testNGArtifactName )
{
this.testNGArtifactName = testNGArtifactName;
@@ -2067,6 +2102,7 @@ public abstract class AbstractSurefireMo
return threadCount;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setThreadCount( int threadCount )
{
this.threadCount = threadCount;
@@ -2077,6 +2113,7 @@ public abstract class AbstractSurefireMo
return perCoreThreadCount;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setPerCoreThreadCount( boolean perCoreThreadCount )
{
this.perCoreThreadCount = perCoreThreadCount;
@@ -2087,6 +2124,7 @@ public abstract class AbstractSurefireMo
return useUnlimitedThreads;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setUseUnlimitedThreads( boolean useUnlimitedThreads )
{
this.useUnlimitedThreads = useUnlimitedThreads;
@@ -2097,6 +2135,7 @@ public abstract class AbstractSurefireMo
return parallel;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setParallel( String parallel )
{
this.parallel = parallel;
@@ -2107,6 +2146,7 @@ public abstract class AbstractSurefireMo
return trimStackTrace;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setTrimStackTrace( boolean trimStackTrace )
{
this.trimStackTrace = trimStackTrace;
@@ -2117,6 +2157,7 @@ public abstract class AbstractSurefireMo
return artifactResolver;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setArtifactResolver( ArtifactResolver artifactResolver )
{
this.artifactResolver = artifactResolver;
@@ -2127,6 +2168,7 @@ public abstract class AbstractSurefireMo
return artifactFactory;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setArtifactFactory( ArtifactFactory artifactFactory )
{
this.artifactFactory = artifactFactory;
@@ -2137,6 +2179,7 @@ public abstract class AbstractSurefireMo
return remoteRepositories;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
{
this.remoteRepositories = remoteRepositories;
@@ -2147,6 +2190,7 @@ public abstract class AbstractSurefireMo
return metadataSource;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setMetadataSource( ArtifactMetadataSource metadataSource )
{
this.metadataSource = metadataSource;
@@ -2158,6 +2202,7 @@ public abstract class AbstractSurefireMo
return disableXmlReport;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setDisableXmlReport( boolean disableXmlReport )
{
this.disableXmlReport = disableXmlReport;
@@ -2169,6 +2214,7 @@ public abstract class AbstractSurefireMo
return enableAssertions;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setEnableAssertions( boolean enableAssertions )
{
this.enableAssertions = enableAssertions;
@@ -2179,6 +2225,7 @@ public abstract class AbstractSurefireMo
return session;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setSession( MavenSession session )
{
this.session = session;
@@ -2189,6 +2236,7 @@ public abstract class AbstractSurefireMo
return objectFactory;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setObjectFactory( String objectFactory )
{
this.objectFactory = objectFactory;
@@ -2199,6 +2247,7 @@ public abstract class AbstractSurefireMo
return toolchainManager;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setToolchainManager( ToolchainManager toolchainManager )
{
this.toolchainManager = toolchainManager;
@@ -2214,6 +2263,7 @@ public abstract class AbstractSurefireMo
return runOrder;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setRunOrder( String runOrder )
{
this.runOrder = runOrder;
@@ -2229,6 +2279,7 @@ public abstract class AbstractSurefireMo
return project;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void setProject( MavenProject project )
{
this.project = project;
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java Thu Aug 9 16:27:59 2012
@@ -19,7 +19,6 @@ package org.apache.maven.plugin.surefire
* under the License.
*/
-import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration;
import org.apache.maven.surefire.suite.RunResult;
public class Summary
@@ -30,9 +29,9 @@ public class Summary
private Exception exception;
- public void reportForkConfiguration( ForkConfiguration configuration )
+ public void reportForkConfiguration( boolean isForking )
{
- forking = configuration.isForking();
+ forking = isForking;
}
public void registerException( Exception exception )
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java Thu Aug 9 16:27:59 2012
@@ -64,8 +64,8 @@ class BooterSerializer
}
- public File serialize( ProviderConfiguration booterConfiguration, StartupConfiguration providerConfiguration,
- Object testSet, String forkMode )
+ public File serialize(ProviderConfiguration booterConfiguration, StartupConfiguration providerConfiguration,
+ Object testSet)
throws IOException
{
providerConfiguration.getClasspathConfiguration().setForkProperties( properties );
@@ -113,7 +113,6 @@ class BooterSerializer
Boolean rep = reporterConfiguration.isTrimStackTrace();
properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep );
properties.setProperty( BooterConstants.REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() );
- properties.setProperty( BooterConstants.FORKMODE, forkMode );
ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration();
properties.setProperty( BooterConstants.USESYSTEMCLASSLOADER,
String.valueOf( classLoaderConfiguration.isUseSystemClassLoader() ) );
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java Thu Aug 9 16:27:59 2012
@@ -58,8 +58,6 @@ public class ForkConfiguration
private final Classpath bootClasspathConfiguration;
- private final String forkMode;
-
private String jvmExecutable;
private String argLine;
@@ -68,16 +66,15 @@ public class ForkConfiguration
private File workingDirectory;
- private File tempDirectory;
+ private final File tempDirectory;
private boolean debug;
private String debugLine;
- public ForkConfiguration( Classpath bootClasspathConfiguration, String forkMode, File tmpDir )
+ public ForkConfiguration(Classpath bootClasspathConfiguration, File tmpDir)
{
this.bootClasspathConfiguration = bootClasspathConfiguration;
- this.forkMode = getForkMode( forkMode );
this.tempDirectory = tmpDir;
}
@@ -86,7 +83,7 @@ public class ForkConfiguration
return bootClasspathConfiguration;
}
- private static String getForkMode( String forkMode )
+ public static String getEffectiveForkMode(String forkMode)
{
if ( "pertest".equalsIgnoreCase( forkMode ) )
{
@@ -107,11 +104,6 @@ public class ForkConfiguration
}
}
- public boolean isForking()
- {
- return !FORK_NEVER.equals( forkMode );
- }
-
public void setJvmExecutable( String jvmExecutable )
{
this.jvmExecutable = jvmExecutable;
@@ -137,16 +129,6 @@ public class ForkConfiguration
this.workingDirectory = workingDirectory;
}
- public void setTempDirectory( File tempDirectory )
- {
- this.tempDirectory = tempDirectory;
- }
-
-
- public String getForkMode()
- {
- return forkMode;
- }
/**
* @param classPath cla the classpath arguments
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java Thu Aug 9 16:27:59 2012
@@ -103,11 +103,10 @@ public class ForkStarter
fileReporterFactory = new FileReporterFactory( startupReportConfiguration );
}
- public RunResult run( DefaultScanResult scanResult )
+ public RunResult run(DefaultScanResult scanResult, String requestedForkMode)
throws SurefireBooterForkException, SurefireExecutionException
{
final RunResult result;
- final String requestedForkMode = forkConfiguration.getForkMode();
try
{
Properties providerProperties = providerConfiguration.getProviderProperties();
@@ -228,8 +227,7 @@ public class ForkStarter
{
BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, properties );
- surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet,
- forkConfiguration.getForkMode() );
+ surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet);
if ( effectiveSystemProperties != null )
{
Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SummaryTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SummaryTest.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SummaryTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/SummaryTest.java Thu Aug 9 16:27:59 2012
@@ -89,25 +89,16 @@ public class SummaryTest
public void testSummaryIsForkingIfTheLastConfigurationIsForking()
{
- summary.reportForkConfiguration( createNonForkingConfiguration() );
- summary.reportForkConfiguration( createForkingConfiguration() );
+ summary.reportForkConfiguration(false);
+ summary.reportForkConfiguration(true);
assertTrue( summary.isForking() );
}
public void testSummaryIsNotForkingIfTheLastConfigurationIsNotForking()
{
- summary.reportForkConfiguration( createForkingConfiguration() );
- summary.reportForkConfiguration( createNonForkingConfiguration() );
+ summary.reportForkConfiguration(true);
+ summary.reportForkConfiguration(false);
assertFalse( summary.isForking() );
}
- private ForkConfiguration createForkingConfiguration()
- {
- return new ForkConfiguration( null, ForkConfiguration.FORK_ALWAYS, null );
- }
-
- private ForkConfiguration createNonForkingConfiguration()
- {
- return new ForkConfiguration( null, ForkConfiguration.FORK_NEVER, null );
- }
}
Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java Thu Aug 9 16:27:59 2012
@@ -174,7 +174,7 @@ public class BooterDeserializerProviderC
Properties props = new Properties();
BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props );
String aTest = "aTest";
- booterSerializer.serialize( booterConfiguration, testProviderConfiguration, aTest, "never" );
+ booterSerializer.serialize( booterConfiguration, testProviderConfiguration, aTest);
final File propsTest =
SystemPropertyManager.writePropertiesFile( props, forkConfiguration.getTempDirectory(), "propsTest", true );
BooterDeserializer booterDeserializer = new BooterDeserializer( new FileInputStream( propsTest ) );
@@ -200,7 +200,7 @@ public class BooterDeserializerProviderC
{
ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( true, true );
- return new StartupConfiguration( "com.provider", classpathConfiguration, classLoaderConfiguration, "never",
+ return new StartupConfiguration( "com.provider", classpathConfiguration, classLoaderConfiguration, false,
false );
}
Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java Thu Aug 9 16:27:59 2012
@@ -130,7 +130,7 @@ public class BooterDeserializerStartupCo
Properties props = new Properties();
BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props );
String aTest = "aTest";
- booterSerializer.serialize( getProviderConfiguration(), startupConfiguration, aTest, "never" );
+ booterSerializer.serialize( getProviderConfiguration(), startupConfiguration, aTest);
final File propsTest =
SystemPropertyManager.writePropertiesFile( props, forkConfiguration.getTempDirectory(), "propsTest", true );
BooterDeserializer booterDeserializer = new BooterDeserializer( new FileInputStream( propsTest ) );
@@ -159,7 +159,7 @@ public class BooterDeserializerStartupCo
private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
{
- return new StartupConfiguration( "com.provider", classpathConfiguration, classLoaderConfiguration, "never",
+ return new StartupConfiguration( "com.provider", classpathConfiguration, classLoaderConfiguration, false,
false );
}
Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkConfigurationTest.java Thu Aug 9 16:27:59 2012
@@ -74,7 +74,7 @@ public class ForkConfigurationTest
throws IOException
{
ForkConfiguration forkConfiguration =
- new ForkConfiguration( new Classpath(), ForkConfiguration.FORK_ONCE, null );
+ new ForkConfiguration( new Classpath(), null );
forkConfiguration.setWorkingDirectory( new File( "." ).getCanonicalFile() );
return forkConfiguration;
}
Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java Thu Aug 9 16:27:59 2012
@@ -39,7 +39,7 @@ public class FileReporterTest
*/
public void testFileNameWithoutSuffix()
{
- File reportDir = new File( "." );
+ File reportDir = new File( "target" );
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
reporter = new FileReporter( true, reportDir, null );
reporter.testSetStarting( reportEntry );
@@ -55,7 +55,7 @@ public class FileReporterTest
*/
public void testFileNameWithSuffix()
{
- File reportDir = new File( "." );
+ File reportDir = new File( "target" );
String suffixText = "sampleSuffixText";
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
reporter = new FileReporter( true, reportDir, suffixText );
Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java Thu Aug 9 16:27:59 2012
@@ -94,7 +94,7 @@ public class XMLReporterTest
*/
public void testFileNameWithSuffix()
{
- File reportDir = new File( "." );
+ File reportDir = new File( "target" );
String testName = "org.apache.maven.surefire.report.XMLReporterTest";
String suffixText = "sampleSuffixText";
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java Thu Aug 9 16:27:59 2012
@@ -35,7 +35,6 @@ public interface BooterConstants
String FAILIFNOTESTS = "failIfNoTests";
String ISTRIMSTACKTRACE = "isTrimStackTrace";
String REPORTSDIRECTORY = "reportsDirectory";
- String FORKMODE = "forkMode";
String TESTARTIFACT_VERSION = "testFwJarVersion";
String TESTARTIFACT_CLASSIFIER = "testFwJarClassifier";
String REQUESTEDTEST = "requestedTest";
Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Thu Aug 9 16:27:59 2012
@@ -98,14 +98,12 @@ public class BooterDeserializer
boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
- String forkMode = properties.getProperty( FORKMODE );
ClassLoaderConfiguration classLoaderConfiguration =
new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar );
ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties );
- return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration,
- forkMode );
+ return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration );
}
}
Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java Thu Aug 9 16:27:59 2012
@@ -40,22 +40,20 @@ public class StartupConfiguration
public StartupConfiguration( String providerClassName, ClasspathConfiguration classpathConfiguration,
- ClassLoaderConfiguration classLoaderConfiguration, String forkMode,
- boolean inForkedVm )
+ ClassLoaderConfiguration classLoaderConfiguration, boolean isForkRequested, boolean inForkedVm )
{
this.providerClassName = providerClassName;
this.classpathConfiguration = classpathConfiguration;
this.classLoaderConfiguration = classLoaderConfiguration;
- isForkRequested = !"never".equals( forkMode );
+ this.isForkRequested = isForkRequested;
isInForkedVm = inForkedVm;
}
public static StartupConfiguration inForkedVm( String providerClassName,
ClasspathConfiguration classpathConfiguration,
- ClassLoaderConfiguration classLoaderConfiguration, String forkMode )
+ ClassLoaderConfiguration classLoaderConfiguration )
{
- return new StartupConfiguration( providerClassName, classpathConfiguration, classLoaderConfiguration, forkMode,
- true );
+ return new StartupConfiguration( providerClassName, classpathConfiguration, classLoaderConfiguration, true, true );
}
public ClasspathConfiguration getClasspathConfiguration()
Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java?rev=1371299&r1=1371298&r2=1371299&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SystemPropertyManager.java Thu Aug 9 16:27:59 2012
@@ -70,11 +70,11 @@ public class SystemPropertyManager
p.setAsSystemProperties();
}
- public static File writePropertiesFile( Properties properties, File tempDirectory, String name, boolean isDebug )
+ public static File writePropertiesFile( Properties properties, File tempDirectory, String name, boolean keepForkFiles )
throws IOException
{
File file = File.createTempFile( name, "tmp", tempDirectory );
- if ( !isDebug )
+ if ( !keepForkFiles )
{
file.deleteOnExit();
}