Author: krosenvold
Date: Thu Jan 13 20:27:08 2011
New Revision: 1058735
URL: http://svn.apache.org/viewvc?rev=1058735&view=rev
Log:
[SUREFIRE-500] puzzling NoClassDefFoundError instead of meaningfull stacktrace
Fixed with integration test
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire500PuzzlingErrorIT.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/ExplodingTest.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/PassingTest.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/Suite.java
(with props)
Modified:
maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire500PuzzlingErrorIT.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire500PuzzlingErrorIT.java?rev=1058735&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire500PuzzlingErrorIT.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire500PuzzlingErrorIT.java
Thu Jan 13 20:27:08 2011
@@ -0,0 +1,58 @@
+package org.apache.maven.surefire.its;
+/*
+ * 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 java.io.File;
+import java.util.List;
+
+import junit.framework.Assert;
+
+/**
+ * SUREFIRE-500 Asserts correct error handling for the "odd" surefire-500 (and
625) issues.
+ *
+ * @author Kristian Rosenvold
+ */
+public class Surefire500PuzzlingErrorIT
+ extends SurefireVerifierTestClass
+{
+ public Surefire500PuzzlingErrorIT()
+ {
+ super( "/surefire-500-puzzling-error" );
+ }
+
+ public void testBuildFailingWhenErrors()
+ throws Exception
+ {
+ failNever();
+ executeTest();
+ final File surefireReportsFile = getSurefireReportsFile(
"surefire500.ExplodingTest.txt" );
+
+ final List<String> list = getVerifier().loadFile( surefireReportsFile,
false );
+ for ( String line : list )
+ {
+
+ if ( line.contains( "java.lang.NoClassDefFoundError: whoops!" ) )
+ {
+ return;
+ }
+ }
+ Assert.fail( "Did not find expected message in log" );
+ }
+}
\ No newline at end of file
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire500PuzzlingErrorIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml?rev=1058735&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml
Thu Jan 13 20:27:08 2011
@@ -0,0 +1,44 @@
+<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>com.example</groupId>
+ <artifactId>surefire-500</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>surefire-500-puzzling-error</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <java.source.version>1.5</java.source.version>
+ <java.target.version>1.5</java.target.version>
+ <junit.version>4.4</junit.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>${java.source.version}</source>
+ <target>${java.target.version}</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/ExplodingTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/ExplodingTest.java?rev=1058735&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/ExplodingTest.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/ExplodingTest.java
Thu Jan 13 20:27:08 2011
@@ -0,0 +1,25 @@
+package surefire500;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+
+public class ExplodingTest {
+
+ static {
+ if (true) {
+ throw new java.lang.NoClassDefFoundError("whoops!");
+ }
+ }
+
+ @Test
+ public void testPass() throws Exception {
+ assertTrue(true);
+ }
+
+ public void testFail() throws Exception {
+ fail("fail");
+ }
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/ExplodingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/PassingTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/PassingTest.java?rev=1058735&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/PassingTest.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/PassingTest.java
Thu Jan 13 20:27:08 2011
@@ -0,0 +1,29 @@
+package surefire500;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class PassingTest {
+
+ @Test
+ public void testOne() throws Exception {
+ assertTrue(true);
+ }
+
+ @Test
+ public void testTwo() throws Exception {
+ assertTrue(true);
+ }
+
+ @Test
+ public void testThree() throws Exception {
+ assertTrue(true);
+ }
+
+ @Test
+ public void testFour() throws Exception {
+ assertTrue(true);
+ }
+
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/PassingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/Suite.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/Suite.java?rev=1058735&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/Suite.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/Suite.java
Thu Jan 13 20:27:08 2011
@@ -0,0 +1,10 @@
+package surefire500;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(org.junit.runners.Suite.class)
+@SuiteClasses(value={ExplodingTest.class, PassingTest.class})
+public class Suite {
+
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-500-puzzling-error/src/test/java/surefire500/Suite.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1058735&r1=1058734&r2=1058735&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
Thu Jan 13 20:27:08 2011
@@ -24,6 +24,7 @@ import org.apache.maven.surefire.common.
import org.apache.maven.surefire.common.junit4.JUnit4TestChecker;
import org.apache.maven.surefire.providerapi.ProviderParameters;
import org.apache.maven.surefire.providerapi.SurefireProvider;
+import org.apache.maven.surefire.report.PojoStackTraceWriter;
import org.apache.maven.surefire.report.ReportEntry;
import org.apache.maven.surefire.report.Reporter;
import org.apache.maven.surefire.report.ReporterException;
@@ -111,7 +112,20 @@ public class JUnit4Provider
reporter.testSetStarting( report );
- JUnit4TestSet.execute( clazz, listeners );
+ try
+ {
+ JUnit4TestSet.execute( clazz, listeners );
+ }
+ catch ( TestSetFailedException e )
+ {
+ throw e;
+ }
+ catch ( Throwable e )
+ {
+ reporter.testFailed( new SimpleReportEntry(
report.getSourceName(), report.getName(),
+ new
PojoStackTraceWriter( report.getSourceName(),
+
report.getName(), e ) ) );
+ }
reporter.testSetCompleted( report );
}