Search in sources :

Example 76 with AnnotationConfigWebApplicationContext

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

the class SecurityAutoConfigurationTests method testDisableIgnoredStaticApplicationPaths.

@Test
public void testDisableIgnoredStaticApplicationPaths() throws Exception {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.setServletContext(new MockServletContext());
    this.context.register(SecurityAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "security.ignored:none");
    this.context.refresh();
    // Just the application endpoints now
    assertThat(this.context.getBean(FilterChainProxy.class).getFilterChains()).hasSize(1);
}
Also used : FilterChainProxy(org.springframework.security.web.FilterChainProxy) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.Test)

Example 77 with AnnotationConfigWebApplicationContext

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

the class SecurityFilterAutoConfigurationTests method filterAutoConfigurationWorksWithoutSecurityAutoConfiguration.

@Test
public void filterAutoConfigurationWorksWithoutSecurityAutoConfiguration() throws Exception {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    try {
        context.register(Config.class);
        context.refresh();
    } finally {
        context.close();
    }
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) MockServletContext(org.springframework.mock.web.MockServletContext) Test(org.junit.Test)

Example 78 with AnnotationConfigWebApplicationContext

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

the class AbstractJpaAutoConfigurationTests method testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff.

@Test
public void testOpenEntityManagerInViewInterceptorNotRegisteredWhenExplicitlyOff() throws Exception {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    EnvironmentTestUtils.addEnvironment(context, "spring.jpa.open_in_view:false");
    context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, PropertyPlaceholderAutoConfiguration.class, getAutoConfigureClass());
    context.refresh();
    assertThat(getInterceptorBeans(context).length).isEqualTo(0);
    context.close();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Example 79 with AnnotationConfigWebApplicationContext

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

the class SitePreferenceAutoConfigurationTests method sitePreferenceHandlerInterceptorCreated.

@Test
public void sitePreferenceHandlerInterceptorCreated() {
    this.context = new AnnotationConfigWebApplicationContext();
    this.context.register(SitePreferenceAutoConfiguration.class);
    this.context.refresh();
    assertThat(this.context.getBean(SitePreferenceHandlerInterceptor.class)).isNotNull();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Example 80 with AnnotationConfigWebApplicationContext

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

the class SitePreferenceAutoConfigurationTests method sitePreferenceMethodArgumentResolverEnabled.

@Test
public void sitePreferenceMethodArgumentResolverEnabled() 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(SitePreferenceHandlerMethodArgumentResolver.class)).isNotNull();
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) Test(org.junit.Test)

Aggregations

AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)192 Test (org.junit.Test)129 MockServletContext (org.springframework.mock.web.MockServletContext)80 MockMvc (org.springframework.test.web.servlet.MockMvc)25 URI (java.net.URI)23 HashMap (java.util.HashMap)23 MapPropertySource (org.springframework.core.env.MapPropertySource)23 StandardEnvironment (org.springframework.core.env.StandardEnvironment)23 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)21 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)16 ProtobufMessageSerDe (com.kixeye.chassis.transport.serde.converter.ProtobufMessageSerDe)15 RestTemplate (org.springframework.web.client.RestTemplate)15 ServiceError (com.kixeye.chassis.transport.dto.ServiceError)14 JsonJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.JsonJacksonMessageSerDe)14 XmlMessageSerDe (com.kixeye.chassis.transport.serde.converter.XmlMessageSerDe)14 YamlJacksonMessageSerDe (com.kixeye.chassis.transport.serde.converter.YamlJacksonMessageSerDe)14 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)13 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)13 QueuingWebSocketListener (com.kixeye.chassis.transport.websocket.QueuingWebSocketListener)9 WebSocketMessageRegistry (com.kixeye.chassis.transport.websocket.WebSocketMessageRegistry)9