spring-framework / org.springframework.test.context.web

Package org.springframework.test.context.web

Types

AnnotationConfigWebContextLoader

open class AnnotationConfigWebContextLoader : AbstractGenericWebContextLoader

Concrete implementation of AbstractGenericWebContextLoader that loads bean definitions from annotated classes.

See the Javadoc for org.springframework.test.context.ContextConfiguration for a definition of annotated class.

Note: AnnotationConfigWebContextLoader supports annotated classes rather than the String-based resource locations defined by the legacy org.springframework.test.context.ContextLoader API. Thus, although AnnotationConfigWebContextLoader extends AbstractGenericWebContextLoader, AnnotationConfigWebContextLoader does not support any String-based methods defined by org.springframework.test.context.support.AbstractContextLoader or AbstractGenericWebContextLoader. Consequently, AnnotationConfigWebContextLoader should chiefly be considered a org.springframework.test.context.SmartContextLoader rather than a org.springframework.test.context.ContextLoader.

GenericGroovyXmlWebContextLoader

open class GenericGroovyXmlWebContextLoader : GenericXmlWebContextLoader

Concrete implementation of AbstractGenericWebContextLoader that loads bean definitions from Groovy scripts and XML configuration files.

Default resource locations are detected using the suffixes "-context.xml" and "Context.groovy".

WebDelegatingSmartContextLoader

open class WebDelegatingSmartContextLoader : AbstractDelegatingSmartContextLoader

WebDelegatingSmartContextLoader is a concrete implementation of AbstractDelegatingSmartContextLoader that delegates to a GenericXmlWebContextLoader (or a GenericGroovyXmlWebContextLoader if Groovy is present on the classpath) and an AnnotationConfigWebContextLoader.

WebMergedContextConfiguration

open class WebMergedContextConfiguration : MergedContextConfiguration

WebMergedContextConfiguration encapsulates the merged context configuration declared on a test class and all of its superclasses via org.springframework.test.context.ContextConfiguration, WebAppConfiguration, and org.springframework.test.context.ActiveProfiles.

WebMergedContextConfiguration extends the contract of MergedContextConfiguration by adding support for the configured via @WebAppConfiguration. This allows the org.springframework.test.context.TestContext to properly cache the corresponding that was loaded using properties of this WebMergedContextConfiguration.

WebTestContextBootstrapper

open class WebTestContextBootstrapper : DefaultTestContextBootstrapper

Web-specific implementation of the TestContextBootstrapper SPI.

  • Uses WebDelegatingSmartContextLoader as the default ContextLoader if the test class is annotated with WebAppConfiguration and otherwise delegates to the superclass.
  • Builds a WebMergedContextConfiguration if the test class is annotated with WebAppConfiguration.

Annotations

WebAppConfiguration

class WebAppConfiguration

@WebAppConfiguration is a class-level annotation that is used to declare that the ApplicationContext loaded for an integration test should be a org.springframework.web.context.WebApplicationContext.

The presence of @WebAppConfiguration on a test class indicates that a WebApplicationContext should be loaded for the test using a default for the path to the root of the web application. To override the default, specify an explicit resource path via the #value attribute.

Note that @WebAppConfiguration must be used in conjunction with org.springframework.test.context.ContextConfiguration, either within a single test class or within a test class hierarchy.

As of Spring Framework 4.0, this annotation may be used as a meta-annotation to create custom composed annotations.