Search in sources :

Example 1 with ServletContextAware

use of org.springframework.web.context.ServletContextAware in project spring-security by spring-projects.

the class AutowireBeanFactoryObjectPostProcessorTests method postProcessWhenServletContextAwareThenAwareInvoked.

@Test
public void postProcessWhenServletContextAwareThenAwareInvoked() {
    this.spring.register(Config.class).autowire();
    ServletContextAware toPostProcess = mock(ServletContextAware.class);
    this.objectObjectPostProcessor.postProcess(toPostProcess);
    verify(toPostProcess).setServletContext(isNotNull());
}
Also used : ServletContextAware(org.springframework.web.context.ServletContextAware) Test(org.junit.jupiter.api.Test)

Example 2 with ServletContextAware

use of org.springframework.web.context.ServletContextAware in project spring-boot by spring-projects.

the class ServletWebServerApplicationContextTests method servletContextAwareBeansAreInjected.

@Test
void servletContextAwareBeansAreInjected() {
    addWebServerFactoryBean();
    ServletContextAware bean = mock(ServletContextAware.class);
    this.context.registerBeanDefinition("bean", beanDefinition(bean));
    this.context.refresh();
    then(bean).should().setServletContext(getWebServerFactory().getServletContext());
}
Also used : ServletContextAware(org.springframework.web.context.ServletContextAware) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 ServletContextAware (org.springframework.web.context.ServletContextAware)2