Properly close context hierarchy in tests

Prior to this commit, some tests were creating a parent/child
relationship but were only closing the child context. This could
be an issue with the autoconfig module as a lot of auto-config
kicks in by default.

This commit adds a new test utility designed to properly handle
those situations. Updated tests that were creating a context
hierarchy to benefit from that.

Fixes gh-1034
This commit is contained in:
Stephane Nicoll
2014-06-11 14:45:39 +02:00
committed by Dave Syer
parent f83395b40c
commit b646231327
6 changed files with 112 additions and 17 deletions

View File

@@ -27,6 +27,7 @@ import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.ApplicationContextTestUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
@@ -55,9 +56,7 @@ public class BasicErrorControllerDirectMockMvcTests {
@After
public void close() {
if (this.wac != null) {
this.wac.close();
}
ApplicationContextTestUtils.closeAll(this.wac);
}
public void setup(ConfigurableWebApplicationContext context) {