File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
module/spring-boot-reactor-netty/src
main/java/org/springframework/boot/reactor/netty/autoconfigure
test/java/org/springframework/boot/reactor/netty/autoconfigure Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 2323import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
2424import org .springframework .boot .autoconfigure .condition .ConditionalOnClass ;
2525import org .springframework .boot .autoconfigure .condition .ConditionalOnMissingBean ;
26+ import org .springframework .boot .autoconfigure .condition .ConditionalOnWebApplication ;
27+ import org .springframework .boot .autoconfigure .condition .ConditionalOnWebApplication .Type ;
2628import org .springframework .boot .context .properties .EnableConfigurationProperties ;
2729import org .springframework .boot .reactor .netty .NettyReactiveWebServerFactory ;
2830import org .springframework .boot .reactor .netty .NettyRouteProvider ;
4244 * server.
4345 *
4446 * @author Andy Wilkinson
47+ * @author Daeho Kwon
4548 * @since 4.0.0
4649 */
4750@ AutoConfiguration
4851@ ConditionalOnClass ({ ReactiveHttpInputMessage .class , HttpServer .class })
52+ @ ConditionalOnWebApplication (type = Type .REACTIVE )
4953@ EnableConfigurationProperties (NettyServerProperties .class )
5054@ Import ({ ReactiveWebServerConfiguration .class , ReactorResourceFactoryConfiguration .class })
5155public final class NettyReactiveWebServerAutoConfiguration {
Original file line number Diff line number Diff line change 1919import org .junit .jupiter .api .Test ;
2020import reactor .netty .http .server .HttpServer ;
2121
22+ import org .springframework .boot .autoconfigure .AutoConfigurations ;
2223import org .springframework .boot .reactor .netty .NettyReactiveWebServerFactory ;
2324import org .springframework .boot .reactor .netty .NettyServerCustomizer ;
25+ import org .springframework .boot .test .context .runner .ApplicationContextRunner ;
2426import org .springframework .boot .web .server .WebServerFactoryCustomizer ;
2527import org .springframework .boot .web .server .autoconfigure .reactive .AbstractReactiveWebServerAutoConfigurationTests ;
28+ import org .springframework .boot .web .server .reactive .ReactiveWebServerFactory ;
2629import org .springframework .context .annotation .Bean ;
2730import org .springframework .context .annotation .Configuration ;
2831
3942 * @author Raheela Aslam
4043 * @author Madhura Bhave
4144 * @author Scott Frederick
45+ * @author Daeho Kwon
4246 */
4347// @DirtiesUrlFactories
4448class NettyReactiveWebServerAutoConfigurationTests extends AbstractReactiveWebServerAutoConfigurationTests {
@@ -67,6 +71,13 @@ void nettyServerCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
6771 });
6872 }
6973
74+ @ Test
75+ void autoConfigurationDoesNotApplyToNonWebApplication () {
76+ new ApplicationContextRunner ()
77+ .withConfiguration (AutoConfigurations .of (NettyReactiveWebServerAutoConfiguration .class ))
78+ .run ((context ) -> assertThat (context ).doesNotHaveBean (ReactiveWebServerFactory .class ));
79+ }
80+
7081 @ Configuration (proxyBeanMethods = false )
7182 static class NettyServerCustomizerConfiguration {
7283
You can’t perform that action at this time.
0 commit comments