use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.
the class ReactiveManagementContextFactoryTests method createManagementContextShouldCreateChildContextWithConfigClasses.
@Test
void createManagementContextShouldCreateChildContextWithConfigClasses() {
this.parent.register(ParentConfiguration.class);
this.parent.refresh();
AnnotationConfigReactiveWebServerApplicationContext childContext = (AnnotationConfigReactiveWebServerApplicationContext) this.factory.createManagementContext(this.parent, TestConfiguration1.class, TestConfiguration2.class);
childContext.refresh();
assertThat(childContext.getBean(TestConfiguration1.class)).isNotNull();
assertThat(childContext.getBean(TestConfiguration2.class)).isNotNull();
assertThat(childContext.getBean(ReactiveWebServerFactoryAutoConfiguration.class)).isNotNull();
childContext.close();
this.parent.close();
}
use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.
the class TomcatMetricsAutoConfigurationTests method autoConfiguresTomcatMetricsWithEmbeddedReactiveTomcat.
@Test
void autoConfiguresTomcatMetricsWithEmbeddedReactiveTomcat() {
resetTomcatState();
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(TomcatMetricsAutoConfiguration.class, ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(ReactiveWebServerConfiguration.class, MeterRegistryConfiguration.class).withPropertyValues("server.tomcat.mbeanregistry.enabled=true").run((context) -> {
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
assertThat(registry.find("tomcat.sessions.active.max").meter()).isNotNull();
assertThat(registry.find("tomcat.threads.current").meter()).isNotNull();
});
}
use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.
the class ReactiveManagementContextFactory method createManagementContext.
@Override
public ConfigurableWebServerApplicationContext createManagementContext(ApplicationContext parent, Class<?>... configClasses) {
AnnotationConfigReactiveWebServerApplicationContext child = new AnnotationConfigReactiveWebServerApplicationContext();
child.setParent(parent);
Class<?>[] combinedClasses = ObjectUtils.addObjectToArray(configClasses, ReactiveWebServerFactoryAutoConfiguration.class);
child.register(combinedClasses);
registerReactiveWebServerFactory(parent, child);
return child;
}
use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.
the class ReactiveWebServerFactoryAutoConfigurationTests method tomcatContextCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void tomcatContextCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(HttpHandlerConfiguration.class, DoubleRegistrationTomcatContextCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
TomcatReactiveWebServerFactory factory = context.getBean(TomcatReactiveWebServerFactory.class);
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
then(customizer).should().customize(any(Context.class));
});
}
use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.
the class RSocketWebSocketNettyRouteProviderTests method webEndpointsShouldWork.
@Test
void webEndpointsShouldWork() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class, ErrorWebFluxAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, JacksonAutoConfiguration.class, CodecsAutoConfiguration.class, RSocketStrategiesAutoConfiguration.class, RSocketServerAutoConfiguration.class, RSocketMessagingAutoConfiguration.class, RSocketRequesterAutoConfiguration.class)).withUserConfiguration(WebConfiguration.class).withPropertyValues("spring.rsocket.server.transport=websocket", "spring.rsocket.server.mapping-path=/rsocket").run((context) -> {
ReactiveWebServerApplicationContext serverContext = (ReactiveWebServerApplicationContext) context.getSourceApplicationContext();
RSocketRequester requester = createRSocketRequester(context, serverContext.getWebServer());
TestProtocol rsocketResponse = requester.route("websocket").data(new TestProtocol("rsocket")).retrieveMono(TestProtocol.class).block(Duration.ofSeconds(3));
assertThat(rsocketResponse.getName()).isEqualTo("rsocket");
WebTestClient client = createWebTestClient(serverContext.getWebServer());
client.get().uri("/protocol").exchange().expectStatus().isOk().expectBody().jsonPath("name", "http");
});
}
Aggregations