Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.server.WebExceptionHandler;
import org.springframework.web.server.WebFilter;

/**
* {@link TypeExcludeFilter} for {@link WebFluxTest @WebFluxTest}.
Expand All @@ -51,6 +52,7 @@ class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizableTypeExclude
includes.add(Converter.class);
includes.add(GenericConverter.class);
includes.add(WebExceptionHandler.class);
includes.add(WebFilter.class);
DEFAULT_INCLUDES = Collections.unmodifiableSet(includes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.IOException;

import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;

import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;
Expand All @@ -30,6 +31,9 @@
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -52,6 +56,7 @@ void matchWhenHasNoControllers() throws Exception {
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
assertThat(excludes(filter, ExampleService.class)).isTrue();
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
assertThat(excludes(filter, ExampleWebFilter.class)).isFalse();
}

@Test
Expand All @@ -63,6 +68,7 @@ void matchWhenHasController() throws Exception {
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
assertThat(excludes(filter, ExampleService.class)).isTrue();
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
assertThat(excludes(filter, ExampleWebFilter.class)).isFalse();
}

@Test
Expand All @@ -74,6 +80,7 @@ void matchNotUsingDefaultFilters() throws Exception {
assertThat(excludes(filter, ExampleWeb.class)).isTrue();
assertThat(excludes(filter, ExampleService.class)).isTrue();
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
assertThat(excludes(filter, ExampleWebFilter.class)).isTrue();
}

@Test
Expand All @@ -85,6 +92,7 @@ void matchWithIncludeFilter() throws Exception {
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
assertThat(excludes(filter, ExampleService.class)).isTrue();
assertThat(excludes(filter, ExampleRepository.class)).isFalse();
assertThat(excludes(filter, ExampleWebFilter.class)).isFalse();
}

@Test
Expand All @@ -96,6 +104,7 @@ void matchWithExcludeFilter() throws Exception {
assertThat(excludes(filter, ExampleWeb.class)).isFalse();
assertThat(excludes(filter, ExampleService.class)).isTrue();
assertThat(excludes(filter, ExampleRepository.class)).isTrue();
assertThat(excludes(filter, ExampleWebFilter.class)).isFalse();
}

private boolean excludes(WebFluxTypeExcludeFilter filter, Class<?> type) throws IOException {
Expand Down Expand Up @@ -157,4 +166,13 @@ static class ExampleRepository {

}

static class ExampleWebFilter implements WebFilter {

@Override
public Mono<Void> filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) {
return null;
}

}

}