Skip to content
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

ApplicationContext not closed when using @ContextConfiguration to implement integration tests [SPR-5395] #10068

Closed
spring-projects-issues opened this issue Jan 5, 2009 · 3 comments
Assignees
Labels
in: test Issues in the test module status: duplicate A duplicate of another issue type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jan 5, 2009

Keith Donald opened SPR-5395 and commented

I am seeing side-effects in an integration test that initializes a Spring ApplicationContext using @ContextConfiguration. Specifically, close() on the context does not appear to be being called, ever. I noticed this because one of my DispoableBeans is not receiving a destroy() callback and that is what is causing the side-effect [which pops up when a @test runs in another, unrelated TestCase class].

I understand a test ApplicationContext is cached between test methods, but I would still expect the context to be closed after all tests have run, before moving on to the next test class in the suite.


Affects: 3.0 M1

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jan 5, 2009

Keith Donald commented

Some information from Colin Sampaleanu on this:


Keith, unfortunately it's not at all clear to me that there should be any expectation that the should have close() called on it by default.

With the old AbstractDependencyInjectionSpringContextTests, the same app context was shared across all the test cases (that used the same context path(s)), and close was only called at the end of the test run, and there was a clear contract here to the extent that the two levels higher superclass of that explicitly mentions that close on the cached context(s) is done via a JVM shutdown hook and therefore woudl only happen when the entire test suite is done.

As for the new TestContext based code, the "contract" is a little bit greyer, but the docs

http://static.springframework.org/spring/docs/2.5.x/reference/testing.html#testcontext-framework
specifically mention the caching, and talk about the fact that a test method may dirty the context, and need to be annotated with @DirtiesContext, so that basically implies that close() would never be called otherwise.

What is probably needed is an annotation that can be applied to the whole class, which says to reload the context after this entire test case, but not after each method...

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 2, 2009

Sam Brannen commented

Duplicates #9379

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jul 6, 2009

Sam Brannen commented

Please note that support for using @DirtiesContext at the class level has been added for the upcoming Spring 3.0.0.RC1 release. Please try out the new feature and provide feedback.

For further details consult #9379 and #10311.

Thanks,

Sam

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: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants