|
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 | import org.springframework.util.unit.DataSize;
|
@@ -141,6 +145,14 @@ void shouldUseCustomNettyRouteProvider() {
|
141 | 145 | .containsExactly("customNettyRouteProvider"));
|
142 | 146 | }
|
143 | 147 |
|
| 148 | + @Test |
| 149 | + void whenSpringWebIsNotPresentThenEmbeddedServerConfigurationBacksOff() { |
| 150 | + contextRunner().withClassLoader(new FilteredClassLoader(ReactorResourceFactory.class)) |
| 151 | + .withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO)) |
| 152 | + .withPropertyValues("spring.rsocket.server.port=0") |
| 153 | + .run((context) -> assertThat(context).doesNotHaveBean(RSocketServerFactory.class)); |
| 154 | + } |
| 155 | + |
144 | 156 | private ApplicationContextRunner contextRunner() {
|
145 | 157 | return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.class)
|
146 | 158 | .withConfiguration(AutoConfigurations.of(RSocketServerAutoConfiguration.class));
|
|
0 commit comments