@@ -88,7 +88,7 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
|||||||
* set the number of buffered to an arbitrary number greater than N.
|
* set the number of buffered to an arbitrary number greater than N.
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static Flux<Long> interval(Duration period, int count) {
|
public static Flux<Long> testInterval(Duration period, int count) {
|
||||||
return Flux.interval(period).take(count).onBackpressureBuffer(count);
|
return Flux.interval(period).take(count).onBackpressureBuffer(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.http.server.reactive;
|
package org.springframework.http.server.reactive;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -27,15 +28,13 @@ import reactor.core.publisher.Mono;
|
|||||||
|
|
||||||
import org.springframework.http.HttpCookie;
|
import org.springframework.http.HttpCookie;
|
||||||
import org.springframework.http.RequestEntity;
|
import org.springframework.http.RequestEntity;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.http.ResponseCookie;
|
import org.springframework.http.ResponseCookie;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
@@ -43,11 +42,11 @@ import static org.junit.Assert.assertThat;
|
|||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
private CookieHandler cookieHandler;
|
private final CookieHandler cookieHandler = new CookieHandler();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpHandler createHttpHandler() {
|
protected HttpHandler createHttpHandler() {
|
||||||
this.cookieHandler = new CookieHandler();
|
|
||||||
return this.cookieHandler;
|
return this.cookieHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -26,14 +26,16 @@ import org.springframework.http.RequestEntity;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Arjen Poutsma
|
||||||
|
*/
|
||||||
public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
private static final int REQUEST_SIZE = 4096 * 3;
|
private static final int REQUEST_SIZE = 4096 * 3;
|
||||||
|
|
||||||
private Random rnd = new Random();
|
private final Random rnd = new Random();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -28,21 +28,23 @@ import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer;
|
|||||||
import org.springframework.web.client.ResponseErrorHandler;
|
import org.springframework.web.client.ResponseErrorHandler;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assume.assumeFalse;
|
import static org.junit.Assume.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
*/
|
*/
|
||||||
public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
private ErrorHandler handler = new ErrorHandler();
|
private final ErrorHandler handler = new ErrorHandler();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpHandler createHttpHandler() {
|
protected HttpHandler createHttpHandler() {
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void responseBodyError() throws Exception {
|
public void responseBodyError() throws Exception {
|
||||||
// TODO: fix Reactor
|
// TODO: fix Reactor
|
||||||
@@ -83,6 +85,7 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
|||||||
assertEquals(HttpStatus.OK, response.getStatusCode());
|
assertEquals(HttpStatus.OK, response.getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ErrorHandler implements HttpHandler {
|
private static class ErrorHandler implements HttpHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,6 +104,7 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {
|
private static final ResponseErrorHandler NO_OP_ERROR_HANDLER = new ResponseErrorHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -33,6 +33,9 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Arjen Poutsma
|
||||||
|
*/
|
||||||
public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
public static final int REQUEST_SIZE = 4096 * 3;
|
public static final int REQUEST_SIZE = 4096 * 3;
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
*/
|
||||||
public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,4 +61,5 @@ public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegr
|
|||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,19 +21,16 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
import org.springframework.http.RequestEntity;
|
import org.springframework.http.RequestEntity;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.server.reactive.HttpHandler;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Violeta Georgieva
|
* @author Violeta Georgieva
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
@@ -52,7 +49,6 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra
|
|||||||
return new WriteOnlyHandler();
|
return new WriteOnlyHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void writeOnly() throws Exception {
|
public void writeOnly() throws Exception {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
@@ -66,7 +62,6 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra
|
|||||||
assertArrayEquals(body, response.getBody());
|
assertArrayEquals(body, response.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private byte[] randomBytes() {
|
private byte[] randomBytes() {
|
||||||
byte[] buffer = new byte[REQUEST_SIZE];
|
byte[] buffer = new byte[REQUEST_SIZE];
|
||||||
rnd.nextBytes(buffer);
|
rnd.nextBytes(buffer);
|
||||||
@@ -83,4 +78,5 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra
|
|||||||
return response.writeAndFlushWith(Flux.just(Flux.just(buffer)));
|
return response.writeAndFlushWith(Flux.just(Flux.just(buffer)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer;
|
|||||||
import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
|
import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assume.*;
|
||||||
import static org.junit.Assume.assumeTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Arjen Poutsma
|
* @author Arjen Poutsma
|
||||||
@@ -43,14 +42,15 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
|
|||||||
|
|
||||||
private final ZeroCopyHandler handler = new ZeroCopyHandler();
|
private final ZeroCopyHandler handler = new ZeroCopyHandler();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpHandler createHttpHandler() {
|
protected HttpHandler createHttpHandler() {
|
||||||
return handler;
|
return this.handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void zeroCopy() throws Exception {
|
public void zeroCopy() throws Exception {
|
||||||
|
|
||||||
// Zero-copy only does not support servlet
|
// Zero-copy only does not support servlet
|
||||||
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
|
assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer);
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
|
|||||||
assertEquals(logo.contentLength(), response.getHeaders().getContentLength());
|
assertEquals(logo.contentLength(), response.getHeaders().getContentLength());
|
||||||
assertEquals(logo.contentLength(), response.getBody().length);
|
assertEquals(logo.contentLength(), response.getBody().length);
|
||||||
assertEquals(MediaType.IMAGE_PNG, response.getHeaders().getContentType());
|
assertEquals(MediaType.IMAGE_PNG, response.getHeaders().getContentType());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ZeroCopyHandler implements HttpHandler {
|
private static class ZeroCopyHandler implements HttpHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -85,4 +85,4 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -38,31 +38,22 @@ import org.springframework.web.server.WebHandler;
|
|||||||
import org.springframework.web.server.WebSession;
|
import org.springframework.web.server.WebSession;
|
||||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for with a server-side session.
|
* Integration tests for with a server-side session.
|
||||||
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
*/
|
*/
|
||||||
public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||||
|
|
||||||
private RestTemplate restTemplate;
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
private DefaultWebSessionManager sessionManager;
|
private DefaultWebSessionManager sessionManager;
|
||||||
|
|
||||||
private TestWebHandler handler;
|
private TestWebHandler handler;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup() throws Exception {
|
|
||||||
super.setup();
|
|
||||||
this.restTemplate = new RestTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpHandler createHttpHandler() {
|
protected HttpHandler createHttpHandler() {
|
||||||
this.sessionManager = new DefaultWebSessionManager();
|
this.sessionManager = new DefaultWebSessionManager();
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest
|
|||||||
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
|
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
|
||||||
String path = request.getURI().getPath();
|
String path = request.getURI().getPath();
|
||||||
if (path.endsWith("write-and-flush")) {
|
if (path.endsWith("write-and-flush")) {
|
||||||
Flux<Publisher<DataBuffer>> responseBody = interval(Duration.ofMillis(50), 2)
|
Flux<Publisher<DataBuffer>> responseBody = testInterval(Duration.ofMillis(50), 2)
|
||||||
.map(l -> toDataBuffer("data" + l + "\n", response.bufferFactory()))
|
.map(l -> toDataBuffer("data" + l + "\n", response.bufferFactory()))
|
||||||
.map(Flux::just);
|
.map(Flux::just);
|
||||||
return response.writeAndFlushWith(responseBody.concatWith(Flux.never()));
|
return response.writeAndFlushWith(responseBody.concatWith(Flux.never()));
|
||||||
|
|||||||
@@ -37,14 +37,18 @@ import org.springframework.web.reactive.function.server.RouterFunction;
|
|||||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
|
import static org.springframework.web.reactive.function.server.RequestPredicates.*;
|
||||||
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
|
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sebastien Deleuze
|
||||||
|
*/
|
||||||
public class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
public class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||||
|
|
||||||
private final WebClient webClient = WebClient.create();
|
private final WebClient webClient = WebClient.create();
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void multipartData() {
|
public void multipartData() {
|
||||||
Mono<ClientResponse> result = webClient
|
Mono<ClientResponse> result = webClient
|
||||||
@@ -87,6 +91,7 @@ public class MultipartIntegrationTests extends AbstractRouterFunctionIntegration
|
|||||||
.andRoute(POST("/parts"), multipartHandler::parts);
|
.andRoute(POST("/parts"), multipartHandler::parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class MultipartHandler {
|
private static class MultipartHandler {
|
||||||
|
|
||||||
public Mono<ServerResponse> multipartData(ServerRequest request) {
|
public Mono<ServerResponse> multipartData(ServerRequest request) {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.springframework.web.reactive.function.client.WebClient;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.springframework.http.MediaType.*;
|
import static org.springframework.http.MediaType.*;
|
||||||
import static org.springframework.web.reactive.function.BodyExtractors.*;
|
|
||||||
import static org.springframework.web.reactive.function.BodyInserters.*;
|
import static org.springframework.web.reactive.function.BodyInserters.*;
|
||||||
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
|
import static org.springframework.web.reactive.function.server.RouterFunctions.*;
|
||||||
|
|
||||||
@@ -43,6 +42,12 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
|
|||||||
private WebClient webClient;
|
private WebClient webClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() throws Exception {
|
||||||
|
super.setup();
|
||||||
|
this.webClient = WebClient.create("http://localhost:" + this.port);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RouterFunction<?> routerFunction() {
|
protected RouterFunction<?> routerFunction() {
|
||||||
SseHandler sseHandler = new SseHandler();
|
SseHandler sseHandler = new SseHandler();
|
||||||
@@ -51,12 +56,6 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
|
|||||||
.and(route(RequestPredicates.GET("/event"), sseHandler::sse));
|
.and(route(RequestPredicates.GET("/event"), sseHandler::sse));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() throws Exception {
|
|
||||||
super.setup();
|
|
||||||
this.webClient = WebClient.create("http://localhost:" + this.port);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sseAsString() {
|
public void sseAsString() {
|
||||||
@@ -118,8 +117,7 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn
|
|||||||
|
|
||||||
private static class SseHandler {
|
private static class SseHandler {
|
||||||
|
|
||||||
private static final Flux<Long> INTERVAL = interval(Duration.ofMillis(100), 2);
|
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 2);
|
||||||
|
|
||||||
|
|
||||||
Mono<ServerResponse> string(ServerRequest request) {
|
Mono<ServerResponse> string(ServerRequest request) {
|
||||||
return ServerResponse.ok()
|
return ServerResponse.ok()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -39,13 +39,12 @@ import org.springframework.http.server.reactive.HttpHandler;
|
|||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.reactive.DispatcherHandler;
|
import org.springframework.web.reactive.DispatcherHandler;
|
||||||
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
|
|
||||||
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping;
|
||||||
import org.springframework.web.server.WebHandler;
|
import org.springframework.web.server.WebHandler;
|
||||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||||
|
import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests with requests mapped via
|
* Integration tests with requests mapped via
|
||||||
@@ -66,6 +65,7 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequestToFooHandler() throws Exception {
|
public void testRequestToFooHandler() throws Exception {
|
||||||
URI url = new URI("http://localhost:" + this.port + "/foo");
|
URI url = new URI("http://localhost:" + this.port + "/foo");
|
||||||
@@ -115,7 +115,6 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler
|
|||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
|
||||||
static class WebConfig {
|
static class WebConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.reactive.result.method.annotation;
|
package org.springframework.web.reactive.result.method.annotation;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -31,9 +32,7 @@ import org.springframework.http.server.reactive.HttpHandler;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||||
|
|
||||||
import static org.springframework.http.RequestEntity.get;
|
import static org.springframework.http.RequestEntity.*;
|
||||||
import static org.springframework.http.RequestEntity.options;
|
|
||||||
import static org.springframework.http.RequestEntity.post;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for integration tests with {@code @RequestMapping methods}.
|
* Base class for integration tests with {@code @RequestMapping methods}.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.web.reactive.result.method.annotation;
|
package org.springframework.web.reactive.result.method.annotation;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -29,7 +30,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code @RequestMapping} integration focusing on controller method parameters.
|
* {@code @RequestMapping} integration focusing on controller method parameters.
|
||||||
@@ -42,7 +43,6 @@ import static org.junit.Assert.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class ControllerInputIntegrationTests extends AbstractRequestMappingIntegrationTests {
|
public class ControllerInputIntegrationTests extends AbstractRequestMappingIntegrationTests {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ApplicationContext initApplicationContext() {
|
protected ApplicationContext initApplicationContext() {
|
||||||
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
|
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
|
||||||
@@ -58,7 +58,7 @@ public class ControllerInputIntegrationTests extends AbstractRequestMappingInteg
|
|||||||
assertEquals(expected, performGet("/param?name=George", new HttpHeaders(), String.class).getBody());
|
assertEquals(expected, performGet("/param?name=George", new HttpHeaders(), String.class).getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-15140
|
@Test // SPR-15140
|
||||||
public void handleWithEncodedParam() throws Exception {
|
public void handleWithEncodedParam() throws Exception {
|
||||||
String expected = "Hello + \u00e0!";
|
String expected = "Hello + \u00e0!";
|
||||||
assertEquals(expected, performGet("/param?name=%20%2B+%C3%A0", new HttpHeaders(), String.class).getBody());
|
assertEquals(expected, performGet("/param?name=%20%2B+%C3%A0", new HttpHeaders(), String.class).getBody());
|
||||||
@@ -77,6 +77,7 @@ public class ControllerInputIntegrationTests extends AbstractRequestMappingInteg
|
|||||||
static class WebConfig {
|
static class WebConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static class TestRestController {
|
private static class TestRestController {
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests with {@code @CrossOrigin} and {@code @RequestMapping}
|
* Integration tests with {@code @CrossOrigin} and {@code @RequestMapping}
|
||||||
@@ -105,7 +103,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
ResponseEntity<String> entity = performGet("/default", this.headers, String.class);
|
ResponseEntity<String> entity = performGet("/default", this.headers, String.class);
|
||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
|
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
assertEquals("default", entity.getBody());
|
assertEquals("default", entity.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +114,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertEquals(1800, entity.getHeaders().getAccessControlMaxAge());
|
assertEquals(1800, entity.getHeaders().getAccessControlMaxAge());
|
||||||
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
|
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -133,7 +131,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
ResponseEntity<String> entity = performGet("/customized", this.headers, String.class);
|
ResponseEntity<String> entity = performGet("/customized", this.headers, String.class);
|
||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
|
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
assertEquals(-1, entity.getHeaders().getAccessControlMaxAge());
|
assertEquals(-1, entity.getHeaders().getAccessControlMaxAge());
|
||||||
assertEquals("customized", entity.getBody());
|
assertEquals("customized", entity.getBody());
|
||||||
}
|
}
|
||||||
@@ -152,7 +150,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
entity.getHeaders().getAccessControlAllowHeaders().toArray());
|
entity.getHeaders().getAccessControlAllowHeaders().toArray());
|
||||||
assertArrayEquals(new String[] {"header3", "header4"},
|
assertArrayEquals(new String[] {"header3", "header4"},
|
||||||
entity.getHeaders().getAccessControlExposeHeaders().toArray());
|
entity.getHeaders().getAccessControlExposeHeaders().toArray());
|
||||||
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
|
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
assertEquals(123, entity.getHeaders().getAccessControlMaxAge());
|
assertEquals(123, entity.getHeaders().getAccessControlMaxAge());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,19 +175,19 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
ResponseEntity<String> entity = performGet("/foo", this.headers, String.class);
|
ResponseEntity<String> entity = performGet("/foo", this.headers, String.class);
|
||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
|
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
assertEquals("foo", entity.getBody());
|
assertEquals("foo", entity.getBody());
|
||||||
|
|
||||||
entity = performGet("/bar", this.headers, String.class);
|
entity = performGet("/bar", this.headers, String.class);
|
||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("*", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertEquals(false, entity.getHeaders().getAccessControlAllowCredentials());
|
assertFalse(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
assertEquals("bar", entity.getBody());
|
assertEquals("bar", entity.getBody());
|
||||||
|
|
||||||
entity = performGet("/baz", this.headers, String.class);
|
entity = performGet("/baz", this.headers, String.class);
|
||||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||||
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertEquals(true, entity.getHeaders().getAccessControlAllowCredentials());
|
assertTrue(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
assertEquals("baz", entity.getBody());
|
assertEquals("baz", entity.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +203,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
entity.getHeaders().getAccessControlAllowMethods().toArray());
|
entity.getHeaders().getAccessControlAllowMethods().toArray());
|
||||||
assertArrayEquals(new String[] {"header1"},
|
assertArrayEquals(new String[] {"header1"},
|
||||||
entity.getHeaders().getAccessControlAllowHeaders().toArray());
|
entity.getHeaders().getAccessControlAllowHeaders().toArray());
|
||||||
assertEquals(true, entity.getHeaders().getAccessControlAllowCredentials());
|
assertTrue(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -217,7 +215,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
|
assertEquals("http://site1.com", entity.getHeaders().getAccessControlAllowOrigin());
|
||||||
assertArrayEquals(new HttpMethod[] {HttpMethod.GET},
|
assertArrayEquals(new HttpMethod[] {HttpMethod.GET},
|
||||||
entity.getHeaders().getAccessControlAllowMethods().toArray());
|
entity.getHeaders().getAccessControlAllowMethods().toArray());
|
||||||
assertEquals(true, entity.getHeaders().getAccessControlAllowCredentials());
|
assertTrue(entity.getHeaders().getAccessControlAllowCredentials());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,6 +226,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
static class WebConfig {
|
static class WebConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RestController @SuppressWarnings("unused")
|
@RestController @SuppressWarnings("unused")
|
||||||
private static class MethodLevelController {
|
private static class MethodLevelController {
|
||||||
|
|
||||||
@@ -254,23 +253,23 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping(path = "/ambiguous-header", headers = "header1=a")
|
@GetMapping(path = "/ambiguous-header", headers = "header1=a")
|
||||||
public void ambigousHeader1a() {
|
public void ambiguousHeader1a() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping(path = "/ambiguous-header", headers = "header1=b")
|
@GetMapping(path = "/ambiguous-header", headers = "header1=b")
|
||||||
public void ambigousHeader1b() {
|
public void ambiguousHeader1b() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping(path = "/ambiguous-produces", produces = "application/xml")
|
@GetMapping(path = "/ambiguous-produces", produces = "application/xml")
|
||||||
public String ambigousProducesXml() {
|
public String ambiguousProducesXml() {
|
||||||
return "<a></a>";
|
return "<a></a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping(path = "/ambiguous-produces", produces = "application/json")
|
@GetMapping(path = "/ambiguous-produces", produces = "application/json")
|
||||||
public String ambigousProducesJson() {
|
public String ambiguousProducesJson() {
|
||||||
return "{}";
|
return "{}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +298,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@CrossOrigin(allowCredentials = "false")
|
@CrossOrigin(allowCredentials = "false")
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegra
|
|||||||
@GetMapping(value = "/stream",
|
@GetMapping(value = "/stream",
|
||||||
produces = { APPLICATION_STREAM_JSON_VALUE, "application/stream+x-jackson-smile" })
|
produces = { APPLICATION_STREAM_JSON_VALUE, "application/stream+x-jackson-smile" })
|
||||||
Flux<Person> person() {
|
Flux<Person> person() {
|
||||||
return interval(Duration.ofMillis(100), 50).map(l -> new Person("foo " + l));
|
return testInterval(Duration.ofMillis(100), 50).map(l -> new Person("foo " + l));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
|||||||
doTest("/mono-error", "Recovered from error: Argument");
|
doTest("/mono-error", "Recovered from error: Argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-16051
|
@Test // SPR-16051
|
||||||
public void exceptionAfterSeveralItems() throws Exception {
|
public void exceptionAfterSeveralItems() {
|
||||||
try {
|
try {
|
||||||
performGet("/SPR-16051", new HttpHeaders(), String.class).getBody();
|
performGet("/SPR-16051", new HttpHeaders(), String.class).getBody();
|
||||||
fail();
|
fail();
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
|
|||||||
|
|
||||||
@GetMapping("/stream")
|
@GetMapping("/stream")
|
||||||
public Publisher<Long> stream() {
|
public Publisher<Long> stream() {
|
||||||
return interval(Duration.ofMillis(50), 5);
|
return testInterval(Duration.ofMillis(50), 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,8 +43,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurer;
|
|||||||
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer;
|
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code @RequestMapping} integration tests with view resolution scenarios.
|
* {@code @RequestMapping} integration tests with view resolution scenarios.
|
||||||
@@ -78,10 +77,9 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
|
|||||||
assertNull(response.getBody());
|
assertNull(response.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-15291
|
@Test // SPR-15291
|
||||||
public void redirect() throws Exception {
|
public void redirect() throws Exception {
|
||||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory() {
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareConnection(HttpURLConnection conn, String method) throws IOException {
|
protected void prepareConnection(HttpURLConnection conn, String method) throws IOException {
|
||||||
super.prepareConnection(conn, method);
|
super.prepareConnection(conn, method);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
|||||||
private WebClient webClient;
|
private WebClient webClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
@@ -64,7 +65,6 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
|||||||
this.webClient = WebClient.create("http://localhost:" + this.port + "/sse");
|
this.webClient = WebClient.create("http://localhost:" + this.port + "/sse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpHandler createHttpHandler() {
|
protected HttpHandler createHttpHandler() {
|
||||||
this.wac = new AnnotationConfigApplicationContext();
|
this.wac = new AnnotationConfigApplicationContext();
|
||||||
@@ -177,7 +177,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
|||||||
@RequestMapping("/sse")
|
@RequestMapping("/sse")
|
||||||
static class SseController {
|
static class SseController {
|
||||||
|
|
||||||
private static final Flux<Long> INTERVAL = interval(Duration.ofMillis(100), 50);
|
private static final Flux<Long> INTERVAL = testInterval(Duration.ofMillis(100), 50);
|
||||||
|
|
||||||
private MonoProcessor<Void> cancellation = MonoProcessor.create();
|
private MonoProcessor<Void> cancellation = MonoProcessor.create();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2017 the original author or authors.
|
* Copyright 2002-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -39,11 +39,11 @@ import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
|
|||||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
import org.springframework.web.reactive.result.method.annotation.AbstractRequestMappingIntegrationTests;
|
import org.springframework.web.reactive.result.method.annotation.AbstractRequestMappingIntegrationTests;
|
||||||
import org.springframework.web.server.i18n.LocaleContextResolver;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import org.springframework.web.server.i18n.FixedLocaleContextResolver;
|
import org.springframework.web.server.i18n.FixedLocaleContextResolver;
|
||||||
|
import org.springframework.web.server.i18n.LocaleContextResolver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sebastien Deleuze
|
* @author Sebastien Deleuze
|
||||||
@@ -52,6 +52,15 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
|
|||||||
|
|
||||||
private final WebClient webClient = WebClient.create();
|
private final WebClient webClient = WebClient.create();
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ApplicationContext initApplicationContext() {
|
||||||
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||||
|
context.register(WebConfig.class);
|
||||||
|
context.refresh();
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void fixedLocale() {
|
public void fixedLocale() {
|
||||||
Mono<ClientResponse> result = webClient
|
Mono<ClientResponse> result = webClient
|
||||||
@@ -67,14 +76,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
|
|||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ApplicationContext initApplicationContext() {
|
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
|
||||||
context.register(WebConfig.class);
|
|
||||||
context.refresh();
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan(resourcePattern = "**/LocaleContextResolverIntegrationTests*.class")
|
@ComponentScan(resourcePattern = "**/LocaleContextResolverIntegrationTests*.class")
|
||||||
@@ -111,9 +112,9 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
|
|||||||
return Mono.empty();
|
return Mono.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
static class TestController {
|
static class TestController {
|
||||||
@@ -122,7 +123,6 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin
|
|||||||
public String foo() {
|
public String foo() {
|
||||||
return "foo";
|
return "foo";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user