Search in sources :

Example 36 with AnnotationConfigServletWebServerApplicationContext

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

the class MultipartAutoConfigurationTests method webServerWithNoMultipartTomcatConfiguration.

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

Example 37 with AnnotationConfigServletWebServerApplicationContext

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

the class MultipartAutoConfigurationTests method webServerWithNoMultipartJettyConfiguration.

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

Example 38 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method contextAlreadyHasDispatcherServletAndRegistration.

@Test
public void contextAlreadyHasDispatcherServletAndRegistration() throws Exception {
    this.context = new AnnotationConfigServletWebServerApplicationContext(DispatcherServletWithRegistrationConfiguration.class, BaseConfiguration.class);
    verifyContext();
    assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length).isEqualTo(1);
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) Test(org.junit.Test)

Example 39 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method initParametersAreConfiguredOnTheServletContext.

@Test
public void initParametersAreConfiguredOnTheServletContext() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    EnvironmentTestUtils.addEnvironment(this.context, "server.servlet.context-parameters.a:alpha", "server.servlet.context-parameters.b:bravo");
    this.context.register(BaseConfiguration.class);
    this.context.refresh();
    ServletContext servletContext = this.context.getServletContext();
    assertThat(servletContext.getInitParameter("a")).isEqualTo("alpha");
    assertThat(servletContext.getInitParameter("b")).isEqualTo("bravo");
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) ServletContext(javax.servlet.ServletContext) Test(org.junit.Test)

Example 40 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method createFromConfigClass.

@Test
public void createFromConfigClass() throws Exception {
    this.context = new AnnotationConfigServletWebServerApplicationContext(BaseConfiguration.class);
    verifyContext();
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) 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