|
39 | 39 | import org.springframework.test.annotation.Repeat;
|
40 | 40 | import org.springframework.test.annotation.Timed;
|
41 | 41 | import org.springframework.test.context.TestContextManager;
|
42 |
| -import org.springframework.test.context.junit4.statements.RunSpringTestContextAfters; |
43 |
| -import org.springframework.test.context.junit4.statements.RunSpringTestContextBefores; |
| 42 | +import org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks; |
| 43 | +import org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks; |
| 44 | +import org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks; |
| 45 | +import org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks; |
44 | 46 | import org.springframework.test.context.junit4.statements.SpringFailOnTimeout;
|
45 | 47 | import org.springframework.test.context.junit4.statements.SpringRepeat;
|
46 | 48 |
|
@@ -142,20 +144,6 @@ protected String getDefaultContextLoaderClassName(Class<?> clazz) {
|
142 | 144 | return null;
|
143 | 145 | }
|
144 | 146 |
|
145 |
| - /** |
146 |
| - * Delegates to the parent implementation for creating the test instance and |
147 |
| - * then allows the {@link #getTestContextManager() TestContextManager} to |
148 |
| - * prepare the test instance before returning it. |
149 |
| - * |
150 |
| - * @see TestContextManager#prepareTestInstance(Object) |
151 |
| - */ |
152 |
| - @Override |
153 |
| - protected Object createTest() throws Exception { |
154 |
| - Object testInstance = super.createTest(); |
155 |
| - getTestContextManager().prepareTestInstance(testInstance); |
156 |
| - return testInstance; |
157 |
| - } |
158 |
| - |
159 | 147 | /**
|
160 | 148 | * Returns a description suitable for an ignored test class if the test is
|
161 | 149 | * disabled via <code>@IfProfileValue</code> at the class-level, and
|
@@ -191,6 +179,47 @@ public void run(RunNotifier notifier) {
|
191 | 179 | super.run(notifier);
|
192 | 180 | }
|
193 | 181 |
|
| 182 | + /** |
| 183 | + * Wraps the {@link Statement} returned by the parent implementation with a |
| 184 | + * {@link RunBeforeTestClassCallbacks} statement, thus preserving the |
| 185 | + * default functionality but adding support for the Spring TestContext |
| 186 | + * Framework. |
| 187 | + * |
| 188 | + * @see RunBeforeTestClassCallbacks |
| 189 | + */ |
| 190 | + @Override |
| 191 | + protected Statement withBeforeClasses(Statement statement) { |
| 192 | + Statement junitBeforeClasses = super.withBeforeClasses(statement); |
| 193 | + return new RunBeforeTestClassCallbacks(junitBeforeClasses, getTestContextManager()); |
| 194 | + } |
| 195 | + |
| 196 | + /** |
| 197 | + * Wraps the {@link Statement} returned by the parent implementation with a |
| 198 | + * {@link RunAfterTestClassCallbacks} statement, thus preserving the default |
| 199 | + * functionality but adding support for the Spring TestContext Framework. |
| 200 | + * |
| 201 | + * @see RunAfterTestClassCallbacks |
| 202 | + */ |
| 203 | + @Override |
| 204 | + protected Statement withAfterClasses(Statement statement) { |
| 205 | + Statement junitAfterClasses = super.withAfterClasses(statement); |
| 206 | + return new RunAfterTestClassCallbacks(junitAfterClasses, getTestContextManager()); |
| 207 | + } |
| 208 | + |
| 209 | + /** |
| 210 | + * Delegates to the parent implementation for creating the test instance and |
| 211 | + * then allows the {@link #getTestContextManager() TestContextManager} to |
| 212 | + * prepare the test instance before returning it. |
| 213 | + * |
| 214 | + * @see TestContextManager#prepareTestInstance(Object) |
| 215 | + */ |
| 216 | + @Override |
| 217 | + protected Object createTest() throws Exception { |
| 218 | + Object testInstance = super.createTest(); |
| 219 | + getTestContextManager().prepareTestInstance(testInstance); |
| 220 | + return testInstance; |
| 221 | + } |
| 222 | + |
194 | 223 | /**
|
195 | 224 | * Performs the same logic as
|
196 | 225 | * {@link BlockJUnit4ClassRunner#runChild(FrameworkMethod, RunNotifier)},
|
@@ -393,30 +422,31 @@ protected long getSpringTimeout(FrameworkMethod frameworkMethod) {
|
393 | 422 |
|
394 | 423 | /**
|
395 | 424 | * Wraps the {@link Statement} returned by the parent implementation with a
|
396 |
| - * {@link RunSpringTestContextBefores} statement, thus preserving the |
| 425 | + * {@link RunBeforeTestMethodCallbacks} statement, thus preserving the |
397 | 426 | * default functionality but adding support for the Spring TestContext
|
398 | 427 | * Framework.
|
399 | 428 | *
|
400 |
| - * @see RunSpringTestContextBefores |
| 429 | + * @see RunBeforeTestMethodCallbacks |
401 | 430 | */
|
402 | 431 | @Override
|
403 | 432 | protected Statement withBefores(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) {
|
404 | 433 | Statement junitBefores = super.withBefores(frameworkMethod, testInstance, statement);
|
405 |
| - return new RunSpringTestContextBefores(junitBefores, testInstance, frameworkMethod.getMethod(), |
| 434 | + return new RunBeforeTestMethodCallbacks(junitBefores, testInstance, frameworkMethod.getMethod(), |
406 | 435 | getTestContextManager());
|
407 | 436 | }
|
408 | 437 |
|
409 | 438 | /**
|
410 | 439 | * Wraps the {@link Statement} returned by the parent implementation with a
|
411 |
| - * {@link RunSpringTestContextAfters} statement, thus preserving the default |
412 |
| - * functionality but adding support for the Spring TestContext Framework. |
| 440 | + * {@link RunAfterTestMethodCallbacks} statement, thus preserving the |
| 441 | + * default functionality but adding support for the Spring TestContext |
| 442 | + * Framework. |
413 | 443 | *
|
414 |
| - * @see RunSpringTestContextAfters |
| 444 | + * @see RunAfterTestMethodCallbacks |
415 | 445 | */
|
416 | 446 | @Override
|
417 | 447 | protected Statement withAfters(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) {
|
418 | 448 | Statement junitAfters = super.withAfters(frameworkMethod, testInstance, statement);
|
419 |
| - return new RunSpringTestContextAfters(junitAfters, testInstance, frameworkMethod.getMethod(), |
| 449 | + return new RunAfterTestMethodCallbacks(junitAfters, testInstance, frameworkMethod.getMethod(), |
420 | 450 | getTestContextManager());
|
421 | 451 | }
|
422 | 452 |
|
|
0 commit comments