|
20 | 20 |
|
21 | 21 | import org.apache.commons.logging.Log; |
22 | 22 | import org.apache.commons.logging.LogFactory; |
| 23 | + |
23 | 24 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
24 | 25 | import org.springframework.context.ApplicationContext; |
25 | 26 | import org.springframework.context.ConfigurableApplicationContext; |
26 | 27 | import org.springframework.mock.web.MockHttpServletRequest; |
27 | 28 | import org.springframework.mock.web.MockHttpServletResponse; |
28 | 29 | import org.springframework.mock.web.MockServletContext; |
29 | 30 | import org.springframework.test.context.TestContext; |
30 | | -import org.springframework.test.context.support.AbstractTestExecutionListener; |
| 31 | +import org.springframework.test.context.TestExecutionListener; |
31 | 32 | import org.springframework.web.context.WebApplicationContext; |
32 | 33 | import org.springframework.web.context.request.RequestContextHolder; |
33 | 34 | import org.springframework.web.context.request.ServletWebRequest; |
|
38 | 39 | * @author Sam Brannen |
39 | 40 | * @since 3.2 |
40 | 41 | */ |
41 | | -public class ServletTestExecutionListener extends AbstractTestExecutionListener { |
| 42 | +public class ServletTestExecutionListener implements TestExecutionListener { |
42 | 43 |
|
43 | 44 | private static final Log logger = LogFactory.getLog(ServletTestExecutionListener.class); |
44 | 45 |
|
45 | 46 |
|
| 47 | + /** |
| 48 | + * The default implementation is <em>empty</em>. Can be overridden by |
| 49 | + * subclasses as necessary. |
| 50 | + * |
| 51 | + * @see org.springframework.test.context.TestExecutionListener#beforeTestClass(TestContext) |
| 52 | + */ |
| 53 | + public void beforeTestClass(TestContext testContext) throws Exception { |
| 54 | + /* no-op */ |
| 55 | + } |
| 56 | + |
46 | 57 | /** |
47 | 58 | * TODO [SPR-9864] Document overridden prepareTestInstance(). |
48 | 59 | * |
49 | | - * @see org.springframework.test.context.support.AbstractTestExecutionListener#prepareTestInstance(org.springframework.test.context.TestContext) |
| 60 | + * @see org.springframework.test.context.TestExecutionListener#prepareTestInstance(TestContext) |
50 | 61 | */ |
51 | | - @Override |
52 | 62 | public void prepareTestInstance(TestContext testContext) throws Exception { |
53 | 63 | setUpRequestContextIfNecessary(testContext); |
54 | 64 | } |
55 | 65 |
|
56 | 66 | /** |
57 | 67 | * TODO [SPR-9864] Document overridden beforeTestMethod(). |
58 | 68 | * |
59 | | - * @see org.springframework.test.context.support.AbstractTestExecutionListener#beforeTestMethod(org.springframework.test.context.TestContext) |
| 69 | + * @see org.springframework.test.context.TestExecutionListener#beforeTestMethod(TestContext) |
60 | 70 | */ |
61 | | - @Override |
62 | 71 | public void beforeTestMethod(TestContext testContext) throws Exception { |
63 | 72 | setUpRequestContextIfNecessary(testContext); |
64 | 73 | } |
65 | 74 |
|
| 75 | + /** |
| 76 | + * TODO [SPR-9864] Document overridden afterTestMethod(). |
| 77 | + * |
| 78 | + * @see org.springframework.test.context.TestExecutionListener#afterTestMethod(TestContext) |
| 79 | + */ |
| 80 | + public void afterTestMethod(TestContext testContext) throws Exception { |
| 81 | + if (logger.isDebugEnabled()) { |
| 82 | + logger.debug(String.format("Resetting RequestContextHolder for test context %s.", testContext)); |
| 83 | + } |
| 84 | + RequestContextHolder.resetRequestAttributes(); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * The default implementation is <em>empty</em>. Can be overridden by |
| 89 | + * subclasses as necessary. |
| 90 | + * |
| 91 | + * @see org.springframework.test.context.TestExecutionListener#afterTestClass(TestContext) |
| 92 | + */ |
| 93 | + public void afterTestClass(TestContext testContext) throws Exception { |
| 94 | + /* no-op */ |
| 95 | + } |
| 96 | + |
66 | 97 | /** |
67 | 98 | * TODO [SPR-9864] Document setUpRequestContext(). |
68 | 99 | * |
@@ -106,17 +137,4 @@ private void setUpRequestContextIfNecessary(TestContext testContext) { |
106 | 137 | } |
107 | 138 | } |
108 | 139 |
|
109 | | - /** |
110 | | - * TODO [SPR-9864] Document overridden afterTestMethod(). |
111 | | - * |
112 | | - * @see org.springframework.test.context.support.AbstractTestExecutionListener#afterTestMethod(org.springframework.test.context.TestContext) |
113 | | - */ |
114 | | - @Override |
115 | | - public void afterTestMethod(TestContext testContext) throws Exception { |
116 | | - if (logger.isDebugEnabled()) { |
117 | | - logger.debug(String.format("Resetting RequestContextHolder for test context %s.", testContext)); |
118 | | - } |
119 | | - RequestContextHolder.resetRequestAttributes(); |
120 | | - } |
121 | | - |
122 | 140 | } |
0 commit comments