Merge pull request #17301 from spencergibb

* pr/17301:
  Polish "Make rSocketServerBootstrap @ConditionalOnMissingBean"
  Make rSocketServerBootstrap @ConditionalOnMissingBean

Closes gh-17301
pull/17322/head
Brian Clozel 5 years ago
commit e2d92b3914

@ -98,6 +98,7 @@ public class RSocketServerAutoConfiguration {
}
@Bean
@ConditionalOnMissingBean
public RSocketServerBootstrap rSocketServerBootstrap(RSocketServerFactory rSocketServerFactory,
RSocketMessageHandler rSocketMessageHandler) {
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 static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link RSocketServerAutoConfiguration}.
@ -77,6 +78,12 @@ class RSocketServerAutoConfigurationTests {
.hasSingleBean(RSocketServerBootstrap.class));
}
@Test
void shoudUseCustomServerBootstrap() {
contextRunner().withUserConfiguration(CustomServerBootstrapConfig.class).run((context) -> assertThat(context)
.getBeanNames(RSocketServerBootstrap.class).containsExactly("customServerBootstrap"));
}
private ApplicationContextRunner contextRunner() {
return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.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…
Cancel
Save