Search in sources :

Example 1 with ReactiveWebServerApplicationContext

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

the class ReactiveWebServerAutoConfigurationTests method createFromConfigClass.

@Test
public void createFromConfigClass() {
    this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class);
    assertThat(this.context.getBeansOfType(ReactiveWebServerFactory.class)).hasSize(1);
    assertThat(this.context.getBeansOfType(WebServerFactoryCustomizer.class)).hasSize(1);
    assertThat(this.context.getBeansOfType(DefaultReactiveWebServerCustomizer.class)).hasSize(1);
}
Also used : ReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext) Test(org.junit.Test)

Example 2 with ReactiveWebServerApplicationContext

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

the class ReactiveWebServerAutoConfigurationTests method missingHttpHandler.

@Test
public void missingHttpHandler() {
    this.thrown.expect(ApplicationContextException.class);
    this.thrown.expectMessage(Matchers.containsString("missing HttpHandler bean"));
    this.context = new ReactiveWebServerApplicationContext(MissingHttpHandlerConfiguration.class);
}
Also used : ReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext) Test(org.junit.Test)

Example 3 with ReactiveWebServerApplicationContext

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

the class ReactiveWebServerAutoConfigurationTests method customizeReactiveWebServer.

@Test
public void customizeReactiveWebServer() {
    this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class, ReactiveWebServerCustomization.class);
    MockReactiveWebServerFactory factory = this.context.getBean(MockReactiveWebServerFactory.class);
    assertThat(factory.getPort()).isEqualTo(9000);
}
Also used : ReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext) Test(org.junit.Test)

Example 4 with ReactiveWebServerApplicationContext

use of org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext 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");
    });
}
Also used : RSocketRequester(org.springframework.messaging.rsocket.RSocketRequester) WebTestClient(org.springframework.test.web.reactive.server.WebTestClient) AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext) AnnotationConfigReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext) ReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext) ReactiveWebApplicationContextRunner(org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner) Test(org.junit.jupiter.api.Test)

Example 5 with ReactiveWebServerApplicationContext

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

the class ReactiveWebServerAutoConfigurationTests method multipleHttpHandler.

@Test
public void multipleHttpHandler() {
    this.thrown.expect(ApplicationContextException.class);
    this.thrown.expectMessage(Matchers.containsString("multiple HttpHandler beans : httpHandler,additionalHttpHandler"));
    this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class, TooManyHttpHandlers.class);
}
Also used : ReactiveWebServerApplicationContext(org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext) Test(org.junit.Test)

Aggregations

ReactiveWebServerApplicationContext (org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext)5 Test (org.junit.Test)4 Test (org.junit.jupiter.api.Test)1 ReactiveWebApplicationContextRunner (org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner)1 AnnotationConfigReactiveWebServerApplicationContext (org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext)1 RSocketRequester (org.springframework.messaging.rsocket.RSocketRequester)1 WebTestClient (org.springframework.test.web.reactive.server.WebTestClient)1