use of org.springframework.web.server.handler.WebHandlerDecorator in project spring-boot by spring-projects.
the class HttpHandlerAutoConfigurationTests method shouldConfigureWebFiltersAnnotation.
@Test
public void shouldConfigureWebFiltersAnnotation() {
load(AnnotationConfigWithWebFilters.class);
HttpHandler handler = this.context.getBean(HttpHandler.class);
assertThat(handler).isInstanceOf(WebHandler.class);
WebHandler webHandler = (WebHandler) handler;
while (webHandler instanceof WebHandlerDecorator) {
if (webHandler instanceof FilteringWebHandler) {
FilteringWebHandler filteringWebHandler = (FilteringWebHandler) webHandler;
assertThat(filteringWebHandler.getFilters()).containsExactly(this.context.getBean("firstWebFilter", WebFilter.class), this.context.getBean("aWebFilter", WebFilter.class), this.context.getBean("lastWebFilter", WebFilter.class));
return;
}
webHandler = ((WebHandlerDecorator) webHandler).getDelegate();
}
fail("Did not find any FilteringWebHandler");
}
use of org.springframework.web.server.handler.WebHandlerDecorator in project spring-boot by spring-projects.
the class HttpHandlerAutoConfigurationTests method shouldConfigureWebFiltersFunctional.
@Test
public void shouldConfigureWebFiltersFunctional() {
load(FunctionalConfigWithWebFilters.class);
assertThat(this.context.getBeansOfType(HttpHandler.class).size()).isEqualTo(1);
HttpHandler handler = this.context.getBean(HttpHandler.class);
assertThat(handler).isInstanceOf(WebHandler.class);
WebHandler webHandler = (WebHandler) handler;
while (webHandler instanceof WebHandlerDecorator) {
if (webHandler instanceof FilteringWebHandler) {
FilteringWebHandler filteringWebHandler = (FilteringWebHandler) webHandler;
assertThat(filteringWebHandler.getFilters()).containsExactly(this.context.getBean("customWebFilter", WebFilter.class));
return;
}
webHandler = ((WebHandlerDecorator) webHandler).getDelegate();
}
fail("Did not find any FilteringWebHandler");
}
Aggregations