use of org.springframework.web.context.ContextCleanupListener in project spring-framework by spring-projects.
the class WebApplicationContextScopeTests method testApplicationScope.
@Test
public void testApplicationScope() {
WebApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_APPLICATION);
assertThat(ac.getServletContext().getAttribute(NAME)).isNull();
DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
assertThat(ac.getServletContext().getAttribute(NAME)).isSameAs(bean);
assertThat(ac.getBean(NAME)).isSameAs(bean);
new ContextCleanupListener().contextDestroyed(new ServletContextEvent(ac.getServletContext()));
assertThat(bean.wasDestroyed()).isTrue();
}
Aggregations