add streaming test, commented due to issue with a tomcat and jetty

This commit is contained in:
Stephane Maldini
2016-01-14 03:59:15 +00:00
parent 0f432f735a
commit 1e28dee608

View File

@@ -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<Void> request = RequestEntity.get(url).build();
ResponseEntity<String[]> 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<String> stringStreamResponseBody() {
return Flux.interval(1).map(Object::toString).as(Stream::from).take(5);
}
@RequestMapping("/raw-flux")
@ResponseBody
public Flux<ByteBuffer> rawFluxResponseBody() {