|
| 1 | +package org.springframework.web.reactive.result.method.annotation; |
| 2 | + |
| 3 | +import org.reactivestreams.Publisher; |
| 4 | +import org.springframework.context.ApplicationContext; |
| 5 | +import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
| 6 | +import org.springframework.http.HttpHeaders; |
| 7 | +import org.springframework.web.bind.annotation.GetMapping; |
| 8 | +import org.springframework.web.bind.annotation.RestController; |
| 9 | +import org.springframework.web.reactive.config.EnableWebFlux; |
| 10 | +import org.springframework.web.testfixture.http.server.reactive.bootstrap.HttpServer; |
| 11 | +import reactor.core.publisher.Flux; |
| 12 | +import reactor.core.scheduler.Schedulers; |
| 13 | + |
| 14 | +import static org.assertj.core.api.Assertions.assertThat; |
| 15 | + |
| 16 | +class ChannelSendOperatorRaceConditionIntegrationTest extends AbstractRequestMappingIntegrationTests { |
| 17 | + |
| 18 | + @Override |
| 19 | + protected ApplicationContext initApplicationContext() { |
| 20 | + return new AnnotationConfigApplicationContext(WebConfig.class, TestRestController.class); |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | + @ParameterizedHttpServerTest |
| 25 | + void handlePublishOn(HttpServer httpServer) throws Exception { |
| 26 | + startServer(httpServer); |
| 27 | + |
| 28 | + String expected = "Hello world!"; |
| 29 | + assertThat(performGet("/test", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); |
| 30 | + } |
| 31 | + |
| 32 | + @EnableWebFlux |
| 33 | + static class WebConfig { |
| 34 | + } |
| 35 | + @RestController |
| 36 | + @SuppressWarnings("unused") |
| 37 | + private static class TestRestController { |
| 38 | + |
| 39 | + @GetMapping("/test") |
| 40 | + public Publisher<String> handlerWithPublishOn() { |
| 41 | + return Flux.just("Hello ", "world", "!") |
| 42 | + .publishOn(Schedulers.boundedElastic()); |
| 43 | + } |
| 44 | + } |
| 45 | +} |
0 commit comments