|
1 | 1 | /* |
2 | | - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
19 | 19 | import org.junit.jupiter.api.Test; |
20 | 20 |
|
21 | 21 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
| 22 | +import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; |
| 23 | +import org.springframework.boot.logging.LogLevel; |
22 | 24 | import org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer; |
23 | 25 | import org.springframework.boot.rsocket.context.RSocketServerBootstrap; |
24 | 26 | import org.springframework.boot.rsocket.server.RSocketServerCustomizer; |
25 | 27 | import org.springframework.boot.rsocket.server.RSocketServerFactory; |
| 28 | +import org.springframework.boot.test.context.FilteredClassLoader; |
26 | 29 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
27 | 30 | import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; |
28 | 31 | import org.springframework.boot.web.server.WebServerFactoryCustomizer; |
29 | 32 | import org.springframework.context.annotation.Bean; |
30 | 33 | import org.springframework.context.annotation.Configuration; |
31 | 34 | import org.springframework.core.codec.CharSequenceEncoder; |
32 | 35 | import org.springframework.core.codec.StringDecoder; |
| 36 | +import org.springframework.http.client.reactive.ReactorResourceFactory; |
33 | 37 | import org.springframework.messaging.rsocket.RSocketStrategies; |
34 | 38 | import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler; |
35 | 39 |
|
@@ -106,6 +110,14 @@ void shouldUseCustomNettyRouteProvider() { |
106 | 110 | .containsExactly("customNettyRouteProvider")); |
107 | 111 | } |
108 | 112 |
|
| 113 | + @Test |
| 114 | + void whenSpringWebIsNotPresentThenEmbeddedServerConfigurationBacksOff() { |
| 115 | + contextRunner().withClassLoader(new FilteredClassLoader(ReactorResourceFactory.class)) |
| 116 | + .withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)) |
| 117 | + .withPropertyValues("spring.rsocket.server.port=0") |
| 118 | + .run((context) -> assertThat(context).doesNotHaveBean(RSocketServerFactory.class)); |
| 119 | + } |
| 120 | + |
109 | 121 | private ApplicationContextRunner contextRunner() { |
110 | 122 | return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.class) |
111 | 123 | .withConfiguration(AutoConfigurations.of(RSocketServerAutoConfiguration.class)); |
|
0 commit comments