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 2013/03/26 17:03:57 UTC
[1/7] git commit: o switch to m-s-u 0.3 again o add legal footer to
site
Updated Branches:
refs/heads/surfire97 bafec33a6 -> ebd229df5 (forced update)
o switch to m-s-u 0.3 again
o add legal footer to site
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/2410d010
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/2410d010
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/2410d010
Branch: refs/heads/surfire97
Commit: 2410d010d89174f396bcee6575e8c71268229e85
Parents: 0eb6fd6
Author: Andreas Gudian <ag...@apache.org>
Authored: Fri Mar 22 22:07:55 2013 +0100
Committer: Andreas Gudian <ag...@apache.org>
Committed: Fri Mar 22 22:07:55 2013 +0100
----------------------------------------------------------------------
pom.xml | 2 +-
src/site/site.xml | 5 +++++
2 files changed, 6 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2410d010/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ff015bf..fa91ab3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -246,7 +246,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/2410d010/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index b92c03d..730c5f0 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -55,5 +55,10 @@
<body>
<menu ref="modules"/>
<menu ref="reports" inherit="bottom"/>
+
+ <footer>
+ <div class="row span12"><span><a href="http://maven.apache.org/privacy-policy.html">Privacy Policy</a> - </span>
+ <span>Apache Maven, Maven, Apache, the Apache feather logo, and the Apache Maven project logos are trademarks of The Apache Software Foundation.</span></div>
+ </footer>
</body>
</project>
[7/7] git commit: [SUREFIRE-972] Bizarre noclassdef found
Posted by kr...@apache.org.
[SUREFIRE-972] Bizarre noclassdef found
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/ebd229df
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/ebd229df
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/ebd229df
Branch: refs/heads/surfire97
Commit: ebd229df566aa3661f060458b289413ecd6c9374
Parents: c1e06f8
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Tue Mar 26 16:52:33 2013 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Tue Mar 26 17:03:52 2013 +0100
----------------------------------------------------------------------
.../maven/surefire/booter/ForkingRunListener.java | 2 +-
.../maven/surefire/booter/ProviderFactory.java | 2 +-
.../surefire-972-bizarre-noclassdef/boom/pom.xml | 51 +++++++++++++++
.../org/apache/maven/surefire/crb/ClassRuleIT.java | 24 +++++++
.../class-rule/pom.xml | 17 +++++
.../ExampleClassRule.java | 29 ++++++++
.../surefire-972-bizarre-noclassdef/pom.xml | 32 +++++++++
.../surefire/common/junit4/JUnit4RunListener.java | 22 ++++++-
8 files changed, 175 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index d20fcf2..bbc6078 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -129,7 +129,7 @@ public class ForkingRunListener
public void testError( ReportEntry report )
{
- target.print( toString( BOOTERCODE_TEST_ERROR, report, testSetChannelId ) );
+ target.print( toString( BOOTERCODE_TEST_ERROR, report, testSetChannelId ) );
}
public void testFailed( ReportEntry report )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
index a21da57..5d9e4b1 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
@@ -113,7 +113,7 @@ public class ProviderFactory
surefireReflector.setIfDirScannerAware( o, providerConfiguration.getDirScannerParams() );
Object provider = surefireReflector.instantiateProvider( starterConfiguration.getProviderClassName(), o );
- Thread.currentThread().setContextClassLoader( systemClassLoader );
+// Thread.currentThread().setContextClassLoader( systemClassLoader );
return new ProviderProxy( provider, testsClassLoader );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml
new file mode 100644
index 0000000..d5e9fbc
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/pom.xml
@@ -0,0 +1,51 @@
+<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>
+ <artifactId>class-rule-boom-boom</artifactId>
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule-boom</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java
new file mode 100644
index 0000000..5554fd9
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/boom/src/test/java/org/apache/maven/surefire/crb/ClassRuleIT.java
@@ -0,0 +1,24 @@
+package org.apache.maven.surefire.crb;
+
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: benson
+ * Date: 3/16/13
+ * Time: 11:00 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ClassRuleIT extends Assert {
+
+ @ClassRule
+ public static ExampleClassRule rule = new ExampleClassRule(ExampleClassRule.someStaticFunction());
+
+ @Test
+ public void dummyTest() {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml
new file mode 100644
index 0000000..e9f44e3
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/pom.xml
@@ -0,0 +1,17 @@
+<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>
+ <artifactId>class-rule</artifactId>
+ <parent>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>class-rule-boom</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java
new file mode 100644
index 0000000..430f7d2
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/class-rule/src/main/java/org.apache.maven.surefire.crb/ExampleClassRule.java
@@ -0,0 +1,29 @@
+package org.apache.maven.surefire.crb;
+
+import org.junit.rules.ExternalResource;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: benson
+ * Date: 3/16/13
+ * Time: 10:52 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ExampleClassRule extends ExternalResource {
+
+ public ExampleClassRule(String dummy) {
+ //
+ }
+
+ protected void before() throws Throwable {
+ System.err.println("ExampleClassRule.before()");
+ }
+
+ protected void after() {
+ System.err.println("ExampleClassRule.after()");
+ }
+
+ public static String someStaticFunction() {
+ throw new RuntimeException("Surprise!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml
new file mode 100644
index 0000000..be4df33
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-972-bizarre-noclassdef/pom.xml
@@ -0,0 +1,32 @@
+<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.surefire</groupId>
+ <artifactId>class-rule-boom</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <modules>
+ <module>class-rule</module>
+ <module>boom</module>
+ </modules>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.14</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ebd229df/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
index 50c7498..ed2a9b7 100644
--- a/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
+++ b/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/common/junit4/JUnit4RunListener.java
@@ -98,8 +98,12 @@ public class JUnit4RunListener
public void testFailure( Failure failure )
throws Exception
{
+ String testHeader = failure.getTestHeader();
+ if (isInsaneJunitNullString( testHeader )){
+ testHeader = "Failure when constructing test";
+ }
ReportEntry report =
- SimpleReportEntry.withException( getClassName( failure.getDescription() ), failure.getTestHeader(),
+ SimpleReportEntry.withException( getClassName( failure.getDescription() ), testHeader,
createStackTraceWriter( failure ) );
if ( failure.getException() instanceof AssertionError )
@@ -146,9 +150,23 @@ public class JUnit4RunListener
return new SimpleReportEntry( getClassName( description ), description.getDisplayName() );
}
+ private boolean isInsaneJunitNullString(String value){
+ return "null".equals( value );
+ }
public String getClassName( Description description )
{
- return extractClassName( description );
+ String name = extractClassName( description );
+ if (name == null || isInsaneJunitNullString( name )){
+ // This can happen upon early failures (class instantiation error etc)
+ Description subDescription = description.getChildren().get( 0 );
+ if (subDescription != null){
+ name = extractClassName( subDescription );
+ }
+ if (name == null){
+ name = "Test Instantiation Error";
+ }
+ }
+ return name;
}
public static String extractClassName( Description description )
[4/7] git commit: merge the two for-loops
Posted by kr...@apache.org.
merge the two for-loops
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/99b3115c
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/99b3115c
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/99b3115c
Branch: refs/heads/surfire97
Commit: 99b3115cc3b1bd0aec0fff912cfe264eb3b2655e
Parents: a57b805
Author: Andreas Gudian <ag...@apache.org>
Authored: Mon Mar 25 20:39:48 2013 +0100
Committer: Andreas Gudian <ag...@apache.org>
Committed: Mon Mar 25 20:39:48 2013 +0100
----------------------------------------------------------------------
.../apache/maven/surefire/junitcore/TestSet.java | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/99b3115c/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
index 462fe12..8b0283c 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
@@ -72,11 +72,6 @@ public class TestSet
try
{
- int elapsed = 0;
- for ( TestMethod testMethod : testMethods )
- {
- elapsed += testMethod.getElapsed();
- }
ReportEntry report = createReportEntry( null );
target.testSetStarting( report );
@@ -86,8 +81,10 @@ public class TestSet
beforeClass.writeDetails( ( (ConsoleOutputReceiver) target ) );
}
+ int elapsed = 0;
for ( TestMethod testMethod : testMethods )
{
+ elapsed += testMethod.getElapsed();
testMethod.replay( target );
}
[2/7] git commit: Fixed ForkMode*IT on mvn 2.2.1 and in other
non-embedded modes
Posted by kr...@apache.org.
Fixed ForkMode*IT on mvn 2.2.1 and in other non-embedded modes
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/4221437c
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/4221437c
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/4221437c
Branch: refs/heads/surfire97
Commit: 4221437cb9a632c7a532bd613dc05e712c1d150d
Parents: 2410d01
Author: Andreas Gudian <ag...@apache.org>
Authored: Fri Mar 22 22:11:30 2013 +0100
Committer: Andreas Gudian <ag...@apache.org>
Committed: Fri Mar 22 22:11:30 2013 +0100
----------------------------------------------------------------------
.../org/apache/maven/surefire/its/ForkModeIT.java | 91 +++++++++------
.../resources/test-helper-dump-pid-plugin/pom.xml | 62 ++++++++++
.../plugins/surefire/dumppid/DumpPidMojo.java | 70 +++++++++++
3 files changed, 188 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4221437c/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
index 233a993..061c5a6 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeIT.java
@@ -19,18 +19,21 @@ package org.apache.maven.surefire.its;
* under the License.
*/
-import java.lang.management.ManagementFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import org.apache.maven.surefire.its.fixture.*;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.apache.maven.surefire.its.fixture.TestFile;
+import org.junit.BeforeClass;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
/**
* Test forkMode
*
@@ -39,13 +42,23 @@ import static org.junit.Assert.fail;
public class ForkModeIT
extends SurefireJUnit4IntegrationTestCase
{
+
+ private OutputValidator outputValidator;
+
+ @BeforeClass
+ public static void installDumpPidPlugin()
+ throws Exception
+ {
+ unpack( ForkModeIT.class, "test-helper-dump-pid-plugin", "plugin" ).executeInstall();
+ }
+
@Test
public void testForkModeAlways()
{
String[] pids = doTest( unpack( getProject() ).setForkJvm().forkAlways() );
assertDifferentPids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertEndWith( pids, "_1_1", 3 );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
@@ -53,8 +66,8 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).setForkJvm().forkPerTest() );
assertDifferentPids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertEndWith( pids, "_1_1", 3 );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
@@ -62,8 +75,8 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).forkNever() );
assertSamePids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertEquals( "my pid is equal to pid 1 of the test", getMyPID(), pids[0] );
+ assertEndWith( pids, "_1_1", 3 );
+ assertEquals( "my pid is equal to pid 1 of the test", getMainPID(), pids[0] );
}
@Test
@@ -71,8 +84,8 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).forkMode( "none" ) );
assertSamePids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertEquals( "my pid is equal to pid 1 of the test", getMyPID(), pids[0] );
+ assertEndWith( pids, "_1_1", 3 );
+ assertEquals( "my pid is equal to pid 1 of the test", getMainPID(), pids[0] );
}
@Test
@@ -80,16 +93,17 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).setForkJvm().forkOncePerThread().threadCount( 1 ) );
assertSamePids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertEndWith( pids, "_1_1", 3 );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
public void testForkModeOncePerThreadTwoThreads()
{
- String[] pids = doTest( unpack( getProject() ).forkOncePerThread().threadCount( 2 ).addGoal( "-DsleepLength=1200" ) );
+ String[] pids =
+ doTest( unpack( getProject() ).forkOncePerThread().threadCount( 2 ).addGoal( "-DsleepLength=1200" ) );
assertDifferentPids( pids, 2 );
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
@@ -97,8 +111,8 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).forkCount( 0 ) );
assertSamePids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertEquals( "my pid is equal to pid 1 of the test", getMyPID(), pids[0] );
+ assertEndWith( pids, "_1_1", 3 );
+ assertEquals( "my pid is equal to pid 1 of the test", getMainPID(), pids[0] );
}
@Test
@@ -106,8 +120,8 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).setForkJvm().forkCount( 1 ).reuseForks( false ) );
assertDifferentPids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertEndWith( pids, "_1_1", 3 );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
@@ -115,35 +129,39 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).setForkJvm().forkCount( 1 ).reuseForks( true ) );
assertSamePids( pids );
- assertEndWith( pids, "_1_1", 3);
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertEndWith( pids, "_1_1", 3 );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
public void testForkCountTwoNoReuse()
{
- String[] pids = doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( false ).addGoal( "-DsleepLength=1200" ) );
+ String[] pids =
+ doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( false ).addGoal( "-DsleepLength=1200" ) );
assertDifferentPids( pids );
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
@Test
public void testForkCountTwoReuse()
{
- String[] pids = doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( true ).addGoal( "-DsleepLength=1200" ) );
+ String[] pids =
+ doTest( unpack( getProject() ).forkCount( 2 ).reuseForks( true ).addGoal( "-DsleepLength=1200" ) );
assertDifferentPids( pids, 2 );
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
private void assertEndWith( String[] pids, String suffix, int expectedMatches )
{
int matches = 0;
- for (String pid : pids) {
- if ( pid.endsWith( suffix )) {
+ for ( String pid : pids )
+ {
+ if ( pid.endsWith( suffix ) )
+ {
matches++;
}
}
-
+
assertEquals( "suffix " + suffix + " matched the correct number of pids", expectedMatches, matches );
}
@@ -158,12 +176,14 @@ public class ForkModeIT
{
String[] pids = doTest( unpack( getProject() ).forkOnce() );
assertSamePids( pids );
- assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMyPID() ) );
+ assertFalse( "pid 1 is not the same as the main process' pid", pids[0].equals( getMainPID() ) );
}
- private String getMyPID()
+ private String getMainPID()
{
- return ManagementFactory.getRuntimeMXBean().getName() + " testValue_1_1";
+ final TestFile targetFile = outputValidator.getTargetFile( "maven.pid" );
+ String pid = targetFile.slurpFile();
+ return pid + " testValue_1_1";
}
private void assertSamePids( String[] pids )
@@ -193,7 +213,8 @@ public class ForkModeIT
private String[] doTest( SurefireLauncher forkMode )
{
forkMode.sysProp( "testProperty", "testValue_${surefire.threadNumber}_${surefire.forkNumber}" );
- final OutputValidator outputValidator = forkMode.debugLogging().executeTest();
+ forkMode.addGoal( "org.apache.maven.plugins.surefire:maven-dump-pid-plugin:dump-pid" );
+ outputValidator = forkMode.executeTest();
outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
String[] pids = new String[3];
for ( int i = 1; i <= pids.length; i++ )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4221437c/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/pom.xml b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/pom.xml
new file mode 100644
index 0000000..26af45b
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/pom.xml
@@ -0,0 +1,62 @@
+<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>maven-dump-pid-plugin</artifactId>
+ <version>0.1</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>maven-dump-pid-plugin Maven Plugin</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.2</version>
+ <configuration>
+ <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/4221437c/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
new file mode 100644
index 0000000..035976b
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/test-helper-dump-pid-plugin/src/main/java/org/apache/maven/plugins/surefire/dumppid/DumpPidMojo.java
@@ -0,0 +1,70 @@
+package org.apache.maven.plugins.surefire.dumppid;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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 java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+/**
+ * Goal dumps the PID of the maven process
+ */
+@Mojo( name = "dump-pid", defaultPhase = LifecyclePhase.GENERATE_TEST_RESOURCES )
+public class DumpPidMojo
+ extends AbstractMojo
+{
+
+ @Parameter( defaultValue = "${project.build.directory}", property = "dumpPid.targetDir" )
+ private File targetDir;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ File target;
+ try
+ {
+ getLog().info( "Dumping PID to " + targetDir );
+
+ if ( !targetDir.exists() )
+ {
+ targetDir.mkdirs();
+ }
+
+ target = new File( targetDir, "maven.pid" ).getCanonicalFile();
+
+ FileWriter fw = new FileWriter( target );
+ String pid = ManagementFactory.getRuntimeMXBean().getName();
+ fw.write( pid );
+ fw.flush();
+ fw.close();
+
+ getLog().info( "Wrote " + pid + " to " + target );
+
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Unable to create pid file", e );
+ }
+ }
+}
[6/7] git commit: o Removed unused dependency, fixed shading
Posted by kr...@apache.org.
o Removed unused dependency, fixed shading
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/c1e06f8e
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/c1e06f8e
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/c1e06f8e
Branch: refs/heads/surfire97
Commit: c1e06f8edc6d2a546eafff0715481486aa6b9640
Parents: 15ad61f
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Tue Mar 26 16:58:19 2013 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Tue Mar 26 16:58:19 2013 +0100
----------------------------------------------------------------------
surefire-providers/surefire-junit47/pom.xml | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/c1e06f8e/surefire-providers/surefire-junit47/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/pom.xml b/surefire-providers/surefire-junit47/pom.xml
index 00d69af..1dede4f 100644
--- a/surefire-providers/surefire-junit47/pom.xml
+++ b/surefire-providers/surefire-junit47/pom.xml
@@ -39,12 +39,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.7</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>common-junit4</artifactId>
<version>${project.version}</version>
@@ -99,6 +93,16 @@
<include>org.apache.maven.surefire:common-java5</include>
</includes>
</artifactSet>
+ <relocations>
+ <relocation>
+ <pattern>javax.annotation</pattern>
+ <shadedPattern>org.apache.maven.surefire.javax.annotation</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.maven.shared</pattern>
+ <shadedPattern>org.apache.maven.surefire.org.apache.maven.shared</shadedPattern>
+ </relocation>
+ </relocations>
</configuration>
</execution>
</executions>
[3/7] git commit: [SUREFIRE-970] Fix elapsed time time of failed and
skipped tests
Posted by kr...@apache.org.
[SUREFIRE-970] Fix elapsed time time of failed and skipped tests
o time measurement is now limited to TestSetRunListener, except for concurrent junit tests
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/a57b805f
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/a57b805f
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/a57b805f
Branch: refs/heads/surfire97
Commit: a57b805f4c079b40ae549e8a22be2f5de006d580
Parents: 4221437
Author: Andreas Gudian <ag...@apache.org>
Authored: Mon Mar 25 20:37:20 2013 +0100
Committer: Andreas Gudian <ag...@apache.org>
Committed: Mon Mar 25 20:37:20 2013 +0100
----------------------------------------------------------------------
.../surefire/report/PrettyPrintXMLWriter.java | 7 +-
.../plugin/surefire/report/TestSetRunListener.java | 40 +++++--
.../plugin/surefire/report/WrappedReportEntry.java | 3 +-
.../maven/surefire/booter/ForkingRunListener.java | 13 ++-
.../its/jiras/Surefire943ReportContentIT.java | 85 ++++++++++++---
.../src/test/java/org/sample/module/My1Test.java | 11 ++
.../src/test/java/org/sample/module/My2Test.java | 11 ++
.../src/test/java/org/sample/module/My3Test.java | 5 +-
.../src/test/java/org/sample/module/My4Test.java | 27 +++++
.../junitcore/NonConcurrentRunListener.java | 27 +++--
.../maven/surefire/junitcore/TestMethod.java | 18 ++--
11 files changed, 187 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/PrettyPrintXMLWriter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/PrettyPrintXMLWriter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/PrettyPrintXMLWriter.java
index ddb4ed9..b0fea62 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/PrettyPrintXMLWriter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/PrettyPrintXMLWriter.java
@@ -21,9 +21,8 @@ package org.apache.maven.plugin.surefire.report;
import java.io.PrintWriter;
import java.util.LinkedList;
-import org.apache.maven.shared.utils.xml.XMLWriter;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+import org.apache.maven.shared.utils.xml.XMLWriter;
public class PrettyPrintXMLWriter
implements XMLWriter
@@ -69,12 +68,12 @@ public class PrettyPrintXMLWriter
public void setEncoding( String encoding )
{
- throw new NotImplementedException();
+ throw new RuntimeException( "Not Implemented" );
}
public void setDocType( String docType )
{
- throw new NotImplementedException();
+ throw new RuntimeException( "Not Implemented" );
}
private PrettyPrintXMLWriter( PrintWriter writer, String encoding, String doctype )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index 230e0e7..c366435 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -33,7 +33,7 @@ import org.apache.maven.surefire.util.internal.ByteBuffer;
/**
* Reports data for a single test set.
* <p/>
- *
+ *
* @author Kristian Rosenvold
*/
public class TestSetRunListener
@@ -62,8 +62,8 @@ public class TestSetRunListener
public TestSetRunListener( ConsoleReporter consoleReporter, FileReporter fileReporter,
StatelessXmlReporter simpleXMLReporter,
TestcycleConsoleOutputReceiver consoleOutputReceiver,
- StatisticsReporter statisticsReporter, RunStatistics globalStats, boolean trimStackTrace,
- boolean isPlainFormat, boolean briefOrPlainFormat )
+ StatisticsReporter statisticsReporter, RunStatistics globalStats,
+ boolean trimStackTrace, boolean isPlainFormat, boolean briefOrPlainFormat )
{
this.consoleReporter = consoleReporter;
this.fileReporter = fileReporter;
@@ -115,7 +115,7 @@ public class TestSetRunListener
public void testSetCompleted( ReportEntry report )
{
- WrappedReportEntry wrap = wrapTestSet( report, null );
+ WrappedReportEntry wrap = wrapTestSet( report );
List<String> testResults = briefOrPlainFormat ? detailsForThis.getTestResults() : null;
if ( consoleReporter != null )
{
@@ -195,7 +195,6 @@ public class TestSetRunListener
public void testSkipped( ReportEntry reportEntry )
{
-
WrappedReportEntry wrapped = wrap( reportEntry, ReportEntryType.skipped );
detailsForThis.testSkipped( wrapped );
if ( statisticsReporter != null )
@@ -225,16 +224,33 @@ public class TestSetRunListener
private WrappedReportEntry wrap( ReportEntry other, ReportEntryType reportEntryType )
{
- return new WrappedReportEntry( other, reportEntryType, other.getElapsed() != null
- ? other.getElapsed()
- : detailsForThis.getElapsedSinceLastStart(), getAsString( testStdOut ), getAsString( testStdErr ) );
+ final int estimatedElapsed;
+ if ( reportEntryType != ReportEntryType.skipped )
+ {
+ if ( other.getElapsed() != null )
+ {
+ estimatedElapsed = other.getElapsed();
+ }
+ else
+ {
+ estimatedElapsed = detailsForThis.getElapsedSinceLastStart();
+ }
+ }
+ else
+ {
+ estimatedElapsed = 0;
+ }
+
+ return new WrappedReportEntry( other, reportEntryType, estimatedElapsed, getAsString( testStdOut ),
+ getAsString( testStdErr ) );
}
- private WrappedReportEntry wrapTestSet( ReportEntry other, ReportEntryType reportEntryType )
+ private WrappedReportEntry wrapTestSet( ReportEntry other )
{
- return new WrappedReportEntry( other, reportEntryType, other.getElapsed() != null
- ? other.getElapsed()
- : detailsForThis.getElapsedSinceTestSetStart(), getAsString( testStdOut ), getAsString( testStdErr ) );
+ return new WrappedReportEntry( other, null, other.getElapsed() != null
+ ? other.getElapsed()
+ : detailsForThis.getElapsedSinceTestSetStart(), getAsString( testStdOut ),
+ getAsString( testStdErr ) );
}
public void close()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
index c77867c..fa941f7 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
@@ -58,10 +58,9 @@ public class WrappedReportEntry
public Integer getElapsed()
{
- return original.getElapsed() != null ? original.getElapsed() : elapsed;
+ return elapsed;
}
-
public ReportEntryType getReportEntryType()
{
return reportEntryType;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
index fa4e9cf..d20fcf2 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
@@ -132,7 +132,6 @@ public class ForkingRunListener
target.print( toString( BOOTERCODE_TEST_ERROR, report, testSetChannelId ) );
}
-
public void testFailed( ReportEntry report )
{
target.print( toString( BOOTERCODE_TEST_FAILED, report, testSetChannelId ) );
@@ -233,8 +232,10 @@ public class ForkingRunListener
private String toPropertyString( String key, String value )
{
StringBuffer stringBuffer = new StringBuffer();
- append( stringBuffer, BOOTERCODE_SYSPROPS ).comma( stringBuffer );
- append( stringBuffer, Integer.toHexString( testSetChannelId.intValue() ) ).comma( stringBuffer );
+ append( stringBuffer, BOOTERCODE_SYSPROPS );
+ comma( stringBuffer );
+ append( stringBuffer, Integer.toHexString( testSetChannelId.intValue() ) );
+ comma( stringBuffer );
StringUtils.escapeJavaStyleString( stringBuffer, key );
append( stringBuffer, "," );
StringUtils.escapeJavaStyleString( stringBuffer, value );
@@ -245,8 +246,10 @@ public class ForkingRunListener
private String toString( byte operationCode, ReportEntry reportEntry, Integer testSetChannelId )
{
StringBuffer stringBuffer = new StringBuffer();
- append( stringBuffer, operationCode ).comma( stringBuffer );
- append( stringBuffer, Integer.toHexString( testSetChannelId.intValue() ) ).comma( stringBuffer );
+ append( stringBuffer, operationCode );
+ comma( stringBuffer );
+ append( stringBuffer, Integer.toHexString( testSetChannelId.intValue() ) );
+ comma( stringBuffer );
nullableEncoding( stringBuffer, reportEntry.getSourceName() );
comma( stringBuffer );
nullableEncoding( stringBuffer, reportEntry.getName() );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
index 5568c48..fe72087 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire943ReportContentIT.java
@@ -1,4 +1,5 @@
package org.apache.maven.surefire.its.jiras;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,7 +19,6 @@ package org.apache.maven.surefire.its.jiras;
* under the License.
*/
-
import java.io.FileNotFoundException;
import org.apache.maven.shared.utils.xml.Xpp3Dom;
import org.apache.maven.shared.utils.xml.Xpp3DomBuilder;
@@ -33,26 +33,57 @@ public class Surefire943ReportContentIT
{
@Test
- public void test()
+ public void test_noParallel()
throws Exception
{
- OutputValidator validator = unpack( "surefire-943-report-content" ).maven().withFailure().executeTest();
- validator.assertTestSuiteResults( 6, 0, 3, 0 );
+ doTest( "none" );
+ }
- validate( validator, "org.sample.module.My1Test" );
- validate( validator, "org.sample.module.My2Test" );
- validate( validator, "org.sample.module.My3Test" );
+ @Test
+ public void test_parallelBoth()
+ throws Exception
+ {
+ doTest( "both" );
}
- private void validate( OutputValidator validator, String className )
+ private void doTest( String parallelMode )
+ throws Exception
+ {
+ OutputValidator validator =
+ unpack( "surefire-943-report-content" ).maven().sysProp( "parallel", parallelMode ).withFailure().executeTest();
+ validator.assertTestSuiteResults( 9, 0, 3, 3 );
+
+ validate( validator, "org.sample.module.My1Test", 1 );
+ validate( validator, "org.sample.module.My2Test", 1 );
+ validate( validator, "org.sample.module.My3Test", 0 );
+ validateSkipped( validator, "org.sample.module.My4Test" );
+ }
+
+ private void validateSkipped( OutputValidator validator, String className )
throws FileNotFoundException
{
- Xpp3Dom testResult =
- Xpp3DomBuilder.build( validator.getSurefireReportsXmlFile( "TEST-" + className + ".xml" ).getFileInputStream(),
- "UTF-8" );
- Xpp3Dom[] children = testResult.getChildren( "testcase" );
+ Xpp3Dom[] children = readTests( validator, className );
- Assert.assertEquals( 2, children.length );
+ Assert.assertEquals( 1, children.length );
+
+ Xpp3Dom child = children[0];
+
+ Assert.assertEquals( className, child.getAttribute( "classname" ) );
+ Assert.assertEquals( className, child.getAttribute( "name" ) );
+
+ Assert.assertEquals( "Expected skipped tag for ignored method for " + className, 1,
+ child.getChildren( "skipped" ).length );
+
+ Assert.assertTrue( "time for ignored test is expected to be zero",
+ Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 0.0d ) == 0 );
+ }
+
+ private void validate( OutputValidator validator, String className, int ignored )
+ throws FileNotFoundException
+ {
+ Xpp3Dom[] children = readTests( validator, className );
+
+ Assert.assertEquals( 2 + ignored, children.length );
for ( Xpp3Dom child : children )
{
@@ -62,15 +93,39 @@ public class Surefire943ReportContentIT
{
Assert.assertEquals( "Expected no failures for method alwaysSuccessful for " + className, 0,
child.getChildCount() );
+
+ Assert.assertTrue( "time for successful test is expected to be positive",
+ Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 0.0d ) > 0 );
+ }
+ else if ( child.getAttribute( "name" ).contains( "Ignored" ) )
+ {
+ Assert.assertEquals( "Expected skipped-tag for ignored method for " + className, 1,
+ child.getChildren( "skipped" ).length );
+
+ Assert.assertTrue( "time for ignored test is expected to be zero",
+ Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 0.0d ) == 0 );
+
}
else
{
- Assert.assertEquals( "Expected methods \"alwaysSuccessful\" and \"fails\" in " + className, "fails",
- child.getAttribute( "name" ) );
+ Assert.assertEquals( "Expected methods \"alwaysSuccessful\", \"*Ignored\" and \"fails\" in "
+ + className, "fails", child.getAttribute( "name" ) );
Assert.assertEquals( "Expected failure description for method \"fails\" in " + className, 1,
child.getChildren( "failure" ).length );
+ Assert.assertTrue( "time for failed test is expected to be positive",
+ Double.compare( Double.parseDouble( child.getAttribute( "time" ) ), 0.0d ) > 0 );
}
}
}
+ private Xpp3Dom[] readTests( OutputValidator validator, String className )
+ throws FileNotFoundException
+ {
+ Xpp3Dom testResult =
+ Xpp3DomBuilder.build( validator.getSurefireReportsXmlFile( "TEST-" + className + ".xml" ).getFileInputStream(),
+ "UTF-8" );
+ Xpp3Dom[] children = testResult.getChildren( "testcase" );
+ return children;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My1Test.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My1Test.java b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My1Test.java
index b2a2919..a5b5b61 100644
--- a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My1Test.java
+++ b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My1Test.java
@@ -6,17 +6,28 @@ import java.lang.management.ManagementFactory;
import org.junit.Before;
import org.junit.Test;
+import org.junit.Ignore;
public class My1Test
{
@Test
public void fails()
+ throws Exception
{
+ Thread.sleep( 100 );
fail( "Always fails" );
}
@Test
public void alwaysSuccessful()
+ throws Exception
+ {
+ Thread.sleep( 100 );
+ }
+
+ @Test
+ @Ignore( "Ignore-Message" )
+ public void alwaysIgnored()
{
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My2Test.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My2Test.java b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My2Test.java
index 7f70c76..a9b6a0a 100644
--- a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My2Test.java
+++ b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My2Test.java
@@ -6,16 +6,27 @@ import java.lang.management.ManagementFactory;
import org.junit.Before;
import org.junit.Test;
+import org.junit.Ignore;
public class My2Test {
@Test
public void fails()
+ throws Exception
{
+ Thread.sleep( 100 );
fail( "Always fails" );
}
@Test
public void alwaysSuccessful()
+ throws Exception
+ {
+ Thread.sleep( 100 );
+ }
+
+ @Test
+ @Ignore
+ public void alwaysIgnored()
{
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My3Test.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My3Test.java b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My3Test.java
index bb2a06b..5f5b2cd 100644
--- a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My3Test.java
+++ b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My3Test.java
@@ -10,13 +10,16 @@ import org.junit.Test;
public class My3Test {
@Test
public void fails()
+ throws Exception
{
+ Thread.sleep( 100 );
fail( "Always fails" );
}
@Test
public void alwaysSuccessful()
+ throws Exception
{
-
+ Thread.sleep( 100 );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My4Test.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My4Test.java b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My4Test.java
new file mode 100644
index 0000000..7124d61
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-943-report-content/src/test/java/org/sample/module/My4Test.java
@@ -0,0 +1,27 @@
+package org.sample.module;
+
+import static org.junit.Assert.fail;
+
+import java.lang.management.ManagementFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Ignore;
+
+@Ignore( "Ignore-Message" )
+public class My4Test
+{
+
+ @Test
+ public void alsoIgnored()
+ {
+
+ }
+
+ @Test
+ @Ignore
+ public void alwaysIgnored()
+ {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
index 240a40f..cf4d19d 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/NonConcurrentRunListener.java
@@ -30,18 +30,15 @@ import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
/**
- * A class to be used when there is no JUnit parallelism (methods or/and class). This
- * allow to workaround JUnit limitation a la Junit4 provider. Specifically, we can redirect
- * properly the output even if we don't have class demarcation in JUnit. It works when
- * if there is a JVM instance per test run, i.e. with forkMode=always or perthread.
+ * A class to be used when there is no JUnit parallelism (methods or/and class). This allow to workaround JUnit
+ * limitation a la Junit4 provider. Specifically, we can redirect properly the output even if we don't have class
+ * demarcation in JUnit. It works when if there is a JVM instance per test run, i.e. with forkMode=always or perthread.
*/
public class NonConcurrentRunListener
extends JUnit4RunListener
implements ConsoleOutputReceiver
{
- private long startTime = System.currentTimeMillis();
-
private java.lang.Class<?> currentTestClass;
private Description lastFinishedDescription;
@@ -60,20 +57,26 @@ public class NonConcurrentRunListener
protected SimpleReportEntry createReportEntry( Description description )
{
- return new SimpleReportEntry( description.getClassName(), description.getDisplayName(),
- (int) ( System.currentTimeMillis() - startTime ) );
+ return new SimpleReportEntry( description.getClassName(), description.getDisplayName()/*,
+ (int) ( System.currentTimeMillis() - startTime ) */);
}
protected SimpleReportEntry createReportEntryForTestSet( Description description )
{
- return new SimpleReportEntry( description.getClassName(), description.getClassName(),
- (int) ( System.currentTimeMillis() - startTime ) );
+ return new SimpleReportEntry( description.getClassName(), description.getClassName() /*,
+ (int) ( System.currentTimeMillis() - startTime ) */);
}
@Override
public void testStarted( Description description )
throws Exception
{
+ finishLastTestSetIfNeccessary( description );
+ super.testStarted( description );
+ }
+
+ private void finishLastTestSetIfNeccessary( Description description )
+ {
if ( !description.getTestClass().equals( currentTestClass ) )
{
currentTestClass = description.getTestClass();
@@ -82,10 +85,8 @@ public class NonConcurrentRunListener
reporter.testSetCompleted( createReportEntryForTestSet( lastFinishedDescription ) );
lastFinishedDescription = null;
}
- startTime = System.currentTimeMillis();
reporter.testSetStarting( createReportEntryForTestSet( description ) );
}
- super.testStarted( description );
}
@Override
@@ -100,6 +101,8 @@ public class NonConcurrentRunListener
public void testIgnored( Description description )
throws Exception
{
+ finishLastTestSetIfNeccessary( description );
+
super.testIgnored( description );
this.lastFinishedDescription = description;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a57b805f/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
index 041db34..cad3fd5 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
@@ -98,11 +98,12 @@ class TestMethod
if ( ignored != null )
{
- reporter.testSkipped( createReportEntry() );
+ reporter.testSkipped( createReportEntry( ignored ) );
return;
}
- reporter.testStarting( createReportEntry() );
+ ReportEntry descriptionReport = createReportEntry( description );
+ reporter.testStarting( descriptionReport );
if ( output != null )
{
output.writeDetails( ( (ConsoleOutputReceiver) reporter ) );
@@ -110,23 +111,22 @@ class TestMethod
if ( testFailure != null )
{
- reporter.testFailed( testFailure );
+ reporter.testFailed( createReportEntry( testFailure ) );
}
else if ( testError != null )
{
- reporter.testError( testError );
+ reporter.testError( createReportEntry( testError ) );
}
else
{
- reporter.testSucceeded( createReportEntry() );
+ reporter.testSucceeded( descriptionReport );
}
}
- private ReportEntry createReportEntry()
+ private ReportEntry createReportEntry( ReportEntry reportEntry )
{
- int elapsed = (int) ( endTime - startTime );
- return new CategorizedReportEntry( description.getSourceName(), description.getName(), description.getGroup(),
- description.getStackTraceWriter(), elapsed, description.getMessage() );
+ return new CategorizedReportEntry( reportEntry.getSourceName(), reportEntry.getName(), reportEntry.getGroup(),
+ reportEntry.getStackTraceWriter(), getElapsed(), reportEntry.getMessage() );
}
public void attachToThread()
[5/7] git commit: [SUREFIRE-979] Wrong classloader used when test
fails in static initializer of base class
Posted by kr...@apache.org.
[SUREFIRE-979] Wrong classloader used when test fails in static initializer of base class
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/15ad61f5
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/15ad61f5
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/15ad61f5
Branch: refs/heads/surfire97
Commit: 15ad61f56ebe215e84db892256361a51cac68d7d
Parents: 99b3115
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Tue Mar 26 12:26:21 2013 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Tue Mar 26 16:55:47 2013 +0100
----------------------------------------------------------------------
.../maven/surefire/booter/ProviderFactory.java | 4 +-
.../its/jiras/Surefire979WrongClassLoaderIT.java | 39 +++++++++++++++
.../module1/pom.xml | 36 +++++++++++++
.../src/main/java/surefire979/TestBase.java | 17 ++++++
.../module2/pom.xml | 37 ++++++++++++++
.../surefire979/FailingStaticInitializerTest.java | 17 ++++++
.../pom.xml | 28 ++++++++++
.../surefire/report/SmartStackTraceParser.java | 2 +-
8 files changed, 177 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
index abef1c6..a21da57 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
@@ -97,7 +97,7 @@ public class ProviderFactory
public SurefireProvider createProvider( boolean isInsideFork )
{
- ClassLoader context = java.lang.Thread.currentThread().getContextClassLoader();
+ ClassLoader systemClassLoader = java.lang.Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader( surefireClassLoader );
StartupConfiguration starterConfiguration = startupConfiguration;
@@ -113,7 +113,7 @@ public class ProviderFactory
surefireReflector.setIfDirScannerAware( o, providerConfiguration.getDirScannerParams() );
Object provider = surefireReflector.instantiateProvider( starterConfiguration.getProviderClassName(), o );
- Thread.currentThread().setContextClassLoader( context );
+ Thread.currentThread().setContextClassLoader( systemClassLoader );
return new ProviderProxy( provider, testsClassLoader );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java
new file mode 100644
index 0000000..d648576
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire979WrongClassLoaderIT.java
@@ -0,0 +1,39 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+
+public class Surefire979WrongClassLoaderIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+
+ @Test
+ public void wrongClassloaderUSedInSmartStacktraceparser()
+ throws Exception
+ {
+ OutputValidator outputValidator =
+ unpack( "surefire-979-smartStackTrace-wrongClassloader" ).failNever().executeTest();
+ outputValidator.verifyTextInLog( "java.lang.NoClassDefFoundError: org/apache/commons/io/input/AutoCloseInputStream" );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml
new file mode 100644
index 0000000..ccd8a05
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/pom.xml
@@ -0,0 +1,36 @@
+<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>surefire-979</groupId>
+ <artifactId>module1</artifactId>
+ <version>1.0</version>
+ <name>surefire-979-base</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.2</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/src/main/java/surefire979/TestBase.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/src/main/java/surefire979/TestBase.java b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/src/main/java/surefire979/TestBase.java
new file mode 100644
index 0000000..4cba852
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module1/src/main/java/surefire979/TestBase.java
@@ -0,0 +1,17 @@
+package surefire979;
+
+
+import org.apache.commons.io.input.AutoCloseInputStream;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+
+
+public class TestBase
+{
+
+ static {
+ AutoCloseInputStream directoryWalker = new AutoCloseInputStream(new ByteArrayInputStream(new byte[200]));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml
new file mode 100644
index 0000000..a0c12a9
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/pom.xml
@@ -0,0 +1,37 @@
+<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>surefire-979</groupId>
+ <artifactId>module2</artifactId>
+ <version>1.0</version>
+ <name>surefire-979</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>surefire-979</groupId>
+ <artifactId>module1</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/src/test/java/surefire979/FailingStaticInitializerTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/src/test/java/surefire979/FailingStaticInitializerTest.java b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/src/test/java/surefire979/FailingStaticInitializerTest.java
new file mode 100644
index 0000000..dd37362
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/module2/src/test/java/surefire979/FailingStaticInitializerTest.java
@@ -0,0 +1,17 @@
+package surefire979;
+
+
+import org.junit.Test;
+
+
+public class FailingStaticInitializerTest extends TestBase
+{
+
+ @Test
+ public void test()
+ {
+ throw new IllegalStateException("This test will never run");
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/pom.xml b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/pom.xml
new file mode 100644
index 0000000..d540d1b
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-979-smartStackTrace-wrongClassloader/pom.xml
@@ -0,0 +1,28 @@
+<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>test</groupId>
+ <artifactId>surefire-979</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>surefire-979</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>module1</module>
+ <module>module2</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/15ad61f5/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
----------------------------------------------------------------------
diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
index 13bc6c9..ec67df8 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
@@ -59,7 +59,7 @@ public class SmartStackTraceParser
{
try
{
- return Class.forName( name );
+ return Thread.currentThread().getContextClassLoader().loadClass( name );
}
catch ( ClassNotFoundException e )
{