maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1054768 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-integration-tests/src/test/resources/junit44-dep/
Date Mon, 03 Jan 2011 21:32:25 GMT
Author: krosenvold
Date: Mon Jan  3 21:32:25 2011
New Revision: 1054768

URL: http://svn.apache.org/viewvc?rev=1054768&view=rev
Log:
[SUREFIRE-519] junit-dep44+ isn't detected properly with 3.x deps

Fixed with IT

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44DepIT.java
  (contents, props changed)
      - copied, changed from r1054767, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44Dep.java
Removed:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44Dep.java
Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml

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=1054768&r1=1054767&r2=1054768&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 Jan  3 21:32:25 2011
@@ -108,8 +108,9 @@ public abstract class AbstractSurefireMo
         try
         {
             wellKnownProviders = new ProviderList( new ProviderInfo[]{ new TestNgProviderInfo(
getTestNgArtifact() ),
-                new JUnitCoreProviderInfo( getJunitArtifact() ), new JUnit4ProviderInfo(
getJunitArtifact() ),
-                new JUnit3ProviderInfo() }, new DynamicProviderInfo( null ) );
+                new JUnitCoreProviderInfo( getJunitArtifact() ),
+                new JUnit4ProviderInfo( getJunitArtifact(), getJunitDepArtifact() ), new
JUnit3ProviderInfo() },
+                                                   new DynamicProviderInfo( null ) );
 
             return wellKnownProviders.resolve( getLog() );
         }
@@ -481,14 +482,12 @@ public abstract class AbstractSurefireMo
 
     private Artifact getJunitArtifact()
     {
-        Artifact junitArtifact;
-        junitArtifact = (Artifact) getProjectArtifactMap().get( getJunitArtifactName() );
-        // SUREFIRE-378, junit can have an alternate artifact name
-        if ( junitArtifact == null && "junit:junit".equals( getJunitArtifactName()
) )
-        {
-            junitArtifact = (Artifact) getProjectArtifactMap().get( "junit:junit-dep" );
-        }
-        return junitArtifact;
+        return (Artifact) getProjectArtifactMap().get( getJunitArtifactName() );
+    }
+
+    private Artifact getJunitDepArtifact()
+    {
+        return (Artifact) getProjectArtifactMap().get( "junit:junit-dep" );
     }
 
     protected ForkStarter createForkStarter( ProviderInfo provider, ForkConfiguration forkConfiguration,
@@ -578,8 +577,8 @@ public abstract class AbstractSurefireMo
 
     protected ClassLoaderConfiguration getClassLoaderConfiguration( ForkConfiguration fork
)
     {
-        return fork.isForking() ? new ClassLoaderConfiguration( isUseSystemClassLoader(),
-                                                                isUseManifestOnlyJar() )
+        return fork.isForking()
+            ? new ClassLoaderConfiguration( isUseSystemClassLoader(), isUseManifestOnlyJar()
)
             : new ClassLoaderConfiguration( false, false );
     }
 
@@ -986,9 +985,12 @@ public abstract class AbstractSurefireMo
     {
         private final Artifact junitArtifact;
 
-        JUnit4ProviderInfo( Artifact junitArtifact )
+        private final Artifact junitDepArtifact;
+
+        JUnit4ProviderInfo( Artifact junitArtifact, Artifact junitDepArtifact )
         {
             this.junitArtifact = junitArtifact;
+            this.junitDepArtifact = junitDepArtifact;
         }
 
         public String getProviderName()
@@ -998,7 +1000,7 @@ public abstract class AbstractSurefireMo
 
         public boolean isApplicable()
         {
-            return isAnyJunit4( junitArtifact );
+            return junitDepArtifact != null || isAnyJunit4( junitArtifact );
         }
 
         public void addProviderProperties()

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44DepIT.java
(from r1054767, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44Dep.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44DepIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44DepIT.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44Dep.java&r1=1054767&r2=1054768&rev=1054768&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44Dep.java
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44DepIT.java
Mon Jan  3 21:32:25 2011
@@ -24,10 +24,10 @@ package org.apache.maven.surefire.its;
  *
  * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
  */
-public class JUnit44Dep
+public class JUnit44DepIT
     extends SurefireVerifierTestClass
 {
-    public JUnit44Dep()
+    public JUnit44DepIT()
     {
         super( "/junit44-dep" );
     }
@@ -39,4 +39,14 @@ public class JUnit44Dep
         verifyErrorFreeLog();
         assertTestSuiteResults( 1, 0, 0, 0 );
     }
+    public void testJUnit44DepWithSneaky381()
+        throws Exception
+    {
+        activateProfile("provided381");
+        executeTest();
+        verifyErrorFreeLog();
+        assertTestSuiteResults( 1, 0, 0, 0 );
+    }
+
+
 }

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit44DepIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java?rev=1054768&r1=1054767&r2=1054768&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
Mon Jan  3 21:32:25 2011
@@ -229,6 +229,12 @@ public abstract class SurefireVerifierTe
         addGoal( "-DforkMode=" + forkMode );
     }
 
+    protected void activateProfile( String profile )
+    {
+        addGoal("-P" + profile);
+    }
+
+
     public void assertTestSuiteResults( int total, int errors, int failures, int skipped
)
         throws MavenReportException
     {

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml?rev=1054768&r1=1054767&r2=1054768&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml
(original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit44-dep/pom.xml
Mon Jan  3 21:32:25 2011
@@ -36,7 +36,20 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
-  
+
+  <profiles>
+    <profile>
+      <id>provided381</id>
+      <dependencies>
+        <dependency>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+          <version>3.8.1</version>
+          <scope>provided</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
   <build>
     <plugins>
       <plugin>



Mime
View raw message