public class MockServerHttpRequest
extends org.springframework.http.server.reactive.AbstractServerHttpRequest
AbstractServerHttpRequest for use in tests without
an actual server.
Use the static builder methods in this class to create an instance possibly
further creating a MockServerWebExchange via toExchange().
| Modifier and Type | Class and Description |
|---|---|
static interface |
MockServerHttpRequest.BaseBuilder<B extends MockServerHttpRequest.BaseBuilder<B>>
Request builder exposing properties not related to the body.
|
static interface |
MockServerHttpRequest.BodyBuilder
A builder that adds a body to the request.
|
| Modifier and Type | Method and Description |
|---|---|
static MockServerHttpRequest.BaseBuilder<?> |
delete(String urlTemplate,
Object... uriVars)
Create an HTTP DELETE builder with the given url.
|
static MockServerHttpRequest.BaseBuilder<?> |
get(String urlTemplate,
Object... uriVars)
Create an HTTP GET builder with the given url.
|
reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> |
getBody() |
org.springframework.http.HttpMethod |
getMethod() |
String |
getMethodValue() |
InetSocketAddress |
getRemoteAddress() |
static MockServerHttpRequest.BaseBuilder<?> |
head(String urlTemplate,
Object... uriVars)
Create an HTTP HEAD builder with the given url.
|
protected org.springframework.util.MultiValueMap<String,org.springframework.http.HttpCookie> |
initCookies() |
static MockServerHttpRequest.BodyBuilder |
method(org.springframework.http.HttpMethod method,
String urlTemplate,
Object... vars)
Alternative to
method(HttpMethod, URI) that accepts a URI template. |
static MockServerHttpRequest.BodyBuilder |
method(org.springframework.http.HttpMethod method,
URI url)
Create a builder with the given HTTP method and a
URI. |
static MockServerHttpRequest.BaseBuilder<?> |
options(String urlTemplate,
Object... uriVars)
Creates an HTTP OPTIONS builder with the given url.
|
static MockServerHttpRequest.BodyBuilder |
patch(String urlTemplate,
Object... uriVars)
Create an HTTP PATCH builder with the given url.
|
static MockServerHttpRequest.BodyBuilder |
post(String urlTemplate,
Object... uriVars)
Create an HTTP POST builder with the given url.
|
static MockServerHttpRequest.BodyBuilder |
put(String urlTemplate,
Object... uriVars)
Create an HTTP PUT builder with the given url.
|
MockServerWebExchange |
toExchange()
Shortcut to wrap the request with a
MockServerWebExchange. |
getCookies, getHeaders, getPath, getQueryParams, getURI, initQueryParamspublic org.springframework.http.HttpMethod getMethod()
public String getMethodValue()
@Nullable public InetSocketAddress getRemoteAddress()
public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> getBody()
protected org.springframework.util.MultiValueMap<String,org.springframework.http.HttpCookie> initCookies()
initCookies in class org.springframework.http.server.reactive.AbstractServerHttpRequestpublic MockServerWebExchange toExchange()
MockServerWebExchange.public static MockServerHttpRequest.BodyBuilder method(org.springframework.http.HttpMethod method, URI url)
URI.method - the HTTP method (GET, POST, etc)url - the URLpublic static MockServerHttpRequest.BodyBuilder method(org.springframework.http.HttpMethod method, String urlTemplate, Object... vars)
method(HttpMethod, URI) that accepts a URI template.method - the HTTP method (GET, POST, etc)urlTemplate - the URL templatevars - variables to expand into the templatepublic static MockServerHttpRequest.BaseBuilder<?> get(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BaseBuilder<?> head(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder post(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder put(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BodyBuilder patch(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BaseBuilder<?> delete(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variablespublic static MockServerHttpRequest.BaseBuilder<?> options(String urlTemplate, Object... uriVars)
urlTemplate - a URL template; the resulting URL will be encodeduriVars - zero or more URI variables