use of org.springframework.boot.rsocket.server.RSocketServer in project spring-boot by spring-projects.
the class RSocketPortInfoApplicationContextInitializerTests method whenServerHasNoAddressThenInitializerDoesNotSetPortProperty.
@Test
void whenServerHasNoAddressThenInitializerDoesNotSetPortProperty() {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class)) {
context.getBean(RSocketPortInfoApplicationContextInitializer.class).initialize(context);
RSocketServer server = mock(RSocketServer.class);
context.publishEvent(new RSocketServerInitializedEvent(server));
then(server).should().address();
assertThat(context.getEnvironment().getProperty("local.rsocket.server.port")).isNull();
}
}
use of org.springframework.boot.rsocket.server.RSocketServer in project spring-boot by spring-projects.
the class RSocketPortInfoApplicationContextInitializerTests method whenServerHasAddressThenInitializerSetsPortProperty.
@Test
void whenServerHasAddressThenInitializerSetsPortProperty() {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class)) {
context.getBean(RSocketPortInfoApplicationContextInitializer.class).initialize(context);
RSocketServer server = mock(RSocketServer.class);
given(server.address()).willReturn(new InetSocketAddress(65535));
context.publishEvent(new RSocketServerInitializedEvent(server));
assertThat(context.getEnvironment().getProperty("local.rsocket.server.port")).isEqualTo("65535");
}
}
Aggregations