Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #426 Applied new coding style

Applied the new coding style to the code base for issue #426.
  • Loading branch information...
commit 30f2b16525dabb477373be9ed3e76bb98b200806 1 parent 68cc61e
Arjan Wulder authored
Showing with 15,515 additions and 14,870 deletions.
  1. +54 −54 src/main/java/junit/extensions/ActiveTestSuite.java
  2. +25 −24 src/main/java/junit/extensions/RepeatedTest.java
  3. +29 −30 src/main/java/junit/extensions/TestDecorator.java
  4. +25 −25 src/main/java/junit/extensions/TestSetup.java
  5. +329 −284 src/main/java/junit/framework/Assert.java
  6. +9 −9 src/main/java/junit/framework/AssertionFailedError.java
  7. +63 −58 src/main/java/junit/framework/ComparisonCompactor.java
  8. +47 −43 src/main/java/junit/framework/ComparisonFailure.java
  9. +69 −68 src/main/java/junit/framework/JUnit4TestAdapter.java
  10. +56 −60 src/main/java/junit/framework/JUnit4TestAdapterCache.java
  11. +18 −21 src/main/java/junit/framework/JUnit4TestCaseFacade.java
  12. +4 −4 src/main/java/junit/framework/Protectable.java
  13. +9 −8 src/main/java/junit/framework/Test.java
  14. +469 −469 src/main/java/junit/framework/TestCase.java
  15. +52 −45 src/main/java/junit/framework/TestFailure.java
  16. +19 −16 src/main/java/junit/framework/TestListener.java
  17. +167 −151 src/main/java/junit/framework/TestResult.java
  18. +275 −261 src/main/java/junit/framework/TestSuite.java
  19. +293 −284 src/main/java/junit/runner/BaseTestRunner.java
  20. +16 −10 src/main/java/junit/runner/TestRunListener.java
  21. +10 −10 src/main/java/junit/runner/Version.java
  22. +121 −123 src/main/java/junit/textui/ResultPrinter.java
  23. +180 −177 src/main/java/junit/textui/TestRunner.java
  24. +3 −3 src/main/java/org/junit/After.java
  25. +3 −3 src/main/java/org/junit/AfterClass.java
  26. +834 −931 src/main/java/org/junit/Assert.java
  27. +116 −115 src/main/java/org/junit/Assume.java
  28. +3 −3 src/main/java/org/junit/Before.java
  29. +3 −2 src/main/java/org/junit/BeforeClass.java
  30. +36 −35 src/main/java/org/junit/ClassRule.java
  31. +141 −130 src/main/java/org/junit/ComparisonFailure.java
  32. +6 −6 src/main/java/org/junit/FixMethodOrder.java
  33. +12 −12 src/main/java/org/junit/Ignore.java
  34. +21 −20 src/main/java/org/junit/Rule.java
  35. +28 −25 src/main/java/org/junit/Test.java
  36. +43 −43 src/main/java/org/junit/experimental/ParallelComputer.java
  37. +163 −150 src/main/java/org/junit/experimental/categories/Categories.java
  38. +28 −28 src/main/java/org/junit/experimental/categories/Category.java
  39. +7 −7 src/main/java/org/junit/experimental/max/CouldNotReadCoreException.java
  40. +150 −139 src/main/java/org/junit/experimental/max/MaxCore.java
  41. +143 −139 src/main/java/org/junit/experimental/max/MaxHistory.java
  42. +16 −19 src/main/java/org/junit/experimental/results/FailureList.java
  43. +41 −41 src/main/java/org/junit/experimental/results/PrintableResult.java
  44. +50 −50 src/main/java/org/junit/experimental/results/ResultMatchers.java
  45. +14 −14 src/main/java/org/junit/experimental/runners/Enclosed.java
  46. +81 −79 src/main/java/org/junit/experimental/theories/ParameterSignature.java
  47. +1 −2  src/main/java/org/junit/experimental/theories/ParameterSupplier.java
  48. +1 −1  src/main/java/org/junit/experimental/theories/ParametersSuppliedBy.java
  49. +26 −26 src/main/java/org/junit/experimental/theories/PotentialAssignment.java
  50. +180 −175 src/main/java/org/junit/experimental/theories/Theories.java
  51. +1 −4 src/main/java/org/junit/experimental/theories/Theory.java
  52. +123 −120 src/main/java/org/junit/experimental/theories/internal/AllMembersSupplier.java
  53. +114 −114 src/main/java/org/junit/experimental/theories/internal/Assignments.java
  54. +38 −41 src/main/java/org/junit/experimental/theories/internal/ParameterizedAssertionError.java
  55. +1 −2  src/main/java/org/junit/experimental/theories/suppliers/TestedOn.java
  56. +10 −9 src/main/java/org/junit/experimental/theories/suppliers/TestedOnSupplier.java
  57. +49 −45 src/main/java/org/junit/internal/ArrayComparisonFailure.java
  58. +66 −64 src/main/java/org/junit/internal/AssumptionViolatedException.java
  59. +60 −58 src/main/java/org/junit/internal/ComparisonCriteria.java
  60. +4 −4 src/main/java/org/junit/internal/ExactComparisonCriteria.java
  61. +16 −15 src/main/java/org/junit/internal/InexactComparisonCriteria.java
  62. +1 −1  src/main/java/org/junit/internal/JUnitSystem.java
  63. +14 −11 src/main/java/org/junit/internal/MethodSorter.java
  64. +3 −3 src/main/java/org/junit/internal/RealSystem.java
  65. +87 −84 src/main/java/org/junit/internal/TextListener.java
  66. +46 −47 src/main/java/org/junit/internal/builders/AllDefaultPossibilitiesBuilder.java
  67. +30 −32 src/main/java/org/junit/internal/builders/AnnotatedBuilder.java
  68. +7 −9 src/main/java/org/junit/internal/builders/IgnoredBuilder.java
  69. +12 −15 src/main/java/org/junit/internal/builders/IgnoredClassRunner.java
  70. +10 −12 src/main/java/org/junit/internal/builders/JUnit3Builder.java
  71. +4 −7 src/main/java/org/junit/internal/builders/JUnit4Builder.java
  72. +4 −7 src/main/java/org/junit/internal/builders/NullBuilder.java
  73. +15 −17 src/main/java/org/junit/internal/builders/SuiteMethodBuilder.java
  74. +41 −41 src/main/java/org/junit/internal/matchers/StacktracePrintingMatcher.java
  75. +28 −28 src/main/java/org/junit/internal/matchers/ThrowableCauseMatcher.java
  76. +28 −28 src/main/java/org/junit/internal/matchers/ThrowableMessageMatcher.java
  77. +8 −9 src/main/java/org/junit/internal/matchers/TypeSafeMatcher.java
  78. +20 −21 src/main/java/org/junit/internal/requests/ClassRequest.java
  79. +25 −27 src/main/java/org/junit/internal/requests/FilterRequest.java
  80. +12 −12 src/main/java/org/junit/internal/requests/SortingRequest.java
  81. +59 −56 src/main/java/org/junit/internal/runners/ClassRoadie.java
  82. +51 −46 src/main/java/org/junit/internal/runners/ErrorReportingRunner.java
  83. +1 −2  src/main/java/org/junit/internal/runners/FailedBefore.java
  84. +16 −16 src/main/java/org/junit/internal/runners/InitializationError.java
  85. +138 −136 src/main/java/org/junit/internal/runners/JUnit38ClassRunner.java
  86. +119 −115 src/main/java/org/junit/internal/runners/JUnit4ClassRunner.java
  87. +129 −124 src/main/java/org/junit/internal/runners/MethodRoadie.java
  88. +67 −61 src/main/java/org/junit/internal/runners/MethodValidator.java
  89. +19 −18 src/main/java/org/junit/internal/runners/SuiteMethod.java
  90. +84 −78 src/main/java/org/junit/internal/runners/TestClass.java
  91. +40 −38 src/main/java/org/junit/internal/runners/TestMethod.java
  92. +39 −41 src/main/java/org/junit/internal/runners/model/EachTestNotifier.java
  93. +4 −4 src/main/java/org/junit/internal/runners/model/MultipleFailureException.java
  94. +8 −11 src/main/java/org/junit/internal/runners/model/ReflectiveCallable.java
  95. +82 −76 src/main/java/org/junit/internal/runners/rules/RuleFieldValidator.java
  96. +29 −31 src/main/java/org/junit/internal/runners/statements/ExpectException.java
  97. +8 −9 src/main/java/org/junit/internal/runners/statements/Fail.java
  98. +77 −78 src/main/java/org/junit/internal/runners/statements/FailOnTimeout.java
  99. +12 −15 src/main/java/org/junit/internal/runners/statements/InvokeMethod.java
  100. +27 −29 src/main/java/org/junit/internal/runners/statements/RunAfters.java
  101. +15 −17 src/main/java/org/junit/internal/runners/statements/RunBefores.java
  102. +91 −104 src/main/java/org/junit/matchers/JUnitMatchers.java
  103. +1 −1  src/main/java/org/junit/package-info.java
  104. +54 −53 src/main/java/org/junit/rules/ErrorCollector.java
  105. +138 −133 src/main/java/org/junit/rules/ExpectedException.java
  106. +30 −30 src/main/java/org/junit/rules/ExpectedExceptionMatcherBuilder.java
  107. +51 −49 src/main/java/org/junit/rules/ExternalResource.java
  108. +14 −13 src/main/java/org/junit/rules/MethodRule.java
  109. +53 −53 src/main/java/org/junit/rules/RuleChain.java
  110. +17 −15 src/main/java/org/junit/rules/RunRules.java
  111. +133 −126 src/main/java/org/junit/rules/TemporaryFolder.java
  112. +25 −24 src/main/java/org/junit/rules/TestName.java
  113. +18 −17 src/main/java/org/junit/rules/TestRule.java
  114. +108 −119 src/main/java/org/junit/rules/TestWatcher.java
  115. +68 −77 src/main/java/org/junit/rules/TestWatchman.java
  116. +30 −29 src/main/java/org/junit/rules/Timeout.java
  117. +19 −18 src/main/java/org/junit/rules/Verifier.java
  118. +26 −25 src/main/java/org/junit/runner/Computer.java
  119. +5 −4 src/main/java/org/junit/runner/Describable.java
  120. +285 −269 src/main/java/org/junit/runner/Description.java
  121. +165 −155 src/main/java/org/junit/runner/JUnitCore.java
  122. +138 −129 src/main/java/org/junit/runner/Request.java
  123. +90 −89 src/main/java/org/junit/runner/Result.java
  124. +12 −11 src/main/java/org/junit/runner/RunWith.java
  125. +21 −19 src/main/java/org/junit/runner/Runner.java
  126. +99 −92 src/main/java/org/junit/runner/manipulation/Filter.java
  127. +8 −6 src/main/java/org/junit/runner/manipulation/Filterable.java
  128. +2 −1  src/main/java/org/junit/runner/manipulation/NoTestsRemainException.java
  129. +7 −5 src/main/java/org/junit/runner/manipulation/Sortable.java
  130. +31 −30 src/main/java/org/junit/runner/manipulation/Sorter.java
  131. +58 −54 src/main/java/org/junit/runner/notification/Failure.java
  132. +59 −54 src/main/java/org/junit/runner/notification/RunListener.java
  133. +190 −168 src/main/java/org/junit/runner/notification/RunNotifier.java
  134. +3 −3 src/main/java/org/junit/runner/notification/StoppedByUserException.java
  135. +9 −7 src/main/java/org/junit/runners/AllTests.java
  136. +376 −374 src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java
  137. +7 −6 src/main/java/org/junit/runners/JUnit4.java
  138. +10 −5 src/main/java/org/junit/runners/MethodSorters.java
  139. +247 −242 src/main/java/org/junit/runners/Parameterized.java
  140. +340 −334 src/main/java/org/junit/runners/ParentRunner.java
  141. +99 −101 src/main/java/org/junit/runners/Suite.java
  142. +47 −46 src/main/java/org/junit/runners/model/FrameworkField.java
  143. +24 −19 src/main/java/org/junit/runners/model/FrameworkMember.java
  144. +181 −171 src/main/java/org/junit/runners/model/FrameworkMethod.java
  145. +28 −27 src/main/java/org/junit/runners/model/InitializationError.java
  146. +50 −47 src/main/java/org/junit/runners/model/MultipleFailureException.java
  147. +46 −41 src/main/java/org/junit/runners/model/NoGenericTypeParametersValidator.java
  148. +69 −66 src/main/java/org/junit/runners/model/RunnerBuilder.java
  149. +13 −12 src/main/java/org/junit/runners/model/RunnerScheduler.java
  150. +5 −4 src/main/java/org/junit/runners/model/Statement.java
  151. +164 −153 src/main/java/org/junit/runners/model/TestClass.java
  152. +11 −11 src/test/java/junit/samples/AllTests.java
  153. +56 −49 src/test/java/junit/samples/ListTest.java
  154. +55 −51 src/test/java/junit/samples/SimpleTest.java
  155. +44 −38 src/test/java/junit/samples/money/IMoney.java
  156. +86 −70 src/test/java/junit/samples/money/Money.java
  157. +144 −113 src/test/java/junit/samples/money/MoneyBag.java
  158. +160 −137 src/test/java/junit/samples/money/MoneyTest.java
  159. +11 −12 src/test/java/junit/tests/AllTests.java
  160. +6 −5 src/test/java/junit/tests/WasRun.java
  161. +49 −49 src/test/java/junit/tests/extensions/ActiveTestTest.java
  162. +11 −12 src/test/java/junit/tests/extensions/AllTests.java
  163. +88 −84 src/test/java/junit/tests/extensions/ExtensionTest.java
  164. +49 −50 src/test/java/junit/tests/extensions/RepeatedTestTest.java
  165. +20 −21 src/test/java/junit/tests/framework/AllTests.java
  166. +162 −162 src/test/java/junit/tests/framework/AssertTest.java
  167. +13 −13 src/test/java/junit/tests/framework/AssertionFailedErrorTest.java
  168. +94 −94 src/test/java/junit/tests/framework/ComparisonCompactorTest.java
  169. +38 −38 src/test/java/junit/tests/framework/ComparisonFailureTest.java
  170. +46 −46 src/test/java/junit/tests/framework/DoublePrecisionAssertTest.java
  171. +4 −5 src/test/java/junit/tests/framework/Failure.java
  172. +54 −54 src/test/java/junit/tests/framework/FloatAssertTest.java
  173. +3 −3 src/test/java/junit/tests/framework/InheritedTestCase.java
  174. +2 −3 src/test/java/junit/tests/framework/NoArgTestCaseTest.java
  175. +2 −3 src/test/java/junit/tests/framework/NoTestCaseClass.java
  176. +4 −4 src/test/java/junit/tests/framework/NoTestCases.java
  177. +7 −6 src/test/java/junit/tests/framework/NotPublicTestCase.java
  178. +8 −7 src/test/java/junit/tests/framework/NotVoidTestCase.java
  179. +10 −8 src/test/java/junit/tests/framework/OneTestCase.java
  180. +3 −3 src/test/java/junit/tests/framework/OverrideTestCase.java
  181. +7 −8 src/test/java/junit/tests/framework/Success.java
  182. +104 −91 src/test/java/junit/tests/framework/SuiteTest.java
  183. +191 −176 src/test/java/junit/tests/framework/TestCaseTest.java
  184. +42 −42 src/test/java/junit/tests/framework/TestImplementorTest.java
  185. +69 −62 src/test/java/junit/tests/framework/TestListenerTest.java
  186. +10 −8 src/test/java/junit/tests/framework/ThreeTestCases.java
  187. +19 −20 src/test/java/junit/tests/runner/AllTests.java
  188. +44 −45 src/test/java/junit/tests/runner/BaseTestRunnerTest.java
  189. +18 −18 src/test/java/junit/tests/runner/ResultTest.java
  190. +35 −35 src/test/java/junit/tests/runner/StackFilterTest.java
  191. +108 −91 src/test/java/junit/tests/runner/TextFeedbackTest.java
  192. +25 −25 src/test/java/junit/tests/runner/TextRunnerSingleMethodTest.java
  193. +47 −46 src/test/java/junit/tests/runner/TextRunnerTest.java
  194. +108 −48 src/test/java/org/junit/internal/MethodSorterTest.java
  195. +21 −20 src/test/java/org/junit/internal/matchers/StacktracePrintingMatcherTest.java
  196. +41 −40 src/test/java/org/junit/runner/notification/RunNotifierTest.java
  197. +72 −58 src/test/java/org/junit/samples/ListTest.java
  198. +33 −29 src/test/java/org/junit/samples/SimpleTest.java
  199. +191 −144 src/test/java/org/junit/samples/money/MoneyTest.java
  200. +78 −78 src/test/java/org/junit/tests/AllTests.java
  201. +23 −23 src/test/java/org/junit/tests/ObjectContractTest.java
  202. +12 −12 src/test/java/org/junit/tests/TestSystem.java
  203. +562 −505 src/test/java/org/junit/tests/assertion/AssertionTest.java
  204. +36 −36 src/test/java/org/junit/tests/assertion/MultipleFailureExceptionTest.java
  205. +47 −37 src/test/java/org/junit/tests/deprecated/JUnit4ClassRunnerTest.java
  206. +80 −80 src/test/java/org/junit/tests/description/AnnotatedDescriptionTest.java
  207. +27 −24 src/test/java/org/junit/tests/description/SuiteDescriptionTest.java
  208. +13 −11 src/test/java/org/junit/tests/description/TestDescriptionTest.java
  209. +240 −229 src/test/java/org/junit/tests/experimental/AssumptionTest.java
  210. +34 −33 src/test/java/org/junit/tests/experimental/AssumptionViolatedExceptionTest.java
  211. +7 −7 src/test/java/org/junit/tests/experimental/ExperimentalTests.java
  212. +21 −21 src/test/java/org/junit/tests/experimental/MatcherTest.java
  213. +101 −101 src/test/java/org/junit/tests/experimental/categories/CategoriesAndParameterizedTest.java
  214. +255 −227 src/test/java/org/junit/tests/experimental/categories/CategoryTest.java
  215. +107 −105 src/test/java/org/junit/tests/experimental/max/DescriptionTest.java
  216. +44 −35 src/test/java/org/junit/tests/experimental/max/JUnit38SortingTest.java
  217. +262 −261 src/test/java/org/junit/tests/experimental/max/MaxStarterTest.java
  218. +64 −54 src/test/java/org/junit/tests/experimental/parallel/ParallelClassTest.java
  219. +47 −38 src/test/java/org/junit/tests/experimental/parallel/ParallelMethodTest.java
  220. +30 −30 src/test/java/org/junit/tests/experimental/results/PrintableResultTest.java
  221. +12 −10 src/test/java/org/junit/tests/experimental/results/ResultMatchersTest.java
  222. +61 −61 src/test/java/org/junit/tests/experimental/rules/BlockJUnit4ClassRunnerOverrideTest.java
  223. +225 −206 src/test/java/org/junit/tests/experimental/rules/ClassRulesTest.java
  224. +159 −158 src/test/java/org/junit/tests/experimental/rules/EventCollector.java
  225. +336 −336 src/test/java/org/junit/tests/experimental/rules/ExpectedExceptionTest.java
  226. +33 −25 src/test/java/org/junit/tests/experimental/rules/ExternalResourceRuleTest.java
  227. +20 −20 src/test/java/org/junit/tests/experimental/rules/LoggingTestWatcher.java
