Copy MockServerRequest to spring-test
This commit copies the MockServerRequest to the spring-test module, in the mock.web.reactive.function.server package. Issue: SPR-15530
This commit is contained in:
@@ -20,9 +20,6 @@ import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -40,6 +37,7 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpRange;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -47,7 +45,9 @@ import org.springframework.web.reactive.function.BodyExtractor;
|
||||
import org.springframework.web.server.WebSession;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link ServerRequest}.
|
||||
* @author Arjen Poutsma
|
||||
* @since 5.0
|
||||
*/
|
||||
public class MockServerRequest implements ServerRequest {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class MockServerRequest implements ServerRequest {
|
||||
private Principal principal;
|
||||
|
||||
private MockServerRequest(HttpMethod method, URI uri,
|
||||
MockHeaders headers, Object body, Map<String, Object> attributes,
|
||||
MockHeaders headers, @Nullable Object body, Map<String, Object> attributes,
|
||||
MultiValueMap<String, String> queryParams,
|
||||
Map<String, String> pathVariables, WebSession session, Principal principal) {
|
||||
|
||||
@@ -160,7 +160,9 @@ public class MockServerRequest implements ServerRequest {
|
||||
return new BuilderImpl();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link MockServerRequest}.
|
||||
*/
|
||||
public interface Builder {
|
||||
|
||||
Builder method(HttpMethod method);
|
||||
@@ -384,15 +386,6 @@ public class MockServerRequest implements ServerRequest {
|
||||
return value != -1 ? OptionalLong.of(value) : OptionalLong.empty();
|
||||
}
|
||||
|
||||
private Optional<ZonedDateTime> toZonedDateTime(long date) {
|
||||
if (date != -1) {
|
||||
Instant instant = Instant.ofEpochMilli(date);
|
||||
return Optional.of(ZonedDateTime.ofInstant(instant, ZoneId.of("GMT")));
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user