Properly close child contexts in destroy()

fixes gh-91
This commit is contained in:
Spencer Gibb
2016-02-22 10:49:54 -07:00
parent 624be9d19e
commit 86ff712398
2 changed files with 11 additions and 1 deletions

View File

@@ -47,6 +47,16 @@ public class NamedContextFactoryTests {
Map<String, Baz> barBazes = factory.getInstances("bar", Baz.class);
assertThat("barBazes was null", barBazes, is(notNullValue()));
assertThat("barBazes size was wrong", barBazes.size(), is(2));
// get the contexts before destroy() to verify these are the old ones
AnnotationConfigApplicationContext fooContext = factory.getContext("foo");
AnnotationConfigApplicationContext barContext = factory.getContext("bar");
factory.destroy();
assertThat("foo context wasn't closed", fooContext.isActive(), is(false));
assertThat("bar context wasn't closed", barContext.isActive(), is(false));
}
private TestSpec getSpec(String name, Class<?> configClass) {