Polish MockServerHttpRequest
Issue: SPR-14421
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -29,11 +28,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.codec.CharSequenceEncoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.EncoderHttpMessageWriter;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
@@ -89,7 +85,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
this.dispatcherHandler = new DispatcherHandler(appContext);
|
||||
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
MockWebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, response, sessionManager);
|
||||
@@ -98,7 +94,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void noHandler() throws Exception {
|
||||
this.request.setUri(new URI("/does-not-exist"));
|
||||
this.request.setUri("/does-not-exist");
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -108,7 +104,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void unknownMethodArgumentType() throws Exception {
|
||||
this.request.setUri(new URI("/unknown-argument-type"));
|
||||
this.request.setUri("/unknown-argument-type");
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -118,7 +114,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void controllerReturnsMonoError() throws Exception {
|
||||
this.request.setUri(new URI("/error-signal"));
|
||||
this.request.setUri("/error-signal");
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -127,7 +123,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void controllerThrowsException() throws Exception {
|
||||
this.request.setUri(new URI("/raise-exception"));
|
||||
this.request.setUri("/raise-exception");
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -136,7 +132,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void unknownReturnType() throws Exception {
|
||||
this.request.setUri(new URI("/unknown-return-type"));
|
||||
this.request.setUri("/unknown-return-type");
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -146,11 +142,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void responseBodyMessageConversionError() throws Exception {
|
||||
DataBuffer dataBuffer = new DefaultDataBufferFactory().allocateBuffer();
|
||||
this.request.setUri(new URI("/request-body"));
|
||||
this.request.getHeaders().add("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
this.request.writeWith(Mono.just(dataBuffer.write("body".getBytes("UTF-8"))));
|
||||
|
||||
this.request.setUri("/request-body").setHeader("Accept", "application/json").setBody("body");
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -159,8 +151,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void requestBodyError() throws Exception {
|
||||
this.request.setUri(new URI("/request-body"));
|
||||
this.request.writeWith(Mono.error(EXCEPTION));
|
||||
this.request.setUri("/request-body").setBody(Mono.error(EXCEPTION));
|
||||
Mono<Void> publisher = this.dispatcherHandler.handle(this.exchange);
|
||||
|
||||
TestSubscriber.subscribe(publisher)
|
||||
@@ -170,7 +161,7 @@ public class DispatcherHandlerErrorTests {
|
||||
|
||||
@Test
|
||||
public void webExceptionHandler() throws Exception {
|
||||
this.request.setUri(new URI("/unknown-argument-type"));
|
||||
this.request.setUri("/unknown-argument-type");
|
||||
|
||||
WebExceptionHandler exceptionHandler = new ServerError500ExceptionHandler();
|
||||
WebHandler webHandler = new ExceptionHandlingWebHandler(this.dispatcherHandler, exceptionHandler);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.accept;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -188,7 +187,7 @@ public class CompositeContentTypeResolverBuilderTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(String path) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI(path));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, path);
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.accept;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -71,7 +70,7 @@ public class HeaderContentTypeResolverTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(String accept) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
if (accept != null) {
|
||||
request.getHeaders().add("Accept", accept);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.accept;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -111,7 +110,7 @@ public class PathExtensionContentTypeResolverTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(String path) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI(path));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, path);
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.config;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -65,8 +64,16 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.http.MediaType.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
|
||||
import static org.springframework.http.MediaType.APPLICATION_XML;
|
||||
import static org.springframework.http.MediaType.IMAGE_PNG;
|
||||
import static org.springframework.http.MediaType.TEXT_PLAIN;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link WebReactiveConfiguration}.
|
||||
@@ -81,7 +88,7 @@ public class WebReactiveConfigurationTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, response, new MockWebSessionManager());
|
||||
}
|
||||
@@ -105,11 +112,11 @@ public class WebReactiveConfigurationTests {
|
||||
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
|
||||
assertSame(resolver, mapping.getContentTypeResolver());
|
||||
|
||||
this.request.setUri(new URI("/path.json"));
|
||||
this.request.setUri("/path.json");
|
||||
List<MediaType> list = Collections.singletonList(MediaType.APPLICATION_JSON);
|
||||
assertEquals(list, resolver.resolveMediaTypes(this.exchange));
|
||||
|
||||
this.request.setUri(new URI("/path.xml"));
|
||||
this.request.setUri("/path.xml");
|
||||
assertEquals(Collections.emptyList(), resolver.resolveMediaTypes(this.exchange));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.function;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -51,7 +50,7 @@ public class BodyResponseTests {
|
||||
|
||||
@Test
|
||||
public void writeTo() throws Exception {
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, URI.create("http://localhost"));
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "http://localhost");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
ServerWebExchange exchange = new DefaultServerWebExchange(request, response, new MockWebSessionManager());
|
||||
exchange.getAttributes().put(Router.HTTP_MESSAGE_WRITERS_ATTRIBUTE, Collections
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.function;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -53,7 +52,7 @@ public class PublisherResponseTests {
|
||||
|
||||
@Test
|
||||
public void writeTo() throws Exception {
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, URI.create("http://localhost"));
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "http://localhost");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
ServerWebExchange exchange = new DefaultServerWebExchange(request, response, new MockWebSessionManager());
|
||||
exchange.getAttributes().put(Router.HTTP_MESSAGE_WRITERS_ATTRIBUTE, Collections
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.function;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -39,8 +38,13 @@ import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -136,10 +140,9 @@ public class RouterTests {
|
||||
HttpHandler result = Router.toHttpHandler(routingFunction, configuration);
|
||||
assertNotNull(result);
|
||||
|
||||
MockServerHttpRequest serverHttpRequest = new MockServerHttpRequest(HttpMethod.GET,
|
||||
URI.create("http://localhost"));
|
||||
MockServerHttpRequest httpRequest = new MockServerHttpRequest(HttpMethod.GET, "http://localhost");
|
||||
MockServerHttpResponse serverHttpResponse = new MockServerHttpResponse();
|
||||
result.handle(serverHttpRequest, serverHttpResponse);
|
||||
result.handle(httpRequest, serverHttpResponse);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.function;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -55,7 +53,7 @@ public class ServerSentEventResponseTests {
|
||||
|
||||
@Test
|
||||
public void writeTo() throws Exception {
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, URI.create("http://localhost"));
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "http://localhost");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
ServerWebExchange exchange = new DefaultServerWebExchange(request, response, new MockWebSessionManager());
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.handler;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -121,7 +120,7 @@ public class SimpleUrlHandlerMappingTests {
|
||||
}
|
||||
|
||||
private ServerWebExchange createExchange(String path) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI(path));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, path);
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ContentNegotiatingResultHandlerSupportTests {
|
||||
|
||||
@Test // SPR-9160
|
||||
public void sortsByQuality() throws Exception {
|
||||
this.request.getHeaders().add("Accept", "text/plain; q=0.5, application/json");
|
||||
this.request.setHeader("Accept", "text/plain; q=0.5, application/json");
|
||||
|
||||
List<MediaType> mediaTypes = Arrays.asList(TEXT_PLAIN, APPLICATION_JSON_UTF8);
|
||||
MediaType actual = this.resultHandler.selectMediaType(this.exchange, mediaTypes);
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -58,7 +56,7 @@ public class CompositeRequestConditionTests {
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
this.param1 = new ParamsRequestCondition("param1");
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -199,7 +198,7 @@ public class ConsumesRequestConditionTests {
|
||||
}
|
||||
|
||||
private ServerWebExchange createExchange(String contentType) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
if (contentType != null) {
|
||||
request.getHeaders().add("Content-Type", contentType);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -162,7 +161,7 @@ public class HeadersRequestConditionTests {
|
||||
}
|
||||
|
||||
private ServerWebExchange createExchange(String headerName, String headerValue) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
if (headerName != null) {
|
||||
request.getHeaders().add(headerName, headerValue);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -134,7 +133,7 @@ public class ParamsRequestConditionTests {
|
||||
}
|
||||
|
||||
private ServerWebExchange createExchange(String paramName, String paramValue) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
if (paramName != null) {
|
||||
request.getQueryParams().add(paramName, paramValue);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@@ -226,7 +225,7 @@ public class PatternsRequestConditionTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(String path) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI(path));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, path);
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -314,7 +313,7 @@ public class ProducesRequestConditionTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(String... accept) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
if (accept != null) {
|
||||
for (String value : accept) {
|
||||
request.getHeaders().add("Accept", value);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -53,7 +52,7 @@ public class RequestConditionHolderTests {
|
||||
}
|
||||
|
||||
private ServerWebExchange createExchange() throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -25,7 +24,6 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
@@ -62,7 +60,7 @@ public class RequestMappingInfoTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("/foo"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "/foo");
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -331,9 +329,9 @@ public class RequestMappingInfoTests {
|
||||
@Test
|
||||
@Ignore
|
||||
public void preFlightRequest() throws Exception {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.OPTIONS, new URI("/foo"));
|
||||
request.getHeaders().add(HttpHeaders.ORIGIN, "http://domain.com");
|
||||
request.getHeaders().add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST");
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.OPTIONS, "/foo");
|
||||
request.getHeaders().setOrigin("http://domain.com");
|
||||
request.getHeaders().setAccessControlRequestMethod(HttpMethod.POST);
|
||||
|
||||
WebSessionManager manager = new MockWebSessionManager();
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.condition;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -149,7 +148,7 @@ public class RequestMethodsRequestConditionTests {
|
||||
}
|
||||
|
||||
private ServerWebExchange createExchange(String method) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.resolve(method), new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.resolve(method), "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -151,7 +150,7 @@ public class HandlerMethodMappingTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(HttpMethod httpMethod, String path) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(httpMethod, new URI(path));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(httpMethod, path);
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.result.method;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -57,7 +56,7 @@ public class InvocableHandlerMethodTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.exchange = new DefaultServerWebExchange(
|
||||
new MockServerHttpRequest(HttpMethod.GET, new URI("http://localhost:8080/path")),
|
||||
new MockServerHttpRequest(HttpMethod.GET, "http://localhost:8080/path"),
|
||||
new MockServerHttpResponse(),
|
||||
new MockWebSessionManager());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -345,7 +344,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
|
||||
|
||||
private ServerWebExchange createExchange(HttpMethod method, String url) throws URISyntaxException {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(method, new URI(url));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(method, url);
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
return new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -68,7 +67,7 @@ public class CookieValueMethodArgumentResolverTests {
|
||||
ConversionService cs = new DefaultConversionService();
|
||||
this.resolver = new CookieValueMethodArgumentResolver(cs, context.getBeanFactory());
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -63,7 +62,7 @@ public class ExpressionValueMethodArgumentResolverTests {
|
||||
context.refresh();
|
||||
this.resolver = new ExpressionValueMethodArgumentResolver(conversionService, context.getBeanFactory());
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
@@ -41,14 +40,13 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.codec.DecoderHttpMessageReader;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.ui.ExtendedModelMap;
|
||||
import org.springframework.tests.TestSubscriber;
|
||||
import org.springframework.ui.ExtendedModelMap;
|
||||
import org.springframework.validation.Validator;
|
||||
import org.springframework.web.reactive.result.ResolvableMethod;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
@@ -85,7 +83,7 @@ public class HttpEntityArgumentResolverTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.request = new MockServerHttpRequest(HttpMethod.POST, new URI("/path"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.POST, "/path");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, response, new MockWebSessionManager());
|
||||
}
|
||||
@@ -302,10 +300,8 @@ public class HttpEntityArgumentResolverTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T resolveValue(ResolvableType type, String body) {
|
||||
|
||||
this.request.getHeaders().add("foo", "bar");
|
||||
this.request.getHeaders().setContentType(MediaType.TEXT_PLAIN);
|
||||
this.request.writeWith(Flux.just(dataBuffer(body)));
|
||||
this.request.setHeader("foo", "bar").setHeader("Content-Type", "text/plain");
|
||||
this.request.setBody(body);
|
||||
|
||||
MethodParameter param = this.testMethod.resolveParam(type);
|
||||
Mono<Object> result = this.resolver.resolveArgument(param, new ExtendedModelMap(), this.exchange);
|
||||
@@ -320,7 +316,6 @@ public class HttpEntityArgumentResolverTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> HttpEntity<T> resolveValueWithEmptyBody(ResolvableType type) {
|
||||
this.request.writeWith(Flux.empty());
|
||||
MethodParameter param = this.testMethod.resolveParam(type);
|
||||
Mono<Object> result = this.resolver.resolveArgument(param, new ExtendedModelMap(), this.exchange);
|
||||
HttpEntity<String> httpEntity = (HttpEntity<String>) result.block(Duration.ofSeconds(5));
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
@@ -45,7 +44,6 @@ import org.springframework.core.codec.Decoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.DecoderHttpMessageReader;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
import org.springframework.http.codec.json.Jackson2JsonDecoder;
|
||||
@@ -63,8 +61,12 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.core.ResolvableType.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.core.ResolvableType.forClass;
|
||||
import static org.springframework.core.ResolvableType.forClassWithGenerics;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractMessageReaderArgumentResolver}.
|
||||
@@ -83,7 +85,7 @@ public class MessageReaderArgumentResolverTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.request = new MockServerHttpRequest(HttpMethod.POST, new URI("/path"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.POST, "/path");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, response, new MockWebSessionManager());
|
||||
}
|
||||
@@ -91,8 +93,7 @@ public class MessageReaderArgumentResolverTests {
|
||||
|
||||
@Test
|
||||
public void missingContentType() throws Exception {
|
||||
String body = "{\"bar\":\"BARBAR\",\"foo\":\"FOOFOO\"}";
|
||||
this.request.writeWith(Flux.just(dataBuffer(body)));
|
||||
this.request.setBody("{\"bar\":\"BARBAR\",\"foo\":\"FOOFOO\"}");
|
||||
ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class);
|
||||
MethodParameter param = this.testMethod.resolveParam(type);
|
||||
Mono<Object> result = this.resolver.readBody(param, true, this.exchange);
|
||||
@@ -105,8 +106,7 @@ public class MessageReaderArgumentResolverTests {
|
||||
|
||||
@Test @SuppressWarnings("unchecked") // SPR-9942
|
||||
public void emptyBody() throws Exception {
|
||||
this.request.writeWith(Flux.empty());
|
||||
this.request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
||||
this.request.setHeader("Content-Type", "application/json");
|
||||
ResolvableType type = forClassWithGenerics(Mono.class, TestBean.class);
|
||||
MethodParameter param = this.testMethod.resolveParam(type);
|
||||
Mono<TestBean> result = (Mono<TestBean>) this.resolver.readBody(param, true, this.exchange).block();
|
||||
@@ -288,10 +288,7 @@ public class MessageReaderArgumentResolverTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T resolveValue(MethodParameter param, String body) {
|
||||
|
||||
this.request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
||||
this.request.writeWith(Flux.just(dataBuffer(body)));
|
||||
|
||||
this.request.setHeader("Content-Type", "application/json").setBody(body);
|
||||
Mono<Object> result = this.resolver.readBody(param, true, this.exchange);
|
||||
Object value = result.block(Duration.ofSeconds(5));
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
@@ -62,9 +61,11 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.http.MediaType.*;
|
||||
import static org.springframework.web.reactive.HandlerMapping.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON;
|
||||
import static org.springframework.http.MediaType.APPLICATION_JSON_UTF8;
|
||||
import static org.springframework.web.reactive.HandlerMapping.PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractMessageWriterResultHandler}.
|
||||
@@ -82,7 +83,7 @@ public class MessageWriterResultHandlerTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.resultHandler = createResultHandler();
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
this.exchange = new DefaultServerWebExchange(request, this.response, new MockWebSessionManager());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -63,7 +62,7 @@ public class PathVariableMapMethodArgumentResolverTests {
|
||||
public void setUp() throws Exception {
|
||||
this.resolver = new PathVariableMapMethodArgumentResolver();
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -45,7 +44,9 @@ import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link PathVariableMethodArgumentResolver}.
|
||||
@@ -73,7 +74,7 @@ public class PathVariableMethodArgumentResolverTests {
|
||||
ConversionService conversionService = new DefaultConversionService();
|
||||
this.resolver = new PathVariableMethodArgumentResolver(conversionService, null);
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -72,7 +71,7 @@ public class RequestAttributeMethodArgumentResolverTests {
|
||||
ConversionService cs = new DefaultConversionService();
|
||||
this.resolver = new RequestAttributeMethodArgumentResolver(cs, context.getBeanFactory());
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -36,8 +33,6 @@ import rx.Single;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.codec.StringDecoder;
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.codec.DecoderHttpMessageReader;
|
||||
import org.springframework.http.codec.HttpMessageReader;
|
||||
@@ -82,7 +77,7 @@ public class RequestBodyArgumentResolverTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.request = new MockServerHttpRequest(HttpMethod.POST, new URI("/path"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.POST, "/path");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, response, new MockWebSessionManager());
|
||||
}
|
||||
@@ -203,7 +198,7 @@ public class RequestBodyArgumentResolverTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T resolveValue(MethodParameter param, String body) {
|
||||
this.request.writeWith(Flux.just(dataBuffer(body)));
|
||||
this.request.setBody(body);
|
||||
Mono<Object> result = this.resolver.readBody(param, true, this.exchange);
|
||||
Object value = result.block(Duration.ofSeconds(5));
|
||||
|
||||
@@ -217,7 +212,6 @@ public class RequestBodyArgumentResolverTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T resolveValueWithEmptyBody(ResolvableType bodyType, boolean isRequired) {
|
||||
this.request.writeWith(Flux.empty());
|
||||
MethodParameter param = this.testMethod.resolveParam(bodyType, requestBody(isRequired));
|
||||
Mono<Object> result = this.resolver.resolveArgument(param, new ExtendedModelMap(), this.exchange);
|
||||
Object value = result.block(Duration.ofSeconds(5));
|
||||
@@ -238,13 +232,8 @@ public class RequestBodyArgumentResolverTests {
|
||||
};
|
||||
}
|
||||
|
||||
private DataBuffer dataBuffer(String body) {
|
||||
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
|
||||
return new DefaultDataBufferFactory().wrap(byteBuffer);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
void handle(
|
||||
@RequestBody String string,
|
||||
@RequestBody Mono<String> mono,
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -71,7 +70,7 @@ public class RequestHeaderMapMethodArgumentResolverTests {
|
||||
paramHttpHeaders = new SynthesizingMethodParameter(method, 2);
|
||||
paramUnsupported = new SynthesizingMethodParameter(method, 3);
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
@@ -90,7 +89,7 @@ public class RequestHeaderMethodArgumentResolverTests {
|
||||
this.paramDate = new SynthesizingMethodParameter(method, 6);
|
||||
this.paramInstant = new SynthesizingMethodParameter(method, 7);
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@@ -66,7 +65,7 @@ public class RequestParamMapMethodArgumentResolverTests {
|
||||
public void setUp() throws Exception {
|
||||
this.resolver = new RequestParamMapMethodArgumentResolver();
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -81,7 +80,7 @@ public class RequestParamMethodArgumentResolverTests {
|
||||
ParameterNameDiscoverer paramNameDiscoverer = new LocalVariableTableParameterNameDiscoverer();
|
||||
Method method = ReflectionUtils.findMethod(getClass(), "handle", (Class<?>[]) null);
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -78,7 +77,7 @@ public class ResponseBodyResultHandlerTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.resultHandler = createHandler();
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
this.exchange = new DefaultServerWebExchange(request, this.response, new MockWebSessionManager());
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ResponseEntityResultHandlerTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.resultHandler = createHandler();
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
WebSessionManager manager = new MockWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, this.response, manager);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -56,7 +54,7 @@ public class ServerWebExchangeArgumentResolverTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
ServerHttpResponse response = new MockServerHttpResponse();
|
||||
|
||||
WebSession session = mock(WebSession.class);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -80,7 +79,7 @@ public class SessionAttributeMethodArgumentResolverTests {
|
||||
this.session = mock(WebSession.class);
|
||||
when(this.session.getAttribute(any())).thenReturn(Optional.empty());
|
||||
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/"));
|
||||
ServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager(this.session);
|
||||
this.exchange = new DefaultServerWebExchange(request, new MockServerHttpResponse(), sessionManager);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.reactive.result.view;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -161,7 +160,7 @@ public class HttpMessageWriterViewTests {
|
||||
this.model.addAttribute("pojoData", pojoData);
|
||||
this.view.setModelKeys(Collections.singleton("pojoData"));
|
||||
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
WebSessionManager manager = new DefaultWebSessionManager();
|
||||
ServerWebExchange exchange = new DefaultServerWebExchange(request, response, manager);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ViewResolutionResultHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
WebSessionManager manager = new DefaultWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(this.request, this.response, manager);
|
||||
}
|
||||
@@ -183,15 +183,15 @@ public class ViewResolutionResultHandlerTests {
|
||||
HandlerResult result = new HandlerResult(new Object(), returnValue, returnType(type), model);
|
||||
ViewResolutionResultHandler handler = createResultHandler(new TestViewResolver("account"));
|
||||
|
||||
this.request.setUri(new URI("/account"));
|
||||
this.request.setUri("/account");
|
||||
handler.handleResult(this.exchange, result).block(Duration.ofSeconds(5));
|
||||
assertResponseBody("account: {id=123}");
|
||||
|
||||
this.request.setUri(new URI("/account/"));
|
||||
this.request.setUri("/account/");
|
||||
handler.handleResult(this.exchange, result).block(Duration.ofSeconds(5));
|
||||
assertResponseBody("account: {id=123}");
|
||||
|
||||
this.request.setUri(new URI("/account.123"));
|
||||
this.request.setUri("/account.123");
|
||||
handler.handleResult(this.exchange, result).block(Duration.ofSeconds(5));
|
||||
assertResponseBody("account: {id=123}");
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public class ViewResolutionResultHandlerTests {
|
||||
ResolvableType type = ResolvableType.forClass(String.class);
|
||||
HandlerResult handlerResult = new HandlerResult(new Object(), returnValue, returnType(type), this.model);
|
||||
|
||||
this.request.setUri(new URI("/path"));
|
||||
this.request.setUri("/path");
|
||||
Mono<Void> mono = createResultHandler().handleResult(this.exchange, handlerResult);
|
||||
|
||||
TestSubscriber.subscribe(mono).assertErrorMessage("Could not resolve view with name 'account'.");
|
||||
@@ -214,8 +214,8 @@ public class ViewResolutionResultHandlerTests {
|
||||
ResolvableType type = ResolvableType.forClass(TestBean.class);
|
||||
HandlerResult handlerResult = new HandlerResult(new Object(), value, returnType(type), this.model);
|
||||
|
||||
this.request.getHeaders().setAccept(Collections.singletonList(APPLICATION_JSON));
|
||||
this.request.setUri(new URI("/account"));
|
||||
this.request.setHeader("Accept", "application/json");
|
||||
this.request.setUri("/account");
|
||||
|
||||
TestView defaultView = new TestView("jsonView", APPLICATION_JSON);
|
||||
|
||||
@@ -233,8 +233,8 @@ public class ViewResolutionResultHandlerTests {
|
||||
ResolvableType type = ResolvableType.forClass(TestBean.class);
|
||||
HandlerResult handlerResult = new HandlerResult(new Object(), value, returnType(type), this.model);
|
||||
|
||||
this.request.getHeaders().setAccept(Collections.singletonList(APPLICATION_JSON));
|
||||
this.request.setUri(new URI("/account"));
|
||||
this.request.setHeader("Accept", "application/json");
|
||||
this.request.setUri("/account");
|
||||
|
||||
ViewResolutionResultHandler resultHandler = createResultHandler(new TestViewResolver("account"));
|
||||
Mono<Void> mono = resultHandler.handleResult(this.exchange, handlerResult);
|
||||
@@ -282,7 +282,7 @@ public class ViewResolutionResultHandlerTests {
|
||||
ModelMap model = new ExtendedModelMap().addAttribute("id", "123");
|
||||
MethodParameter returnType = resolvableMethod.resolveReturnType();
|
||||
HandlerResult result = new HandlerResult(new Object(), returnValue, returnType, model);
|
||||
this.request.setUri(new URI(path));
|
||||
this.request.setUri(path);
|
||||
createResultHandler(resolvers).handleResult(this.exchange, result).block(Duration.ofSeconds(5));
|
||||
assertResponseBody(responseBody);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.reactive.result.view.freemarker;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
@@ -33,16 +32,17 @@ import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.reactive.MockServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.MockServerHttpResponse;
|
||||
import org.springframework.tests.TestSubscriber;
|
||||
import org.springframework.ui.ExtendedModelMap;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.tests.TestSubscriber;
|
||||
import org.springframework.web.reactive.HandlerResult;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.DefaultWebSessionManager;
|
||||
import org.springframework.web.server.session.WebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -78,7 +78,7 @@ public class FreeMarkerViewTests {
|
||||
FreeMarkerView fv = new FreeMarkerView();
|
||||
fv.setApplicationContext(this.context);
|
||||
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
this.response = new MockServerHttpResponse();
|
||||
WebSessionManager manager = new DefaultWebSessionManager();
|
||||
this.exchange = new DefaultServerWebExchange(request, response, manager);
|
||||
|
||||
@@ -16,18 +16,22 @@
|
||||
package org.springframework.http.server.reactive;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.io.buffer.DataBuffer;
|
||||
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.HttpCookie;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link ServerHttpRequest}.
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -36,46 +40,73 @@ public class MockServerHttpRequest implements ServerHttpRequest {
|
||||
|
||||
private HttpMethod httpMethod;
|
||||
|
||||
private URI uri;
|
||||
private URI url;
|
||||
|
||||
private MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
private final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
|
||||
private HttpHeaders headers = new HttpHeaders();
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
private MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>();
|
||||
private final MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>();
|
||||
|
||||
private Flux<DataBuffer> body;
|
||||
private Flux<DataBuffer> body = Flux.empty();
|
||||
|
||||
|
||||
public MockServerHttpRequest(HttpMethod httpMethod, URI uri) {
|
||||
/**
|
||||
* Create a new instance where the HTTP method and/or URL can be set later
|
||||
* via {@link #setHttpMethod(HttpMethod)} and {@link #setUri(URI)}.
|
||||
*/
|
||||
public MockServerHttpRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience alternative to {@link #MockServerHttpRequest(HttpMethod, URI)}
|
||||
* that accepts a String URL.
|
||||
*/
|
||||
public MockServerHttpRequest(HttpMethod httpMethod, String url) {
|
||||
this(httpMethod, (url != null ? URI.create(url) : null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with the given HTTP method and URL.
|
||||
*/
|
||||
public MockServerHttpRequest(HttpMethod httpMethod, URI url) {
|
||||
this.httpMethod = httpMethod;
|
||||
this.uri = uri;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest(Publisher<DataBuffer> body, HttpMethod httpMethod,
|
||||
URI uri) {
|
||||
this.body = Flux.from(body);
|
||||
this.httpMethod = httpMethod;
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HttpMethod getMethod() {
|
||||
return this.httpMethod;
|
||||
}
|
||||
|
||||
public void setHttpMethod(HttpMethod httpMethod) {
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return this.uri;
|
||||
public HttpMethod getMethod() {
|
||||
return this.httpMethod;
|
||||
}
|
||||
|
||||
public void setUri(URI uri) {
|
||||
this.uri = uri;
|
||||
public MockServerHttpRequest setUri(String url) {
|
||||
this.url = URI.create(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest setUri(URI uri) {
|
||||
this.url = uri;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest addHeader(String name, String value) {
|
||||
getHeaders().add(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest setHeader(String name, String value) {
|
||||
getHeaders().set(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,13 +124,32 @@ public class MockServerHttpRequest implements ServerHttpRequest {
|
||||
return this.cookies;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest setBody(Publisher<DataBuffer> body) {
|
||||
this.body = Flux.from(body);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest setBody(String body) {
|
||||
DataBuffer buffer = toDataBuffer(body, StandardCharsets.UTF_8);
|
||||
this.body = Flux.just(buffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MockServerHttpRequest setBody(String body, Charset charset) {
|
||||
DataBuffer buffer = toDataBuffer(body, charset);
|
||||
this.body = Flux.just(buffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
private DataBuffer toDataBuffer(String body, Charset charset) {
|
||||
byte[] bytes = body.getBytes(charset);
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
|
||||
return new DefaultDataBufferFactory().wrap(byteBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<DataBuffer> getBody() {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
public Mono<Void> writeWith(Publisher<DataBuffer> body) {
|
||||
this.body = Flux.from(body);
|
||||
return this.body.then();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,15 +39,15 @@ public class MockServerHttpResponse implements ServerHttpResponse {
|
||||
|
||||
private HttpStatus status;
|
||||
|
||||
private HttpHeaders headers = new HttpHeaders();
|
||||
private final HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
private MultiValueMap<String, ResponseCookie> cookies = new LinkedMultiValueMap<>();
|
||||
private final MultiValueMap<String, ResponseCookie> cookies = new LinkedMultiValueMap<>();
|
||||
|
||||
private Publisher<DataBuffer> body;
|
||||
|
||||
private Publisher<Publisher<DataBuffer>> bodyWithFlushes;
|
||||
|
||||
private DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
|
||||
private DataBufferFactory bufferFactory = new DefaultDataBufferFactory();
|
||||
|
||||
|
||||
@Override
|
||||
@@ -101,6 +101,7 @@ public class MockServerHttpResponse implements ServerHttpResponse {
|
||||
|
||||
@Override
|
||||
public DataBufferFactory bufferFactory() {
|
||||
return this.dataBufferFactory;
|
||||
return this.bufferFactory;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.server.adapter;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
@@ -80,7 +79,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||
currentDate = Instant.now().truncatedTo(ChronoUnit.SECONDS);
|
||||
dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
request = new MockServerHttpRequest(method, new URI("http://example.org"));
|
||||
request = new MockServerHttpRequest(method, "http://example.org");
|
||||
response = new MockServerHttpResponse();
|
||||
exchange = new DefaultServerWebExchange(request, response, new MockWebSessionManager());
|
||||
}
|
||||
@@ -287,7 +286,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||
public void checkNotModifiedTimestampWithLengthPart() throws Exception {
|
||||
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
|
||||
request.setHttpMethod(HttpMethod.GET);
|
||||
request.getHeaders().add("If-Modified-Since", "Wed, 09 Apr 2014 09:57:42 GMT; length=13774");
|
||||
request.setHeader("If-Modified-Since", "Wed, 09 Apr 2014 09:57:42 GMT; length=13774");
|
||||
|
||||
assertTrue(exchange.checkNotModified(Instant.ofEpochMilli(epochTime)));
|
||||
|
||||
@@ -299,7 +298,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests {
|
||||
public void checkModifiedTimestampWithLengthPart() throws Exception {
|
||||
long epochTime = dateFormat.parse(CURRENT_TIME).getTime();
|
||||
request.setHttpMethod(HttpMethod.GET);
|
||||
request.getHeaders().add("If-Modified-Since", "Tue, 08 Apr 2014 09:57:42 GMT; length=13774");
|
||||
request.setHeader("If-Modified-Since", "Tue, 08 Apr 2014 09:57:42 GMT; length=13774");
|
||||
|
||||
assertFalse(exchange.checkNotModified(Instant.ofEpochMilli(epochTime)));
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.web.server.handler;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -50,9 +48,8 @@ public class ExceptionHandlingHttpHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
URI uri = new URI("http://localhost:8080");
|
||||
WebSessionManager sessionManager = new MockWebSessionManager();
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, uri);
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "http://localhost:8080");
|
||||
this.response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(request, this.response, sessionManager);
|
||||
this.targetHandler = new StubWebHandler(new IllegalStateException("boo"));
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package org.springframework.web.server.handler;
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
@@ -56,7 +54,7 @@ public class FilteringWebHandlerTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, new URI("http://localhost"));
|
||||
this.request = new MockServerHttpRequest(HttpMethod.GET, "http://localhost");
|
||||
this.response = new MockServerHttpResponse();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.server.handler;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -33,7 +32,8 @@ import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
import org.springframework.web.server.session.MockWebSessionManager;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ResponseStatusExceptionHandler}.
|
||||
@@ -54,8 +54,7 @@ public class ResponseStatusExceptionHandlerTests {
|
||||
this.handler = new ResponseStatusExceptionHandler();
|
||||
this.response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(
|
||||
new MockServerHttpRequest(HttpMethod.GET, new URI("/path")),
|
||||
this.response,
|
||||
new MockServerHttpRequest(HttpMethod.GET, "/path"), this.response,
|
||||
new MockWebSessionManager());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.web.server.session;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
@@ -57,7 +56,7 @@ public class DefaultWebSessionManagerTests {
|
||||
public void setUp() throws Exception {
|
||||
this.manager.setSessionIdResolver(this.idResolver);
|
||||
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, new URI("/path"));
|
||||
MockServerHttpRequest request = new MockServerHttpRequest(HttpMethod.GET, "/path");
|
||||
MockServerHttpResponse response = new MockServerHttpResponse();
|
||||
this.exchange = new DefaultServerWebExchange(request, response, this.manager);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user