Updated Branches: refs/heads/master 867b33c8e -> 75f05d794
[SUREFIRE-1030] Remove nested exception wrappers Java 1.5 dependency is sufficient to get Throwable.getCause. Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/ddcd3468 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/ddcd3468 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/ddcd3468 Branch: refs/heads/master Commit: ddcd3468757dde39bed56cab2707a620af90171b Parents: 867b33c Author: Andrew Gaul <g...@maginatics.com> Authored: Wed Sep 4 22:14:59 2013 -0700 Committer: Andreas Gudian <agud...@apache.org> Committed: Mon Oct 21 19:37:16 2013 +0200 ---------------------------------------------------------------------- .../plugin/failsafe/IntegrationTestMojo.java | 5 +- .../plugin/surefire/AbstractSurefireMojo.java | 10 +- .../maven/plugin/surefire/ProviderList.java | 3 +- .../booterclient/ChecksumCalculator.java | 5 +- .../booterclient/output/ForkClient.java | 3 +- .../report/ConsoleOutputFileReporter.java | 3 +- .../surefire/report/TestSetRunListener.java | 3 +- .../surefire/runorder/StatisticsReporter.java | 3 +- .../maven/plugin/surefire/SurefirePlugin.java | 7 +- .../surefire/report/ReporterException.java | 3 +- .../testset/TestSetFailedException.java | 3 +- .../surefire/util/DefaultDirectoryScanner.java | 2 +- .../maven/surefire/util/DefaultScanResult.java | 2 +- .../surefire/util/NestedCheckedException.java | 167 ------------------ .../surefire/util/NestedRuntimeException.java | 170 ------------------- .../maven/surefire/util/ReflectionUtils.java | 2 +- .../util/SurefireReflectionException.java | 2 +- .../apache/maven/surefire/util/UrlUtils.java | 2 +- .../booter/SurefireBooterForkException.java | 3 +- .../booter/SurefireExecutionException.java | 3 +- .../maven/surefire/booter/TypeEncodedValue.java | 3 +- .../surefire/booter/SurefireReflectorTest.java | 7 +- .../surefire/common/junit3/JUnit3Reflector.java | 3 +- .../surefire/junitcore/AsynchronousRunner.java | 5 +- .../junitcore/ConfigurableParallelComputer.java | 3 +- .../maven/surefire/junitcore/TestSet.java | 3 +- .../maven/surefire/testng/TestNGExecutor.java | 3 +- .../maven/surefire/testng/TestNGProvider.java | 3 +- .../testng/conf/AbstractDirectConfigurator.java | 3 +- 29 files changed, 37 insertions(+), 397 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java ---------------------------------------------------------------------- diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java index 3329bcb..e84f16e 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java @@ -36,7 +36,6 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.shared.utils.ReaderFactory; import org.apache.maven.shared.utils.StringUtils; import org.apache.maven.surefire.suite.RunResult; -import org.apache.maven.surefire.util.NestedCheckedException; import static org.apache.maven.shared.utils.io.IOUtil.close; @@ -212,14 +211,14 @@ public class IntegrationTestMojo @Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" ) private String encoding; - protected void handleSummary( RunResult summary, NestedCheckedException firstForkException ) + protected void handleSummary( RunResult summary, Exception firstForkException ) throws MojoExecutionException, MojoFailureException { writeSummary( summary, firstForkException ); } @SuppressWarnings( "unchecked" ) - private void writeSummary( RunResult summary, NestedCheckedException firstForkException ) + private void writeSummary( RunResult summary, Exception firstForkException ) throws MojoExecutionException { File summaryFile = getSummaryFile(); http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 3e0c0c1..d436f83 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -83,8 +83,6 @@ import org.apache.maven.surefire.testset.TestArtifactInfo; import org.apache.maven.surefire.testset.TestRequest; import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.DefaultScanResult; -import org.apache.maven.surefire.util.NestedCheckedException; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.RunOrder; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; @@ -817,7 +815,7 @@ public abstract class AbstractSurefireMojo RunResult current = RunResult.noTestsRun(); - NestedCheckedException firstForkException = null; + Exception firstForkException = null; for ( ProviderInfo provider : providers ) { try @@ -1005,7 +1003,7 @@ public abstract class AbstractSurefireMojo } } - protected abstract void handleSummary( RunResult summary, NestedCheckedException firstForkException ) + protected abstract void handleSummary( RunResult summary, Exception firstForkException ) throws MojoExecutionException, MojoFailureException; protected void logReportsDirectory() @@ -2096,11 +2094,11 @@ public abstract class AbstractSurefireMojo } catch ( ArtifactResolutionException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } catch ( ArtifactNotFoundException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java index d7424af..7e56aa4 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java @@ -26,7 +26,6 @@ import java.util.Set; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.surefire.booterclient.ProviderDetector; import org.apache.maven.surefire.providerapi.SurefireProvider; -import org.apache.maven.surefire.util.NestedRuntimeException; import javax.annotation.Nonnull; @@ -90,7 +89,7 @@ public class ProviderList catch ( IOException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java index 29fbf11..5f703b1 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.surefire.util.NestedRuntimeException; /** * @author Kristian Rosenvold @@ -159,11 +158,11 @@ public class ChecksumCalculator } catch ( NoSuchAlgorithmException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } catch ( UnsupportedEncodingException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java index d2b86b4..0d8f7ff 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java @@ -39,7 +39,6 @@ import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterException; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.StackTraceWriter; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.internal.StringUtils; /** @@ -169,7 +168,7 @@ public class ForkClient } catch ( ReporterException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java index 7aeb1f7..184d0bf 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java @@ -25,7 +25,6 @@ import java.io.IOException; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.ReporterException; -import org.apache.maven.surefire.util.NestedRuntimeException; /** * Surefire output consumer proxy that writes test output to a {@link java.io.File} for each test suite. @@ -99,7 +98,7 @@ public class ConsoleOutputFileReporter } catch ( IOException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/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 027c326..cfe866d 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 @@ -26,7 +26,6 @@ import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.RunStatistics; -import org.apache.maven.surefire.util.NestedRuntimeException; import java.io.File; import java.io.IOException; @@ -105,7 +104,7 @@ public class TestSetRunListener } catch ( IOException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } consoleOutputReceiver.writeTestOutput( buf, off, len, stdout ); } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java index 93cadf1..4451d1d 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java @@ -22,7 +22,6 @@ package org.apache.maven.plugin.surefire.runorder; import java.io.File; import java.io.FileNotFoundException; import org.apache.maven.surefire.report.ReportEntry; -import org.apache.maven.surefire.util.NestedRuntimeException; /** * @author Kristian Rosenvold @@ -50,7 +49,7 @@ public class StatisticsReporter } catch ( FileNotFoundException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java ---------------------------------------------------------------------- diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java index 1477b23..131ad74 100644 --- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java +++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java @@ -28,7 +28,6 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.surefire.suite.RunResult; -import org.apache.maven.surefire.util.NestedCheckedException; import org.apache.maven.surefire.util.internal.StringUtils; /** @@ -188,7 +187,7 @@ public class SurefirePlugin @Parameter( property = "surefire.useManifestOnlyJar", defaultValue = "true" ) private boolean useManifestOnlyJar; - protected void handleSummary( RunResult summary, NestedCheckedException firstForkException ) + protected void handleSummary( RunResult summary, Exception firstForkException ) throws MojoExecutionException, MojoFailureException { assertNoException( firstForkException ); @@ -196,7 +195,7 @@ public class SurefirePlugin SurefireHelper.reportExecution( this, summary, getLog() ); } - private void assertNoException( NestedCheckedException firstForkException ) + private void assertNoException( Exception firstForkException ) throws MojoFailureException { if ( firstForkException != null ) @@ -205,7 +204,7 @@ public class SurefirePlugin } } - private void assertNoFailureOrTimeout( NestedCheckedException summary ) + private void assertNoFailureOrTimeout( Exception summary ) throws MojoFailureException { if ( summary != null ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java index f790a8a..2bf2313 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java @@ -19,7 +19,6 @@ package org.apache.maven.surefire.report; * under the License. */ -import org.apache.maven.surefire.util.NestedRuntimeException; /** * Exception occurring during report generation. @@ -27,7 +26,7 @@ import org.apache.maven.surefire.util.NestedRuntimeException; * @author <a href="mailto:br...@apache.org">Brett Porter</a> */ public class ReporterException - extends NestedRuntimeException + extends RuntimeException { public ReporterException( String message, Exception nested ) { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java index 13c5b6a..e0b03aa 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/testset/TestSetFailedException.java @@ -19,7 +19,6 @@ package org.apache.maven.surefire.testset; * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; /** * Exception that indicates a test failed. @@ -27,7 +26,7 @@ import org.apache.maven.surefire.util.NestedCheckedException; * @author Bill Venners */ public class TestSetFailedException - extends NestedCheckedException + extends Exception { /** http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java index 559da21..f9d48c4 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java @@ -102,7 +102,7 @@ public class DefaultDirectoryScanner } catch ( ClassNotFoundException e ) { - throw new NestedRuntimeException( "Unable to create test class '" + className + "'", e ); + throw new RuntimeException( "Unable to create test class '" + className + "'", e ); } return testClass; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java index cb34ae9..8957e5a 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultScanResult.java @@ -132,7 +132,7 @@ public class DefaultScanResult } catch ( ClassNotFoundException e ) { - throw new NestedRuntimeException( "Unable to create test class '" + className + "'", e ); + throw new RuntimeException( "Unable to create test class '" + className + "'", e ); } return testClass; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedCheckedException.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedCheckedException.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedCheckedException.java deleted file mode 100644 index 6871317..0000000 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedCheckedException.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.apache.maven.surefire.util; - -/* - * 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. - */ - -/* - * Copyright 2002-2005 the original author or authors. - * - * 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.PrintStream; -import java.io.PrintWriter; - -/** - * <p>Copied from Spring framework to keep Java 1.3 compatibility.</p> - * <p/> - * <p>Handy class for wrapping checked Exceptions with a root cause.</p> - * <p/> - * <p>This time-honored technique is no longer necessary in Java 1.4, which - * finally provides built-in support for exception nesting. Thus exceptions in - * applications written to use Java 1.4 need not extend this class. To ease - * migration, this class mirrors Java 1.4's nested exceptions as closely as possible. - * <p/> - * <p>Abstract to force the programmer to extend the class. <code>getMessage</code> - * will include nested exception information; <code>printStackTrace</code> etc will - * delegate to the wrapped exception, if any. - * <p/> - * <p>The similarity between this class and the NestedRuntimeException class is - * unavoidable, as Java forces these two classes to have different superclasses - * (ah, the inflexibility of concrete inheritance!). - * <p/> - * <p>As discussed in - * <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and - * Development</a>, runtime exceptions are often a better alternative to checked exceptions. - * However, all exceptions should preserve their stack trace, if caused by a - * lower-level exception. - * - * @author Rod Johnson - * @author Juergen Hoeller - * @see #getMessage - * @see #printStackTrace - * @see NestedRuntimeException - */ -public class NestedCheckedException - extends Exception -{ - - /** - * Root cause of this nested exception - */ - private Throwable cause; - - /** - * Construct a <code>NestedCheckedException</code> with the specified detail message. - * - * @param msg the detail message - */ - public NestedCheckedException( String msg ) - { - super( msg ); - } - - /** - * Construct a <code>NestedCheckedException</code> with the specified detail message - * and nested exception. - * - * @param msg the detail message - * @param ex the nested exception - */ - public NestedCheckedException( String msg, Throwable ex ) - { - super( msg ); - this.cause = ex; - } - - /** - * Return the nested cause, or <code>null</code> if none. - */ - public Throwable getCause() - { - // Even if you cannot set the cause of this exception other than through - // the constructor, we check for the cause being "this" here, as the cause - // could still be set to "this" via reflection: for example, by a remoting - // deserializer like Hessian's. - return ( this.cause == this ? null : this.cause ); - } - - /** - * Return the detail message, including the message from the nested exception - * if there is one. - */ - public String getMessage() - { - if ( getCause() == null ) - { - return super.getMessage(); - } - else - { - return super.getMessage() + "; nested exception is " + getCause().getClass().getName() + ": " - + getCause().getMessage(); - } - } - - /** - * Print the composite message and the embedded stack trace to the specified stream. - * - * @param ps the print stream - */ - public void printStackTrace( PrintStream ps ) - { - if ( getCause() == null ) - { - super.printStackTrace( ps ); - } - else - { - ps.println( this ); - getCause().printStackTrace( ps ); - } - } - - /** - * Print the composite message and the embedded stack trace to the specified print writer. - * - * @param pw the print writer - */ - public void printStackTrace( PrintWriter pw ) - { - if ( getCause() == null ) - { - super.printStackTrace( pw ); - } - else - { - pw.println( this ); - getCause().printStackTrace( pw ); - } - } -} http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedRuntimeException.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedRuntimeException.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedRuntimeException.java deleted file mode 100644 index 91c53d5..0000000 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/NestedRuntimeException.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.apache.maven.surefire.util; - -/* - * 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. - */ - -/* - * Copyright 2002-2005 the original author or authors. - * - * 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.PrintStream; -import java.io.PrintWriter; - -/** - * <p>Copied from Spring framework to keep Java 1.3 compatability.</p> - * <p/> - * <p>Handy class for wrapping runtime Exceptions with a root cause.</p> - * <p/> - * <p>This time-honoured technique is no longer necessary in Java 1.4, which - * finally provides built-in support for exception nesting. Thus exceptions in - * applications written to use Java 1.4 need not extend this class. To ease - * migration, this class mirrors Java 1.4's nested exceptions as closely as possible. - * <p/> - * <p>Abstract to force the programmer to extend the class. <code>getMessage</code> - * will include nested exception information; <code>printStackTrace</code> etc will - * delegate to the wrapped exception, if any. - * <p/> - * <p>The similarity between this class and the NestedCheckedException class is - * unavoidable, as Java forces these two classes to have different superclasses - * (ah, the inflexibility of concrete inheritance!). - * <p/> - * <p>As discussed in - * <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/">Expert One-On-One J2EE Design and - * Development</a>, runtime exceptions are often a better alternative to checked exceptions. - * However, all exceptions should preserve their stack trace, if caused by a - * lower-level exception. - * - * @author Rod Johnson - * @author Juergen Hoeller - * @see #getMessage - * @see #printStackTrace - * @see NestedCheckedException - */ -public class NestedRuntimeException - extends RuntimeException -{ - - /** - * Root cause of this nested exception - */ - private final Throwable cause; - - /** - * Construct a <code>NestedRuntimeException</code> with the specified detail message - * and nested exception. - * - * @param msg the detail message - * @param ex the nested exception - */ - public NestedRuntimeException( String msg, Throwable ex ) - { - super( msg ); - this.cause = ex; - } - - /** - * Construct a <code>NestedRuntimeException</code> with the specified nested exception. - * - * @param ex the nested exception - */ - public NestedRuntimeException( Throwable ex ) - { - super(); - this.cause = ex; - } - - /** - * Return the nested cause, or <code>null</code> if none. - * <p>Note that this will only check one level of nesting. - * Use <code>getRootCause()</code> to retrieve the innermost cause. - */ - public Throwable getCause() - { - // Even if you cannot set the cause of this exception other than through - // the constructor, we check for the cause being "this" here, as the cause - // could still be set to "this" via reflection: for example, by a remoting - // deserializer like Hessian's. - return ( this.cause == this ? null : this.cause ); - } - - /** - * Return the detail message, including the message from the nested exception - * if there is one. - */ - public String getMessage() - { - if ( getCause() == null ) - { - return super.getMessage(); - } - else - { - return super.getMessage() + "; nested exception is " + getCause().getClass().getName() + ": " - + getCause().getMessage(); - } - } - - /** - * Print the composite message and the embedded stack trace to the specified stream. - * - * @param ps the print stream - */ - public void printStackTrace( PrintStream ps ) - { - if ( getCause() == null ) - { - super.printStackTrace( ps ); - } - else - { - ps.println( this ); - getCause().printStackTrace( ps ); - } - } - - /** - * Print the composite message and the embedded stack trace to the specified writer. - * - * @param pw the print writer - */ - public void printStackTrace( PrintWriter pw ) - { - if ( getCause() == null ) - { - super.printStackTrace( pw ); - } - else - { - pw.println( this ); - getCause().printStackTrace( pw ); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java index a3c9e15..19c1c3f 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java @@ -46,7 +46,7 @@ public class ReflectionUtils } catch ( NoSuchMethodException e ) { - throw new NestedRuntimeException( "When finding method " + methodName, e ); + throw new RuntimeException( "When finding method " + methodName, e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java index 18fbb94..6c75e8f 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/SurefireReflectionException.java @@ -27,7 +27,7 @@ package org.apache.maven.surefire.util; * @author Kristian Rosenvold */ public class SurefireReflectionException - extends NestedRuntimeException + extends RuntimeException { /** * Create a <code>SurefireReflectionException</code> with the specified cause. The http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java ---------------------------------------------------------------------- diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java index b7059d9..34dfe3d 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/UrlUtils.java @@ -89,7 +89,7 @@ public class UrlUtils catch ( UnsupportedEncodingException e ) { // should not happen as UTF-8 must be present - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java index 6ad7647..9571c92 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooterForkException.java @@ -19,13 +19,12 @@ package org.apache.maven.surefire.booter; * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; /** * Encapsulates exceptions thrown during Surefire forking. */ public class SurefireBooterForkException - extends NestedCheckedException + extends Exception { public SurefireBooterForkException( String message, Throwable cause ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java index 5318102..9a0af3b 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireExecutionException.java @@ -19,7 +19,6 @@ package org.apache.maven.surefire.booter; * under the License. */ -import org.apache.maven.surefire.util.NestedCheckedException; /** * An error occurring during the invocation of Surefire via an alternate class loader. @@ -27,7 +26,7 @@ import org.apache.maven.surefire.util.NestedCheckedException; * @author <a href="mailto:br...@apache.org">Brett Porter</a> */ public class SurefireExecutionException - extends NestedCheckedException + extends Exception { public SurefireExecutionException( String message, Throwable nested ) { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java index a71d40b..4b0cfb8 100644 --- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java +++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java @@ -22,7 +22,6 @@ package org.apache.maven.surefire.booter; import java.io.ByteArrayInputStream; import java.io.File; import java.util.Properties; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.ReflectionUtils; /** @@ -86,7 +85,7 @@ public class TypeEncodedValue } catch ( Exception e ) { - throw new NestedRuntimeException( "bug in property conversion", e ); + throw new RuntimeException( "bug in property conversion", e ); } return result; } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java ---------------------------------------------------------------------- diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java index 72d7da6..cfedc8c 100644 --- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java +++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java @@ -31,7 +31,6 @@ import org.apache.maven.surefire.testset.DirectoryScannerParameters; import org.apache.maven.surefire.testset.RunOrderParameters; import org.apache.maven.surefire.testset.TestArtifactInfo; import org.apache.maven.surefire.testset.TestRequest; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.RunOrder; import junit.framework.TestCase; @@ -149,15 +148,15 @@ public class SurefireReflectorTest } catch ( IllegalAccessException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } catch ( InvocationTargetException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } catch ( NoSuchMethodException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java ---------------------------------------------------------------------- diff --git a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java index 3ffec88..eec23d8 100644 --- a/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java +++ b/surefire-providers/common-junit3/src/main/java/org/apache/maven/surefire/common/junit3/JUnit3Reflector.java @@ -23,7 +23,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.ReflectionUtils; public final class JUnit3Reflector @@ -110,7 +109,7 @@ public final class JUnit3Reflector } catch ( NoSuchMethodException e ) { - throw new NestedRuntimeException( "When finding method " + methodName, e ); + throw new RuntimeException( "When finding method " + methodName, e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java index 4d14d31..dcadeff 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/AsynchronousRunner.java @@ -26,7 +26,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.junit.runners.model.RunnerScheduler; @@ -59,7 +58,7 @@ public class AsynchronousRunner } catch ( ExecutionException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } @@ -74,7 +73,7 @@ public class AsynchronousRunner } catch ( InterruptedException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java index 96f52fa..cf5b2e7 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConfigurableParallelComputer.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.junit.runner.Computer; import org.junit.runner.Runner; @@ -94,7 +93,7 @@ public class ConfigurableParallelComputer } catch ( InterruptedException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/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 8b0283c..af63acd 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 @@ -28,7 +28,6 @@ import org.apache.maven.surefire.report.ConsoleOutputReceiver; import org.apache.maven.surefire.report.ReportEntry; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.report.SimpleReportEntry; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.junit.runner.Description; @@ -98,7 +97,7 @@ public class TestSet } catch ( Exception e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java index 9d8c4dd..4ff7acf 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java @@ -23,7 +23,6 @@ import org.apache.maven.surefire.booter.ProviderParameterNames; import org.apache.maven.surefire.report.RunListener; import org.apache.maven.surefire.testng.conf.Configurator; import org.apache.maven.surefire.testset.TestSetFailedException; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.internal.StringUtils; import org.testng.TestNG; import org.testng.xml.XmlClass; @@ -271,7 +270,7 @@ public class TestNGExecutor } catch ( Exception e ) { - throw new NestedRuntimeException( "Bug in ConfigurationAwareTestNGReporter", e ); + throw new RuntimeException( "Bug in ConfigurationAwareTestNGReporter", e ); } } catch ( ClassNotFoundException e ) http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java index ff3eaac..1f28a29 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java @@ -29,7 +29,6 @@ import org.apache.maven.surefire.report.ReporterFactory; import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestRequest; import org.apache.maven.surefire.testset.TestSetFailedException; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.apache.maven.surefire.util.RunOrderCalculator; import org.apache.maven.surefire.util.ScanResult; import org.apache.maven.surefire.util.TestsToRun; @@ -149,7 +148,7 @@ public class TestNGProvider } catch ( TestSetFailedException e ) { - throw new NestedRuntimeException( e ); + throw new RuntimeException( e ); } } else http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/ddcd3468/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java ---------------------------------------------------------------------- diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java index e457da8..3c1e95e 100644 --- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java +++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/AbstractDirectConfigurator.java @@ -28,7 +28,6 @@ import java.util.Map; import org.apache.maven.surefire.booter.ProviderParameterNames; import org.apache.maven.surefire.testset.TestSetFailedException; -import org.apache.maven.surefire.util.NestedRuntimeException; import org.testng.TestNG; import org.testng.xml.XmlSuite; @@ -104,7 +103,7 @@ public abstract class AbstractDirectConfigurator } catch ( Exception ex ) { - throw new NestedRuntimeException( "Cannot set option " + key + " with value " + val, ex ); + throw new RuntimeException( "Cannot set option " + key + " with value " + val, ex ); } }