Search in sources :

Example 6 with AnnotationConfigReactiveWebServerApplicationContext

use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.

the class JettyMetricsAutoConfigurationTests method autoConfiguresSslHandshakeMetricsWithEmbeddedReactiveJetty.

@Test
void autoConfiguresSslHandshakeMetricsWithEmbeddedReactiveJetty() {
    new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(JettyMetricsAutoConfiguration.class, ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(ReactiveWebServerConfiguration.class, MeterRegistryConfiguration.class).withPropertyValues("server.ssl.enabled: true", "server.ssl.key-store: src/test/resources/test.jks", "server.ssl.key-store-password: secret", "server.ssl.key-password: password").run((context) -> {
        context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
        SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
        assertThat(registry.find("jetty.ssl.handshakes").meter()).isNotNull();
    });
}
Also used : AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Example 7 with AnnotationConfigReactiveWebServerApplicationContext

use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.

the class WebEndpointTestInvocationContextProvider method createWebFluxContext.

private static ConfigurableApplicationContext createWebFluxContext(List<Class<?>> classes) {
    AnnotationConfigReactiveWebServerApplicationContext context = new AnnotationConfigReactiveWebServerApplicationContext();
    classes.add(WebFluxEndpointConfiguration.class);
    context.register(ClassUtils.toClassArray(classes));
    context.refresh();
    return context;
}
Also used : AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext)

Example 8 with AnnotationConfigReactiveWebServerApplicationContext

use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.

the class WebFluxEndpointIntegrationTests method createApplicationContext.

private static AnnotationConfigReactiveWebServerApplicationContext createApplicationContext() {
    AnnotationConfigReactiveWebServerApplicationContext context = new AnnotationConfigReactiveWebServerApplicationContext();
    context.register(ReactiveConfiguration.class);
    return context;
}
Also used : AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext)

Example 9 with AnnotationConfigReactiveWebServerApplicationContext

use of org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext in project spring-boot by spring-projects.

the class ReactiveWebServerFactoryAutoConfigurationTests method tomcatContextCustomizerBeanIsAddedToFactory.

@Test
void tomcatContextCustomizerBeanIsAddedToFactory() {
    ReactiveWebApplicationContextRunner runner = new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withUserConfiguration(HttpHandlerConfiguration.class, TomcatContextCustomizerConfiguration.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));
    });
}
Also used : TomcatContextCustomizer(org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer) AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) Context(org.apache.catalina.Context) TomcatReactiveWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotationConfigReactiveWebServerApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext)9 Test (org.junit.jupiter.api.Test)6 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)5 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 Context (org.apache.catalina.Context)2 TomcatContextCustomizer (org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer)2 TomcatReactiveWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory)2 AnnotationConfigReactiveWebApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext)2 ReactiveWebServerApplicationContext (org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext)1 RSocketRequester (org.springframework.messaging.rsocket.RSocketRequester)1 WebTestClient (org.springframework.test.web.reactive.server.WebTestClient)1