Merge pull request #5672 from izeye/context-close
* context-close: Close the context in TypeExcludeFilterTests
This commit is contained in:
commit
57a665cbef
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.context;
|
package org.springframework.boot.context;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
@ -42,19 +43,27 @@ public class TypeExcludeFilterTests {
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
|
private AnnotationConfigApplicationContext context;
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanUp() {
|
||||||
|
if (this.context != null) {
|
||||||
|
this.context.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void loadsTypeExcludeFilters() throws Exception {
|
public void loadsTypeExcludeFilters() throws Exception {
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
context.getBeanFactory().registerSingleton("filter1",
|
this.context.getBeanFactory().registerSingleton("filter1",
|
||||||
new WithoutMatchOverrideFilter());
|
new WithoutMatchOverrideFilter());
|
||||||
context.getBeanFactory().registerSingleton("filter2",
|
this.context.getBeanFactory().registerSingleton("filter2",
|
||||||
new SampleTypeExcludeFilter());
|
new SampleTypeExcludeFilter());
|
||||||
context.register(Config.class);
|
this.context.register(Config.class);
|
||||||
context.refresh();
|
this.context.refresh();
|
||||||
assertThat(context.getBean(ExampleComponent.class)).isNotNull();
|
assertThat(this.context.getBean(ExampleComponent.class)).isNotNull();
|
||||||
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
this.thrown.expect(NoSuchBeanDefinitionException.class);
|
||||||
context.getBean(ExampleFilteredComponent.class);
|
this.context.getBean(ExampleFilteredComponent.class);
|
||||||
context.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue