Search in sources :

Example 21 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method contextAlreadyHasNonDispatcherServlet.

@Test
public void contextAlreadyHasNonDispatcherServlet() throws Exception {
    this.context = new AnnotationConfigServletWebServerApplicationContext(NonSpringServletConfiguration.class, BaseConfiguration.class);
    // the non default servlet is still registered
    verifyContext();
    assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length).isEqualTo(0);
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) Test(org.junit.Test)

Example 22 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method contextAlreadyHasDispatcherServletWithDefaultName.

@Test
public void contextAlreadyHasDispatcherServletWithDefaultName() throws Exception {
    this.context = new AnnotationConfigServletWebServerApplicationContext(DispatcherServletConfiguration.class, BaseConfiguration.class);
    verifyContext();
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) Test(org.junit.Test)

Example 23 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method contextAlreadyHasNonServlet.

@Test
public void contextAlreadyHasNonServlet() throws Exception {
    this.context = new AnnotationConfigServletWebServerApplicationContext(NonServletConfiguration.class, BaseConfiguration.class);
    assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length).isEqualTo(0);
    assertThat(this.context.getBeanNamesForType(Servlet.class).length).isEqualTo(0);
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) Servlet(javax.servlet.Servlet) FrameworkServlet(org.springframework.web.servlet.FrameworkServlet) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) Test(org.junit.Test)

Example 24 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerFactoryAutoConfigurationTests method customizeWebServerFactoryThroughCallback.

@Test
public void customizeWebServerFactoryThroughCallback() throws Exception {
    this.context = new AnnotationConfigServletWebServerApplicationContext(CallbackEmbeddedServerFactoryCustomizer.class, BaseConfiguration.class);
    verifyContext();
    assertThat(getWebServerFactory().getPort()).isEqualTo(9000);
}
Also used : AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) Test(org.junit.Test)

Example 25 with AnnotationConfigServletWebServerApplicationContext

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

the class ServletWebServerServletContextListenerTests method registeredServletContextListenerBeanIsCalled.

private void registeredServletContextListenerBeanIsCalled(Class<?> configuration) {
    AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(ServletListenerRegistrationBeanConfiguration.class, configuration);
    ServletContextListener servletContextListener = (ServletContextListener) context.getBean("registration", ServletListenerRegistrationBean.class).getListener();
    verify(servletContextListener).contextInitialized(any(ServletContextEvent.class));
    context.close();
}
Also used : ServletContextListener(javax.servlet.ServletContextListener) AnnotationConfigServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext) ServletContextEvent(javax.servlet.ServletContextEvent)

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