use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class SitePreferenceAutoConfigurationTests method sitePreferenceHandlerInterceptorRegistered.
@Test
public void sitePreferenceHandlerInterceptorRegistered() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(Config.class, WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, SitePreferenceAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
RequestMappingHandlerMapping mapping = this.context.getBean(RequestMappingHandlerMapping.class);
HandlerInterceptor[] interceptors = mapping.getHandler(new MockHttpServletRequest()).getInterceptors();
assertThat(interceptors).hasAtLeastOneElementOfType(SitePreferenceHandlerInterceptor.class);
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class SitePreferenceAutoConfigurationTests method sitePreferenceHandlerInterceptorEnabled.
@Test
public void sitePreferenceHandlerInterceptorEnabled() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.mobile.sitepreference.enabled:true");
this.context.register(SitePreferenceAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(SitePreferenceHandlerInterceptor.class)).isNotNull();
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class AbstractJpaAutoConfigurationTests method testOpenEntityManagerInViewInterceptorNotRegisteredWhenFilterPresent.
@Test
public void testOpenEntityManagerInViewInterceptorNotRegisteredWhenFilterPresent() throws Exception {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(TestFilterConfiguration.class, EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class, getAutoConfigureClass());
context.refresh();
assertThat(getInterceptorBeans(context).length).isEqualTo(0);
context.close();
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class DeviceResolverAutoConfigurationTests method deviceResolverHandlerInterceptorRegistered.
@Test
public void deviceResolverHandlerInterceptorRegistered() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(Config.class);
this.context.refresh();
RequestMappingHandlerMapping mapping = this.context.getBean(RequestMappingHandlerMapping.class);
HandlerInterceptor[] interceptors = mapping.getHandler(new MockHttpServletRequest()).getInterceptors();
assertThat(interceptors).hasAtLeastOneElementOfType(DeviceResolverHandlerInterceptor.class);
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class DeviceResolverAutoConfigurationTests method deviceResolverHandlerInterceptorCreated.
@Test
public void deviceResolverHandlerInterceptorCreated() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.register(DeviceResolverAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(DeviceResolverHandlerInterceptor.class)).isNotNull();
}
Aggregations