Skip to content

Allow a TestExecutionListener to configure the ApplicationContext [SPR-5185] #9858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Sep 29, 2008 · 4 comments
Assignees
Labels
in: test Issues in the test module status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

Tuomas Kiviaho opened SPR-5185 and commented

Status Quo

Currently the application context gets refreshed by the loader itself. So the only option to configure the XmlBeanDefinitionReader, PassthoughSourceExtrator, etc. without a double refresh is to extend or implement a ContextLoader.

Proposal

A ContextLoader could return a non-refreshed ApplicationContext to the TestContextManager and leave refreshing to a new configurable application context aware TestExecutionListener that would ensure that the ApplicationContext has been properly initialized before test methods and refresh it as needed or every time (based on the presence of the @DirtiesContext annotation).


Affects: 2.5.5

Attachments:

3 votes, 4 watchers

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Sep 29, 2008

Tuomas Kiviaho commented

I commented #9309 a while back about utilizing test execution listeners to register default annotation post processors (and shutdown hook). This one goes to the same area.

@spring-projects-issues
Copy link
Collaborator Author

Tuomas Kiviaho commented

Extending of the context loader and test execution listeners could be made transparent to the tests themselves (Spring JavaConfig for instance requires explicit 'loader' definition for each type.

Patches contain direct ServiceLoader implementation which allows treating any interface/abstract class as service but expanding target @ContextConfiguration to package level would be an alternative (and in my opinion more elegant) approach. I have no idea how @Inherited is supposed work on package level but I guess it doesn't mean parent folder.

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Tuomas Kiviaho, with the new support for ApplicationContextInitializers introduced in Spring Framework 3.2, do you still see a need for programmatic configuration of the ApplicationContext beyond what one can achieve with an ApplicationContextInitializer?

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Since there have not been any comments of votes for this issue in several years, I am resolving this issue as Won't Fix, based on the assumption that support for ApplicationContextInitializers is sufficient.

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply in: test Issues in the test module type: enhancement A general enhancement labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants