Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove junit source from libcore.

Will be replaced with library built from external/junit.

Bug 5826326

Change-Id: I78518a04b57bade113b1797a808ec1a39bd82ad7
  • Loading branch information...
commit 17cdf1ac454247016f338d84be763789e6416100 1 parent 99e7245
Brett Chabot authored

Showing 21 changed files with 0 additions and 1,523 deletions. Show diff stats Hide diff stats

  1. +0 1  Docs.mk
  2. +0 21 JavaLibrary.mk
  3. +0 1  junit/MODULE_LICENSE_CPL
  4. +0 70 junit/src/main/java/junit/extensions/ActiveTestSuite.java
  5. +0 46 junit/src/main/java/junit/extensions/ExceptionTestCase.java
  6. +0 38 junit/src/main/java/junit/extensions/RepeatedTest.java
  7. +0 43 junit/src/main/java/junit/extensions/TestDecorator.java
  8. +0 42 junit/src/main/java/junit/extensions/TestSetup.java
  9. +0 6 junit/src/main/java/junit/extensions/package.html
  10. +0 296 junit/src/main/java/junit/framework/Assert.java
  11. +0 20 junit/src/main/java/junit/framework/AssertionFailedError.java
  12. +0 76 junit/src/main/java/junit/framework/ComparisonCompactor.java
  13. +0 52 junit/src/main/java/junit/framework/ComparisonFailure.java
  14. +0 14 junit/src/main/java/junit/framework/Protectable.java
  15. +0 17 junit/src/main/java/junit/framework/Test.java
  16. +0 212 junit/src/main/java/junit/framework/TestCase.java
  17. +0 58 junit/src/main/java/junit/framework/TestFailure.java
  18. +0 23 junit/src/main/java/junit/framework/TestListener.java
  19. +0 175 junit/src/main/java/junit/framework/TestResult.java
  20. +0 307 junit/src/main/java/junit/framework/TestSuite.java
  21. +0 5 junit/src/main/java/junit/framework/package.html
1  Docs.mk
@@ -21,7 +21,6 @@ define libcore_to_document
21 21 dalvik/src/main/java/dalvik/annotation \
22 22 dalvik/src/main/java/dalvik/bytecode \
23 23 json/src/main/java \
24   - junit/src/main/java \
25 24 luni/src/main/java/java \
26 25 luni/src/main/java/javax \
27 26 luni/src/main/java/org/xml/sax \
21 JavaLibrary.mk
@@ -88,16 +88,6 @@ include $(BUILD_JAVA_LIBRARY)
88 88 core-intermediates := ${intermediates}
89 89
90 90
91   -# Make core-junit
92   -include $(CLEAR_VARS)
93   -LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
94   -LOCAL_NO_STANDARD_LIBRARIES := true
95   -LOCAL_JAVA_LIBRARIES := core
96   -LOCAL_JAVACFLAGS := $(local_javac_flags)
97   -LOCAL_MODULE_TAGS := optional
98   -LOCAL_MODULE := core-junit
99   -include $(BUILD_JAVA_LIBRARY)
100   -
101 91 # Make the core-tests library.
102 92 include $(CLEAR_VARS)
103 93 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
@@ -153,17 +143,6 @@ ifeq ($(WITH_HOST_DALVIK),true)
153 143
154 144 include $(BUILD_HOST_JAVA_LIBRARY)
155 145
156   - # Make core-junit
157   - include $(CLEAR_VARS)
158   - LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
159   - LOCAL_NO_STANDARD_LIBRARIES := true
160   - LOCAL_JAVA_LIBRARIES := core-hostdex
161   - LOCAL_JAVACFLAGS := $(local_javac_flags)
162   - LOCAL_MODULE_TAGS := optional
163   - LOCAL_MODULE := core-junit-hostdex
164   - LOCAL_BUILD_HOST_DEX := true
165   - include $(BUILD_HOST_JAVA_LIBRARY)
166   -
167 146 # Make the core-tests library.
168 147 include $(CLEAR_VARS)
169 148 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
1  junit/MODULE_LICENSE_CPL
... ... @@ -1 +0,0 @@
1   -http://www.opensource.org/licenses/cpl1.0.php
70 junit/src/main/java/junit/extensions/ActiveTestSuite.java
... ... @@ -1,70 +0,0 @@
1   -package junit.extensions;
2   -
3   -import junit.framework.Test;
4   -import junit.framework.TestCase;
5   -import junit.framework.TestResult;
6   -import junit.framework.TestSuite;
7   -
8   -/**
9   - * A TestSuite for active Tests. It runs each
10   - * test in a separate thread and waits until all
11   - * threads have terminated.
12   - * -- Aarhus Radisson Scandinavian Center 11th floor
13   - */
14   -public class ActiveTestSuite extends TestSuite {
15   - private volatile int fActiveTestDeathCount;
16   -
17   - public ActiveTestSuite() {
18   - }
19   -
20   - public ActiveTestSuite(Class<? extends TestCase> theClass) {
21   - super(theClass);
22   - }
23   -
24   - public ActiveTestSuite(String name) {
25   - super (name);
26   - }
27   -
28   - public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {
29   - super(theClass, name);
30   - }
31   -
32   - @Override
33   - public void run(TestResult result) {
34   - fActiveTestDeathCount= 0;
35   - super.run(result);
36   - waitUntilFinished();
37   - }
38   -
39   - @Override
40   - public void runTest(final Test test, final TestResult result) {
41   - Thread t= new Thread() {
42   - @Override
43   - public void run() {
44   - try {
45   - // inlined due to limitation in VA/Java
46   - //ActiveTestSuite.super.runTest(test, result);
47   - test.run(result);
48   - } finally {
49   - ActiveTestSuite.this.runFinished();
50   - }
51   - }
52   - };
53   - t.start();
54   - }
55   -
56   - synchronized void waitUntilFinished() {
57   - while (fActiveTestDeathCount < testCount()) {
58   - try {
59   - wait();
60   - } catch (InterruptedException e) {
61   - return; // ignore
62   - }
63   - }
64   - }
65   -
66   - synchronized public void runFinished() {
67   - fActiveTestDeathCount++;
68   - notifyAll();
69   - }
70   -}
46 junit/src/main/java/junit/extensions/ExceptionTestCase.java
... ... @@ -1,46 +0,0 @@
1   -package junit.extensions;
2   -
3   -import junit.framework.*;
4   -
5   -/**
6   - * A TestCase that expects an Exception of class fExpected to be thrown.
7   - * The other way to check that an expected exception is thrown is:
8   - * <pre>
9   - * try {
10   - * shouldThrow();
11   - * }
12   - * catch (SpecialException e) {
13   - * return;
14   - * }
15   - * fail("Expected SpecialException");
16   - * </pre>
17   - *
18   - * To use ExceptionTestCase, create a TestCase like:
19   - * <pre>
20   - * new ExceptionTestCase("testShouldThrow", SpecialException.class);
21   - * </pre>
22   - */
23   -public class ExceptionTestCase extends TestCase {
24   - Class fExpected;
25   -
26   - public ExceptionTestCase(String name, Class exception) {
27   - super(name);
28   - fExpected= exception;
29   - }
30   - /**
31   - * Execute the test method expecting that an Exception of
32   - * class fExpected or one of its subclasses will be thrown
33   - */
34   - protected void runTest() throws Throwable {
35   - try {
36   - super.runTest();
37   - }
38   - catch (Exception e) {
39   - if (fExpected.isAssignableFrom(e.getClass()))
40   - return;
41   - else
42   - throw e;
43   - }
44   - fail("Expected exception " + fExpected);
45   - }
46   -}
38 junit/src/main/java/junit/extensions/RepeatedTest.java
... ... @@ -1,38 +0,0 @@
1   -package junit.extensions;
2   -
3   -import junit.framework.Test;
4   -import junit.framework.TestResult;
5   -
6   -/**
7   - * A Decorator that runs a test repeatedly.
8   - *
9   - */
10   -public class RepeatedTest extends TestDecorator {
11   - private int fTimesRepeat;
12   -
13   - public RepeatedTest(Test test, int repeat) {
14   - super(test);
15   - if (repeat < 0)
16   - throw new IllegalArgumentException("Repetition count must be >= 0");
17   - fTimesRepeat= repeat;
18   - }
19   -
20   - @Override
21   - public int countTestCases() {
22   - return super.countTestCases() * fTimesRepeat;
23   - }
24   -
25   - @Override
26   - public void run(TestResult result) {
27   - for (int i= 0; i < fTimesRepeat; i++) {
28   - if (result.shouldStop())
29   - break;
30   - super.run(result);
31   - }
32   - }
33   -
34   - @Override
35   - public String toString() {
36   - return super.toString() + "(repeated)";
37   - }
38   -}
43 junit/src/main/java/junit/extensions/TestDecorator.java
... ... @@ -1,43 +0,0 @@
1   -package junit.extensions;
2   -
3   -import junit.framework.Assert;
4   -import junit.framework.Test;
5   -import junit.framework.TestResult;
6   -
7   -/**
8   - * A Decorator for Tests. Use TestDecorator as the base class for defining new
9   - * test decorators. Test decorator subclasses can be introduced to add behaviour
10   - * before or after a test is run.
11   - *
12   - */
13   -public class TestDecorator extends Assert implements Test {
14   - protected Test fTest;
15   -
16   - public TestDecorator(Test test) {
17   - fTest= test;
18   - }
19   -
20   - /**
21   - * The basic run behaviour.
22   - */
23   - public void basicRun(TestResult result) {
24   - fTest.run(result);
25   - }
26   -
27   - public int countTestCases() {
28   - return fTest.countTestCases();
29   - }
30   -
31   - public void run(TestResult result) {
32   - basicRun(result);
33   - }
34   -
35   - @Override
36   - public String toString() {
37   - return fTest.toString();
38   - }
39   -
40   - public Test getTest() {
41   - return fTest;
42   - }
43   -}
42 junit/src/main/java/junit/extensions/TestSetup.java
... ... @@ -1,42 +0,0 @@
1   -package junit.extensions;
2   -
3   -import junit.framework.Protectable;
4   -import junit.framework.Test;
5   -import junit.framework.TestResult;
6   -
7   -/**
8   - * A Decorator to set up and tear down additional fixture state. Subclass
9   - * TestSetup and insert it into your tests when you want to set up additional
10   - * state once before the tests are run.
11   - */
12   -public class TestSetup extends TestDecorator {
13   -
14   - public TestSetup(Test test) {
15   - super(test);
16   - }
17   -
18   - @Override
19   - public void run(final TestResult result) {
20   - Protectable p= new Protectable() {
21   - public void protect() throws Exception {
22   - setUp();
23   - basicRun(result);
24   - tearDown();
25   - }
26   - };
27   - result.runProtected(this, p);
28   - }
29   -
30   - /**
31   - * Sets up the fixture. Override to set up additional fixture state.
32   - */
33   - protected void setUp() throws Exception {
34   - }
35   -
36   - /**
37   - * Tears down the fixture. Override to tear down the additional fixture
38   - * state.
39   - */
40   - protected void tearDown() throws Exception {
41   - }
42   -}
6 junit/src/main/java/junit/extensions/package.html
... ... @@ -1,6 +0,0 @@
1   -<HTML>
2   -<BODY>
3   -Utility classes supporting the junit test framework.
4   -{@hide} - Not needed for 1.0 SDK
5   -</BODY>
6   -</HTML>
296 junit/src/main/java/junit/framework/Assert.java
... ... @@ -1,296 +0,0 @@
1   -package junit.framework;
2   -
3   -/**
4   - * A set of assert methods. Messages are only displayed when an assert fails.
5   - */
6   -
7   -public class Assert {
8   - /**
9   - * Protect constructor since it is a static only class
10   - */
11   - protected Assert() {
12   - }
13   -
14   - /**
15   - * Asserts that a condition is true. If it isn't it throws
16   - * an AssertionFailedError with the given message.
17   - */
18   - static public void assertTrue(String message, boolean condition) {
19   - if (!condition)
20   - fail(message);
21   - }
22   - /**
23   - * Asserts that a condition is true. If it isn't it throws
24   - * an AssertionFailedError.
25   - */
26   - static public void assertTrue(boolean condition) {
27   - assertTrue(null, condition);
28   - }
29   - /**
30   - * Asserts that a condition is false. If it isn't it throws
31   - * an AssertionFailedError with the given message.
32   - */
33   - static public void assertFalse(String message, boolean condition) {
34   - assertTrue(message, !condition);
35   - }
36   - /**
37   - * Asserts that a condition is false. If it isn't it throws
38   - * an AssertionFailedError.
39   - */
40   - static public void assertFalse(boolean condition) {
41   - assertFalse(null, condition);
42   - }
43   - /**
44   - * Fails a test with the given message.
45   - */
46   - static public void fail(String message) {
47   - if (message == null) {
48   - throw new AssertionFailedError();
49   - }
50   - throw new AssertionFailedError(message);
51   - }
52   - /**
53   - * Fails a test with no message.
54   - */
55   - static public void fail() {
56   - fail(null);
57   - }
58   - /**
59   - * Asserts that two objects are equal. If they are not
60   - * an AssertionFailedError is thrown with the given message.
61   - */
62   - static public void assertEquals(String message, Object expected, Object actual) {
63   - if (expected == null && actual == null)
64   - return;
65   - if (expected != null && expected.equals(actual))
66   - return;
67   - failNotEquals(message, expected, actual);
68   - }
69   - /**
70   - * Asserts that two objects are equal. If they are not
71   - * an AssertionFailedError is thrown.
72   - */
73   - static public void assertEquals(Object expected, Object actual) {
74   - assertEquals(null, expected, actual);
75   - }
76   - /**
77   - * Asserts that two Strings are equal.
78   - */
79   - static public void assertEquals(String message, String expected, String actual) {
80   - if (expected == null && actual == null)
81   - return;
82   - if (expected != null && expected.equals(actual))
83   - return;
84   - String cleanMessage= message == null ? "" : message;
85   - throw new ComparisonFailure(cleanMessage, expected, actual);
86   - }
87   - /**
88   - * Asserts that two Strings are equal.
89   - */
90   - static public void assertEquals(String expected, String actual) {
91   - assertEquals(null, expected, actual);
92   - }
93   - /**
94   - * Asserts that two doubles are equal concerning a delta. If they are not
95   - * an AssertionFailedError is thrown with the given message. If the expected
96   - * value is infinity then the delta value is ignored.
97   - */
98   - static public void assertEquals(String message, double expected, double actual, double delta) {
99   - if (Double.compare(expected, actual) == 0)
100   - return;
101   - if (!(Math.abs(expected-actual) <= delta))
102   - failNotEquals(message, new Double(expected), new Double(actual));
103   - }
104   - /**
105   - * Asserts that two doubles are equal concerning a delta. If the expected
106   - * value is infinity then the delta value is ignored.
107   - */
108   - static public void assertEquals(double expected, double actual, double delta) {
109   - assertEquals(null, expected, actual, delta);
110   - }
111   - /**
112   - * Asserts that two floats are equal concerning a positive delta. If they
113   - * are not an AssertionFailedError is thrown with the given message. If the
114   - * expected value is infinity then the delta value is ignored.
115   - */
116   - static public void assertEquals(String message, float expected, float actual, float delta) {
117   - if (Float.compare(expected, actual) == 0)
118   - return;
119   - if (!(Math.abs(expected - actual) <= delta))
120   - failNotEquals(message, new Float(expected), new Float(actual));
121   - }
122   - /**
123   - * Asserts that two floats are equal concerning a delta. If the expected
124   - * value is infinity then the delta value is ignored.
125   - */
126   - static public void assertEquals(float expected, float actual, float delta) {
127   - assertEquals(null, expected, actual, delta);
128   - }
129   - /**
130   - * Asserts that two longs are equal. If they are not
131   - * an AssertionFailedError is thrown with the given message.
132   - */
133   - static public void assertEquals(String message, long expected, long actual) {
134   - assertEquals(message, new Long(expected), new Long(actual));
135   - }
136   - /**
137   - * Asserts that two longs are equal.
138   - */
139   - static public void assertEquals(long expected, long actual) {
140   - assertEquals(null, expected, actual);
141   - }
142   - /**
143   - * Asserts that two booleans are equal. If they are not
144   - * an AssertionFailedError is thrown with the given message.
145   - */
146   - static public void assertEquals(String message, boolean expected, boolean actual) {
147   - assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual));
148   - }
149   - /**
150   - * Asserts that two booleans are equal.
151   - */
152   - static public void assertEquals(boolean expected, boolean actual) {
153   - assertEquals(null, expected, actual);
154   - }
155   - /**
156   - * Asserts that two bytes are equal. If they are not
157   - * an AssertionFailedError is thrown with the given message.
158   - */
159   - static public void assertEquals(String message, byte expected, byte actual) {
160   - assertEquals(message, new Byte(expected), new Byte(actual));
161   - }
162   - /**
163   - * Asserts that two bytes are equal.
164   - */
165   - static public void assertEquals(byte expected, byte actual) {
166   - assertEquals(null, expected, actual);
167   - }
168   - /**
169   - * Asserts that two chars are equal. If they are not
170   - * an AssertionFailedError is thrown with the given message.
171   - */
172   - static public void assertEquals(String message, char expected, char actual) {
173   - assertEquals(message, new Character(expected), new Character(actual));
174   - }
175   - /**
176   - * Asserts that two chars are equal.
177   - */
178   - static public void assertEquals(char expected, char actual) {
179   - assertEquals(null, expected, actual);
180   - }
181   - /**
182   - * Asserts that two shorts are equal. If they are not
183   - * an AssertionFailedError is thrown with the given message.
184   - */
185   - static public void assertEquals(String message, short expected, short actual) {
186   - assertEquals(message, new Short(expected), new Short(actual));
187   - }
188   - /**
189   - * Asserts that two shorts are equal.
190   - */
191   - static public void assertEquals(short expected, short actual) {
192   - assertEquals(null, expected, actual);
193   - }
194   - /**
195   - * Asserts that two ints are equal. If they are not
196   - * an AssertionFailedError is thrown with the given message.
197   - */
198   - static public void assertEquals(String message, int expected, int actual) {
199   - assertEquals(message, new Integer(expected), new Integer(actual));
200   - }
201   - /**
202   - * Asserts that two ints are equal.
203   - */
204   - static public void assertEquals(int expected, int actual) {
205   - assertEquals(null, expected, actual);
206   - }
207   - /**
208   - * Asserts that an object isn't null.
209   - */
210   - static public void assertNotNull(Object object) {
211   - assertNotNull(null, object);
212   - }
213   - /**
214   - * Asserts that an object isn't null. If it is
215   - * an AssertionFailedError is thrown with the given message.
216   - */
217   - static public void assertNotNull(String message, Object object) {
218   - assertTrue(message, object != null);
219   - }
220   - /**
221   - * Asserts that an object is null. If it isn't an {@link AssertionError} is
222   - * thrown.
223   - * Message contains: Expected: <null> but was: object
224   - *
225   - * @param object
226   - * Object to check or <code>null</code>
227   - */
228   - static public void assertNull(Object object) {
229   - String message = "Expected: <null> but was: " + String.valueOf(object);
230   - assertNull(message, object);
231   - }
232   - /**
233   - * Asserts that an object is null. If it is not
234   - * an AssertionFailedError is thrown with the given message.
235   - */
236   - static public void assertNull(String message, Object object) {
237   - assertTrue(message, object == null);
238   - }
239   - /**
240   - * Asserts that two objects refer to the same object. If they are not
241   - * an AssertionFailedError is thrown with the given message.
242   - */
243   - static public void assertSame(String message, Object expected, Object actual) {
244   - if (expected == actual)
245   - return;
246   - failNotSame(message, expected, actual);
247   - }
248   - /**
249   - * Asserts that two objects refer to the same object. If they are not
250   - * the same an AssertionFailedError is thrown.
251   - */
252   - static public void assertSame(Object expected, Object actual) {
253   - assertSame(null, expected, actual);
254   - }
255   - /**
256   - * Asserts that two objects do not refer to the same object. If they do
257   - * refer to the same object an AssertionFailedError is thrown with the
258   - * given message.
259   - */
260   - static public void assertNotSame(String message, Object expected, Object actual) {
261   - if (expected == actual)
262   - failSame(message);
263   - }
264   - /**
265   - * Asserts that two objects do not refer to the same object. If they do
266   - * refer to the same object an AssertionFailedError is thrown.
267   - */
268   - static public void assertNotSame(Object expected, Object actual) {
269   - assertNotSame(null, expected, actual);
270   - }
271   -
272   - static public void failSame(String message) {
273   - String formatted= "";
274   - if (message != null)
275   - formatted= message+" ";
276   - fail(formatted+"expected not same");
277   - }
278   -
279   - static public void failNotSame(String message, Object expected, Object actual) {
280   - String formatted= "";
281   - if (message != null)
282   - formatted= message+" ";
283   - fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
284   - }
285   -
286   - static public void failNotEquals(String message, Object expected, Object actual) {
287   - fail(format(message, expected, actual));
288   - }
289   -
290   - public static String format(String message, Object expected, Object actual) {
291   - String formatted= "";
292   - if (message != null && message.length() > 0)
293   - formatted= message+" ";
294   - return formatted+"expected:<"+expected+"> but was:<"+actual+">";
295   - }
296   -}
20 junit/src/main/java/junit/framework/AssertionFailedError.java
... ... @@ -1,20 +0,0 @@
1   -package junit.framework;
2   -
3   -/**
4   - * Thrown when an assertion failed.
5   - */
6   -public class AssertionFailedError extends AssertionError {
7   -
8   - private static final long serialVersionUID= 1L;
9   -
10   - public AssertionFailedError() {
11   - }
12   -
13   - public AssertionFailedError(String message) {
14   - super(defaultString(message));
15   - }
16   -
17   - private static String defaultString(String message) {
18   - return message == null ? "" : message;
19   - }
20   -}
76 junit/src/main/java/junit/framework/ComparisonCompactor.java
... ... @@ -1,76 +0,0 @@
1   -package junit.framework;
2   -
3   -// android-changed add @hide
4   -/**
5   - * @hide not needed for public API
6   - */
7   -public class ComparisonCompactor {
8   -
9   - private static final String ELLIPSIS= "...";
10   - private static final String DELTA_END= "]";
11   - private static final String DELTA_START= "[";
12   -
13   - private int fContextLength;
14   - private String fExpected;
15   - private String fActual;
16   - private int fPrefix;
17   - private int fSuffix;
18   -
19   - public ComparisonCompactor(int contextLength, String expected, String actual) {
20   - fContextLength= contextLength;
21   - fExpected= expected;
22   - fActual= actual;
23   - }
24   -
25   - public String compact(String message) {
26   - if (fExpected == null || fActual == null || areStringsEqual())
27   - return Assert.format(message, fExpected, fActual);
28   -
29   - findCommonPrefix();
30   - findCommonSuffix();
31   - String expected= compactString(fExpected);
32   - String actual= compactString(fActual);
33   - return Assert.format(message, expected, actual);
34   - }
35   -
36   - private String compactString(String source) {
37   - String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;
38   - if (fPrefix > 0)
39   - result= computeCommonPrefix() + result;
40   - if (fSuffix > 0)
41   - result= result + computeCommonSuffix();
42   - return result;
43   - }
44   -
45   - private void findCommonPrefix() {
46   - fPrefix= 0;
47   - int end= Math.min(fExpected.length(), fActual.length());
48   - for (; fPrefix < end; fPrefix++) {
49   - if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix))
50   - break;
51   - }
52   - }
53   -
54   - private void findCommonSuffix() {
55   - int expectedSuffix= fExpected.length() - 1;
56   - int actualSuffix= fActual.length() - 1;
57   - for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) {
58   - if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix))
59   - break;
60   - }
61   - fSuffix= fExpected.length() - expectedSuffix;
62   - }
63   -
64   - private String computeCommonPrefix() {
65   - return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);
66   - }
67   -
68   - private String computeCommonSuffix() {
69   - int end= Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());
70   - return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : "");
71   - }
72   -
73   - private boolean areStringsEqual() {
74   - return fExpected.equals(fActual);
75   - }
76   -}
52 junit/src/main/java/junit/framework/ComparisonFailure.java
... ... @@ -1,52 +0,0 @@
1   -package junit.framework;
2   -
3   -/**
4   - * Thrown when an assert equals for Strings failed.
5   - *
6   - * Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com
7   - */
8   -public class ComparisonFailure extends AssertionFailedError {
9   - private static final int MAX_CONTEXT_LENGTH= 20;
10   - private static final long serialVersionUID= 1L;
11   -
12   - private String fExpected;
13   - private String fActual;
14   -
15   - /**
16   - * Constructs a comparison failure.
17   - * @param message the identifying message or null
18   - * @param expected the expected string value
19   - * @param actual the actual string value
20   - */
21   - public ComparisonFailure (String message, String expected, String actual) {
22   - super (message);
23   - fExpected= expected;
24   - fActual= actual;
25   - }
26   -
27   - /**
28   - * Returns "..." in place of common prefix and "..." in
29   - * place of common suffix between expected and actual.
30   - *
31   - * @see Throwable#getMessage()
32   - */
33   - @Override
34   - public String getMessage() {
35   - return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
36   - }
37   -
38   - /**
39   - * Gets the actual string value
40   - * @return the actual string value
41   - */
42   - public String getActual() {
43   - return fActual;
44   - }
45   - /**
46   - * Gets the expected string value
47   - * @return the expected string value
48   - */
49   - public String getExpected() {
50   - return fExpected;
51   - }
52   -}
14 junit/src/main/java/junit/framework/Protectable.java
... ... @@ -1,14 +0,0 @@
1   -package junit.framework;
2   -
3   -/**
4   - * A <em>Protectable</em> can be run and can throw a Throwable.
5   - *
6   - * @see TestResult
7   - */
8   -public interface Protectable {
9   -
10   - /**
11   - * Run the the following method protected.
12   - */
13   - public abstract void protect() throws Throwable;
14   -}
17 junit/src/main/java/junit/framework/Test.java
... ... @@ -1,17 +0,0 @@
1   -package junit.framework;
2   -
3   -/**
4   - * A <em>Test</em> can be run and collect its results.
5   - *
6   - * @see TestResult
7   - */
8   -public interface Test {
9   - /**
10   - * Counts the number of test cases that will be run by this test.
11   - */
12   - public abstract int countTestCases();
13   - /**
14   - * Runs a test and collects its result in a TestResult instance.
15   - */
16   - public abstract void run(TestResult result);
17   -}
212 junit/src/main/java/junit/framework/TestCase.java
... ... @@ -1,212 +0,0 @@
1   -package junit.framework;
2   -
3   -import java.lang.reflect.InvocationTargetException;
4   -import java.lang.reflect.Method;
5   -import java.lang.reflect.Modifier;
6   -
7   -/**
8   - * A test case defines the fixture to run multiple tests. To define a test case<br/>
9   - * <ol>
10   - * <li>implement a subclass of <code>TestCase</code></li>
11   - * <li>define instance variables that store the state of the fixture</li>
12   - * <li>initialize the fixture state by overriding {@link #setUp()}</li>
13   - * <li>clean-up after a test by overriding {@link #tearDown()}.</li>
14   - * </ol>
15   - * Each test runs in its own fixture so there
16   - * can be no side effects among test runs.
17   - * Here is an example:
18   - * <pre>
19   - * public class MathTest extends TestCase {
20   - * protected double fValue1;
21   - * protected double fValue2;
22   - *
23   - * protected void setUp() {
24   - * fValue1= 2.0;
25   - * fValue2= 3.0;
26   - * }
27   - * }
28   - * </pre>
29   - *
30   - * For each test implement a method which interacts
31   - * with the fixture. Verify the expected results with assertions specified
32   - * by calling {@link junit.framework.Assert#assertTrue(String, boolean)} with a boolean.
33   - * <pre>
34   - * public void testAdd() {
35   - * double result= fValue1 + fValue2;
36   - * assertTrue(result == 5.0);
37   - * }
38   - * </pre>
39   - *
40   - * Once the methods are defined you can run them. The framework supports
41   - * both a static type safe and more dynamic way to run a test.
42   - * In the static way you override the runTest method and define the method to
43   - * be invoked. A convenient way to do so is with an anonymous inner class.
44   - * <pre>
45   - * TestCase test= new MathTest("add") {
46   - * public void runTest() {
47   - * testAdd();
48   - * }
49   - * };
50   - * test.run();
51   - * </pre>
52   - *
53   - * The dynamic way uses reflection to implement {@link #runTest()}. It dynamically finds
54   - * and invokes a method.
55   - * In this case the name of the test case has to correspond to the test method
56   - * to be run.
57   - * <pre>
58   - * TestCase test= new MathTest("testAdd");
59   - * test.run();
60   - * </pre>
61   - *
62   - * The tests to be run can be collected into a TestSuite. JUnit provides
63   - * different <i>test runners</i> which can run a test suite and collect the results.
64   - * A test runner either expects a static method <code>suite</code> as the entry
65   - * point to get a test to run or it will extract the suite automatically.
66   - * <pre>
67   - * public static Test suite() {
68   - * suite.addTest(new MathTest("testAdd"));
69   - * suite.addTest(new MathTest("testDivideByZero"));
70   - * return suite;
71   - * }
72   - * </pre>
73   - * @see TestResult
74   - * @see TestSuite
75   - */
76   -public abstract class TestCase extends Assert implements Test {
77   - /**
78   - * the name of the test case
79   - */
80   - private String fName;
81   -
82   - /**
83   - * No-arg constructor to enable serialization. This method
84   - * is not intended to be used by mere mortals without calling setName().
85   - */
86   - public TestCase() {
87   - fName= null;
88   - }
89   - /**
90   - * Constructs a test case with the given name.
91   - */
92   - public TestCase(String name) {
93   - fName= name;
94   - }
95   - /**
96   - * Counts the number of test cases executed by run(TestResult result).
97   - */
98   - public int countTestCases() {
99   - return 1;
100   - }
101   - /**
102   - * Creates a default TestResult object
103   - *
104   - * @see TestResult
105   - */
106   - protected TestResult createResult() {
107   - return new TestResult();
108   - }
109   - /**
110   - * A convenience method to run this test, collecting the results with a
111   - * default TestResult object.
112   - *
113   - * @see TestResult
114   - */
115   - public TestResult run() {
116   - TestResult result= createResult();
117   - run(result);
118   - return result;
119   - }
120   - /**
121   - * Runs the test case and collects the results in TestResult.
122   - */
123   - public void run(TestResult result) {
124   - result.run(this);
125   - }
126   - /**
127   - * Runs the bare test sequence.
128   - * @throws Throwable if any exception is thrown
129   - */
130   - public void runBare() throws Throwable {
131   - Throwable exception= null;
132   - setUp();
133   - try {
134   - runTest();
135   - } catch (Throwable running) {
136   - exception= running;
137   - }
138   - finally {
139   - try {
140   - tearDown();
141   - } catch (Throwable tearingDown) {
142   - if (exception == null) exception= tearingDown;
143   - }
144   - }
145   - if (exception != null) throw exception;
146   - }
147   - /**
148   - * Override to run the test and assert its state.
149   - * @throws Throwable if any exception is thrown
150   - */
151   - protected void runTest() throws Throwable {
152   - assertNotNull("TestCase.fName cannot be null", fName); // Some VMs crash when calling getMethod(null,null);
153   - Method runMethod= null;
154   - try {
155   - // use getMethod to get all public inherited
156   - // methods. getDeclaredMethods returns all
157   - // methods of this class but excludes the
158   - // inherited ones.
159   - runMethod= getClass().getMethod(fName, (Class[])null);
160   - } catch (NoSuchMethodException e) {
161   - fail("Method \""+fName+"\" not found");
162   - }
163   - if (!Modifier.isPublic(runMethod.getModifiers())) {
164   - fail("Method \""+fName+"\" should be public");
165   - }
166   -
167   - try {
168   - runMethod.invoke(this);
169   - }
170   - catch (InvocationTargetException e) {
171   - e.fillInStackTrace();
172   - throw e.getTargetException();
173   - }
174   - catch (IllegalAccessException e) {
175   - e.fillInStackTrace();
176   - throw e;
177   - }
178   - }
179   - /**
180   - * Sets up the fixture, for example, open a network connection.
181   - * This method is called before a test is executed.
182   - */
183   - protected void setUp() throws Exception {
184   - }
185   - /**
186   - * Tears down the fixture, for example, close a network connection.
187   - * This method is called after a test is executed.
188   - */
189   - protected void tearDown() throws Exception {
190   - }
191   - /**
192   - * Returns a string representation of the test case
193   - */
194   - @Override
195   - public String toString() {
196   - return getName() + "(" + getClass().getName() + ")";
197   - }
198   - /**
199   - * Gets the name of a TestCase
200   - * @return the name of the TestCase
201   - */
202   - public String getName() {
203   - return fName;
204   - }
205   - /**
206   - * Sets the name of a TestCase
207   - * @param name the name to set
208   - */
209   - public void setName(String name) {
210   - fName= name;
211   - }
212   -}
58 junit/src/main/java/junit/framework/TestFailure.java
... ... @@ -1,58 +0,0 @@
1   -package junit.framework;
2   -
3   -import java.io.PrintWriter;
4   -import java.io.StringWriter;
5   -
6   -
7   -/**
8   - * A <code>TestFailure</code> collects a failed test together with
9   - * the caught exception.
10   - * @see TestResult
11   - */
12   -public class TestFailure extends Object {
13   - protected Test fFailedTest;
14   - protected Throwable fThrownException;
15   -
16   -
17   - /**
18   - * Constructs a TestFailure with the given test and exception.
19   - */
20   - public TestFailure(Test failedTest, Throwable thrownException) {
21   - fFailedTest= failedTest;
22   - fThrownException= thrownException;
23   - }
24   - /**
25   - * Gets the failed test.
26   - */
27   - public Test failedTest() {
28   - return fFailedTest;
29   - }
30   - /**
31   - * Gets the thrown exception.
32   - */
33   - public Throwable thrownException() {
34   - return fThrownException;
35   - }
36   - /**
37   - * Returns a short description of the failure.
38   - */
39   - @Override
40   - public String toString() {
41   - StringBuffer buffer= new StringBuffer();
42   - buffer.append(fFailedTest+": "+fThrownException.getMessage());
43   - return buffer.toString();
44   - }
45   - public String trace() {
46   - StringWriter stringWriter= new StringWriter();
47   - PrintWriter writer= new PrintWriter(stringWriter);
48   - thrownException().printStackTrace(writer);
49   - StringBuffer buffer= stringWriter.getBuffer();
50   - return buffer.toString();
51   - }
52   - public String exceptionMessage() {
53   - return thrownException().getMessage();
54   - }
55   - public boolean isFailure() {
56   - return thrownException() instanceof AssertionFailedError;
57   - }
58   -}
23 junit/src/main/java/junit/framework/TestListener.java
... ... @@ -1,23 +0,0 @@
1   -package junit.framework;
2   -
3   -/**
4   - * A Listener for test progress
5   - */
6   -public interface TestListener {
7   - /**