Search in sources :

Example 31 with AnnotationConfigServletWebServerApplicationContext

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

the class WebMvcAutoConfigurationTests method load.

private void load(Class<?> config, String... environment) {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, environment);
    List<Class<?>> configClasses = new ArrayList<>();
    if (config != null) {
        configClasses.add(config);
    }
    configClasses.addAll(Arrays.asList(Config.class, WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class));
    this.context.register(configClasses.toArray(new Class<?>[configClasses.size()]));
    this.context.refresh();
}
Also used : HttpMessageConvertersAutoConfiguration(org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration) AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) ArrayList(java.util.ArrayList) PropertyPlaceholderAutoConfiguration(org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration)

Example 32 with AnnotationConfigServletWebServerApplicationContext

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

the class FilterOrderingIntegrationTests method load.

private void load() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.session.store-type=hash-map");
    this.context.register(MockWebServerConfiguration.class, TestRedisConfiguration.class, WebMvcAutoConfiguration.class, SecurityAutoConfiguration.class, SessionAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, HttpEncodingAutoConfiguration.class);
    this.context.refresh();
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)

Example 33 with AnnotationConfigServletWebServerApplicationContext

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

the class MultipartAutoConfigurationTests method testWebServerWithCustomMultipartConfigEnabledSetting.

private void testWebServerWithCustomMultipartConfigEnabledSetting(final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.http.multipart.enabled=" + propertyValue);
    this.context.register(WebServerWithNoMultipartTomcat.class, BaseConfiguration.class);
    this.context.refresh();
    this.context.getBean(MultipartProperties.class);
    assertThat(this.context.getBeansOfType(MultipartConfigElement.class)).hasSize(expectedNumberOfMultipartConfigElementBeans);
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)

Example 34 with AnnotationConfigServletWebServerApplicationContext

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

the class MultipartAutoConfigurationTests method configureResolveLazily.

@Test
public void configureResolveLazily() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "spring.http.multipart.resolve-lazily=true");
    this.context.register(WebServerWithNothing.class, BaseConfiguration.class);
    this.context.refresh();
    StandardServletMultipartResolver multipartResolver = this.context.getBean(StandardServletMultipartResolver.class);
    boolean resolveLazily = (Boolean) ReflectionTestUtils.getField(multipartResolver, "resolveLazily");
    assertThat(resolveLazily).isTrue();
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) StandardServletMultipartResolver(org.springframework.web.multipart.support.StandardServletMultipartResolver) Test(org.junit.Test)

Example 35 with AnnotationConfigServletWebServerApplicationContext

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

the class MultipartAutoConfigurationTests method webServerWithNoMultipartUndertowConfiguration.

@Test
public void webServerWithNoMultipartUndertowConfiguration() {
    this.context = new AnnotationConfigServletWebServerApplicationContext(WebServerWithNoMultipartUndertow.class, BaseConfiguration.class);
    DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
    verifyServletWorks();
    assertThat(servlet.getMultipartResolver()).isNotNull();
    assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class)).hasSize(1);
    assertThat(this.context.getBeansOfType(MultipartResolver.class)).hasSize(1);
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) Test(org.junit.Test)

Aggregations

AnnotationConfigServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext)52 Test (org.junit.Test)41 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)8 BaseClientDetails (org.springframework.security.oauth2.provider.client.BaseClientDetails)7 ClientDetails (org.springframework.security.oauth2.provider.ClientDetails)6 Jsr250MethodSecurityMetadataSource (org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource)4 DelegatingMethodSecurityMetadataSource (org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource)4 MethodSecurityMetadataSource (org.springframework.security.access.method.MethodSecurityMetadataSource)4 ServerPortInfoApplicationContextInitializer (org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer)3 ServletContextEvent (javax.servlet.ServletContextEvent)2 ServletContextListener (javax.servlet.ServletContextListener)2 MethodSecurityExpressionHandler (org.springframework.security.access.expression.method.MethodSecurityExpressionHandler)2 PreInvocationAuthorizationAdvice (org.springframework.security.access.prepost.PreInvocationAuthorizationAdvice)2 PrePostAnnotationSecurityMetadataSource (org.springframework.security.access.prepost.PrePostAnnotationSecurityMetadataSource)2 OAuth2ClientContext (org.springframework.security.oauth2.client.OAuth2ClientContext)2 OAuth2MethodSecurityExpressionHandler (org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler)2 RestTemplate (org.springframework.web.client.RestTemplate)2 StandardServletMultipartResolver (org.springframework.web.multipart.support.StandardServletMultipartResolver)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1