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/08 21:42:48 UTC
svn commit: r1370913 - in /maven/surefire/trunk:
maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/
maven-surefire-common/src/main/java/org/apache/maven/plugin/sur...
Author: krosenvold
Date: Wed Aug 8 19:42:47 2012
New Revision: 1370913
URL: http://svn.apache.org/viewvc?rev=1370913&view=rev
Log:
o More simplification
Modified:
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
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/SurefireExecutionParameters.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.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=1370913&r1=1370912&r2=1370913&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 Wed Aug 8 19:42:47 2012
@@ -363,16 +363,6 @@ public class IntegrationTestMojo
this.classesDirectory = classesDirectory;
}
- public MavenProject getProject()
- {
- return project;
- }
-
- public void setProject( MavenProject project )
- {
- this.project = project;
- }
-
public List<String> getClasspathDependencyExcludes()
{
return classpathDependencyExcludes;
@@ -413,16 +403,6 @@ public class IntegrationTestMojo
this.reportsDirectory = reportsDirectory;
}
- public File getTestSourceDirectory()
- {
- return testSourceDirectory;
- }
-
- public void setTestSourceDirectory( File testSourceDirectory )
- {
- this.testSourceDirectory = testSourceDirectory;
- }
-
public String getTest()
{
if ( StringUtils.isBlank( test ) )
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=1370913&r1=1370912&r2=1370913&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 Wed Aug 8 19:42:47 2012
@@ -622,21 +622,9 @@ public abstract class AbstractSurefireMo
{
createDependencyResolver();
- Properties originalSystemProperties =
- ForkConfiguration.isInProcess( getForkMode() ) ? (Properties) System.getProperties().clone() : null;
- try
- {
- Summary summary = executeAllProviders( scanResult );
+ Summary summary = executeAllProviders( scanResult );
- handleSummary( summary );
- }
- finally
- {
- if ( originalSystemProperties != null )
- {
- System.setProperties( originalSystemProperties );
- }
- }
+ handleSummary( summary );
}
private Artifact surefireBooterArtifact;
@@ -723,9 +711,18 @@ public abstract class AbstractSurefireMo
}
else
{
- ForkStarter forkStarter =
- createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters, effectiveProperties );
- result = forkStarter.run( scanResult );
+ Properties originalSystemProperties = (Properties) System.getProperties().clone();
+ try
+ {
+ ForkStarter forkStarter =
+ createForkStarter( provider, forkConfiguration, classLoaderConfiguration, runOrderParameters,
+ effectiveProperties );
+ result = forkStarter.run( scanResult );
+ }
+ finally
+ {
+ System.setProperties( originalSystemProperties );
+ }
}
summary.registerRunResult( result );
}
@@ -1182,7 +1179,8 @@ public abstract class AbstractSurefireMo
StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration( configChecksum );
ProviderConfiguration providerConfiguration = createProviderConfiguration( runOrderParameters );
return new ForkStarter( providerConfiguration, startupConfiguration, forkConfiguration,
- getForkedProcessTimeoutInSeconds(), startupReportConfiguration, effectiveSystemProperties );
+ getForkedProcessTimeoutInSeconds(), startupReportConfiguration,
+ effectiveSystemProperties );
}
protected InPluginVMSurefireStarter createInprocessStarter( ProviderInfo provider,
@@ -1225,6 +1223,7 @@ public abstract class AbstractSurefireMo
Toolchain tc = getToolchain();
+ String jvmToUse = getJvm();
if ( tc != null )
{
getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + tc );
@@ -1232,13 +1231,13 @@ public abstract class AbstractSurefireMo
{
setForkMode( ForkConfiguration.FORK_ONCE );
}
- if ( getJvm() != null )
+ if ( jvmToUse != null )
{
- getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + getJvm() );
+ getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + jvmToUse );
}
else
{
- setJvm( tc.findTool( "java" ) ); //NOI18N
+ jvmToUse = tc.findTool( "java" ); //NOI18N
}
}
@@ -1254,14 +1253,14 @@ public abstract class AbstractSurefireMo
fork.setDebugLine( getDebugForkedProcess() );
- if ( ( getJvm() == null || "".equals( getJvm() ) ) )
+ if ( ( jvmToUse == null || "".equals( jvmToUse ) ) )
{
// use the same JVM as the one used to run Maven (the "java.home" one)
- setJvm( System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java" );
- getLog().debug( "Using JVM: " + getJvm() );
+ jvmToUse = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java";
+ getLog().debug( "Using JVM: " + jvmToUse );
}
- fork.setJvmExecutable( getJvm() );
+ fork.setJvmExecutable( jvmToUse );
if ( getWorkingDirectory() != null )
{
@@ -1569,20 +1568,6 @@ public abstract class AbstractSurefireMo
return new Classpath( items );
}
- private SurefireProperties createEffectiveProperties()
- {
- SurefireProperties result =
- SurefireProperties.calculateEffectiveProperties( getSystemProperties(), getSystemPropertiesFile(),
- getSystemPropertyVariables(), getUserProperties(),
- getLog() );
-
- result.setProperty( "basedir", getBasedir().getAbsolutePath() );
- result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() );
- result.setProperty( "localRepository", getLocalRepository().getBasedir() );
- return result;
- }
-
-
private Properties getUserProperties()
{
Properties props = null;
@@ -1986,11 +1971,6 @@ public abstract class AbstractSurefireMo
return jvm;
}
- public void setJvm( String jvm )
- {
- this.jvm = jvm;
- }
-
public String getArgLine()
{
return argLine;
@@ -2244,4 +2224,24 @@ public abstract class AbstractSurefireMo
return pluginDescriptor;
}
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+ public void setProject( MavenProject project )
+ {
+ this.project = project;
+ }
+
+ public File getTestSourceDirectory()
+ {
+ return testSourceDirectory;
+ }
+
+ public void setTestSourceDirectory( File testSourceDirectory )
+ {
+ this.testSourceDirectory = testSourceDirectory;
+ }
+
}
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java?rev=1370913&r1=1370912&r2=1370913&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java Wed Aug 8 19:42:47 2012
@@ -21,20 +21,10 @@ package org.apache.maven.plugin.surefire
import java.io.File;
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.ArtifactResolver;
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.toolchain.ToolchainManager;
/**
- * The parameters required to execute surefire.
+ * This interface contains all the common parameters that have different implementations in Surefire vs IntegrationTest
*
* @author Stephen Connolly
* @noinspection UnusedDeclaration, UnusedDeclaration
@@ -65,10 +55,6 @@ public interface SurefireExecutionParame
void setClassesDirectory( File classesDirectory );
- MavenProject getProject();
-
- void setProject( MavenProject project );
-
List<String> getClasspathDependencyExcludes();
void setClasspathDependencyExcludes( List<String> classpathDependencyExcludes );
@@ -107,32 +93,6 @@ public interface SurefireExecutionParame
void setLocalRepository( ArtifactRepository localRepository );
- Properties getSystemProperties();
-
- void setSystemProperties( Properties systemProperties );
-
- Map<String, String> getSystemPropertyVariables();
-
- void setSystemPropertyVariables( Map<String, String> systemPropertyVariables );
-
- File getSystemPropertiesFile();
-
- void setSystemPropertiesFile( File systemPropertiesFile );
-
- Properties getProperties();
-
- void setProperties( Properties properties );
-
- PluginDescriptor getPluginDescriptor();
-
- Map<String, Artifact> getPluginArtifactMap();
-
- void setPluginArtifactMap( Map<String, Artifact> pluginArtifactMap );
-
- Map<String, Artifact> getProjectArtifactMap();
-
- void setProjectArtifactMap( Map<String, Artifact> projectArtifactMap );
-
boolean isPrintSummary();
void setPrintSummary( boolean printSummary );
@@ -141,30 +101,10 @@ public interface SurefireExecutionParame
void setReportFormat( String reportFormat );
- String getReportNameSuffix();
-
- void setReportNameSuffix( String reportNameSuffix );
-
boolean isUseFile();
void setUseFile( boolean useFile );
- boolean isRedirectTestOutputToFile();
-
- void setRedirectTestOutputToFile( boolean redirectTestOutputToFile );
-
- String getForkMode();
-
- void setForkMode( String forkMode );
-
- String getJvm();
-
- void setJvm( String jvm );
-
- String getArgLine();
-
- void setArgLine( String argLine );
-
String getDebugForkedProcess();
void setDebugForkedProcess( String debugForkedProcess );
@@ -173,78 +113,6 @@ public interface SurefireExecutionParame
void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds );
- Map<String, String> getEnvironmentVariables();
-
- void setEnvironmentVariables( Map<String, String> environmentVariables );
-
- File getWorkingDirectory();
-
- void setWorkingDirectory( File workingDirectory );
-
- boolean isChildDelegation();
-
- void setChildDelegation( boolean childDelegation );
-
- String getGroups();
-
- void setGroups( String groups );
-
- String getExcludedGroups();
-
- void setExcludedGroups( String excludedGroups );
-
- File[] getSuiteXmlFiles();
-
- void setSuiteXmlFiles( File[] suiteXmlFiles );
-
- String getJunitArtifactName();
-
- void setJunitArtifactName( String junitArtifactName );
-
- String getTestNGArtifactName();
-
- void setTestNGArtifactName( String testNGArtifactName );
-
- int getThreadCount();
-
- void setThreadCount( int threadCount );
-
- boolean getPerCoreThreadCount();
-
- void setPerCoreThreadCount( boolean perCoreThreadCount );
-
- boolean getUseUnlimitedThreads();
-
- void setUseUnlimitedThreads( boolean useUnlimitedThreads );
-
- String getParallel();
-
- void setParallel( String parallel );
-
- boolean isTrimStackTrace();
-
- void setTrimStackTrace( boolean trimStackTrace );
-
- ArtifactResolver getArtifactResolver();
-
- void setArtifactResolver( ArtifactResolver artifactResolver );
-
- ArtifactFactory getArtifactFactory();
-
- void setArtifactFactory( ArtifactFactory artifactFactory );
-
- List<ArtifactRepository> getRemoteRepositories();
-
- void setRemoteRepositories( List<ArtifactRepository> remoteRepositories );
-
- ArtifactMetadataSource getMetadataSource();
-
- void setMetadataSource( ArtifactMetadataSource metadataSource );
-
- boolean isDisableXmlReport();
-
- void setDisableXmlReport( boolean disableXmlReport );
-
boolean isUseSystemClassLoader();
void setUseSystemClassLoader( boolean useSystemClassLoader );
@@ -253,34 +121,7 @@ public interface SurefireExecutionParame
void setUseManifestOnlyJar( boolean useManifestOnlyJar );
- boolean isEnableAssertions();
-
- void setEnableAssertions( boolean enableAssertions );
-
- MavenSession getSession();
-
- void setSession( MavenSession session );
-
- String getObjectFactory();
-
- void setObjectFactory( String objectFactory );
-
- ToolchainManager getToolchainManager();
-
- void setToolchainManager( ToolchainManager toolchainManager );
-
Boolean getFailIfNoSpecifiedTests();
void setFailIfNoSpecifiedTests( Boolean failIfNoSpecifiedTests );
-
- Boolean getFailIfNoTests();
-
- void setFailIfNoTests( Boolean failIfNoTests );
-
- boolean isMavenParallel();
-
- void setRunOrder( String runOrder );
-
- String getRunOrder();
-
}
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java?rev=1370913&r1=1370912&r2=1370913&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java Wed Aug 8 19:42:47 2012
@@ -11,7 +11,7 @@ package org.apache.maven.plugin.surefire
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
+ * Unless required| by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
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=1370913&r1=1370912&r2=1370913&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 Wed Aug 8 19:42:47 2012
@@ -23,10 +23,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
@@ -62,13 +60,11 @@ public class ForkConfiguration
private final String forkMode;
- private Properties systemProperties;
-
private String jvmExecutable;
private String argLine;
- private Map environmentVariables;
+ private Map<String, String> environmentVariables;
private File workingDirectory;
@@ -116,21 +112,6 @@ public class ForkConfiguration
return !FORK_NEVER.equals( forkMode );
}
- public static boolean isForking( String forkMode )
- {
- return !FORK_NEVER.equals( getForkMode( forkMode ) );
- }
-
- public static boolean isInProcess( String forkMode )
- {
- return !isForking( forkMode );
- }
-
- public void setSystemProperties( Properties systemProperties )
- {
- this.systemProperties = (Properties) systemProperties.clone();
- }
-
public void setJvmExecutable( String jvmExecutable )
{
this.jvmExecutable = jvmExecutable;
@@ -146,9 +127,9 @@ public class ForkConfiguration
this.debugLine = debugLine;
}
- public void setEnvironmentVariables( Map environmentVariables )
+ public void setEnvironmentVariables( Map<String, String> environmentVariables )
{
- this.environmentVariables = new HashMap( environmentVariables );
+ this.environmentVariables = new HashMap<String, String>( environmentVariables );
}
public void setWorkingDirectory( File workingDirectory )
@@ -196,13 +177,10 @@ public class ForkConfiguration
if ( environmentVariables != null )
{
- Iterator iter = environmentVariables.keySet().iterator();
- while ( iter.hasNext() )
+ for ( String key : environmentVariables.keySet() )
{
- String key = (String) iter.next();
-
- String value = (String) environmentVariables.get( key );
+ String value = environmentVariables.get( key );
cli.addEnvironment( key, value );
}
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=1370913&r1=1370912&r2=1370913&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 Wed Aug 8 19:42:47 2012
@@ -270,15 +270,6 @@ public class SurefirePlugin
this.classesDirectory = classesDirectory;
}
- public MavenProject getProject()
- {
- return project;
- }
-
- public void setProject( MavenProject project )
- {
- this.project = project;
- }
public List<String> getClasspathDependencyExcludes()
{
@@ -320,16 +311,6 @@ public class SurefirePlugin
this.reportsDirectory = reportsDirectory;
}
- public File getTestSourceDirectory()
- {
- return testSourceDirectory;
- }
-
- public void setTestSourceDirectory( File testSourceDirectory )
- {
- this.testSourceDirectory = testSourceDirectory;
- }
-
public String getTest()
{
if ( StringUtils.isBlank( test ) )