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/junit/framework | |
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/junit/framework')
-rw-r--r-- | src/main/java/junit/framework/Assert.java | 78 | ||||
-rw-r--r-- | src/main/java/junit/framework/ComparisonCompactor.java | 1 | ||||
-rw-r--r-- | src/main/java/junit/framework/JUnit4TestAdapter.java | 25 | ||||
-rw-r--r-- | src/main/java/junit/framework/Protectable.java | 4 | ||||
-rw-r--r-- | src/main/java/junit/framework/TestCase.java | 47 | ||||
-rw-r--r-- | src/main/java/junit/framework/TestFailure.java | 8 | ||||
-rw-r--r-- | src/main/java/junit/framework/TestResult.java | 10 | ||||
-rw-r--r-- | src/main/java/junit/framework/TestSuite.java | 29 |
8 files changed, 116 insertions, 86 deletions
diff --git a/src/main/java/junit/framework/Assert.java b/src/main/java/junit/framework/Assert.java index 43482a1..663461c 100644 --- a/src/main/java/junit/framework/Assert.java +++ b/src/main/java/junit/framework/Assert.java @@ -17,7 +17,7 @@ public class Assert { * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. */ - public static void assertTrue(String message, boolean condition) { + static public void assertTrue(String message, boolean condition) { if (!condition) { fail(message); } @@ -27,7 +27,7 @@ public class Assert { * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError. */ - public static void assertTrue(boolean condition) { + static public void assertTrue(boolean condition) { assertTrue(null, condition); } @@ -35,7 +35,7 @@ public class Assert { * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError with the given message. */ - public static void assertFalse(String message, boolean condition) { + static public void assertFalse(String message, boolean condition) { assertTrue(message, !condition); } @@ -43,14 +43,14 @@ public class Assert { * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError. */ - public static void assertFalse(boolean condition) { + static public void assertFalse(boolean condition) { assertFalse(null, condition); } /** * Fails a test with the given message. */ - public static void fail(String message) { + static public void fail(String message) { if (message == null) { throw new AssertionFailedError(); } @@ -60,7 +60,7 @@ public class Assert { /** * Fails a test with no message. */ - public static void fail() { + static public void fail() { fail(null); } @@ -68,7 +68,7 @@ public class Assert { * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, Object expected, Object actual) { + static public void assertEquals(String message, Object expected, Object actual) { if (expected == null && actual == null) { return; } @@ -82,14 +82,14 @@ public class Assert { * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ - public static void assertEquals(Object expected, Object actual) { + static public void assertEquals(Object expected, Object actual) { assertEquals(null, expected, actual); } /** * Asserts that two Strings are equal. */ - public static void assertEquals(String message, String expected, String actual) { + static public void assertEquals(String message, String expected, String actual) { if (expected == null && actual == null) { return; } @@ -103,7 +103,7 @@ public class Assert { /** * Asserts that two Strings are equal. */ - public static void assertEquals(String expected, String actual) { + static public void assertEquals(String expected, String actual) { assertEquals(null, expected, actual); } @@ -112,12 +112,12 @@ public class Assert { * an AssertionFailedError is thrown with the given message. If the expected * value is infinity then the delta value is ignored. */ - public static void assertEquals(String message, double expected, double actual, double delta) { + static public void assertEquals(String message, double expected, double actual, double delta) { if (Double.compare(expected, actual) == 0) { return; } if (!(Math.abs(expected - actual) <= delta)) { - failNotEquals(message, Double.valueOf(expected), Double.valueOf(actual)); + failNotEquals(message, new Double(expected), new Double(actual)); } } @@ -125,7 +125,7 @@ public class Assert { * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ - public static void assertEquals(double expected, double actual, double delta) { + static public void assertEquals(double expected, double actual, double delta) { assertEquals(null, expected, actual, delta); } @@ -134,12 +134,12 @@ public class Assert { * are not an AssertionFailedError is thrown with the given message. If the * expected value is infinity then the delta value is ignored. */ - public static void assertEquals(String message, float expected, float actual, float delta) { + static public void assertEquals(String message, float expected, float actual, float delta) { if (Float.compare(expected, actual) == 0) { return; } if (!(Math.abs(expected - actual) <= delta)) { - failNotEquals(message, Float.valueOf(expected), Float.valueOf(actual)); + failNotEquals(message, new Float(expected), new Float(actual)); } } @@ -147,7 +147,7 @@ public class Assert { * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ - public static void assertEquals(float expected, float actual, float delta) { + static public void assertEquals(float expected, float actual, float delta) { assertEquals(null, expected, actual, delta); } @@ -155,14 +155,14 @@ public class Assert { * Asserts that two longs are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, long expected, long actual) { + static public void assertEquals(String message, long expected, long actual) { assertEquals(message, Long.valueOf(expected), Long.valueOf(actual)); } /** * Asserts that two longs are equal. */ - public static void assertEquals(long expected, long actual) { + static public void assertEquals(long expected, long actual) { assertEquals(null, expected, actual); } @@ -170,14 +170,14 @@ public class Assert { * Asserts that two booleans are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, boolean expected, boolean actual) { + static public void assertEquals(String message, boolean expected, boolean actual) { assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual)); } /** * Asserts that two booleans are equal. */ - public static void assertEquals(boolean expected, boolean actual) { + static public void assertEquals(boolean expected, boolean actual) { assertEquals(null, expected, actual); } @@ -185,14 +185,14 @@ public class Assert { * Asserts that two bytes are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, byte expected, byte actual) { + static public void assertEquals(String message, byte expected, byte actual) { assertEquals(message, Byte.valueOf(expected), Byte.valueOf(actual)); } /** * Asserts that two bytes are equal. */ - public static void assertEquals(byte expected, byte actual) { + static public void assertEquals(byte expected, byte actual) { assertEquals(null, expected, actual); } @@ -200,14 +200,14 @@ public class Assert { * Asserts that two chars are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, char expected, char actual) { + static public void assertEquals(String message, char expected, char actual) { assertEquals(message, Character.valueOf(expected), Character.valueOf(actual)); } /** * Asserts that two chars are equal. */ - public static void assertEquals(char expected, char actual) { + static public void assertEquals(char expected, char actual) { assertEquals(null, expected, actual); } @@ -215,14 +215,14 @@ public class Assert { * Asserts that two shorts are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, short expected, short actual) { + static public void assertEquals(String message, short expected, short actual) { assertEquals(message, Short.valueOf(expected), Short.valueOf(actual)); } /** * Asserts that two shorts are equal. */ - public static void assertEquals(short expected, short actual) { + static public void assertEquals(short expected, short actual) { assertEquals(null, expected, actual); } @@ -230,21 +230,21 @@ public class Assert { * Asserts that two ints are equal. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertEquals(String message, int expected, int actual) { + static public void assertEquals(String message, int expected, int actual) { assertEquals(message, Integer.valueOf(expected), Integer.valueOf(actual)); } /** * Asserts that two ints are equal. */ - public static void assertEquals(int expected, int actual) { + static public void assertEquals(int expected, int actual) { assertEquals(null, expected, actual); } /** * Asserts that an object isn't null. */ - public static void assertNotNull(Object object) { + static public void assertNotNull(Object object) { assertNotNull(null, object); } @@ -252,7 +252,7 @@ public class Assert { * Asserts that an object isn't null. If it is * an AssertionFailedError is thrown with the given message. */ - public static void assertNotNull(String message, Object object) { + static public void assertNotNull(String message, Object object) { assertTrue(message, object != null); } @@ -263,7 +263,7 @@ public class Assert { * * @param object Object to check or <code>null</code> */ - public static void assertNull(Object object) { + static public void assertNull(Object object) { if (object != null) { assertNull("Expected: <null> but was: " + object.toString(), object); } @@ -273,7 +273,7 @@ public class Assert { * Asserts that an object is null. If it is not * an AssertionFailedError is thrown with the given message. */ - public static void assertNull(String message, Object object) { + static public void assertNull(String message, Object object) { assertTrue(message, object == null); } @@ -281,7 +281,7 @@ public class Assert { * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown with the given message. */ - public static void assertSame(String message, Object expected, Object actual) { + static public void assertSame(String message, Object expected, Object actual) { if (expected == actual) { return; } @@ -292,7 +292,7 @@ public class Assert { * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ - public static void assertSame(Object expected, Object actual) { + static public void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); } @@ -301,7 +301,7 @@ public class Assert { * refer to the same object an AssertionFailedError is thrown with the * given message. */ - public static void assertNotSame(String message, Object expected, Object actual) { + static public void assertNotSame(String message, Object expected, Object actual) { if (expected == actual) { failSame(message); } @@ -311,21 +311,21 @@ public class Assert { * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ - public static void assertNotSame(Object expected, Object actual) { + static public void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); } - public static void failSame(String message) { + static public void failSame(String message) { String formatted = (message != null) ? message + " " : ""; fail(formatted + "expected not same"); } - public static void failNotSame(String message, Object expected, Object actual) { + static public void failNotSame(String message, Object expected, Object actual) { String formatted = (message != null) ? message + " " : ""; fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">"); } - public static void failNotEquals(String message, Object expected, Object actual) { + static public void failNotEquals(String message, Object expected, Object actual) { fail(format(message, expected, actual)); } diff --git a/src/main/java/junit/framework/ComparisonCompactor.java b/src/main/java/junit/framework/ComparisonCompactor.java index 81ddd5b..fa20a8e 100644 --- a/src/main/java/junit/framework/ComparisonCompactor.java +++ b/src/main/java/junit/framework/ComparisonCompactor.java @@ -18,7 +18,6 @@ public class ComparisonCompactor { fActual = actual; } - @SuppressWarnings("deprecation") public String compact(String message) { if (fExpected == null || fActual == null || areStringsEqual()) { return Assert.format(message, fExpected, fActual); diff --git a/src/main/java/junit/framework/JUnit4TestAdapter.java b/src/main/java/junit/framework/JUnit4TestAdapter.java index 9d32031..cbb66db 100644 --- a/src/main/java/junit/framework/JUnit4TestAdapter.java +++ b/src/main/java/junit/framework/JUnit4TestAdapter.java @@ -9,23 +9,11 @@ import org.junit.runner.Request; import org.junit.runner.Runner; import org.junit.runner.manipulation.Filter; import org.junit.runner.manipulation.Filterable; -import org.junit.runner.manipulation.Orderer; -import org.junit.runner.manipulation.InvalidOrderingException; import org.junit.runner.manipulation.NoTestsRemainException; -import org.junit.runner.manipulation.Orderable; +import org.junit.runner.manipulation.Sortable; import org.junit.runner.manipulation.Sorter; -/** - * The JUnit4TestAdapter enables running JUnit-4-style tests using a JUnit-3-style test runner. - * - * <p> To use it, add the following to a test class: - * <pre> - public static Test suite() { - return new JUnit4TestAdapter(<em>YourJUnit4TestClass</em>.class); - } -</pre> - */ -public class JUnit4TestAdapter implements Test, Filterable, Orderable, Describable { +public class JUnit4TestAdapter implements Test, Filterable, Sortable, Describable { private final Class<?> fNewTestClass; private final Runner fRunner; @@ -95,13 +83,4 @@ public class JUnit4TestAdapter implements Test, Filterable, Orderable, Describab public void sort(Sorter sorter) { sorter.apply(fRunner); } - - /** - * {@inheritDoc} - * - * @since 4.13 - */ - public void order(Orderer orderer) throws InvalidOrderingException { - orderer.apply(fRunner); - } }
\ No newline at end of file diff --git a/src/main/java/junit/framework/Protectable.java b/src/main/java/junit/framework/Protectable.java index c5ceb16..9f30b10 100644 --- a/src/main/java/junit/framework/Protectable.java +++ b/src/main/java/junit/framework/Protectable.java @@ -8,7 +8,7 @@ package junit.framework; public interface Protectable { /** - * Run the following method protected. + * Run the the following method protected. */ public abstract void protect() throws Throwable; -} +}
\ No newline at end of file diff --git a/src/main/java/junit/framework/TestCase.java b/src/main/java/junit/framework/TestCase.java index e474a64..b89ce71 100644 --- a/src/main/java/junit/framework/TestCase.java +++ b/src/main/java/junit/framework/TestCase.java @@ -73,7 +73,6 @@ import java.lang.reflect.Modifier; * @see TestResult * @see TestSuite */ -@SuppressWarnings("deprecation") public abstract class TestCase extends Assert implements Test { /** * the name of the test case @@ -103,7 +102,7 @@ public abstract class TestCase extends Assert implements Test { } /** - * Creates a default TestResult object. + * Creates a default TestResult object * * @see TestResult */ @@ -188,6 +187,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. */ + @SuppressWarnings("deprecation") public static void assertTrue(String message, boolean condition) { Assert.assertTrue(message, condition); } @@ -196,6 +196,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError. */ + @SuppressWarnings("deprecation") public static void assertTrue(boolean condition) { Assert.assertTrue(condition); } @@ -204,6 +205,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError with the given message. */ + @SuppressWarnings("deprecation") public static void assertFalse(String message, boolean condition) { Assert.assertFalse(message, condition); } @@ -212,6 +214,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError. */ + @SuppressWarnings("deprecation") public static void assertFalse(boolean condition) { Assert.assertFalse(condition); } @@ -219,6 +222,7 @@ public abstract class TestCase extends Assert implements Test { /** * Fails a test with the given message. */ + @SuppressWarnings("deprecation") public static void fail(String message) { Assert.fail(message); } @@ -226,6 +230,7 @@ public abstract class TestCase extends Assert implements Test { /** * Fails a test with no message. */ + @SuppressWarnings("deprecation") public static void fail() { Assert.fail(); } @@ -234,6 +239,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, Object expected, Object actual) { Assert.assertEquals(message, expected, actual); } @@ -242,6 +248,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ + @SuppressWarnings("deprecation") public static void assertEquals(Object expected, Object actual) { Assert.assertEquals(expected, actual); } @@ -249,6 +256,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two Strings are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, String expected, String actual) { Assert.assertEquals(message, expected, actual); } @@ -256,6 +264,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two Strings are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(String expected, String actual) { Assert.assertEquals(expected, actual); } @@ -265,6 +274,7 @@ public abstract class TestCase extends Assert implements Test { * an AssertionFailedError is thrown with the given message. If the expected * value is infinity then the delta value is ignored. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, double expected, double actual, double delta) { Assert.assertEquals(message, expected, actual, delta); } @@ -273,6 +283,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ + @SuppressWarnings("deprecation") public static void assertEquals(double expected, double actual, double delta) { Assert.assertEquals(expected, actual, delta); } @@ -282,6 +293,7 @@ public abstract class TestCase extends Assert implements Test { * are not an AssertionFailedError is thrown with the given message. If the * expected value is infinity then the delta value is ignored. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, float expected, float actual, float delta) { Assert.assertEquals(message, expected, actual, delta); } @@ -290,6 +302,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ + @SuppressWarnings("deprecation") public static void assertEquals(float expected, float actual, float delta) { Assert.assertEquals(expected, actual, delta); } @@ -298,6 +311,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two longs are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, long expected, long actual) { Assert.assertEquals(message, expected, actual); } @@ -305,6 +319,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two longs are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(long expected, long actual) { Assert.assertEquals(expected, actual); } @@ -313,6 +328,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two booleans are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, boolean expected, boolean actual) { Assert.assertEquals(message, expected, actual); } @@ -320,6 +336,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two booleans are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(boolean expected, boolean actual) { Assert.assertEquals(expected, actual); } @@ -328,6 +345,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two bytes are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, byte expected, byte actual) { Assert.assertEquals(message, expected, actual); } @@ -335,6 +353,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two bytes are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(byte expected, byte actual) { Assert.assertEquals(expected, actual); } @@ -343,6 +362,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two chars are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, char expected, char actual) { Assert.assertEquals(message, expected, actual); } @@ -350,6 +370,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two chars are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(char expected, char actual) { Assert.assertEquals(expected, actual); } @@ -358,6 +379,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two shorts are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, short expected, short actual) { Assert.assertEquals(message, expected, actual); } @@ -365,6 +387,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two shorts are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(short expected, short actual) { Assert.assertEquals(expected, actual); } @@ -373,6 +396,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two ints are equal. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertEquals(String message, int expected, int actual) { Assert.assertEquals(message, expected, actual); } @@ -380,6 +404,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that two ints are equal. */ + @SuppressWarnings("deprecation") public static void assertEquals(int expected, int actual) { Assert.assertEquals(expected, actual); } @@ -387,6 +412,7 @@ public abstract class TestCase extends Assert implements Test { /** * Asserts that an object isn't null. */ + @SuppressWarnings("deprecation") public static void assertNotNull(Object object) { Assert.assertNotNull(object); } @@ -395,6 +421,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that an object isn't null. If it is * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertNotNull(String message, Object object) { Assert.assertNotNull(message, object); } @@ -406,6 +433,7 @@ public abstract class TestCase extends Assert implements Test { * * @param object Object to check or <code>null</code> */ + @SuppressWarnings("deprecation") public static void assertNull(Object object) { Assert.assertNull(object); } @@ -414,6 +442,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that an object is null. If it is not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertNull(String message, Object object) { Assert.assertNull(message, object); } @@ -422,6 +451,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown with the given message. */ + @SuppressWarnings("deprecation") public static void assertSame(String message, Object expected, Object actual) { Assert.assertSame(message, expected, actual); } @@ -430,6 +460,7 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ + @SuppressWarnings("deprecation") public static void assertSame(Object expected, Object actual) { Assert.assertSame(expected, actual); } @@ -439,6 +470,7 @@ public abstract class TestCase extends Assert implements Test { * refer to the same object an AssertionFailedError is thrown with the * given message. */ + @SuppressWarnings("deprecation") public static void assertNotSame(String message, Object expected, Object actual) { Assert.assertNotSame(message, expected, actual); } @@ -447,22 +479,27 @@ public abstract class TestCase extends Assert implements Test { * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ + @SuppressWarnings("deprecation") public static void assertNotSame(Object expected, Object actual) { Assert.assertNotSame(expected, actual); } + @SuppressWarnings("deprecation") public static void failSame(String message) { Assert.failSame(message); } + @SuppressWarnings("deprecation") public static void failNotSame(String message, Object expected, Object actual) { Assert.failNotSame(message, expected, actual); } + @SuppressWarnings("deprecation") public static void failNotEquals(String message, Object expected, Object actual) { Assert.failNotEquals(message, expected, actual); } + @SuppressWarnings("deprecation") public static String format(String message, Object expected, Object actual) { return Assert.format(message, expected, actual); } @@ -482,7 +519,7 @@ public abstract class TestCase extends Assert implements Test { } /** - * Returns a string representation of the test case. + * Returns a string representation of the test case */ @Override public String toString() { @@ -490,7 +527,7 @@ public abstract class TestCase extends Assert implements Test { } /** - * Gets the name of a TestCase. + * Gets the name of a TestCase * * @return the name of the TestCase */ @@ -499,7 +536,7 @@ public abstract class TestCase extends Assert implements Test { } /** - * Sets the name of a TestCase. + * Sets the name of a TestCase * * @param name the name to set */ diff --git a/src/main/java/junit/framework/TestFailure.java b/src/main/java/junit/framework/TestFailure.java index d1ddfbc..6168b58 100644 --- a/src/main/java/junit/framework/TestFailure.java +++ b/src/main/java/junit/framework/TestFailure.java @@ -1,6 +1,7 @@ package junit.framework; -import org.junit.internal.Throwables; +import java.io.PrintWriter; +import java.io.StringWriter; /** @@ -48,7 +49,10 @@ public class TestFailure { * thrown by TestFailure. */ public String trace() { - return Throwables.getStacktrace(thrownException()); + StringWriter stringWriter = new StringWriter(); + PrintWriter writer = new PrintWriter(stringWriter); + thrownException().printStackTrace(writer); + return stringWriter.toString(); } /** diff --git a/src/main/java/junit/framework/TestResult.java b/src/main/java/junit/framework/TestResult.java index e01a2b0..8332542 100644 --- a/src/main/java/junit/framework/TestResult.java +++ b/src/main/java/junit/framework/TestResult.java @@ -52,14 +52,14 @@ public class TestResult { } /** - * Registers a TestListener. + * Registers a TestListener */ public synchronized void addListener(TestListener listener) { fListeners.add(listener); } /** - * Unregisters a TestListener. + * Unregisters a TestListener */ public synchronized void removeListener(TestListener listener) { fListeners.remove(listener); @@ -91,7 +91,7 @@ public class TestResult { } /** - * Returns an Enumeration for the errors. + * Returns an Enumeration for the errors */ public synchronized Enumeration<TestFailure> errors() { return Collections.enumeration(fErrors); @@ -106,7 +106,7 @@ public class TestResult { } /** - * Returns an Enumeration for the failures. + * Returns an Enumeration for the failures */ public synchronized Enumeration<TestFailure> failures() { return Collections.enumeration(fFailures); @@ -150,7 +150,7 @@ public class TestResult { } /** - * Checks whether the test run should stop. + * Checks whether the test run should stop */ public synchronized boolean shouldStop() { return fStop; diff --git a/src/main/java/junit/framework/TestSuite.java b/src/main/java/junit/framework/TestSuite.java index 50cd5f8..366f1cf 100644 --- a/src/main/java/junit/framework/TestSuite.java +++ b/src/main/java/junit/framework/TestSuite.java @@ -1,5 +1,7 @@ package junit.framework; +import java.io.PrintWriter; +import java.io.StringWriter; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -10,7 +12,6 @@ import java.util.List; import java.util.Vector; import org.junit.internal.MethodSorter; -import org.junit.internal.Throwables; /** * A <code>TestSuite</code> is a <code>Composite</code> of Tests. @@ -34,7 +35,7 @@ import org.junit.internal.Throwables; * <p> * A final option is to do the same for a large array of test classes. * <pre> - * Class[] testClasses = { MathTest.class, AnotherTest.class }; + * Class[] testClasses = { MathTest.class, AnotherTest.class } * TestSuite suite= new TestSuite(testClasses); * </pre> * @@ -64,11 +65,11 @@ public class TestSuite implements Test { test = constructor.newInstance(new Object[]{name}); } } catch (InstantiationException e) { - return (warning("Cannot instantiate test case: " + name + " (" + Throwables.getStacktrace(e) + ")")); + return (warning("Cannot instantiate test case: " + name + " (" + exceptionToString(e) + ")")); } catch (InvocationTargetException e) { - return (warning("Exception in constructor: " + name + " (" + Throwables.getStacktrace(e.getTargetException()) + ")")); + return (warning("Exception in constructor: " + name + " (" + exceptionToString(e.getTargetException()) + ")")); } catch (IllegalAccessException e) { - return (warning("Cannot access test case: " + name + " (" + Throwables.getStacktrace(e) + ")")); + return (warning("Cannot access test case: " + name + " (" + exceptionToString(e) + ")")); } return (Test) test; } @@ -98,6 +99,16 @@ public class TestSuite implements Test { }; } + /** + * Converts the stack trace into a string + */ + private static String exceptionToString(Throwable e) { + StringWriter stringWriter = new StringWriter(); + PrintWriter writer = new PrintWriter(stringWriter); + e.printStackTrace(writer); + return stringWriter.toString(); + } + private String fName; private Vector<Test> fTests = new Vector<Test>(10); // Cannot convert this to List because it is used directly by some test runners @@ -199,7 +210,7 @@ public class TestSuite implements Test { } /** - * Adds the tests from the given class to the suite. + * Adds the tests from the given class to the suite */ public void addTestSuite(Class<? extends TestCase> testClass) { addTest(new TestSuite(testClass)); @@ -251,21 +262,21 @@ public class TestSuite implements Test { } /** - * Returns the test at the given index. + * Returns the test at the given index */ public Test testAt(int index) { return fTests.get(index); } /** - * Returns the number of tests in this suite. + * Returns the number of tests in this suite */ public int testCount() { return fTests.size(); } /** - * Returns the tests as an enumeration. + * Returns the tests as an enumeration */ public Enumeration<Test> tests() { return fTests.elements(); |