From a6387dc725e9913d9ade35b2b56f136df0e8243c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 11 Dec 2012 01:58:10 +0100 Subject: [PATCH] Document WebApplicationContext support in the TCF This commit adds Javadoc documentation for the WebApplicationContext testing support that was recently introduced in the Spring TestContext Framework. Issue: SPR-9864 --- .../AnnotationConfigContextLoaderUtils.java | 4 +- .../web/AbstractGenericWebContextLoader.java | 114 ++++++++++++++++-- .../web/AnnotationConfigWebContextLoader.java | 36 ++++-- .../web/GenericXmlWebContextLoader.java | 7 +- .../web/ServletTestExecutionListener.java | 39 ++++-- .../test/context/web/WebAppConfiguration.java | 29 ++++- .../web/WebMergedContextConfiguration.java | 44 ++++++- 7 files changed, 236 insertions(+), 37 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java index 78c60e9bf5..1c46076587 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtils.java @@ -23,10 +23,12 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.SmartContextLoader; import org.springframework.util.Assert; /** - * TODO [SPR-9864] Document AnnotationConfigContextLoaderUtils. + * Utility methods for {@link SmartContextLoader SmartContextLoaders} that deal + * with annotated classes (e.g., {@link Configuration @Configuration} classes). * * @author Sam Brannen * @since 3.2 diff --git a/spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.java b/spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.java index 42bdc7ee46..8b02eb4c32 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/AbstractGenericWebContextLoader.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.support.DefaultListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; @@ -34,10 +35,26 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext; /** - * TODO [SPR-9864] Document AbstractGenericWebContextLoader. + * Abstract, generic extension of {@link AbstractContextLoader} that loads a + * {@link GenericWebApplicationContext}. + * + *

If instances of concrete subclasses are invoked via the + * {@link org.springframework.test.context.SmartContextLoader SmartContextLoader} + * SPI, the context will be loaded from the {@link MergedContextConfiguration} + * provided to {@link #loadContext(MergedContextConfiguration)}. In such cases, a + * {@code SmartContextLoader} will decide whether to load the context from + * locations or annotated classes. Note that {@code + * AbstractGenericWebContextLoader} does not support the {@code + * loadContext(String... locations)} method from the legacy + * {@link org.springframework.test.context.ContextLoader ContextLoader} SPI. + * + *

Concrete subclasses must provide an appropriate implementation of + * {@link #loadBeanDefinitions()}. * * @author Sam Brannen * @since 3.2 + * @see #loadContext(MergedContextConfiguration) + * @see #loadContext(String...) */ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoader { @@ -47,9 +64,33 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa // --- SmartContextLoader ----------------------------------------------- /** - * TODO [SPR-9864] Document overridden loadContext(MergedContextConfiguration). + * Load a Spring {@link WebApplicationContext} from the supplied + * {@link MergedContextConfiguration}. * - * @see org.springframework.test.context.SmartContextLoader#loadContext(org.springframework.test.context.MergedContextConfiguration) + *

Implementation details: + * + *

+ * + * @return a new web application context + * @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration) + * @see GenericWebApplicationContext */ public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { @@ -78,7 +119,29 @@ public abstract class AbstractGenericWebContextLoader extends AbstractContextLoa } /** - * TODO [SPR-9864] Document configureWebResources(). + * Configures web resources for the supplied web application context. + * + *

Implementation details: + * + *