Skip to content

Introduce a DelegatingSmartContextLoader [SPR-8387] #13034

Closed
@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-8387 and commented

Status Quo

Placing an empty @ContextConfiguration annotation on a test class signals that default resource locations should be generated. Without declaring a specific ContextLoader, GenericXmlContextLoader will be used by default, which generates a default XML resource location.

With the introduction of AnnotationConfigContextLoader in Spring 3.1 M2, it would be nice if the TestContext framework supported a look-up mechanism to determine which ContextLoader (from a list of candidates) should be used to generate default resource locations or configuration classes and eventually load the context.

Goals

Introduce a DelegatingSmartContextLoader that delegates to a candidate SmartContextLoader list to determine which context loader is able to generate default resource locations or configuration classes for a given test class. The winning candidate should then be used to actually load the context.

Implementation Notes

By default, DelegatingSmartContextLoader should delegate to GenericXmlContextLoader and AnnotationConfigContextLoader, in that order. GenericPropertiesContextLoader will not be included by default.

Furthermore, the new SmartContextLoader SPI will have to provide support to query a SmartContextLoader to determine if the context loader is capable of generating default resource locations or configuration classes. Implementations must preemptively determine if the generated default(s) actually exists.

Depending on time and complexity, the implementation may or may not be generic in terms of whether it knows explicitly about only GenericXmlContextLoader and AnnotationConfigContextLoader or whether it supports any number of configured SmartContextLoader candidates.


Affects: 3.1 M2

Issue Links:

Referenced from: commits 72da569, 9a40021, a298c2d, d0cd678, 4611199, 21f3f59, f874ed9, e7298a8, e34fa6a, b8624b4, d2e6f82, 12eb9d7, 8e497d9, 4aed64e, 4cbe2ae, 19fc200, 4ef895a, b49d11f

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions