use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletContextAwareWithNullServletContextAndNonNullServletConfig.
@Test
public void servletContextAwareWithNullServletContextAndNonNullServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, servletConfig);
ServletContextAwareBean bean = new ServletContextAwareBean();
assertThat(bean.getServletContext()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletContext()).as("ServletContext should have been set").isNotNull();
assertThat(bean.getServletContext()).isEqualTo(servletContext);
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithNullServletContext.
@Test
public void servletConfigAwareWithNullServletContext() {
ServletContext servletContext = null;
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext);
ServletConfigAwareBean bean = new ServletConfigAwareBean();
assertThat(bean.getServletConfig()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletConfig()).isNull();
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletContextAwareWithNullServletContext.
@Test
public void servletContextAwareWithNullServletContext() {
ServletContext servletContext = null;
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext);
ServletContextAwareBean bean = new ServletContextAwareBean();
assertThat(bean.getServletContext()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletContext()).isNull();
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithServletContextAndServletConfig.
@Test
public void servletConfigAwareWithServletContextAndServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, servletConfig);
ServletConfigAwareBean bean = new ServletConfigAwareBean();
assertThat(bean.getServletConfig()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletConfig()).as("ServletConfig should have been set").isNotNull();
assertThat(bean.getServletConfig()).isEqualTo(servletConfig);
}
Aggregations