maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1042820 - in /maven/surefire/trunk: maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-failsafe-plugin/src/site/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-plugin/src/main/...
Date Mon, 06 Dec 2010 22:29:56 GMT
Author: krosenvold
Date: Mon Dec  6 22:29:54 2010
New Revision: 1042820

URL: http://svn.apache.org/viewvc?rev=1042820&view=rev
Log:
[SUREFIRE-141] Feature complete, including simple first version docs and javadoc.

A little fine tuning and some more docs remain before I close the issue

Added:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ConfigurableProviderInfo.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java   (with props)
    maven/surefire/trunk/maven-surefire-plugin/src/site/apt/api.apt   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire141PluggableProvidersIT.java
      - copied, changed from r1042818, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/pom.xml   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java
      - copied, changed from r1042818, maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/services/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/pom.xml   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/BasicTest.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/TestTwo.java   (with props)
Removed:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BooterParameters.java
Modified:
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml
    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/SurefireDependencyResolver.java
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java
    maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.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=1042820&r1=1042819&r2=1042820&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 Mon Dec  6 22:29:54 2010
@@ -27,6 +27,7 @@ import org.apache.maven.execution.MavenS
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.surefire.AbstractSurefireMojo;
+import org.apache.maven.plugin.surefire.ProviderInfo;
 import org.apache.maven.plugin.surefire.SurefireExecutionParameters;
 import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration;
 import org.apache.maven.plugin.surefire.booterclient.ForkStarter;
@@ -47,6 +48,7 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -604,33 +606,44 @@ public class IntegrationTestMojo
         {
             logReportsDirectory();
 
-            final AbstractSurefireMojo.WellKnownProvider provider = initialize();
-            ForkConfiguration forkConfiguration = getForkConfiguration();
-            ForkStarter forkStarter = createForkStarter( provider, forkConfiguration );
-
+            final List providers = initialize();
+            String exceptionMessage = null;
             FailsafeSummary result = new FailsafeSummary();
-            try
-            {
-                result.setResult( forkStarter.run() );
-            }
-            catch ( SurefireBooterForkException e )
+
+            ForkConfiguration forkConfiguration = null;
+            for ( Iterator iter = providers.iterator(); iter.hasNext(); )
             {
-                // Don't stop processing when timeout or other exception occures
-                // Otherwise, the following life cycles (e.g. post-integration-test)
-                // won't be executed
-                result.setResult( ProviderConfiguration.TESTS_FAILED_EXIT_CODE );
-                result.setException( e.getMessage() );
+                ProviderInfo provider = (ProviderInfo) iter.next();
+                forkConfiguration = getForkConfiguration();
+                ForkStarter forkStarter = createForkStarter( provider, forkConfiguration );
+                try
+                {
+                    result.setResult( forkStarter.run() );
+                }
+                catch ( SurefireBooterForkException e )
+                {
+                    if ( exceptionMessage == null )
+                    {
+                        exceptionMessage = e.getMessage();
+                    }
+                }
+                catch ( SurefireExecutionException e )
+                {
+                    if ( exceptionMessage == null )
+                    {
+                        exceptionMessage = e.getMessage();
+                    }
+                }
             }
-            catch ( SurefireExecutionException e )
+
+            if ( exceptionMessage != null )
             {
-                // Don't stop processing when timeout or other exception occures
-                // Otherwise, the following life cycles (e.g. post-integration-test)
-                // won't be executed
+                // Fail no matter what as long as any provider failed
                 result.setResult( ProviderConfiguration.TESTS_FAILED_EXIT_CODE );
-                result.setException( e.getMessage() );
+                result.setException( exceptionMessage );
             }
 
-            if ( getOriginalSystemProperties() != null && !forkConfiguration.isForking() )
+            if ( getOriginalSystemProperties() != null && forkConfiguration != null && !forkConfiguration.isForking() )
             {
                 // restore system properties, only makes sense when not forking..
                 System.setProperties( getOriginalSystemProperties() );

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml (original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/site/site.xml Mon Dec  6 22:29:54 2010
@@ -25,6 +25,7 @@
       <item name="Introduction" href="index.html"/>
       <item name="Goals" href="plugin-info.html"/>
       <item name="Usage" href="usage.html"/>
+      <item name="API" href="api.html"/>
       <item name="FAQ" href="faq.html"/>
     </menu>
     <menu name="Examples">

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=1042820&r1=1042819&r2=1042820&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 Mon Dec  6 22:29:54 2010
@@ -39,9 +39,7 @@ import org.apache.maven.shared.artifact.
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ClasspathConfiguration;
 import org.apache.maven.surefire.booter.ProviderConfiguration;
-import org.apache.maven.surefire.booter.ProviderDetector;
 import org.apache.maven.surefire.booter.StartupConfiguration;
-import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.BriefConsoleReporter;
 import org.apache.maven.surefire.report.BriefFileReporter;
 import org.apache.maven.surefire.report.ConsoleReporter;
@@ -57,7 +55,6 @@ import org.apache.maven.toolchain.Toolch
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
-import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -98,9 +95,9 @@ public abstract class AbstractSurefireMo
     private Artifact surefireArtifact;
 
 
-    WellKnownProvider[] wellKnownProviders;
+    ProviderList wellKnownProviders;
 
-    protected WellKnownProvider initialize()
+    protected List initialize()
         throws MojoFailureException
     {
         dependencyResolver =
@@ -109,32 +106,11 @@ public abstract class AbstractSurefireMo
 
         try
         {
-            wellKnownProviders = new WellKnownProvider[]{ new TestNgProviderInfo( getTestNgArtifact() ),
+            wellKnownProviders = new ProviderList(new ProviderInfo[]{ new TestNgProviderInfo( getTestNgArtifact() ),
                 new JUnitCoreProviderInfo( getJunitArtifact() ), new JUnit4ProviderInfo( getJunitArtifact() ),
-                new JUnit3ProviderInfo() };
-            String manuallyConfiguredProvider = getManuallyConfiguredProviderName();
-            if ( manuallyConfiguredProvider != null )
-            {
-                // Ok, all this code will have to go when we solve surefire-141. In the meantime we solve surefire-408
-                for ( int i = 0; i < wellKnownProviders.length; i++ )
-                {
-                    WellKnownProvider wellKnownProvider = wellKnownProviders[i];
-                    if ( wellKnownProvider.getProviderName().equals( manuallyConfiguredProvider ) )
-                    {
-                        getLog().info( "Using explicitly configured provider " + wellKnownProvider.getProviderName() );
-                        return wellKnownProvider;
-                    }
-                }
-                throw new IllegalArgumentException( "Unknown provider configured " + manuallyConfiguredProvider );
-            }
-            for ( int i = 0; i < wellKnownProviders.length; i++ )
-            {
-                if ( wellKnownProviders[i].isApplicable() )
-                {
-                    return wellKnownProviders[i];
-                }
-            }
-            return null;
+                new JUnit3ProviderInfo() }, new DynamicProviderInfo( null ) );
+
+            return wellKnownProviders.resolve(getLog());
         }
         catch ( InvalidVersionSpecificationException e )
         {
@@ -149,33 +125,6 @@ public abstract class AbstractSurefireMo
     }
 
 
-    private String getManuallyConfiguredProviderName()
-    {
-        try
-        {
-            final Set objects = ProviderDetector.getServiceNames( SurefireProvider.class,
-                                                                  Thread.currentThread().getContextClassLoader() );
-            if ( objects == null || objects.size() == 0 )
-            {
-                return null;
-            }
-            if ( objects.size() > 1 )
-            {
-                throw new IllegalArgumentException(
-                    "Surefire currently only supports on manually configured provider" );
-            }
-            return (String) objects.iterator().next();
-
-        }
-
-        catch ( IOException e )
-        {
-            throw new RuntimeException( e );
-        }
-
-
-    }
-
     protected final Toolchain getToolchain()
     {
         Toolchain tc = null;
@@ -277,9 +226,7 @@ public abstract class AbstractSurefireMo
         return ForkConfiguration.FORK_NEVER.equals( getForkMode() );
     }
 
-    protected ProviderConfiguration createProviderConfiguration( ForkConfiguration forkConfiguration,
-                                                                 WellKnownProvider provider,
-                                                                 StartupConfiguration startupConfiguration )
+    protected ProviderConfiguration createProviderConfiguration( ForkConfiguration forkConfiguration )
         throws MojoExecutionException, MojoFailureException
     {
 
@@ -304,10 +251,6 @@ public abstract class AbstractSurefireMo
             junitArtifact = getJunitArtifact();
 
             testNgArtifact = getTestNgArtifact();
-
-            provider.addProviderProperties();
-            provider.addProviderArtifactToBootClasspath( forkConfiguration.getBootClasspath() );
-            provider.addProviderArtifactToSurefireClasspath( startupConfiguration.getClasspathConfiguration() );
         }
         catch ( ArtifactNotFoundException e )
         {
@@ -391,7 +334,7 @@ public abstract class AbstractSurefireMo
     }
 
     protected StartupConfiguration createStartupConfiguration( ForkConfiguration forkConfiguration,
-                                                               WellKnownProvider provider )
+                                                               ProviderInfo provider )
         throws MojoExecutionException, MojoFailureException
     {
         final ClasspathConfiguration classpathConfiguration =
@@ -559,12 +502,12 @@ public abstract class AbstractSurefireMo
         return junitArtifact;
     }
 
-    protected ForkStarter createForkStarter( WellKnownProvider provider, ForkConfiguration forkConfiguration )
+    protected ForkStarter createForkStarter( ProviderInfo provider, ForkConfiguration forkConfiguration )
         throws MojoExecutionException, MojoFailureException
     {
         StartupConfiguration startupConfiguration = createStartupConfiguration( forkConfiguration, provider );
         ProviderConfiguration providerConfiguration =
-            createProviderConfiguration( forkConfiguration, provider, startupConfiguration );
+            createProviderConfiguration( forkConfiguration );
         return new ForkStarter( providerConfiguration, startupConfiguration, getReportsDirectory(), forkConfiguration,
                                 getForkedProcessTimeoutInSeconds() );
     }
@@ -955,26 +898,8 @@ public abstract class AbstractSurefireMo
         }
     }
 
-
-    public interface WellKnownProvider
-    {
-        String getProviderName();
-
-        String getProviderArtifactName();
-
-        public boolean isApplicable();
-
-        public void addProviderArtifactToBootClasspath( Classpath bootclasspath )
-            throws ArtifactResolutionException, ArtifactNotFoundException;
-
-        public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration bootclasspath )
-            throws ArtifactResolutionException, ArtifactNotFoundException;
-
-        public void addProviderProperties();
-    }
-
     class TestNgProviderInfo
