类 AbstractDelegatingSmartContextLoader

  • 所有已实现的接口:
    ContextLoader, SmartContextLoader
    直接已知子类:
    DelegatingSmartContextLoader, WebDelegatingSmartContextLoader

    public abstract class AbstractDelegatingSmartContextLoader
    extends Object
    implements SmartContextLoader
    AbstractDelegatingSmartContextLoader serves as an abstract base class for implementations of the SmartContextLoader SPI that delegate to a set of candidate SmartContextLoaders (i.e., one that supports XML configuration files or Groovy scripts and one that supports annotated classes) to determine which context loader is appropriate for a given test class's configuration. Each candidate is given a chance to process the ContextConfigurationAttributes for each class in the test class hierarchy that is annotated with @ContextConfiguration, and the candidate that supports the merged, processed configuration will be used to actually load the context.

    Any reference to an XML-based loader can be interpreted to mean a context loader that supports only XML configuration files or one that supports both XML configuration files and Groovy scripts simultaneously.

    Placing an empty @ContextConfiguration annotation on a test class signals that default resource locations (e.g., XML configuration files or Groovy scripts) or default configuration classes should be detected. Furthermore, if a specific ContextLoader or SmartContextLoader is not explicitly declared via @ContextConfiguration, a concrete subclass of AbstractDelegatingSmartContextLoader will be used as the default loader, thus providing automatic support for either path-based resource locations (e.g., XML configuration files and Groovy scripts) or annotated classes, but not both simultaneously.

    As of Spring 3.2, a test class may optionally declare neither path-based resource locations nor annotated classes and instead declare only application context initializers. In such cases, an attempt will still be made to detect defaults, but their absence will not result in an exception.

    从以下版本开始:
    3.2
    作者:
    Sam Brannen, Phillip Webb
    另请参阅:
    SmartContextLoader