Sorry, we could not display the entire diff because too many files (305) changed.
View
108 src/main/java/junit/extensions/ActiveTestSuite.java
@@ -10,61 +10,61 @@
* test in a separate thread and waits until all
* threads have terminated.
* -- Aarhus Radisson Scandinavian Center 11th floor
- */
+ */
public class ActiveTestSuite extends TestSuite {
- private volatile int fActiveTestDeathCount;
+ private volatile int fActiveTestDeathCount;
- public ActiveTestSuite() {
- }
-
- public ActiveTestSuite(Class<? extends TestCase> theClass) {
- super(theClass);
- }
-
- public ActiveTestSuite(String name) {
- super (name);
- }
-
- public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {
- super(theClass, name);
- }
-
- @Override
- public void run(TestResult result) {
- fActiveTestDeathCount= 0;
- super.run(result);
- waitUntilFinished();
- }
-
- @Override
- public void runTest(final Test test, final TestResult result) {
- Thread t= new Thread() {
- @Override
- public void run() {
- try {
- // inlined due to limitation in VA/Java
- //ActiveTestSuite.super.runTest(test, result);
- test.run(result);
- } finally {
- ActiveTestSuite.this.runFinished();
- }
- }
- };
- t.start();
- }
+ public ActiveTestSuite() {
+ }
- synchronized void waitUntilFinished() {
- while (fActiveTestDeathCount < testCount()) {
- try {
- wait();
- } catch (InterruptedException e) {
- return; // ignore
- }
- }
- }
-
- synchronized public void runFinished() {
- fActiveTestDeathCount++;
- notifyAll();
- }
+ public ActiveTestSuite(Class<? extends TestCase> theClass) {
+ super(theClass);
+ }
+
+ public ActiveTestSuite(String name) {
+ super(name);
+ }
+
+ public ActiveTestSuite(Class<? extends TestCase> theClass, String name) {
+ super(theClass, name);
+ }
+
+ @Override
+ public void run(TestResult result) {
+ fActiveTestDeathCount = 0;
+ super.run(result);
+ waitUntilFinished();
+ }
+
+ @Override
+ public void runTest(final Test test, final TestResult result) {
+ Thread t = new Thread() {
+ @Override
+ public void run() {
+ try {
+ // inlined due to limitation in VA/Java
+ //ActiveTestSuite.super.runTest(test, result);
+ test.run(result);
+ } finally {
+ ActiveTestSuite.this.runFinished();
+ }
+ }
+ };
+ t.start();
+ }
+
+ synchronized void waitUntilFinished() {
+ while (fActiveTestDeathCount < testCount()) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ return; // ignore
+ }
+ }
+ }
+
+ synchronized public void runFinished() {
+ fActiveTestDeathCount++;
+ notifyAll();
+ }
}
View
49 src/main/java/junit/extensions/RepeatedTest.java
@@ -5,34 +5,35 @@
/**
* A Decorator that runs a test repeatedly.
- *
*/
public class RepeatedTest extends TestDecorator {
- private int fTimesRepeat;
+ private int fTimesRepeat;
- public RepeatedTest(Test test, int repeat) {
- super(test);
- if (repeat < 0)
- throw new IllegalArgumentException("Repetition count must be >= 0");
- fTimesRepeat= repeat;
- }
+ public RepeatedTest(Test test, int repeat) {
+ super(test);
+ if (repeat < 0) {
+ throw new IllegalArgumentException("Repetition count must be >= 0");
+ }
+ fTimesRepeat = repeat;
+ }
- @Override
- public int countTestCases() {
- return super.countTestCases() * fTimesRepeat;
- }
+ @Override
+ public int countTestCases() {
+ return super.countTestCases() * fTimesRepeat;
+ }
- @Override
- public void run(TestResult result) {
- for (int i= 0; i < fTimesRepeat; i++) {
- if (result.shouldStop())
- break;
- super.run(result);
- }
- }
+ @Override
+ public void run(TestResult result) {
+ for (int i = 0; i < fTimesRepeat; i++) {
+ if (result.shouldStop()) {
+ break;
+ }
+ super.run(result);
+ }
+ }
- @Override
- public String toString() {
- return super.toString() + "(repeated)";
- }
+ @Override
+ public String toString() {
+ return super.toString() + "(repeated)";
+ }
}
View
59 src/main/java/junit/extensions/TestDecorator.java
@@ -8,36 +8,35 @@
* A Decorator for Tests. Use TestDecorator as the base class for defining new
* test decorators. Test decorator subclasses can be introduced to add behaviour
* before or after a test is run.
- *
*/
public class TestDecorator extends Assert implements Test {
- protected Test fTest;
-
- public TestDecorator(Test test) {
- fTest= test;
- }
-
- /**
- * The basic run behaviour.
- */
- public void basicRun(TestResult result) {
- fTest.run(result);
- }
-
- public int countTestCases() {
- return fTest.countTestCases();
- }
-
- public void run(TestResult result) {
- basicRun(result);
- }
-
- @Override
- public String toString() {
- return fTest.toString();
- }
-
- public Test getTest() {
- return fTest;
- }
+ protected Test fTest;
+
+ public TestDecorator(Test test) {
+ fTest = test;
+ }
+
+ /**
+ * The basic run behaviour.
+ */
+ public void basicRun(TestResult result) {
+ fTest.run(result);
+ }
+
+ public int countTestCases() {
+ return fTest.countTestCases();
+ }
+
+ public void run(TestResult result) {
+ basicRun(result);
+ }
+
+ @Override
+ public String toString() {
+ return fTest.toString();
+ }
+
+ public Test getTest() {
+ return fTest;
+ }
}
View
50 src/main/java/junit/extensions/TestSetup.java
@@ -11,32 +11,32 @@
*/
public class TestSetup extends TestDecorator {
- public TestSetup(Test test) {
- super(test);
- }
+ public TestSetup(Test test) {
+ super(test);
+ }
- @Override
- public void run(final TestResult result) {
- Protectable p= new Protectable() {
- public void protect() throws Exception {
- setUp();
- basicRun(result);
- tearDown();
- }
- };
- result.runProtected(this, p);
- }
+ @Override
+ public void run(final TestResult result) {
+ Protectable p = new Protectable() {
+ public void protect() throws Exception {
+ setUp();
+ basicRun(result);
+ tearDown();
+ }
+ };
+ result.runProtected(this, p);
+ }
- /**
- * Sets up the fixture. Override to set up additional fixture state.
- */
- protected void setUp() throws Exception {
- }
+ /**
+ * Sets up the fixture. Override to set up additional fixture state.
+ */
+ protected void setUp() throws Exception {
+ }
- /**
- * Tears down the fixture. Override to tear down the additional fixture
- * state.
- */
- protected void tearDown() throws Exception {
- }
+ /**
+ * Tears down the fixture. Override to tear down the additional fixture
+ * state.
+ */
+ protected void tearDown() throws Exception {
+ }
}
View
613 src/main/java/junit/framework/Assert.java
@@ -7,288 +7,333 @@
*/
@Deprecated
public class Assert {
- /**
- * Protect constructor since it is a static only class
- */
- protected Assert() {
- }
-
- /**
- * Asserts that a condition is true. If it isn't it throws
- * an AssertionFailedError with the given message.
- */
- static public void assertTrue(String message, boolean condition) {
- if (!condition)
- fail(message);
- }
- /**
- * Asserts that a condition is true. If it isn't it throws
- * an AssertionFailedError.
- */
- static public void assertTrue(boolean condition) {
- assertTrue(null, condition);
- }
- /**
- * Asserts that a condition is false. If it isn't it throws
- * an AssertionFailedError with the given message.
- */
- static public void assertFalse(String message, boolean condition) {
- assertTrue(message, !condition);
- }
- /**
- * Asserts that a condition is false. If it isn't it throws
- * an AssertionFailedError.
- */
- static public void assertFalse(boolean condition) {
- assertFalse(null, condition);
- }
- /**
- * Fails a test with the given message.
- */
- static public void fail(String message) {
- if (message == null) {
- throw new AssertionFailedError();
- }
- throw new AssertionFailedError(message);
- }
- /**
- * Fails a test with no message.
- */
- static public void fail() {
- fail(null);
- }
- /**
- * Asserts that two objects are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, Object expected, Object actual) {
- if (expected == null && actual == null)
- return;
- if (expected != null && expected.equals(actual))
- return;
- failNotEquals(message, expected, actual);
- }
- /**
- * Asserts that two objects are equal. If they are not
- * an AssertionFailedError is thrown.
- */
- static public void assertEquals(Object expected, Object actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two Strings are equal.
- */
- static public void assertEquals(String message, String expected, String actual) {
- if (expected == null && actual == null)
- return;
- if (expected != null && expected.equals(actual))
- return;
- String cleanMessage= message == null ? "" : message;
- throw new ComparisonFailure(cleanMessage, expected, actual);
- }
- /**
- * Asserts that two Strings are equal.
- */
- static public void assertEquals(String expected, String actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two doubles are equal concerning a delta. If they are not
- * an AssertionFailedError is thrown with the given message. If the expected
- * value is infinity then the delta value is ignored.
- */
- 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, new Double(expected), new Double(actual));
- }
- /**
- * Asserts that two doubles are equal concerning a delta. If the expected
- * value is infinity then the delta value is ignored.
- */
- static public void assertEquals(double expected, double actual, double delta) {
- assertEquals(null, expected, actual, delta);
- }
- /**
- * Asserts that two floats are equal concerning a positive delta. If they
- * are not an AssertionFailedError is thrown with the given message. If the
- * expected value is infinity then the delta value is ignored.
- */
- 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, new Float(expected), new Float(actual));
- }
- /**
- * Asserts that two floats are equal concerning a delta. If the expected
- * value is infinity then the delta value is ignored.
- */
- static public void assertEquals(float expected, float actual, float delta) {
- assertEquals(null, expected, actual, delta);
- }
- /**
- * Asserts that two longs are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, long expected, long actual) {
- assertEquals(message, new Long(expected), new Long(actual));
- }
- /**
- * Asserts that two longs are equal.
- */
- static public void assertEquals(long expected, long actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two booleans are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, boolean expected, boolean actual) {
- assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual));
- }
- /**
- * Asserts that two booleans are equal.
- */
- static public void assertEquals(boolean expected, boolean actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two bytes are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, byte expected, byte actual) {
- assertEquals(message, new Byte(expected), new Byte(actual));
- }
- /**
- * Asserts that two bytes are equal.
- */
- static public void assertEquals(byte expected, byte actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two chars are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, char expected, char actual) {
- assertEquals(message, new Character(expected), new Character(actual));
- }
- /**
- * Asserts that two chars are equal.
- */
- static public void assertEquals(char expected, char actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two shorts are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, short expected, short actual) {
- assertEquals(message, new Short(expected), new Short(actual));
- }
- /**
- * Asserts that two shorts are equal.
- */
- static public void assertEquals(short expected, short actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that two ints are equal. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertEquals(String message, int expected, int actual) {
- assertEquals(message, new Integer(expected), new Integer(actual));
- }
- /**
- * Asserts that two ints are equal.
- */
- static public void assertEquals(int expected, int actual) {
- assertEquals(null, expected, actual);
- }
- /**
- * Asserts that an object isn't null.
- */
- static public void assertNotNull(Object object) {
- assertNotNull(null, object);
- }
- /**
- * Asserts that an object isn't null. If it is
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertNotNull(String message, Object object) {
- assertTrue(message, object != null);
- }
- /**
- * Asserts that an object is null. If it isn't an {@link AssertionError} is
- * thrown.
- * Message contains: Expected: <null> but was: object
- *
- * @param object
- * Object to check or <code>null</code>
- */
- static public void assertNull(Object object) {
- if (object != null)
- assertNull("Expected: <null> but was: " + object.toString(), object);
- }
- /**
- * Asserts that an object is null. If it is not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertNull(String message, Object object) {
- assertTrue(message, object == null);
- }
- /**
- * Asserts that two objects refer to the same object. If they are not
- * an AssertionFailedError is thrown with the given message.
- */
- static public void assertSame(String message, Object expected, Object actual) {
- if (expected == actual)
- return;
- failNotSame(message, expected, actual);
- }
- /**
- * Asserts that two objects refer to the same object. If they are not
- * the same an AssertionFailedError is thrown.
- */
- static public void assertSame(Object expected, Object actual) {
- assertSame(null, expected, actual);
- }
- /**
- * Asserts that two objects do not refer to the same object. If they do
- * refer to the same object an AssertionFailedError is thrown with the
- * given message.
- */
- static public void assertNotSame(String message, Object expected, Object actual) {
- if (expected == actual)
- failSame(message);
- }
- /**
- * Asserts that two objects do not refer to the same object. If they do
- * refer to the same object an AssertionFailedError is thrown.
- */
- static public void assertNotSame(Object expected, Object actual) {
- assertNotSame(null, expected, actual);
- }
-
- static public void failSame(String message) {
- String formatted= (message != null) ? message+" " : "";
- fail(formatted+"expected not same");
- }
-
- static public void failNotSame(String message, Object expected, Object actual) {
- String formatted= (message != null) ? message+" " : "";
- fail(formatted+"expected same:<"+expected+"> was not:<"+actual+">");
- }
-
- static public void failNotEquals(String message, Object expected, Object actual) {
- fail(format(message, expected, actual));
- }
-
- public static String format(String message, Object expected, Object actual) {
- String formatted= "";
- if (message != null && message.length() > 0)
- formatted= message+" ";
- return formatted+"expected:<"+expected+"> but was:<"+actual+">";
- }
+ /**
+ * Protect constructor since it is a static only class
+ */
+ protected Assert() {
+ }
+
+ /**
+ * Asserts that a condition is true. If it isn't it throws
+ * an AssertionFailedError with the given message.
+ */
+ static public void assertTrue(String message, boolean condition) {
+ if (!condition) {
+ fail(message);
+ }
+ }
+
+ /**
+ * Asserts that a condition is true. If it isn't it throws
+ * an AssertionFailedError.
+ */
+ static public void assertTrue(boolean condition) {
+ assertTrue(null, condition);
+ }
+
+ /**
+ * Asserts that a condition is false. If it isn't it throws
+ * an AssertionFailedError with the given message.
+ */
+ static public void assertFalse(String message, boolean condition) {
+ assertTrue(message, !condition);
+ }
+
+ /**
+ * Asserts that a condition is false. If it isn't it throws
+ * an AssertionFailedError.
+ */
+ static public void assertFalse(boolean condition) {
+ assertFalse(null, condition);
+ }
+
+ /**
+ * Fails a test with the given message.
+ */
+ static public void fail(String message) {
+ if (message == null) {
+ throw new AssertionFailedError();
+ }
+ throw new AssertionFailedError(message);
+ }
+
+ /**
+ * Fails a test with no message.
+ */
+ static public void fail() {
+ fail(null);
+ }
+
+ /**
+ * Asserts that two objects are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, Object expected, Object actual) {
+ if (expected == null && actual == null) {
+ return;
+ }
+ if (expected != null && expected.equals(actual)) {
+ return;
+ }
+ failNotEquals(message, expected, actual);
+ }
+
+ /**
+ * Asserts that two objects are equal. If they are not
+ * an AssertionFailedError is thrown.
+ */
+ static public void assertEquals(Object expected, Object actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two Strings are equal.
+ */
+ static public void assertEquals(String message, String expected, String actual) {
+ if (expected == null && actual == null) {
+ return;
+ }
+ if (expected != null && expected.equals(actual)) {
+ return;
+ }
+ String cleanMessage = message == null ? "" : message;
+ throw new ComparisonFailure(cleanMessage, expected, actual);
+ }
+
+ /**
+ * Asserts that two Strings are equal.
+ */
+ static public void assertEquals(String expected, String actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two doubles are equal concerning a delta. If they are not
+ * an AssertionFailedError is thrown with the given message. If the expected
+ * value is infinity then the delta value is ignored.
+ */
+ 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, new Double(expected), new Double(actual));
+ }
+ }
+
+ /**
+ * Asserts that two doubles are equal concerning a delta. If the expected
+ * value is infinity then the delta value is ignored.
+ */
+ static public void assertEquals(double expected, double actual, double delta) {
+ assertEquals(null, expected, actual, delta);
+ }
+
+ /**
+ * Asserts that two floats are equal concerning a positive delta. If they
+ * are not an AssertionFailedError is thrown with the given message. If the
+ * expected value is infinity then the delta value is ignored.
+ */
+ 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, new Float(expected), new Float(actual));
+ }
+ }
+
+ /**
+ * Asserts that two floats are equal concerning a delta. If the expected
+ * value is infinity then the delta value is ignored.
+ */
+ static public void assertEquals(float expected, float actual, float delta) {
+ assertEquals(null, expected, actual, delta);
+ }
+
+ /**
+ * Asserts that two longs are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, long expected, long actual) {
+ assertEquals(message, new Long(expected), new Long(actual));
+ }
+
+ /**
+ * Asserts that two longs are equal.
+ */
+ static public void assertEquals(long expected, long actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two booleans are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, boolean expected, boolean actual) {
+ assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual));
+ }
+
+ /**
+ * Asserts that two booleans are equal.
+ */
+ static public void assertEquals(boolean expected, boolean actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two bytes are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, byte expected, byte actual) {
+ assertEquals(message, new Byte(expected), new Byte(actual));
+ }
+
+ /**
+ * Asserts that two bytes are equal.
+ */
+ static public void assertEquals(byte expected, byte actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two chars are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, char expected, char actual) {
+ assertEquals(message, new Character(expected), new Character(actual));
+ }
+
+ /**
+ * Asserts that two chars are equal.
+ */
+ static public void assertEquals(char expected, char actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two shorts are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, short expected, short actual) {
+ assertEquals(message, new Short(expected), new Short(actual));
+ }
+
+ /**
+ * Asserts that two shorts are equal.
+ */
+ static public void assertEquals(short expected, short actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two ints are equal. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertEquals(String message, int expected, int actual) {
+ assertEquals(message, new Integer(expected), new Integer(actual));
+ }
+
+ /**
+ * Asserts that two ints are equal.
+ */
+ static public void assertEquals(int expected, int actual) {
+ assertEquals(null, expected, actual);
+ }
+
+ /**
+ * Asserts that an object isn't null.
+ */
+ static public void assertNotNull(Object object) {
+ assertNotNull(null, object);
+ }
+
+ /**
+ * Asserts that an object isn't null. If it is
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertNotNull(String message, Object object) {
+ assertTrue(message, object != null);
+ }
+
+ /**
+ * Asserts that an object is null. If it isn't an {@link AssertionError} is
+ * thrown.
+ * Message contains: Expected: <null> but was: object
+ *
+ * @param object Object to check or <code>null</code>
+ */
+ static public void assertNull(Object object) {
+ if (object != null) {
+ assertNull("Expected: <null> but was: " + object.toString(), object);
+ }
+ }
+
+ /**
+ * Asserts that an object is null. If it is not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertNull(String message, Object object) {
+ assertTrue(message, object == null);
+ }
+
+ /**
+ * Asserts that two objects refer to the same object. If they are not
+ * an AssertionFailedError is thrown with the given message.
+ */
+ static public void assertSame(String message, Object expected, Object actual) {
+ if (expected == actual) {
+ return;
+ }
+ failNotSame(message, expected, actual);
+ }
+
+ /**
+ * Asserts that two objects refer to the same object. If they are not
+ * the same an AssertionFailedError is thrown.
+ */
+ static public void assertSame(Object expected, Object actual) {
+ assertSame(null, expected, actual);
+ }
+
+ /**
+ * Asserts that two objects do not refer to the same object. If they do
+ * refer to the same object an AssertionFailedError is thrown with the
+ * given message.
+ */
+ static public void assertNotSame(String message, Object expected, Object actual) {
+ if (expected == actual) {
+ failSame(message);
+ }
+ }
+
+ /**
+ * Asserts that two objects do not refer to the same object. If they do
+ * refer to the same object an AssertionFailedError is thrown.
+ */
+ static public void assertNotSame(Object expected, Object actual) {
+ assertNotSame(null, expected, actual);
+ }
+
+ static public void failSame(String message) {
+ String formatted = (message != null) ? message + " " : "";
+ fail(formatted + "expected not same");
+ }
+
+ static public void failNotSame(String message, Object expected, Object actual) {
+ String formatted = (message != null) ? message + " " : "";
+ fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">");
+ }
+
+ static public void failNotEquals(String message, Object expected, Object actual) {
+ fail(format(message, expected, actual));
+ }
+
+ public static String format(String message, Object expected, Object actual) {
+ String formatted = "";
+ if (message != null && message.length() > 0) {
+ formatted = message + " ";
+ }
+ return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
+ }
}
View
18 src/main/java/junit/framework/AssertionFailedError.java
@@ -5,16 +5,16 @@
*/
public class AssertionFailedError extends AssertionError {
- private static final long serialVersionUID= 1L;
+ private static final long serialVersionUID = 1L;
- public AssertionFailedError() {
- }
+ public AssertionFailedError() {
+ }
- public AssertionFailedError(String message) {
- super(defaultString(message));
- }
+ public AssertionFailedError(String message) {
+ super(defaultString(message));
+ }
- private static String defaultString(String message) {
- return message == null ? "" : message;
- }
+ private static String defaultString(String message) {
+ return message == null ? "" : message;
+ }
}
View
121 src/main/java/junit/framework/ComparisonCompactor.java
@@ -2,71 +2,76 @@
public class ComparisonCompactor {
- private static final String ELLIPSIS= "...";
- private static final String DELTA_END= "]";
- private static final String DELTA_START= "[";
-
- private int fContextLength;
- private String fExpected;
- private String fActual;
- private int fPrefix;
- private int fSuffix;
+ private static final String ELLIPSIS = "...";
+ private static final String DELTA_END = "]";
+ private static final String DELTA_START = "[";
- public ComparisonCompactor(int contextLength, String expected, String actual) {
- fContextLength= contextLength;
- fExpected= expected;
- fActual= actual;
- }
+ private int fContextLength;
+ private String fExpected;
+ private String fActual;
+ private int fPrefix;
+ private int fSuffix;
- public String compact(String message) {
- if (fExpected == null || fActual == null || areStringsEqual())
- return Assert.format(message, fExpected, fActual);
+ public ComparisonCompactor(int contextLength, String expected, String actual) {
+ fContextLength = contextLength;
+ fExpected = expected;
+ fActual = actual;
+ }
- findCommonPrefix();
- findCommonSuffix();
- String expected= compactString(fExpected);
- String actual= compactString(fActual);
- return Assert.format(message, expected, actual);
- }
+ public String compact(String message) {
+ if (fExpected == null || fActual == null || areStringsEqual()) {
+ return Assert.format(message, fExpected, fActual);
+ }
- private String compactString(String source) {
- String result= DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;
- if (fPrefix > 0)
- result= computeCommonPrefix() + result;
- if (fSuffix > 0)
- result= result + computeCommonSuffix();
- return result;
- }
+ findCommonPrefix();
+ findCommonSuffix();
+ String expected = compactString(fExpected);
+ String actual = compactString(fActual);
+ return Assert.format(message, expected, actual);
+ }
- private void findCommonPrefix() {
- fPrefix= 0;
- int end= Math.min(fExpected.length(), fActual.length());
- for (; fPrefix < end; fPrefix++) {
- if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix))
- break;
- }
- }
+ private String compactString(String source) {
+ String result = DELTA_START + source.substring(fPrefix, source.length() - fSuffix + 1) + DELTA_END;
+ if (fPrefix > 0) {
+ result = computeCommonPrefix() + result;
+ }
+ if (fSuffix > 0) {
+ result = result + computeCommonSuffix();
+ }
+ return result;
+ }
- private void findCommonSuffix() {
- int expectedSuffix= fExpected.length() - 1;
- int actualSuffix= fActual.length() - 1;
- for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) {
- if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix))
- break;
- }
- fSuffix= fExpected.length() - expectedSuffix;
- }
+ private void findCommonPrefix() {
+ fPrefix = 0;
+ int end = Math.min(fExpected.length(), fActual.length());
+ for (; fPrefix < end; fPrefix++) {
+ if (fExpected.charAt(fPrefix) != fActual.charAt(fPrefix)) {
+ break;
+ }
+ }
+ }
- private String computeCommonPrefix() {
- return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);
- }
+ private void findCommonSuffix() {
+ int expectedSuffix = fExpected.length() - 1;
+ int actualSuffix = fActual.length() - 1;
+ for (; actualSuffix >= fPrefix && expectedSuffix >= fPrefix; actualSuffix--, expectedSuffix--) {
+ if (fExpected.charAt(expectedSuffix) != fActual.charAt(actualSuffix)) {
+ break;
+ }
+ }
+ fSuffix = fExpected.length() - expectedSuffix;
+ }
- private String computeCommonSuffix() {
- int end= Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());
- return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : "");
- }
+ private String computeCommonPrefix() {
+ return (fPrefix > fContextLength ? ELLIPSIS : "") + fExpected.substring(Math.max(0, fPrefix - fContextLength), fPrefix);
+ }
- private boolean areStringsEqual() {
- return fExpected.equals(fActual);
- }
+ private String computeCommonSuffix() {
+ int end = Math.min(fExpected.length() - fSuffix + 1 + fContextLength, fExpected.length());
+ return fExpected.substring(fExpected.length() - fSuffix + 1, end) + (fExpected.length() - fSuffix + 1 < fExpected.length() - fContextLength ? ELLIPSIS : "");
+ }
+
+ private boolean areStringsEqual() {
+ return fExpected.equals(fActual);
+ }
}
View
90 src/main/java/junit/framework/ComparisonFailure.java
@@ -2,51 +2,55 @@
/**
* Thrown when an assert equals for Strings failed.
- *
+ *
* Inspired by a patch from Alex Chaffee mailto:alex@purpletech.com
*/
public class ComparisonFailure extends AssertionFailedError {
- private static final int MAX_CONTEXT_LENGTH= 20;
- private static final long serialVersionUID= 1L;
-
- private String fExpected;
- private String fActual;
+ private static final int MAX_CONTEXT_LENGTH = 20;
+ private static final long serialVersionUID = 1L;
- /**
- * Constructs a comparison failure.
- * @param message the identifying message or null
- * @param expected the expected string value
- * @param actual the actual string value
- */
- public ComparisonFailure (String message, String expected, String actual) {
- super (message);
- fExpected= expected;
- fActual= actual;
- }
-
- /**
- * Returns "..." in place of common prefix and "..." in
- * place of common suffix between expected and actual.
- *
- * @see Throwable#getMessage()
- */
- @Override
- public String getMessage() {
- return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
- }
-
- /**
- * Gets the actual string value
- * @return the actual string value
- */
- public String getActual() {
- return fActual;
- }
- /**
- * Gets the expected string value
- * @return the expected string value
- */
- public String getExpected() {
- return fExpected;
- }
+ private String fExpected;
+ private String fActual;
+
+ /**
+ * Constructs a comparison failure.
+ *
+ * @param message the identifying message or null
+ * @param expected the expected string value
+ * @param actual the actual string value
+ */
+ public ComparisonFailure(String message, String expected, String actual) {
+ super(message);
+ fExpected = expected;
+ fActual = actual;
+ }
+
+ /**
+ * Returns "..." in place of common prefix and "..." in
+ * place of common suffix between expected and actual.
+ *
+ * @see Throwable#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return new ComparisonCompactor(MAX_CONTEXT_LENGTH, fExpected, fActual).compact(super.getMessage());
+ }
+
+ /**
+ * Gets the actual string value
+ *
+ * @return the actual string value
+ */
+ public String getActual() {
+ return fActual;
+ }
+
+ /**
+ * Gets the expected string value
+ *
+ * @return the expected string value
+ */
+ public String getExpected() {
+ return fExpected;
+ }
}
View
137 src/main/java/junit/framework/JUnit4TestAdapter.java
@@ -14,72 +14,73 @@
import org.junit.runner.manipulation.Sorter;
public class JUnit4TestAdapter implements Test, Filterable, Sortable, Describable {
- private final Class<?> fNewTestClass;
-
- private final Runner fRunner;
-
- private final JUnit4TestAdapterCache fCache;
-
- public JUnit4TestAdapter(Class<?> newTestClass) {
- this(newTestClass, JUnit4TestAdapterCache.getDefault());
- }
-
- public JUnit4TestAdapter(final Class<?> newTestClass,
- JUnit4TestAdapterCache cache) {
- fCache = cache;
- fNewTestClass = newTestClass;
- fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();
- }
-
- public int countTestCases() {
- return fRunner.testCount();
- }
-
- public void run(TestResult result) {
- fRunner.run(fCache.getNotifier(result, this));
- }
-
- // reflective interface for Eclipse
- public List<Test> getTests() {
- return fCache.asTestList(getDescription());
- }
-
- // reflective interface for Eclipse
- public Class<?> getTestClass() {
- return fNewTestClass;
- }
-
- public Description getDescription() {
- Description description= fRunner.getDescription();
- return removeIgnored(description);
- }
-
- private Description removeIgnored(Description description) {
- if (isIgnored(description))
- return Description.EMPTY;
- Description result = description.childlessCopy();
- for (Description each : description.getChildren()) {
- Description child= removeIgnored(each);
- if (! child.isEmpty())
- result.addChild(child);
- }
- return result;
- }
-
- private boolean isIgnored(Description description) {
- return description.getAnnotation(Ignore.class) != null;
- }
-
- @Override
- public String toString() {
- return fNewTestClass.getName();
- }
-
- public void filter(Filter filter) throws NoTestsRemainException {
- filter.apply(fRunner);
- }
-
- public void sort(Sorter sorter) {
- sorter.apply(fRunner);
- }
+ private final Class<?> fNewTestClass;
+
+ private final Runner fRunner;
+
+ private final JUnit4TestAdapterCache fCache;
+
+ public JUnit4TestAdapter(Class<?> newTestClass) {
+ this(newTestClass, JUnit4TestAdapterCache.getDefault());
+ }
+
+ public JUnit4TestAdapter(final Class<?> newTestClass, JUnit4TestAdapterCache cache) {
+ fCache = cache;
+ fNewTestClass = newTestClass;
+ fRunner = Request.classWithoutSuiteMethod(newTestClass).getRunner();
+ }
+
+ public int countTestCases() {
+ return fRunner.testCount();
+ }
+
+ public void run(TestResult result) {
+ fRunner.run(fCache.getNotifier(result, this));
+ }
+
+ // reflective interface for Eclipse
+ public List<Test> getTests() {
+ return fCache.asTestList(getDescription());
+ }
+
+ // reflective interface for Eclipse
+ public Class<?> getTestClass() {
+ return fNewTestClass;
+ }
+
+ public Description getDescription() {
+ Description description = fRunner.getDescription();
+ return removeIgnored(description);
+ }
+
+ private Description removeIgnored(Description description) {
+ if (isIgnored(description)) {
+ return Description.EMPTY;
+ }
+ Description result = description.childlessCopy();
+ for (Description each : description.getChildren()) {
+ Description child = removeIgnored(each);
+ if (!child.isEmpty()) {
+ result.addChild(child);
+ }
+ }
+ return result;
+ }
+
+ private boolean isIgnored(Description description) {
+ return description.getAnnotation(Ignore.class) != null;
+ }
+
+ @Override
+ public String toString() {
+ return fNewTestClass.getName();
+ }
+
+ public void filter(Filter filter) throws NoTestsRemainException {
+ filter.apply(fRunner);
+ }
+
+ public void sort(Sorter sorter) {
+ sorter.apply(fRunner);
+ }
}
View
116 src/main/java/junit/framework/JUnit4TestAdapterCache.java
@@ -1,6 +1,3 @@
-/**
- *
- */
package junit.framework;
import java.util.ArrayList;
@@ -14,68 +11,67 @@
import org.junit.runner.notification.RunNotifier;
public class JUnit4TestAdapterCache extends HashMap<Description, Test> {
- private static final long serialVersionUID = 1L;
- private static final JUnit4TestAdapterCache fInstance = new JUnit4TestAdapterCache();
+ private static final long serialVersionUID = 1L;
+ private static final JUnit4TestAdapterCache fInstance = new JUnit4TestAdapterCache();
- public static JUnit4TestAdapterCache getDefault() {
- return fInstance;
- }
-
- public Test asTest(Description description) {
- if (description.isSuite())
- return createTest(description);
- else {
- if (!containsKey(description))
- put(description, createTest(description));
- return get(description);
- }
- }
+ public static JUnit4TestAdapterCache getDefault() {
+ return fInstance;
+ }
- Test createTest(Description description) {
- if (description.isTest())
- return new JUnit4TestCaseFacade(description);
- else {
- TestSuite suite = new TestSuite(description.getDisplayName());
- for (Description child : description.getChildren())
- suite.addTest(asTest(child));
- return suite;
- }
- }
+ public Test asTest(Description description) {
+ if (description.isSuite()) {
+ return createTest(description);
+ } else {
+ if (!containsKey(description)) {
+ put(description, createTest(description));
+ }
+ return get(description);
+ }
+ }
- public RunNotifier getNotifier(final TestResult result,
- final JUnit4TestAdapter adapter) {
- RunNotifier notifier = new RunNotifier();
- notifier.addListener(new RunListener() {
- @Override
- public void testFailure(Failure failure) throws Exception {
- result.addError(asTest(failure.getDescription()), failure.getException());
- }
+ Test createTest(Description description) {
+ if (description.isTest()) {
+ return new JUnit4TestCaseFacade(description);
+ } else {
+ TestSuite suite = new TestSuite(description.getDisplayName());
+ for (Description child : description.getChildren()) {
+ suite.addTest(asTest(child));
+ }
+ return suite;
+ }
+ }
- @Override
- public void testFinished(Description description)
- throws Exception {
- result.endTest(asTest(description));
- }
+ public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) {
+ RunNotifier notifier = new RunNotifier();
+ notifier.addListener(new RunListener() {
+ @Override
+ public void testFailure(Failure failure) throws Exception {
+ result.addError(asTest(failure.getDescription()), failure.getException());
+ }
- @Override
- public void testStarted(Description description)
- throws Exception {
- result.startTest(asTest(description));
- }
- });
- return notifier;
- }
+ @Override
+ public void testFinished(Description description) throws Exception {
+ result.endTest(asTest(description));
+ }
- public List<Test> asTestList(Description description) {
- if (description.isTest())
- return Arrays.asList(asTest(description));
- else {
- List<Test> returnThis = new ArrayList<Test>();
- for (Description child : description.getChildren()) {
- returnThis.add(asTest(child));
- }
- return returnThis;
- }
- }
+ @Override
+ public void testStarted(Description description) throws Exception {
+ result.startTest(asTest(description));
+ }
+ });
+ return notifier;
+ }
+
+ public List<Test> asTestList(Description description) {
+ if (description.isTest()) {
+ return Arrays.asList(asTest(description));
+ } else {
+ List<Test> returnThis = new ArrayList<Test>();
+ for (Description child : description.getChildren()) {
+ returnThis.add(asTest(child));
+ }
+ return returnThis;
+ }
+ }
}
View
39 src/main/java/junit/framework/JUnit4TestCaseFacade.java
@@ -1,33 +1,30 @@
-/**
- *
- */
package junit.framework;
import org.junit.runner.Describable;
import org.junit.runner.Description;
public class JUnit4TestCaseFacade implements Test, Describable {
- private final Description fDescription;
+ private final Description fDescription;
- JUnit4TestCaseFacade(Description description) {
- fDescription = description;
- }
+ JUnit4TestCaseFacade(Description description) {
+ fDescription = description;
+ }
- @Override
- public String toString() {
- return getDescription().toString();
- }
+ @Override
+ public String toString() {
+ return getDescription().toString();
+ }
- public int countTestCases() {
- return 1;
- }
+ public int countTestCases() {
+ return 1;
+ }
- public void run(TestResult result) {
- throw new RuntimeException(
- "This test stub created only for informational purposes.");
- }
+ public void run(TestResult result) {
+ throw new RuntimeException(
+ "This test stub created only for informational purposes.");
+ }
- public Description getDescription() {
- return fDescription;
- }
+ public Description getDescription() {
+ return fDescription;
+ }
}
View
8 src/main/java/junit/framework/Protectable.java
@@ -7,8 +7,8 @@
*/
public interface Protectable {
- /**
- * Run the the following method protected.
- */
- public abstract void protect() throws Throwable;
+ /**
+ * Run the the following method protected.
+ */
+ public abstract void protect() throws Throwable;
}
View
17 src/main/java/junit/framework/Test.java
@@ -6,12 +6,13 @@
* @see TestResult
*/
public interface Test {
- /**
- * Counts the number of test cases that will be run by this test.
- */
- public abstract int countTestCases();
- /**
- * Runs a test and collects its result in a TestResult instance.
- */
- public abstract void run(TestResult result);
+ /**
+ * Counts the number of test cases that will be run by this test.
+ */
+ public abstract int countTestCases();
+
+ /**
+ * Runs a test and collects its result in a TestResult instance.
+ */
+ public abstract void run(TestResult result);
}
View
938 src/main/java/junit/framework/TestCase.java
@@ -74,473 +74,473 @@
* @see TestSuite
*/
public abstract class TestCase extends Assert implements Test {
- /**
- * the name of the test case
- */
- private String fName;
-
- /**
- * No-arg constructor to enable serialization. This method
- * is not intended to be used by mere mortals without calling setName().
- */
- public TestCase() {
- fName= null;
- }
-
- /**
- * Constructs a test case with the given name.
- */
- public TestCase(String name) {
- fName= name;
- }
-
- /**
- * Counts the number of test cases executed by run(TestResult result).
- */
- public int countTestCases() {
- return 1;
- }
-
- /**
- * Creates a default TestResult object
- *
- * @see TestResult
- */
- protected TestResult createResult() {
- return new TestResult();
- }
-
- /**
- * A convenience method to run this test, collecting the results with a
- * default TestResult object.
- *
- * @see TestResult
- */
- public TestResult run() {
- TestResult result= createResult();
- run(result);
- return result;
- }
-
- /**
- * Runs the test case and collects the results in TestResult.
- */
- public void run(TestResult result) {
- result.run(this);
- }
-
- /**
- * Runs the bare test sequence.
- *
- * @throws Throwable if any exception is thrown
- */
- public void runBare() throws Throwable {
- Throwable exception= null;
- setUp();
- try {
- runTest();
- } catch(Throwable running) {
- exception = running;
- } finally {
- try {
- tearDown();
- } catch(Throwable tearingDown) {
- if (exception == null) exception = tearingDown;
- }
- }
- if (exception != null) throw exception;
- }
-
- /**
- * Override to run the test and assert its state.
- *
- * @throws Throwable if any exception is thrown
- */
- protected void runTest() throws Throwable {
- assertNotNull("TestCase.fName cannot be null", fName); // Some VMs crash when calling getMethod(null,null);
- Method runMethod= null;
- try {
- // use getMethod to get all public inherited
- // methods. getDeclaredMethods returns all
- // methods of this class but excludes the
- // inherited ones.
- runMethod = getClass().getMethod(fName, (Class[]) null);
- } catch(NoSuchMethodException e) {
- fail("Method \"" + fName + "\" not found");
- }
- if (!Modifier.isPublic(runMethod.getModifiers())) {
- fail("Method \"" + fName + "\" should be public");
- }
-
- try {
- runMethod.invoke(this);
- } catch(InvocationTargetException e) {
- e.fillInStackTrace();
- throw e.getTargetException();
- } catch(IllegalAccessException e) {
- e.fillInStackTrace();
- throw e;
- }
- }
-
- /**
- * 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);
- }
-
- /**
- * 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);
- }
-
- /**
- * 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);
- }
-
- /**
- * 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);
- }
-
- /**
- * Fails a test with the given message.
- */
- @SuppressWarnings("deprecation")
- public static void fail(String message) {
- Assert.fail(message);
- }
-
- /**
- * Fails a test with no message.
- */
- @SuppressWarnings("deprecation")
- public static void fail() {
- Assert.fail();
- }
-
- /**
- * 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);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two Strings are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(String message, String expected, String actual) {
- Assert.assertEquals(message, expected, actual);
- }
-
- /**
- * Asserts that two Strings are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(String expected, String actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * Asserts that two doubles are equal concerning a delta. If they 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, double expected, double actual, double delta) {
- Assert.assertEquals(message, expected, actual, delta);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two floats are equal concerning a positive delta. If they
- * 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);
- }
-
- /**
- * 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);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two longs are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(long expected, long actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two booleans are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(boolean expected, boolean actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two bytes are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(byte expected, byte actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two chars are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(char expected, char actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two shorts are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(short expected, short actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that two ints are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertEquals(int expected, int actual) {
- Assert.assertEquals(expected, actual);
- }
-
- /**
- * Asserts that an object isn't null.
- */
- @SuppressWarnings("deprecation")
- public static void assertNotNull(Object object) {
- Assert.assertNotNull(object);
- }
-
- /**
- * 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);
- }
-
- /**
- * Asserts that an object is null. If it isn't an {@link AssertionError} is
- * thrown.
- * Message contains: Expected: <null> but was: object
- *
- * @param object Object to check or <code>null</code>
- */
- @SuppressWarnings("deprecation")
- public static void assertNull(Object object) {
- Assert.assertNull(object);
- }
-
- /**
- * Asserts that an object is null. If it is not