Skip to content

Introduce SmartContextLoader SPI [SPR-8386] #13033

Closed

Description

@spring-projects-issues

Sam Brannen opened SPR-8386 and commented

Status Quo

The current ContextLoader SPI has the following shortcomings:

  • it only supports String-based resource locations, but we need first-class support for Class-based resources for @Configuration classes
  • it does not support the notion of bean definition profiles that were introduced in Spring 3.1 M1

Deliverables

  1. Introduce a new SmartContextLoader SPI that extends ContextLoader and supports both String[] and Class[] resources, likely retrieved from a new "context" parameter object as opposed to hard-coded, inflexible method signatures. This will replace the need for ResourceTypeAwareContextLoader and its ResourceType enum, and it will result in a more flexible SPI that is better suited to support future, unknown requirements.
  2. Refactor existing AnnotationConfigContextLoader, ContextLoaderUtils, and TestContext implementations to take advantage of the SmartContextLoader SPI
  3. Delete ResourceTypeAwareContextLoader
  4. Delete ContextLoaderUtils.LocationsResolver and implementations

Implementation Notes Regarding Profiles

Design the SmartContextLoader SPI so that a reference to the configured active profiles can be passed to a variant of loadContext(). This reference may potentially take the form of the "context" parameter object introduced with the new SmartContextLoader SPI. See AbstractGenericContextLoader's loadContext() method for an example of where the profiles would need to be set in the code (i.e., prior to refreshing the context).


Affects: 3.1 M2

Issue Links:

Activity

  1. spring-projects-issues commented on Jun 20, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Introduced a new SmartContextLoader SPI which supersedes the existing ContextLoader SPI by adding support for @Configuration classes and bean definition profiles.

    Introduced ContextConfigurationAttributes as an abstraction for parsed attributes from @ContextConfiguration declarations in the test hierarchy.

    Introduced MergedContextConfiguration as an abstraction for:

    • all processed and merged ContextConfigurationAttributes for a given test class hierarchy
    • merged bean definition profiles for the test class hierarchy
    • the resolved ContextLoader

    MergedContextConfiguration also generates a unique context key which is used by TestContext for ApplicationContext caching.

  2. added
    in: test
    type: enhancement
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: testtype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions