19
19
import java .io .IOException ;
20
20
21
21
import org .junit .jupiter .api .Test ;
22
+ import reactor .core .publisher .Mono ;
22
23
23
24
import org .springframework .context .annotation .ComponentScan .Filter ;
24
25
import org .springframework .context .annotation .FilterType ;
30
31
import org .springframework .stereotype .Service ;
31
32
import org .springframework .web .bind .annotation .ControllerAdvice ;
32
33
import org .springframework .web .reactive .config .WebFluxConfigurer ;
34
+ import org .springframework .web .server .ServerWebExchange ;
35
+ import org .springframework .web .server .WebFilter ;
36
+ import org .springframework .web .server .WebFilterChain ;
33
37
34
38
import static org .assertj .core .api .Assertions .assertThat ;
35
39
@@ -52,6 +56,7 @@ void matchWhenHasNoControllers() throws Exception {
52
56
assertThat (excludes (filter , ExampleWeb .class )).isFalse ();
53
57
assertThat (excludes (filter , ExampleService .class )).isTrue ();
54
58
assertThat (excludes (filter , ExampleRepository .class )).isTrue ();
59
+ assertThat (excludes (filter , ExampleWebFilter .class )).isFalse ();
55
60
}
56
61
57
62
@ Test
@@ -63,6 +68,7 @@ void matchWhenHasController() throws Exception {
63
68
assertThat (excludes (filter , ExampleWeb .class )).isFalse ();
64
69
assertThat (excludes (filter , ExampleService .class )).isTrue ();
65
70
assertThat (excludes (filter , ExampleRepository .class )).isTrue ();
71
+ assertThat (excludes (filter , ExampleWebFilter .class )).isFalse ();
66
72
}
67
73
68
74
@ Test
@@ -74,6 +80,7 @@ void matchNotUsingDefaultFilters() throws Exception {
74
80
assertThat (excludes (filter , ExampleWeb .class )).isTrue ();
75
81
assertThat (excludes (filter , ExampleService .class )).isTrue ();
76
82
assertThat (excludes (filter , ExampleRepository .class )).isTrue ();
83
+ assertThat (excludes (filter , ExampleWebFilter .class )).isTrue ();
77
84
}
78
85
79
86
@ Test
@@ -85,6 +92,7 @@ void matchWithIncludeFilter() throws Exception {
85
92
assertThat (excludes (filter , ExampleWeb .class )).isFalse ();
86
93
assertThat (excludes (filter , ExampleService .class )).isTrue ();
87
94
assertThat (excludes (filter , ExampleRepository .class )).isFalse ();
95
+ assertThat (excludes (filter , ExampleWebFilter .class )).isFalse ();
88
96
}
89
97
90
98
@ Test
@@ -96,6 +104,7 @@ void matchWithExcludeFilter() throws Exception {
96
104
assertThat (excludes (filter , ExampleWeb .class )).isFalse ();
97
105
assertThat (excludes (filter , ExampleService .class )).isTrue ();
98
106
assertThat (excludes (filter , ExampleRepository .class )).isTrue ();
107
+ assertThat (excludes (filter , ExampleWebFilter .class )).isFalse ();
99
108
}
100
109
101
110
private boolean excludes (WebFluxTypeExcludeFilter filter , Class <?> type ) throws IOException {
@@ -157,4 +166,13 @@ static class ExampleRepository {
157
166
158
167
}
159
168
169
+ static class ExampleWebFilter implements WebFilter {
170
+
171
+ @ Override
172
+ public Mono <Void > filter (ServerWebExchange serverWebExchange , WebFilterChain webFilterChain ) {
173
+ return null ;
174
+ }
175
+
176
+ }
177
+
160
178
}
0 commit comments