diff options
author | David Srbecky <dsrbecky@google.com> | 2021-02-24 15:52:50 +0000 |
---|---|---|
committer | David Srbecky <dsrbecky@google.com> | 2021-02-24 15:52:50 +0000 |
commit | 08a6d4b74555db6d01048fc7065eb1e2bfaf33bc (patch) | |
tree | 81124de095a6b4a53b223d0f70cadde9744ee44a /src/main/java/org/junit/runner/notification | |
parent | 6a658e7a4df0cc8ea6465da46fcf1a823cb0d491 (diff) | |
download | junit-08a6d4b74555db6d01048fc7065eb1e2bfaf33bc.tar.gz |
Revert "Upgrade external/junit to 4.13.2"
Revert submission 1601635
Reason for revert: b/181123058
Reverted Changes:
I8f5cd1266:Remove support for stuck threads
Ifdb59336d:Remove DisableOnDebug (new in 4.12) as it is not s...
I6abae5aed:Extra generic type information to aid certain java...
I5ec909df6:Upgrade external/junit to 4.13.2
Change-Id: Idaddfc2039816a8d7b12c91fdd540b801ab854ff
Diffstat (limited to 'src/main/java/org/junit/runner/notification')
4 files changed, 14 insertions, 111 deletions
diff --git a/src/main/java/org/junit/runner/notification/Failure.java b/src/main/java/org/junit/runner/notification/Failure.java index 4551302..c03b4c1 100644 --- a/src/main/java/org/junit/runner/notification/Failure.java +++ b/src/main/java/org/junit/runner/notification/Failure.java @@ -1,8 +1,9 @@ package org.junit.runner.notification; +import java.io.PrintWriter; import java.io.Serializable; +import java.io.StringWriter; -import org.junit.internal.Throwables; import org.junit.runner.Description; /** @@ -20,7 +21,7 @@ public class Failure implements Serializable { /* * We have to use the f prefix until the next major release to ensure * serialization compatibility. - * See https://github.com/junit-team/junit4/issues/976 + * See https://github.com/junit-team/junit/issues/976 */ private final Description fDescription; private final Throwable fThrownException; @@ -64,19 +65,15 @@ public class Failure implements Serializable { } /** - * Gets the printed form of the exception and its stack trace. + * Convenience method + * + * @return the printed form of the exception */ public String getTrace() { - return Throwables.getStacktrace(getException()); - } - - /** - * Gets a the printed form of the exception, with a trimmed version of the stack trace. - * This method will attempt to filter out frames of the stack trace that are below - * the test method call. - */ - public String getTrimmedTrace() { - return Throwables.getTrimmedStackTrace(getException()); + StringWriter stringWriter = new StringWriter(); + PrintWriter writer = new PrintWriter(stringWriter); + getException().printStackTrace(writer); + return stringWriter.toString(); } /** diff --git a/src/main/java/org/junit/runner/notification/RunListener.java b/src/main/java/org/junit/runner/notification/RunListener.java index d7cac00..db9d8c1 100644 --- a/src/main/java/org/junit/runner/notification/RunListener.java +++ b/src/main/java/org/junit/runner/notification/RunListener.java @@ -70,34 +70,6 @@ public class RunListener { } /** - * Called when a test suite is about to be started. If this method is - * called for a given {@link Description}, then {@link #testSuiteFinished(Description)} - * will also be called for the same {@code Description}. - * - * <p>Note that not all runners will call this method, so runners should - * be prepared to handle {@link #testStarted(Description)} calls for tests - * where there was no corresponding {@code testSuiteStarted()} call for - * the parent {@code Description}. - * - * @param description the description of the test suite that is about to be run - * (generally a class name) - * @since 4.13 - */ - public void testSuiteStarted(Description description) throws Exception { - } - - /** - * Called when a test suite has finished, whether the test suite succeeds or fails. - * This method will not be called for a given {@link Description} unless - * {@link #testSuiteStarted(Description)} was called for the same @code Description}. - * - * @param description the description of the test suite that just ran - * @since 4.13 - */ - public void testSuiteFinished(Description description) throws Exception { - } - - /** * Called when an atomic test is about to be started. * * @param description the description of the test that is about to be run diff --git a/src/main/java/org/junit/runner/notification/RunNotifier.java b/src/main/java/org/junit/runner/notification/RunNotifier.java index 752fa3b..6875f76 100644 --- a/src/main/java/org/junit/runner/notification/RunNotifier.java +++ b/src/main/java/org/junit/runner/notification/RunNotifier.java @@ -65,8 +65,8 @@ public class RunNotifier { void run() { int capacity = currentListeners.size(); - List<RunListener> safeListeners = new ArrayList<RunListener>(capacity); - List<Failure> failures = new ArrayList<Failure>(capacity); + ArrayList<RunListener> safeListeners = new ArrayList<RunListener>(capacity); + ArrayList<Failure> failures = new ArrayList<Failure>(capacity); for (RunListener listener : currentListeners) { try { notifyListener(listener); @@ -78,7 +78,7 @@ public class RunNotifier { fireTestFailures(safeListeners, failures); } - protected abstract void notifyListener(RunListener each) throws Exception; + abstract protected void notifyListener(RunListener each) throws Exception; } /** @@ -106,41 +106,6 @@ public class RunNotifier { } /** - * Invoke to tell listeners that a test suite is about to start. Runners are strongly - * encouraged--but not required--to call this method. If this method is called for - * a given {@link Description} then {@link #fireTestSuiteFinished(Description)} MUST - * be called for the same {@code Description}. - * - * @param description the description of the suite test (generally a class name) - * @since 4.13 - */ - public void fireTestSuiteStarted(final Description description) { - new SafeNotifier() { - @Override - protected void notifyListener(RunListener each) throws Exception { - each.testSuiteStarted(description); - } - }.run(); - } - - /** - * Invoke to tell listeners that a test suite is about to finish. Always invoke - * this method if you invoke {@link #fireTestSuiteStarted(Description)} - * as listeners are likely to expect them to come in pairs. - * - * @param description the description of the suite test (generally a class name) - * @since 4.13 - */ - public void fireTestSuiteFinished(final Description description) { - new SafeNotifier() { - @Override - protected void notifyListener(RunListener each) throws Exception { - each.testSuiteFinished(description); - } - }.run(); - } - - /** * Invoke to tell listeners that an atomic test is about to start. * * @param description the description of the atomic test (generally a class and method name) diff --git a/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java b/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java index 400fed8..c53c1ee 100644 --- a/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java +++ b/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java @@ -10,7 +10,7 @@ import org.junit.runner.Result; * <p>This class synchronizes all listener calls on a RunNotifier instance. This is done because * prior to JUnit 4.12, all listeners were called in a synchronized block in RunNotifier, * so no two listeners were ever called concurrently. If we instead made the methods here - * synchronized, clients that added multiple listeners that called common code might see + * sychronized, clients that added multiple listeners that called common code might see * issues due to the reduced synchronization. * * @author Tibor Digana (tibor17) @@ -43,37 +43,6 @@ final class SynchronizedRunListener extends RunListener { } } - /** - * {@inheritDoc} - * <p/> - * Synchronized decorator for {@link RunListener#testSuiteStarted(Description)}. - * @param description the description of the test suite that is about to be run - * (generally a class name). - * @throws Exception if any occurs. - * @since 4.13 - */ - @Override - public void testSuiteStarted(Description description) throws Exception { - synchronized (monitor) { - listener.testSuiteStarted(description); - } - } - - /** - * {@inheritDoc} - * <p/> - * Synchronized decorator for {@link RunListener#testSuiteFinished(Description)}. - * @param description the description of the test suite that just ran. - * @throws Exception - * @since 4.13 - */ - @Override - public void testSuiteFinished(Description description) throws Exception { - synchronized (monitor) { - listener.testSuiteFinished(description); - } - } - @Override public void testStarted(Description description) throws Exception { synchronized (monitor) { |