use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext in project spring-boot by spring-projects.
the class MustacheAutoConfigurationTests method loadWithReactive.
private void loadWithReactive(Class<?> config) {
this.reactiveWebContext = new AnnotationConfigReactiveWebApplicationContext();
TestPropertyValues.of("spring.mustache.prefix=classpath:/mustache-templates/").applyTo(this.reactiveWebContext);
if (config != null) {
this.reactiveWebContext.register(config);
}
this.reactiveWebContext.register(BaseConfiguration.class);
this.reactiveWebContext.refresh();
}
use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext in project spring-boot by spring-projects.
the class DefaultErrorWebExceptionHandlerTests method nonStandardErrorStatusCodeShouldNotFail.
@Test
void nonStandardErrorStatusCodeShouldNotFail() {
ErrorAttributes errorAttributes = mock(ErrorAttributes.class);
given(errorAttributes.getErrorAttributes(any(), any())).willReturn(getErrorAttributes());
Resources resourceProperties = new Resources();
ErrorProperties errorProperties = new ErrorProperties();
ApplicationContext context = new AnnotationConfigReactiveWebApplicationContext();
DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, resourceProperties, errorProperties, context);
setupViewResolver(exceptionHandler);
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/some-other-path").accept(MediaType.TEXT_HTML));
exceptionHandler.handle(exchange, new RuntimeException()).block();
}
use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext in project spring-boot by spring-projects.
the class DefaultErrorWebExceptionHandlerTests method acceptsTextHtmlShouldNotConsiderMediaAllEvenWithQuality.
@Test
void acceptsTextHtmlShouldNotConsiderMediaAllEvenWithQuality() {
ErrorAttributes errorAttributes = mock(ErrorAttributes.class);
Resources resourceProperties = new Resources();
ErrorProperties errorProperties = new ErrorProperties();
ApplicationContext context = new AnnotationConfigReactiveWebApplicationContext();
DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, resourceProperties, errorProperties, context);
MediaType allWithQuality = new MediaType(MediaType.ALL.getType(), MediaType.ALL.getSubtype(), 0.9);
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/test").accept(allWithQuality));
List<HttpMessageReader<?>> readers = ServerCodecConfigurer.create().getReaders();
ServerRequest request = ServerRequest.create(exchange, readers);
assertThat(exceptionHandler.acceptsTextHtml().test(request)).isFalse();
}
Aggregations