use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method webServerHasNoServletContext.
@Test
public void webServerHasNoServletContext() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(EnsureWebServerHasNoServletContext.class, BaseConfiguration.class);
verifyContext();
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method contextAlreadyHasDispatcherServlet.
@Test
public void contextAlreadyHasDispatcherServlet() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(SpringServletConfiguration.class, BaseConfiguration.class);
verifyContext();
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length).isEqualTo(2);
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project spring-boot by spring-projects.
the class ServletWebServerServletContextListenerTests method servletContextListenerBeanIsCalled.
private void servletContextListenerBeanIsCalled(Class<?> configuration) {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(ServletContextListenerBeanConfiguration.class, configuration);
ServletContextListener servletContextListener = context.getBean("servletContextListener", ServletContextListener.class);
verify(servletContextListener).contextInitialized(any(ServletContextEvent.class));
context.close();
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project spring-boot by spring-projects.
the class TomcatPublicMetricsTests method tomcatMetrics.
@Test
public void tomcatMetrics() throws Exception {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(Config.class);
try {
TomcatPublicMetrics tomcatMetrics = context.getBean(TomcatPublicMetrics.class);
Iterator<Metric<?>> metrics = tomcatMetrics.metrics().iterator();
assertThat(metrics.next().getName()).isEqualTo("httpsessions.max");
assertThat(metrics.next().getName()).isEqualTo("httpsessions.active");
assertThat(metrics.hasNext()).isFalse();
} finally {
context.close();
}
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext in project spring-boot by spring-projects.
the class OAuth2AutoConfigurationTests method testDefaultPrePostSecurityAnnotations.
@Test
public void testDefaultPrePostSecurityAnnotations() {
this.context = new AnnotationConfigServletWebServerApplicationContext();
this.context.register(AuthorizationAndResourceServerConfiguration.class, MinimalSecureWebApplication.class);
this.context.refresh();
this.context.getBean(OAuth2MethodSecurityConfiguration.class);
ClientDetails config = this.context.getBean(ClientDetails.class);
DelegatingMethodSecurityMetadataSource source = this.context.getBean(DelegatingMethodSecurityMetadataSource.class);
List<MethodSecurityMetadataSource> sources = source.getMethodSecurityMetadataSources();
assertThat(sources.size()).isEqualTo(1);
assertThat(sources.get(0).getClass().getName()).isEqualTo(PrePostAnnotationSecurityMetadataSource.class.getName());
verifyAuthentication(config);
}
Aggregations