Merge pull request #17301 from spencergibb
* pr/17301: Polish "Make rSocketServerBootstrap @ConditionalOnMissingBean" Make rSocketServerBootstrap @ConditionalOnMissingBean Closes gh-17301
This commit is contained in:
commit
e2d92b3914
|
|
@ -98,6 +98,7 @@ public class RSocketServerAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
public RSocketServerBootstrap rSocketServerBootstrap(RSocketServerFactory rSocketServerFactory,
|
public RSocketServerBootstrap rSocketServerBootstrap(RSocketServerFactory rSocketServerFactory,
|
||||||
RSocketMessageHandler rSocketMessageHandler) {
|
RSocketMessageHandler rSocketMessageHandler) {
|
||||||
return new RSocketServerBootstrap(rSocketServerFactory, rSocketMessageHandler.serverAcceptor());
|
return new RSocketServerBootstrap(rSocketServerFactory, rSocketMessageHandler.serverAcceptor());
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
|
||||||
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
|
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link RSocketServerAutoConfiguration}.
|
* Tests for {@link RSocketServerAutoConfiguration}.
|
||||||
|
|
@ -77,6 +78,12 @@ class RSocketServerAutoConfigurationTests {
|
||||||
.hasSingleBean(RSocketServerBootstrap.class));
|
.hasSingleBean(RSocketServerBootstrap.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shoudUseCustomServerBootstrap() {
|
||||||
|
contextRunner().withUserConfiguration(CustomServerBootstrapConfig.class).run((context) -> assertThat(context)
|
||||||
|
.getBeanNames(RSocketServerBootstrap.class).containsExactly("customServerBootstrap"));
|
||||||
|
}
|
||||||
|
|
||||||
private ApplicationContextRunner contextRunner() {
|
private ApplicationContextRunner contextRunner() {
|
||||||
return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.class)
|
return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.class)
|
||||||
.withConfiguration(AutoConfigurations.of(RSocketServerAutoConfiguration.class));
|
.withConfiguration(AutoConfigurations.of(RSocketServerAutoConfiguration.class));
|
||||||
|
|
@ -100,4 +107,14 @@ class RSocketServerAutoConfigurationTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
static class CustomServerBootstrapConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RSocketServerBootstrap customServerBootstrap() {
|
||||||
|
return mock(RSocketServerBootstrap.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue