You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/05/01 05:57:38 UTC

svn commit: r398518 - /maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Author: brett
Date: Sun Apr 30 20:57:38 2006
New Revision: 398518

URL: http://svn.apache.org/viewcvs?rev=398518&view=rev
Log:
[MSUREFIRE-94] correct setting of system properties when not forking. Restore original system properties after tests.

Modified:
    maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Modified: maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewcvs/maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=398518&r1=398517&r2=398518&view=diff
==============================================================================
--- maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original)
+++ maven/plugins/branches/maven-surefire-plugin-testng/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Sun Apr 30 20:57:38 2006
@@ -331,6 +331,8 @@
 
     private static final String PLAIN_REPORT_FORMAT = "plain";
 
+    private Properties originalSystemProperties;
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -370,6 +372,12 @@
                 throw new MojoExecutionException( e.getMessage(), e );
             }
 
+            if ( originalSystemProperties != null )
+            {
+                // restore system properties
+                System.setProperties( originalSystemProperties );
+            }
+
             if ( !success )
             {
                 String msg = "There are test failures.";
@@ -414,7 +422,9 @@
                 VersionRange range = VersionRange.createFromVersionSpec( "[4.7-SNAPSHOT,)" );
                 if ( !range.containsVersion( testNgArtifact.getSelectedVersion() ) )
                 {
-                    throw new MojoFailureException( "TestNG support requires version 4.7 or above. You have declared version " + testNgArtifact.getVersion() );
+                    throw new MojoFailureException(
+                        "TestNG support requires version 4.7 or above. You have declared version " +
+                            testNgArtifact.getVersion() );
                 }
 
                 // The plugin uses a JDK based profile to select the right testng. We might be explicity using a
@@ -437,8 +447,7 @@
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw new MojoExecutionException(
-                "Error determining the TestNG version requested: " + e.getMessage(), e );
+            throw new MojoExecutionException( "Error determining the TestNG version requested: " + e.getMessage(), e );
         }
         catch ( ArtifactResolutionException e )
         {
@@ -557,7 +566,7 @@
 
         fork.setForkMode( forkMode );
 
-        processSystemProperties( fork.isForking() );
+        processSystemProperties( !fork.isForking() );
 
         if ( getLog().isDebugEnabled() )
         {
@@ -658,6 +667,8 @@
         {
             systemProperties = new Properties();
         }
+
+        originalSystemProperties = (Properties) systemProperties.clone();
 
         systemProperties.setProperty( "basedir", basedir.getAbsolutePath() );