-        implements WellKnownProvider
+        implements ProviderInfo
     {
         private final Artifact testNgArtifact;
 
@@ -988,11 +913,6 @@ public abstract class AbstractSurefireMo
             return "org.apache.maven.surefire.testng.TestNGProvider";
         }
 
-        public String getProviderArtifactName()
-        {
-            return "surefire-testng";
-        }
-
         public boolean isApplicable()
         {
             return testNgArtifact != null;
@@ -1021,18 +941,13 @@ public abstract class AbstractSurefireMo
     }
 
     class JUnit3ProviderInfo
-        implements WellKnownProvider
+        implements ProviderInfo
     {
         public String getProviderName()
         {
             return "org.apache.maven.surefire.junit.JUnit3Provider";
         }
 
-        public String getProviderArtifactName()
-        {
-            return "surefire-junit3";
-        }
-
         public boolean isApplicable()
         {
             return true;
@@ -1051,7 +966,7 @@ public abstract class AbstractSurefireMo
         {
             // add the JUnit provider as default - it doesn't require JUnit to be present,
             // since it supports POJO tests.
-            dependencyResolver.addProviderToClasspath( classpathConfiguration, getProviderArtifactName(),
+            dependencyResolver.addProviderToClasspath( classpathConfiguration, "surefire-junit3",
                                                        surefireArtifact.getBaseVersion(), null );
 
         }
@@ -1059,7 +974,7 @@ public abstract class AbstractSurefireMo
     }
 
     class JUnit4ProviderInfo
-        implements WellKnownProvider
+        implements ProviderInfo
     {
         private final Artifact junitArtifact;
 
@@ -1073,11 +988,6 @@ public abstract class AbstractSurefireMo
             return "org.apache.maven.surefire.junit4.JUnit4Provider";
         }
 
-        public String getProviderArtifactName()
-        {
-            return "surefire-junit4";
-        }
-
         public boolean isApplicable()
         {
             return isAnyJunit4( junitArtifact );
@@ -1094,7 +1004,7 @@ public abstract class AbstractSurefireMo
         public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration )
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
-            dependencyResolver.addProviderToClasspath( classpathConfiguration, getProviderArtifactName(),
+            dependencyResolver.addProviderToClasspath( classpathConfiguration, "surefire-junit4",
                                                        surefireArtifact.getBaseVersion(), null );
 
         }
@@ -1102,7 +1012,7 @@ public abstract class AbstractSurefireMo
     }
 
     class JUnitCoreProviderInfo
-        implements WellKnownProvider
+        implements ProviderInfo
     {
         private final Artifact junitArtifact;
 
@@ -1116,19 +1026,57 @@ public abstract class AbstractSurefireMo
             return "org.apache.maven.surefire.junitcore.JUnitCoreProvider";
         }
 
-        public String getProviderArtifactName()
+        public boolean isApplicable()
         {
-            return "surefire-junit47";
+            return isAnyJunit4( junitArtifact ) && isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact );
+        }
+
+        public void addProviderProperties()
+        {
+            convertJunitCoreParameters();
+        }
+
+        public void addProviderArtifactToBootClasspath( Classpath bootclasspath )
+        {
+        }
+
+        public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration )
+            throws ArtifactResolutionException, ArtifactNotFoundException
+        {
+            dependencyResolver.addProviderToClasspath( classpathConfiguration, "surefire-junit47",
+                                                       surefireArtifact.getBaseVersion(), null );
+        }
+
+    }
+    public class DynamicProviderInfo
+        implements ConfigurableProviderInfo
+    {
+        final String providerName;
+
+        DynamicProviderInfo( String providerName )
+        {
+            this.providerName = providerName;
+        }
+
+        public ProviderInfo instantiate(String providerName){
+            return new DynamicProviderInfo(providerName);
+        }
+
+        public String getProviderName()
+        {
+            return providerName;
         }
 
         public boolean isApplicable()
         {
-            return isAnyJunit4( junitArtifact ) && isAnyConcurrencySelected() && isJunit47Compatible( junitArtifact );
+            return true;
         }
 
         public void addProviderProperties()
         {
+            // Ok this is a bit lazy.
             convertJunitCoreParameters();
+            convertTestNGParameters();
         }
 
         public void addProviderArtifactToBootClasspath( Classpath bootclasspath )
@@ -1138,9 +1086,11 @@ public abstract class AbstractSurefireMo
         public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration classpathConfiguration )
             throws ArtifactResolutionException, ArtifactNotFoundException
         {
-            dependencyResolver.addProviderToClasspath( classpathConfiguration, getProviderArtifactName(),
-                                                       surefireArtifact.getBaseVersion(), null );
+            final Map pluginArtifactMap = getPluginArtifactMap();
+            Artifact plugin = (Artifact) pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin");
+            dependencyResolver.addProviderToClasspath( classpathConfiguration, pluginArtifactMap, plugin );
         }
 
     }
