diff --git a/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java index 86e9a9f2a0..969234061e 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/ServletTestExecutionListener.java @@ -20,6 +20,7 @@ import javax.servlet.ServletContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; @@ -27,7 +28,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; import org.springframework.test.context.TestContext; -import org.springframework.test.context.support.AbstractTestExecutionListener; +import org.springframework.test.context.TestExecutionListener; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletWebRequest; @@ -38,17 +39,26 @@ import org.springframework.web.context.request.ServletWebRequest; * @author Sam Brannen * @since 3.2 */ -public class ServletTestExecutionListener extends AbstractTestExecutionListener { +public class ServletTestExecutionListener implements TestExecutionListener { private static final Log logger = LogFactory.getLog(ServletTestExecutionListener.class); + /** + * The default implementation is empty. Can be overridden by + * subclasses as necessary. + * + * @see org.springframework.test.context.TestExecutionListener#beforeTestClass(TestContext) + */ + public void beforeTestClass(TestContext testContext) throws Exception { + /* no-op */ + } + /** * TODO [SPR-9864] Document overridden prepareTestInstance(). * - * @see org.springframework.test.context.support.AbstractTestExecutionListener#prepareTestInstance(org.springframework.test.context.TestContext) + * @see org.springframework.test.context.TestExecutionListener#prepareTestInstance(TestContext) */ - @Override public void prepareTestInstance(TestContext testContext) throws Exception { setUpRequestContextIfNecessary(testContext); } @@ -56,13 +66,34 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener /** * TODO [SPR-9864] Document overridden beforeTestMethod(). * - * @see org.springframework.test.context.support.AbstractTestExecutionListener#beforeTestMethod(org.springframework.test.context.TestContext) + * @see org.springframework.test.context.TestExecutionListener#beforeTestMethod(TestContext) */ - @Override public void beforeTestMethod(TestContext testContext) throws Exception { setUpRequestContextIfNecessary(testContext); } + /** + * TODO [SPR-9864] Document overridden afterTestMethod(). + * + * @see org.springframework.test.context.TestExecutionListener#afterTestMethod(TestContext) + */ + public void afterTestMethod(TestContext testContext) throws Exception { + if (logger.isDebugEnabled()) { + logger.debug(String.format("Resetting RequestContextHolder for test context %s.", testContext)); + } + RequestContextHolder.resetRequestAttributes(); + } + + /** + * The default implementation is empty. Can be overridden by + * subclasses as necessary. + * + * @see org.springframework.test.context.TestExecutionListener#afterTestClass(TestContext) + */ + public void afterTestClass(TestContext testContext) throws Exception { + /* no-op */ + } + /** * TODO [SPR-9864] Document setUpRequestContext(). * @@ -106,17 +137,4 @@ public class ServletTestExecutionListener extends AbstractTestExecutionListener } } - /** - * TODO [SPR-9864] Document overridden afterTestMethod(). - * - * @see org.springframework.test.context.support.AbstractTestExecutionListener#afterTestMethod(org.springframework.test.context.TestContext) - */ - @Override - public void afterTestMethod(TestContext testContext) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug(String.format("Resetting RequestContextHolder for test context %s.", testContext)); - } - RequestContextHolder.resetRequestAttributes(); - } - }