use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class ConditionEvaluationReportLoggingListenerTests method canBeUsedInNonGenericApplicationContext.
@Test
void canBeUsedInNonGenericApplicationContext() {
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(Config.class);
new ConditionEvaluationReportLoggingListener().initialize(context);
context.refresh();
assertThat(context.getBean(ConditionEvaluationReport.class)).isNotNull();
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class ConditionalOnWebApplicationTests method testWebApplicationWithServletContext.
@Test
void testWebApplicationWithServletContext() {
AnnotationConfigServletWebApplicationContext ctx = new AnnotationConfigServletWebApplicationContext();
ctx.register(AnyWebApplicationConfiguration.class, ServletWebApplicationConfiguration.class, ReactiveWebApplicationConfiguration.class);
ctx.setServletContext(new MockServletContext());
ctx.refresh();
this.context = ctx;
assertThat(this.context.getBeansOfType(String.class)).containsExactly(entry("any", "any"), entry("servlet", "servlet"));
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class SecurityFilterAutoConfigurationTests method filterAutoConfigurationWorksWithoutSecurityAutoConfiguration.
@Test
void filterAutoConfigurationWorksWithoutSecurityAutoConfiguration() {
try (AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext()) {
context.setServletContext(new MockServletContext());
context.register(Config.class);
context.refresh();
}
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class ControllerEndpointWebMvcIntegrationTests method endpointsCanBeAccessed.
@Test
void endpointsCanBeAccessed() throws Exception {
TestSecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigServletWebApplicationContext();
this.context.register(SecureConfiguration.class, ExampleController.class);
TestPropertyValues.of("management.endpoints.web.base-path:/management", "management.endpoints.web.exposure.include=*").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/example")).andExpect(status().isOk());
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class ControllerEndpointWebMvcIntegrationTests method endpointsAreSecureByDefault.
@Test
void endpointsAreSecureByDefault() throws Exception {
this.context = new AnnotationConfigServletWebApplicationContext();
this.context.register(SecureConfiguration.class, ExampleController.class);
MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/actuator/example").accept(MediaType.APPLICATION_JSON)).andExpect(status().isUnauthorized());
}
Aggregations