use of org.springframework.web.testfixture.servlet.MockServletContext in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithServletConfig.
@Test
public void servletConfigAwareWithServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(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);
}
use of org.springframework.web.testfixture.servlet.MockServletContext in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithNonNullServletContextAndNullServletConfig.
@Test
public void servletConfigAwareWithNonNullServletContextAndNullServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, null);
ServletConfigAwareBean bean = new ServletConfigAwareBean();
assertThat(bean.getServletConfig()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletConfig()).isNull();
}
use of org.springframework.web.testfixture.servlet.MockServletContext in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithServletContextOnly.
@Test
public void servletConfigAwareWithServletContextOnly() {
ServletContext servletContext = new MockServletContext();
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.testfixture.servlet.MockServletContext in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletContextAwareWithServletContextAndServletConfig.
@Test
public void servletContextAwareWithServletContextAndServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, 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.testfixture.servlet.MockServletContext in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithNullServletContextAndNonNullServletConfig.
@Test
public void servletConfigAwareWithNullServletContextAndNonNullServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, 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