+
 }

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ConfigurableProviderInfo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ConfigurableProviderInfo.java?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ConfigurableProviderInfo.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ConfigurableProviderInfo.java Mon Dec  6 22:29:54 2010
@@ -0,0 +1,29 @@
+package org.apache.maven.plugin.surefire;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Kristian Rosenvold
+ */
+interface ConfigurableProviderInfo
+    extends ProviderInfo
+{
+    ProviderInfo instantiate( String providerName );
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ConfigurableProviderInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java Mon Dec  6 22:29:54 2010
@@ -0,0 +1,43 @@
+package org.apache.maven.plugin.surefire;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.surefire.booter.Classpath;
+import org.apache.maven.surefire.booter.ClasspathConfiguration;
+
+/**
+* @author Kristian Rosenvold
+*/
+public interface ProviderInfo
+{
+    String getProviderName();
+
+    public boolean isApplicable();
+
+    public void addProviderArtifactToBootClasspath( Classpath bootclasspath )
+        throws ArtifactResolutionException, ArtifactNotFoundException;
+
+    public void addProviderArtifactToSurefireClasspath( ClasspathConfiguration bootclasspath )
+        throws ArtifactResolutionException, ArtifactNotFoundException;
+
+    public void addProviderProperties();
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java Mon Dec  6 22:29:54 2010
@@ -0,0 +1,113 @@
+package org.apache.maven.plugin.surefire;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.surefire.booter.ProviderDetector;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class ProviderList
+{
+    private final ProviderInfo[] wellKnownProviders;
+
+    private final ConfigurableProviderInfo dynamicProvider;
+
+    public ProviderList( ProviderInfo[] wellKnownProviders, ConfigurableProviderInfo dynamicProviderInfo )
+    {
+        this.wellKnownProviders = wellKnownProviders;
+        this.dynamicProvider = dynamicProviderInfo;
+    }
+
+
+    public List resolve( Log log )
+    {
+        List providersToRun = new ArrayList();
+
+        Set manuallyConfiguredProviders = getManuallyConfiguredProviders();
+        if ( manuallyConfiguredProviders.size() > 0 )
+        {
+            Iterator iter = manuallyConfiguredProviders.iterator();
+            String name;
+            while ( iter.hasNext() )
+            {
+                name = (String) iter.next();
+                ProviderInfo wellKnown = findByName( name );
+                ProviderInfo providerToAdd = wellKnown != null ? wellKnown : dynamicProvider.instantiate( name );
+                log.info( "Using configured provider " + providerToAdd.getProviderName() );
+                providersToRun.add( providerToAdd );
+            }
+            return providersToRun;
+        }
+
+        return autoDetectOneProvider();
+    }
+
+    private List autoDetectOneProvider()
+    {
+        List providersToRun = new ArrayList();
+        for ( int i = 0; i < wellKnownProviders.length; i++ )
+        {
+            if ( wellKnownProviders[i].isApplicable() )
+            {
+                providersToRun.add( wellKnownProviders[i] );
+                return providersToRun;
+            }
+        }
+        return providersToRun;
+    }
+
+    private Set getManuallyConfiguredProviders()
+    {
+        try
+        {
+            return ProviderDetector.getServiceNames( SurefireProvider.class,
+                                                     Thread.currentThread().getContextClassLoader() );
+        }
+
+        catch ( IOException e )
+        {
+            throw new RuntimeException( e );
+        }
+
+
+    }
+
+    private ProviderInfo findByName( String providerClassName )
+    {
+        for ( int i = 0; i < wellKnownProviders.length; i++ )
+        {
+            ProviderInfo wellKnownProvider = wellKnownProviders[i];
+            if ( wellKnownProvider.getProviderName().equals( providerClassName ) )
+            {
+                return wellKnownProvider;
+            }
+        }
+        return null;
+    }
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireDependencyResolver.java Mon Dec  6 22:29:54 2010
@@ -41,10 +41,11 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
- * Abstract base class for running tests using Surefire.
+ * Does dependency resolution and artifact handling for the surefire plugin.
  *
  * @author Stephen Connolly
  * @author Kristian Rosenvold
@@ -186,4 +187,17 @@ public class SurefireDependencyResolver
             bootClasspath.addClassPathElementUrl( artifact.getFile().getAbsolutePath() );
         }
     }
+
+    public void addProviderToClasspath( ClasspathConfiguration classpathConfiguration, Map pluginArtifactMap,
+                                        Artifact surefireArtifact )
+        throws ArtifactResolutionException, ArtifactNotFoundException
+    {
+        final ArtifactResolutionResult artifactResolutionResult = resolveArtifact( null, surefireArtifact );
+        for (Iterator iterator = pluginArtifactMap.values().iterator(); iterator.hasNext();){
+            Artifact artifact = (Artifact) iterator.next();
+            if( !artifactResolutionResult.getArtifacts().contains( artifact )){
+                classpathConfiguration.addClasspathUrl(  artifact.getFile().getPath() );
+            }
+        }
+    }
 }

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=1042820&r1=1042819&r2=1042820&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 Mon Dec  6 22:29:54 2010
@@ -32,10 +32,10 @@ import org.apache.maven.project.MavenPro
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 import org.apache.maven.toolchain.ToolchainManager;
-import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -569,25 +569,36 @@ public class SurefirePlugin
         {
             logReportsDirectory();
 
-            final WellKnownProvider provider = initialize();
-            ForkConfiguration forkConfiguration = getForkConfiguration();
-            ForkStarter forkStarter = createForkStarter( provider, forkConfiguration );
-
-            int result;
-            try
-            {
-                result = forkStarter.run();
-            }
-            catch ( SurefireBooterForkException e )
+            final List providers = initialize();
+            Exception exception = null;
+            ForkConfiguration forkConfiguration = null;
+            int result = 0;
+            for ( Iterator iter = providers.iterator(); iter.hasNext(); )
             {
-                throw new MojoExecutionException( e.getMessage(), e );
+                ProviderInfo provider = (ProviderInfo) iter.next();
+                forkConfiguration = getForkConfiguration();
+                ForkStarter forkStarter = createForkStarter( provider, forkConfiguration );
+
+                try
+                {
+                    result = forkStarter.run();
+                }
+                catch ( SurefireBooterForkException e )
+                {
+                    exception = e;
+                }
+                catch ( SurefireExecutionException e )
+                {
+                    exception = e;
+                }
             }
-            catch ( SurefireExecutionException e )
+
+            if ( exception != null )
             {
-                throw new MojoExecutionException( e.getMessage(), e );
+                throw new MojoExecutionException( exception.getMessage(), exception );
             }
 
-            if ( getOriginalSystemProperties() != null && !forkConfiguration.isForking() )
+            if ( getOriginalSystemProperties() != null && forkConfiguration != null && !forkConfiguration.isForking() )
             {
                 // restore system properties, only makes sense when not forking..
                 System.setProperties( getOriginalSystemProperties() );

Added: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/api.apt
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/site/apt/api.apt?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/site/apt/api.apt (added)
+++ maven/surefire/trunk/maven-surefire-plugin/src/site/apt/api.apt Mon Dec  6 22:29:54 2010
@@ -0,0 +1,51 @@
+  ------
+  Provider API
+  ------
+  Kristian Rosenvold
+  ------
+  2010-12-09
+  ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~   http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ 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
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Surefire Provider API
+
+  As of version 2.7 of surefire, there is a proposed public api available for
+  external providers to use surefire features.
+
+  The key features of surefire are forking, reporting and directory/classpath scanning.
+  The remaining features are implemented in the providers.
+
+   Please note that this API is still subject to change until otherwise declared, even in minor revisions.
+
+* Requirements for a provider
+
+  A provider contains a META-INF/services file entry named org.apache.maven.surefire.providerapi.SurefireProvider
+  ( as per {{{http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html}ServiceLoader}}). This file
+  contains the name of the actual provider class.
+
+  The actual provider class contains a one-arg constructor that accepts an instance of
+  org.apache.maven.surefire.providerapi.ProviderParameters. This interface delivers all the surefire feature
+  to the provider implementation, please see the javadoc of this interface for options.
+
+  There are 4 well-known providers within surefire that are also implemented this way, so
+  examples can be found by looking at the surefire source code itself. surefire-junit47 is
+  the showcase implementation.
\ No newline at end of file

Propchange: maven/surefire/trunk/maven-surefire-plugin/src/site/apt/api.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java Mon Dec  6 22:29:54 2010
@@ -20,7 +20,7 @@ package org.apache.maven.surefire.booter
  */
 
 import org.apache.maven.surefire.providerapi.BaseProviderFactory;
-import org.apache.maven.surefire.providerapi.BooterParameters;
+import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.DirectoryScannerParametersAware;
 import org.apache.maven.surefire.providerapi.ProviderPropertiesAware;
 import org.apache.maven.surefire.providerapi.ReporterConfigurationAware;
@@ -97,7 +97,7 @@ public class SurefireReflector
             reporterConfigurationAware = surefireClassLoader.loadClass( ReporterConfigurationAware.class.getName() );
             providerPropertiesAware = surefireClassLoader.loadClass( ProviderPropertiesAware.class.getName() );
             runResult = surefireClassLoader.loadClass( RunResult.class.getName() );
-            booterParameters= surefireClassLoader.loadClass( BooterParameters.class.getName() );
+            booterParameters= surefireClassLoader.loadClass( ProviderParameters.class.getName() );
         }
         catch ( ClassNotFoundException e )
         {

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/BaseProviderFactory.java Mon Dec  6 22:29:54 2010
@@ -35,7 +35,7 @@ import java.util.Properties;
  */
 public class BaseProviderFactory
     implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware, TestRequestAware,
-    ProviderPropertiesAware, BooterParameters, TestArtifactInfoAware
+    ProviderPropertiesAware, ProviderParameters, TestArtifactInfoAware
 {
     private Properties providerProperties;
 

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java Mon Dec  6 22:29:54 2010
@@ -0,0 +1,67 @@
+package org.apache.maven.surefire.providerapi;
+
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestRequest;
+import org.apache.maven.surefire.util.DirectoryScanner;
+
+import java.util.Properties;
+
+/**
+ * Injected into the providers upon provider construction. Allows the provider to request services and data it needs.
+ *
+ * @author Kristian Rosenvold
+ */
+public interface ProviderParameters
+{
+    /**
+     * Provides a directory scanner that enforces the includes/excludes parameters that were passed to surefire.
+     * @return The directory scanner
+     */
+    DirectoryScanner getDirectoryScanner();
+
+    /**
+     * Provides features for creating reporting objects
+     * @return A reportermanager factory that allows the creation of one or more ReporterManagers
+     */
+    ReporterManagerFactory getReporterManagerFactory();
+
+    /**
+     * The raw parameters used in creating the directory scanner
+     * @return The parameters
+     */
+    DirectoryScannerParameters getDirectoryScannerParameters();
+
+    /**
+     * The raw parameters used in creating the ReporterManagerFactory
+     * @return The reporter configuration
+     */
+    ReporterConfiguration getReporterConfiguration();
+
+    /**
+     * Contains information about requested test suites or individual tests from the command line.
+     * @return The testRequest
+     */
+
+    TestRequest getTestRequest();
+
+    /**
+     * The class loader for the tests
+     * @return the classloader
+     */
+    ClassLoader getTestClassLoader();
+
+    /**
+     * The per-provider specific properties that may come all the way from the plugin's properties setting.
+     * @return the provider specific properties
+     */
+    Properties getProviderProperties();
+
+    /**
+     * Artifact info about the artifact used to autodetect provider
+     * @return The artifactinfo, or null if autodetect was not used.
+     */
+    TestArtifactInfo getTestArtifactInfo();
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire141PluggableProvidersIT.java (from r1042818, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire141PluggableProvidersIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire141PluggableProvidersIT.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java&r1=1042818&r2=1042820&rev=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire141PluggableProvidersIT.java Mon Dec  6 22:29:54 2010
@@ -31,20 +31,26 @@ import java.util.Arrays;
  *
  * @author Kristian Rosenvold
  */
-public class Surefire408ManualProviderSelectionIT
+public class Surefire141PluggableProvidersIT
     extends AbstractSurefireIntegrationTestClass
 {
     public void testPaallelBuildResultCount()
         throws Exception
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/surefire-408-manual-provider-selection" );
-
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/surefire-141-pluggableproviders/test-provider" );
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
-        String[] opts = { "-X" };
-        verifier.setCliOptions( new ArrayList( Arrays.asList( opts ) ) );
-        this.executeGoal( verifier, "test" );
+        this.executeGoal(  verifier, "install" );
         verifier.resetStreams();
 
-        verifier.verifyTextInLog("Using explicitly configured provider org.apache.maven.surefire.junit.JUnit3Provider");
+        testDir = ResourceExtractor.simpleExtractResources( getClass(), "/surefire-141-pluggableproviders/test" );
+        verifier = new Verifier( testDir.getAbsolutePath() );
+        String[] opts = { "-e" };
+        verifier.setCliOptions( new ArrayList( Arrays.asList( opts ) ) );
+        this.executeGoal( verifier, "install" );
+
+        verifier.verifyTextInLog("Using configured provider org.apache.maven.surefire.testprovider.TestProvider");
+        verifier.verifyTextInLog("Using configured provider org.apache.maven.surefire.junit.JUnit3Provider");
+
+        verifier.verifyErrorFreeLog();
     }
 }
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire408ManualProviderSelectionIT.java Mon Dec  6 22:29:54 2010
@@ -40,11 +40,11 @@ public class Surefire408ManualProviderSe
         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/surefire-408-manual-provider-selection" );
 
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
-        String[] opts = { "-X" };
+        String[] opts = { "-e" };
         verifier.setCliOptions( new ArrayList( Arrays.asList( opts ) ) );
         this.executeGoal( verifier, "test" );
         verifier.resetStreams();
 
-        verifier.verifyTextInLog("Using explicitly configured provider org.apache.maven.surefire.junit.JUnit3Provider");
+        verifier.verifyTextInLog("Using configured provider org.apache.maven.surefire.junit.JUnit3Provider");
     }
 }
\ No newline at end of file

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/pom.xml?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/pom.xml Mon Dec  6 22:29:54 2010
@@ -0,0 +1,47 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ 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
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.surefire</groupId>
+  <artifactId>surefire-test-provider</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Test provider</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.surefire</groupId>
+      <artifactId>surefire-api</artifactId>
+      <version>${surefire.version}</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources/META-INF</directory>
+        <targetPath>META-INF</targetPath>
+      </resource>
+    </resources>
+  </build>
+
+
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java (from r1042818, maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java&p1=maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java&r1=1042818&r2=1042820&rev=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/java/org/apache/maven/surefire/testprovider/TestProvider.java Mon Dec  6 22:29:54 2010
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.junit;
+package org.apache.maven.surefire.testprovider;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,75 +19,44 @@ package org.apache.maven.surefire.junit;
  * under the License.
  */
 
-import org.apache.maven.surefire.providerapi.BooterParameters;
+import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.util.Iterator;
 
 /**
  * @author Kristian Rosenvold
- * @noinspection UnusedDeclaration
  */
-public class JUnit3Provider
+public class TestProvider
     implements SurefireProvider
 {
     private final ReporterManagerFactory reporterManagerFactory;
-
     private final ClassLoader testClassLoader;
 
-    private final DirectoryScanner directoryScanner;
-
-    public JUnit3Provider( BooterParameters booterParameters )
+    public TestProvider( ProviderParameters booterParameters )
     {
         this.reporterManagerFactory = booterParameters.getReporterManagerFactory();
         this.testClassLoader = booterParameters.getTestClassLoader();
-        this.directoryScanner = booterParameters.getDirectoryScanner();
     }
 
-    public RunResult invoke( Object forkTestSet )
-        throws TestSetFailedException, ReporterException
-    {
-        JUnitDirectoryTestSuite suite = getSuite();
-        suite.locateTestSets( testClassLoader );
-        if ( forkTestSet != null )
-        {
-            suite.execute( (String) forkTestSet, reporterManagerFactory, testClassLoader );
-        }
-        else
-        {
-            suite.execute( reporterManagerFactory, testClassLoader );
-        }
-
-        reporterManagerFactory.warnIfNoTests();
-
-        return reporterManagerFactory.close();
-    }
 
-    private JUnitDirectoryTestSuite getSuite()
+    public Boolean isRunnable()
     {
-        return new JUnitDirectoryTestSuite( directoryScanner );
-
+        return Boolean.TRUE;
     }
 
     public Iterator getSuites()
     {
-        try
-        {
-            return getSuite().locateTestSets( testClassLoader ).keySet().iterator();
-        }
-        catch ( TestSetFailedException e )
-        {
-            throw new RuntimeException( e );
-        }
+        return null;
     }
 
-    public Boolean isRunnable()
+    public RunResult invoke( Object forkTestSet )
+        throws TestSetFailedException, ReporterException
     {
-        return Boolean.TRUE;
+        return new RunResult( 1,0,0,2 );
     }
 }

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test-provider/src/main/resources/META-INF/services/org.apache.maven.surefire.providerapi.SurefireProvider Mon Dec  6 22:29:54 2010
@@ -0,0 +1 @@
+org.apache.maven.surefire.testprovider.TestProvider

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/pom.xml?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/pom.xml Mon Dec  6 22:29:54 2010
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ 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
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins.surefire</groupId>
+    <artifactId>junit-twoTestCases</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>Test for two test cases</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.surefire</groupId>
+                        <artifactId>surefire-junit3</artifactId>
+                        <version>${surefire.version}</version>
+                    </dependency>
+                  <dependency>
+                      <groupId>org.apache.maven.plugins.surefire</groupId>
+                      <artifactId>surefire-test-provider</artifactId>
+                      <version>1.0-SNAPSHOT</version>
+                  </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/BasicTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/BasicTest.java?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/BasicTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/BasicTest.java Mon Dec  6 22:29:54 2010
@@ -0,0 +1,67 @@
+package junit.twoTestCases;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class BasicTest
+    extends TestCase
+{
+
+    private boolean setUpCalled = false;
+
+    private static boolean tearDownCalled = false;
+
+    public BasicTest( String name, String extraName )
+    {
+        super( name );
+    }
+
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite();
+        Test test = new BasicTest( "testSetUp", "dummy" );
+        suite.addTest( test );
+        TestSetup setup = new TestSetup( suite )
+        {
+
+            protected void setUp()
+            {
+                //oneTimeSetUp();
+            }
+
+            protected void tearDown()
+            {
+                oneTimeTearDown();
+            }
+
+        };
+
+        return setup;
+    }
+
+    protected void setUp()
+    {
+        setUpCalled = true;
+        tearDownCalled = false;
+        System.out.println( "Called setUp" );
+    }
+
+    protected void tearDown()
+    {
+        setUpCalled = false;
+        tearDownCalled = true;
+        System.out.println( "Called tearDown" );
+    }
+
+    public void testSetUp()
+    {
+        assertTrue( "setUp was not called", setUpCalled );
+    }
+
+    public static void oneTimeTearDown()
+    {
+        assertTrue( "tearDown was not called", tearDownCalled );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/BasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/TestTwo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/TestTwo.java?rev=1042820&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/TestTwo.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/TestTwo.java Mon Dec  6 22:29:54 2010
@@ -0,0 +1,9 @@
+package junit.twoTestCases;
+import junit.framework.TestCase;
+
+
+public class TestTwo
+    extends TestCase
+{
+    public void testTwo() {}
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-141-pluggableproviders/test/src/test/java/junit/twoTestCases/TestTwo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java Mon Dec  6 22:29:54 2010
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.junit;
  * under the License.
  */
 
-import org.apache.maven.surefire.providerapi.BooterParameters;
+import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
@@ -42,7 +42,7 @@ public class JUnit3Provider
 
     private final DirectoryScanner directoryScanner;
 
-    public JUnit3Provider( BooterParameters booterParameters )
+    public JUnit3Provider( ProviderParameters booterParameters )
     {
         this.reporterManagerFactory = booterParameters.getReporterManagerFactory();
         this.testClassLoader = booterParameters.getTestClassLoader();

Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java Mon Dec  6 22:29:54 2010
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.junit4
  * under the License.
  */
 
-import org.apache.maven.surefire.providerapi.BooterParameters;
+import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
@@ -43,7 +43,7 @@ public class JUnit4Provider
 
     private final DirectoryScanner directoryScanner;
 
-    public JUnit4Provider( BooterParameters booterParameters )
+    public JUnit4Provider( ProviderParameters booterParameters )
     {
         this.reporterManagerFactory = booterParameters.getReporterManagerFactory();
         this.testClassLoader = booterParameters.getTestClassLoader();

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java Mon Dec  6 22:29:54 2010
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.junitc
  * under the License.
  */
 
-import org.apache.maven.surefire.providerapi.BooterParameters;
+import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManagerFactory;
@@ -44,7 +44,7 @@ public class JUnitCoreProvider
     private final DirectoryScanner directoryScanner;
 
 
-    public JUnitCoreProvider( BooterParameters booterParameters )
+    public JUnitCoreProvider( ProviderParameters booterParameters )
     {
         this.reporterManagerFactory = booterParameters.getReporterManagerFactory();
         this.testClassLoader = booterParameters.getTestClassLoader();

Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java?rev=1042820&r1=1042819&r2=1042820&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java Mon Dec  6 22:29:54 2010
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.testng
  * under the License.
  */
 
-import org.apache.maven.surefire.providerapi.BooterParameters;
+import org.apache.maven.surefire.providerapi.ProviderParameters;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterException;
@@ -30,7 +30,6 @@ import org.apache.maven.surefire.testset
 import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.DirectoryScanner;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -60,7 +59,7 @@ public class TestNGProvider
 
     private final File basedir;
 
-    public TestNGProvider( BooterParameters booterParameters )
+    public TestNGProvider( ProviderParameters booterParameters )
     {
         this.reporterManagerFactory = booterParameters.getReporterManagerFactory();
         this.testClassLoader = booterParameters.getTestClassLoader();



Mime
View raw message