Search in sources :

Example 1 with AnnotationConfigReactiveWebApplicationContext

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

the class ControllerEndpointWebFluxIntegrationTests method endpointsCanBeAccessed.

@Test
void endpointsCanBeAccessed() {
    TestSecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
    this.context = new AnnotationConfigReactiveWebApplicationContext();
    this.context.register(DefaultConfiguration.class, ExampleController.class);
    TestPropertyValues.of("management.endpoints.web.exposure.include=*").applyTo(this.context);
    this.context.refresh();
    WebTestClient webClient = WebTestClient.bindToApplicationContext(this.context).build();
    webClient.get().uri("/actuator/example").exchange().expectStatus().isOk();
}
Also used : WebTestClient(org.springframework.test.web.reactive.server.WebTestClient) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) Test(org.junit.jupiter.api.Test)

Example 2 with AnnotationConfigReactiveWebApplicationContext

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

the class ConditionalOnWebApplicationTests method testWebApplicationWithReactiveContext.

@Test
void testWebApplicationWithReactiveContext() {
    AnnotationConfigReactiveWebApplicationContext context = new AnnotationConfigReactiveWebApplicationContext();
    context.register(AnyWebApplicationConfiguration.class, ServletWebApplicationConfiguration.class, ReactiveWebApplicationConfiguration.class);
    context.refresh();
    this.context = context;
    assertThat(this.context.getBeansOfType(String.class)).containsExactly(entry("any", "any"), entry("reactive", "reactive"));
}
Also used : AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) Test(org.junit.jupiter.api.Test)

Example 3 with AnnotationConfigReactiveWebApplicationContext

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

the class ReactiveWebServerFactoryAutoConfigurationTests method nettyServerCustomizerBeanIsAddedToFactory.

@Test
void nettyServerCustomizerBeanIsAddedToFactory() {
    new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, Server.class, Undertow.class)).withUserConfiguration(NettyServerCustomizerConfiguration.class, HttpHandlerConfiguration.class).run((context) -> {
        NettyReactiveWebServerFactory factory = context.getBean(NettyReactiveWebServerFactory.class);
        assertThat(factory.getServerCustomizers()).hasSize(1);
    });
}
Also used : NettyReactiveWebServerFactory(org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory) Tomcat(org.apache.catalina.startup.Tomcat) Server(org.eclipse.jetty.server.Server) HttpServer(reactor.netty.http.server.HttpServer) Undertow(io.undertow.Undertow) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Example 4 with AnnotationConfigReactiveWebApplicationContext

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

the class ReactiveWebServerFactoryAutoConfigurationTests method jettyServerCustomizerBeanIsAddedToFactory.

@Test
void jettyServerCustomizerBeanIsAddedToFactory() {
    new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class)).withUserConfiguration(JettyServerCustomizerConfiguration.class, HttpHandlerConfiguration.class).run((context) -> {
        JettyReactiveWebServerFactory factory = context.getBean(JettyReactiveWebServerFactory.class);
        assertThat(factory.getServerCustomizers()).hasSize(1);
    });
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) JettyReactiveWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory) HttpServer(reactor.netty.http.server.HttpServer) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Example 5 with AnnotationConfigReactiveWebApplicationContext

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

the class ReactiveWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerBeanIsAddedToFactory.

@Test
void undertowBuilderCustomizerBeanIsAddedToFactory() {
    new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new).withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class)).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withUserConfiguration(UndertowBuilderCustomizerConfiguration.class, HttpHandlerConfiguration.class).run((context) -> {
        UndertowReactiveWebServerFactory factory = context.getBean(UndertowReactiveWebServerFactory.class);
        assertThat(factory.getBuilderCustomizers()).hasSize(1);
    });
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) Server(org.eclipse.jetty.server.Server) HttpServer(reactor.netty.http.server.HttpServer) HttpServer(reactor.netty.http.server.HttpServer) UndertowReactiveWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) AnnotationConfigReactiveWebApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext) FilteredClassLoader(org.springframework.boot.test.context.FilteredClassLoader) Test(org.junit.jupiter.api.Test)

Aggregations

AnnotationConfigReactiveWebApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext)8 Test (org.junit.jupiter.api.Test)7 Tomcat (org.apache.catalina.startup.Tomcat)3 FilteredClassLoader (org.springframework.boot.test.context.FilteredClassLoader)3 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)3 HttpServer (reactor.netty.http.server.HttpServer)3 Server (org.eclipse.jetty.server.Server)2 ErrorProperties (org.springframework.boot.autoconfigure.web.ErrorProperties)2 Resources (org.springframework.boot.autoconfigure.web.WebProperties.Resources)2 ErrorAttributes (org.springframework.boot.web.reactive.error.ErrorAttributes)2 ApplicationContext (org.springframework.context.ApplicationContext)2 MockServerWebExchange (org.springframework.mock.web.server.MockServerWebExchange)2 Undertow (io.undertow.Undertow)1 JettyReactiveWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory)1 NettyReactiveWebServerFactory (org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory)1 UndertowReactiveWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory)1 MediaType (org.springframework.http.MediaType)1 HttpMessageReader (org.springframework.http.codec.HttpMessageReader)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1 WebTestClient (org.springframework.test.web.reactive.server.WebTestClient)1