Include ServletTEL in abstract base test classes

The ServletTestExecutionListener is now prepended to the set of default
listeners in AbstractJUnit4SpringContextTests and
AbstractTestNGSpringContextTests.

Issue: SPR-11340
This commit is contained in:
Sam Brannen
2014-01-21 15:01:29 +01:00
parent 098d7c7465
commit 3370f8b1b1
4 changed files with 271 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.web.ServletTestExecutionListener;
/**
* Abstract base test class which integrates the <em>Spring TestContext
@@ -45,6 +46,15 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
* the appropriate {@link org.springframework.test.context.TestExecutionListener
* TestExecutionListeners} manually.</em>
*
* <p>The following {@link org.springframework.test.context.TestExecutionListener
* TestExecutionListeners} are configured by default:
*
* <ul>
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
* </ul>
*
* <p>Note: this class serves only as a convenience for extension. If you do not
* wish for your test classes to be tied to a Spring-specific class hierarchy,
* you may configure your own custom test classes by using
@@ -57,11 +67,16 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
* @see ContextConfiguration
* @see TestContext
* @see TestContextManager
* @see TestExecutionListeners
* @see ServletTestExecutionListener
* @see DependencyInjectionTestExecutionListener
* @see DirtiesContextTestExecutionListener
* @see AbstractTransactionalJUnit4SpringContextTests
* @see org.springframework.test.context.testng.AbstractTestNGSpringContextTests
*/
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })
@TestExecutionListeners({ ServletTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class })
public abstract class AbstractJUnit4SpringContextTests implements ApplicationContextAware {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.web.ServletTestExecutionListener;
import org.testng.IHookCallBack;
import org.testng.IHookable;
@@ -59,16 +60,30 @@ import org.testng.annotations.BeforeMethod;
* {@code super();}.</li>
* </ul>
*
* <p>The following {@link org.springframework.test.context.TestExecutionListener
* TestExecutionListeners} are configured by default:
*
* <ul>
* <li>{@link org.springframework.test.context.web.ServletTestExecutionListener}
* <li>{@link org.springframework.test.context.support.DependencyInjectionTestExecutionListener}
* <li>{@link org.springframework.test.context.support.DirtiesContextTestExecutionListener}
* </ul>
*
* @author Sam Brannen
* @author Juergen Hoeller
* @since 2.5
* @see ContextConfiguration
* @see TestContext
* @see TestContextManager
* @see TestExecutionListeners
* @see ServletTestExecutionListener
* @see DependencyInjectionTestExecutionListener
* @see DirtiesContextTestExecutionListener
* @see AbstractTransactionalTestNGSpringContextTests
* @see org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
*/
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })
@TestExecutionListeners({ ServletTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class })
public abstract class AbstractTestNGSpringContextTests implements IHookable, ApplicationContextAware {
/** Logger available to subclasses */