From 1e28dee6085fe9b086edea989fd70bf445134993 Mon Sep 17 00:00:00 2001 From: Stephane Maldini Date: Thu, 14 Jan 2016 03:59:15 +0000 Subject: [PATCH] add streaming test, commented due to issue with a tomcat and jetty --- .../RequestMappingIntegrationTests.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/method/annotation/RequestMappingIntegrationTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/method/annotation/RequestMappingIntegrationTests.java index 1de455fe7c1..28cdf6a3135 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/method/annotation/RequestMappingIntegrationTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/method/annotation/RequestMappingIntegrationTests.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; +import org.junit.Ignore; import org.junit.Test; import org.reactivestreams.Publisher; import reactor.Flux; @@ -64,6 +65,7 @@ import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.handler.SimpleHandlerResultHandler; import org.springframework.web.server.WebToHttpHandlerBuilder; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; /** @@ -160,6 +162,19 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati assertEquals("Recovered from error: Boo", response.getBody()); } + @Test + @Ignore + //FIXME Fail with Jetty and Tomcat + public void streamResult() throws Exception { + RestTemplate restTemplate = new RestTemplate(); + + URI url = new URI("http://localhost:" + port + "/stream-result"); + RequestEntity request = RequestEntity.get(url).build(); + ResponseEntity response = restTemplate.exchange(request, String[].class); + + assertArrayEquals(new String[]{"0", "1", "2", "3", "4"}, response.getBody()); + } + @Test public void serializeAsPojo() throws Exception { serializeAsPojo("http://localhost:" + port + "/person"); @@ -421,6 +436,12 @@ public class RequestMappingIntegrationTests extends AbstractHttpHandlerIntegrati ResolvableType.forClass(Person.class), MediaType.APPLICATION_JSON); } + @RequestMapping("/stream-result") + @ResponseBody + public Publisher stringStreamResponseBody() { + return Flux.interval(1).map(Object::toString).as(Stream::from).take(5); + } + @RequestMapping("/raw-flux") @ResponseBody public Flux rawFluxResponseBody() {