public interface WebTestClientRequestSpecification extends WebTestClientRequestSender
Modifier and Type | Method and Description |
---|---|
WebTestClientRequestSpecification |
accept(io.restassured.http.ContentType contentType)
Specify the accept header of the request.
|
WebTestClientRequestSpecification |
accept(org.springframework.http.MediaType... mediaTypes)
Specify the accept header of the request.
|
WebTestClientRequestSpecification |
accept(String mediaTypes)
Specify the accept header of the request.
|
WebTestClientRequestSpecification |
and()
Syntactic sugar
|
WebTestClientRequestSpecification |
applicationContextSetup(org.springframework.context.ApplicationContext context,
org.springframework.test.web.reactive.server.WebTestClientConfigurer... configurers) |
WebTestClientRequestSpecification |
attribute(String attributeName,
Object attributeValue)
Specify a single-value request attribute
|
WebTestClientRequestSpecification |
attributes(Map<String,?> attributesMap)
Specify request attributes as a map
|
WebTestClientRequestSpecification |
body(byte[] body)
Specify a byte array request body that'll be sent with the request.
|
WebTestClientRequestSpecification |
body(File body)
Specify file content that'll be sent with the request.
|
WebTestClientRequestSpecification |
body(Object object)
Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request.
|
WebTestClientRequestSpecification |
body(Object object,
io.restassured.mapper.ObjectMapper mapper)
Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request using a specific object mapper.
|
WebTestClientRequestSpecification |
body(Object object,
io.restassured.mapper.ObjectMapperType mapperType)
Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request using a specific object mapper type.
|
WebTestClientRequestSpecification |
body(String body)
Specify a String request body (such as e.g.
|
WebTestClientRequestSpecification |
config(RestAssuredWebTestClientConfig config)
Define a REST Assured WebTestClient configuration.
|
WebTestClientRequestSpecification |
config(SpecificationConfig config) |
WebTestClientRequestSpecification |
contentType(io.restassured.http.ContentType contentType)
Specify the content type of the request.
|
WebTestClientRequestSpecification |
contentType(String contentType)
Specify the content type of the request.
|
WebTestClientRequestSpecification |
cookie(io.restassured.http.Cookie cookie)
Specify a
Cookie to send with the request. |
WebTestClientRequestSpecification |
cookie(String cookieName,
Object value,
Object... additionalValues)
Specify a cookie that'll be sent with the request e.g:
|
WebTestClientRequestSpecification |
cookies(io.restassured.http.Cookies cookies)
Specify the cookies that'll be sent with the request as
Cookies : |
WebTestClientRequestSpecification |
cookies(Map<String,?> cookies)
Specify the cookies that'll be sent with the request as Map e.g:
|
WebTestClientRequestSpecification |
cookies(String firstCookieName,
Object firstCookieValue,
Object... cookieNameValuePairs)
Specify the cookies that'll be sent with the request.
|
WebTestClientRequestSpecification |
formParam(String parameterName,
Collection<?> parameterValues)
Specify a multi-value form parameter that'll be sent with the request e.g:
|
WebTestClientRequestSpecification |
formParam(String parameterName,
Object... parameterValues)
Specify a form parameter that'll be sent with the request.
|
WebTestClientRequestSpecification |
formParams(Map<String,?> parametersMap)
Specify the form parameters that'll be sent with the request.
|
WebTestClientRequestSpecification |
formParams(String firstParameterName,
Object firstParameterValue,
Object... parameterNameValuePairs)
Specify the form parameters that'll be sent with the request.
|
WebTestClientRequestSpecification |
header(io.restassured.http.Header header)
Specify a
Header to send with the request. |
WebTestClientRequestSpecification |
header(String headerName,
Object headerValue,
Object... additionalHeaderValues)
Specify a header that'll be sent with the request e.g:
|
WebTestClientRequestSpecification |
headers(io.restassured.http.Headers headers)
Specify the headers that'll be sent with the request as
Headers , e.g: |
WebTestClientRequestSpecification |
headers(Map<String,?> headers)
Specify the headers that'll be sent with the request as Map e.g:
|
WebTestClientRequestSpecification |
headers(String firstHeaderName,
Object firstHeaderValue,
Object... headerNameValuePairs)
Specify the headers that'll be sent with the request.
|
WebTestClientRequestLogSpecification |
log()
Returns the
WebTestClientRequestLogSpecification that allows you to log different parts of the WebTestClientRequestSpecification . |
WebTestClientRequestSpecification |
multiPart(File file)
Specify a file to upload to the server using multi-part form data uploading.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
File file)
Specify a file to upload to the server using multi-part form data uploading with a specific
control name.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
File file,
String mimeType)
Specify a file to upload to the server using multi-part form data uploading with a specific
control name and mime-type.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
Object object)
Specify an object that will be serialized to JSON and uploaded to the server using multi-part form data
uploading with a specific control name.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
Object object,
String mimeType)
Specify an object that will be serialized and uploaded to the server using multi-part form data
uploading with a specific control name.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String contentBody)
Specify a string to send to the server using multi-part form data.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String fileName,
byte[] bytes)
Specify a byte-array to upload to the server using multi-part form data.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String fileName,
byte[] bytes,
String mimeType)
Specify a byte-array to upload to the server using multi-part form data.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String fileName,
InputStream stream)
Specify an inputstream to upload to the server using multi-part form data.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String fileName,
InputStream stream,
String mimeType)
Specify an inputstream to upload to the server using multi-part form data.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String filename,
Object object,
String mimeType)
Specify an object that will be serialized and uploaded to the server using multi-part form data
uploading with a specific control name.
|
WebTestClientRequestSpecification |
multiPart(String controlName,
String contentBody,
String mimeType)
Specify a string to send to the server using multi-part form data with a specific mime-type.
|
WebTestClientRequestSpecification |
param(String parameterName,
Collection<?> parameterValues)
Specify a multi-value parameter that'll be sent with the request e.g:
|
WebTestClientRequestSpecification |
param(String parameterName,
Object... parameterValues)
Specify a parameter that'll be sent with the request e.g:
|
WebTestClientRequestSpecification |
params(Map<String,?> parametersMap)
Specify the parameters that'll be sent with the request as Map e.g:
|
WebTestClientRequestSpecification |
params(String firstParameterName,
Object firstParameterValue,
Object... parameterNameValuePairs)
Specify the parameters that'll be sent with the request.
|
WebTestClientRequestSpecification |
queryParam(String parameterName,
Collection<?> parameterValues)
Specify a multi-value query parameter that'll be sent with the request e.g:
|
WebTestClientRequestSpecification |
queryParam(String parameterName,
Object... parameterValues)
Specify a query parameter that'll be sent with the request.
|
WebTestClientRequestSpecification |
queryParams(Map<String,?> parametersMap)
Specify the query parameters that'll be sent with the request.
|
WebTestClientRequestSpecification |
queryParams(String firstParameterName,
Object firstParameterValue,
Object... parameterNameValuePairs)
Specify the query parameters that'll be sent with the request.
|
WebTestClientRequestSpecification |
sessionId(String sessionIdValue)
Set the session id for this request.
|
WebTestClientRequestSpecification |
sessionId(String sessionIdName,
String sessionIdValue)
Set the session id name and value for this request.
|
WebTestClientRequestSpecification |
spec(WebTestClientRequestSpecification requestSpecificationToMerge)
Add request data from a pre-defined specification.
|
WebTestClientRequestSpecification |
standaloneSetup(Object... controllerOrWebTestClientConfigurer)
Build a
WebTestClient by registering one or more @Controller 's
instances and configuring Spring infrastructure programmatically. |
WebTestClientRequestSpecification |
standaloneSetup(org.springframework.web.reactive.function.server.RouterFunction routerFunction,
org.springframework.test.web.reactive.server.WebTestClientConfigurer... configurers) |
WebTestClientRequestSpecification |
standaloneSetup(org.springframework.test.web.reactive.server.WebTestClient.Builder builder)
Build a
WebTestClient by using a provided AbstractWebTestClientBuilder
for configuring Spring infrastructure programmatically. |
WebTestClientRequestSpecification |
webAppContextSetup(org.springframework.web.context.WebApplicationContext context,
org.springframework.test.web.reactive.server.WebTestClientConfigurer... configurers)
Build a
WebTestClient using the given, fully initialized, i.e. |
WebTestClientRequestSpecification |
webTestClient(org.springframework.test.web.reactive.server.WebTestClient webTestClient)
Provide a
WebTestClient instance to that REST Assured will use when making this request. |
WebTestClientRequestSender |
when()
Call this method when you're done setting up the request specification.
|
consumeWith, delete, get, head, options, patch, post, put, request, request
delete, delete, delete, delete, delete, get, get, get, get, get, head, head, head, head, head, options, options, options, options, options, patch, patch, patch, patch, patch, post, post, post, post, post, put, put, put, put, put, request, request, request, request, request, request, request, request
WebTestClientRequestSpecification contentType(io.restassured.http.ContentType contentType)
contentType
- The content type of the requestContentType
WebTestClientRequestSpecification contentType(String contentType)
contentType
- The content type of the requestContentType
WebTestClientRequestSpecification accept(io.restassured.http.ContentType contentType)
header("Accept", contentType);
contentType
- The content type whose accept header ContentType.getAcceptHeader()
will be used as Accept header in the request.ContentType
,
header(String, Object, Object...)
WebTestClientRequestSpecification accept(org.springframework.http.MediaType... mediaTypes)
header("Accept", contentType);
mediaTypes
- The media type(s) that will be used as Accept header in the request.ContentType
,
header(String, Object, Object...)
WebTestClientRequestSpecification accept(String mediaTypes)
header("Accept", contentType);
mediaTypes
- The media type(s) that will be used as Accept header in the request.ContentType
,
header(String, Object, Object...)
WebTestClientRequestSpecification headers(String firstHeaderName, Object firstHeaderValue, Object... headerNameValuePairs)
given().headers("headerName1", "headerValue1", "headerName2", "headerValue2").then().expect().body(equalTo("something")).when().get("/headers");This will send a GET request to "/headers" with two headers:
firstHeaderName
- The name of the first headerfirstHeaderValue
- The value of the first headerheaderNameValuePairs
- Additional headers in name-value pairs.WebTestClientRequestSpecification headers(Map<String,?> headers)
Map<String, String> headers = new HashMap<String, String>(); parameters.put("headerName1", "headerValue1"); parameters.put("headerName2", "headerValue2"); given().headers(headers).then().expect().body(equalTo("something")).when().get("/headers");This will send a GET request to "/headers" with two headers:
headers
- The Map containing the header names and their values to send with the request.WebTestClientRequestSpecification headers(io.restassured.http.Headers headers)
Headers
, e.g:
Header first = new Header("headerName1", "headerValue1"); Header second = new Header("headerName2", "headerValue2"); Headers headers = new Header(first, second); given().headers(headers).then().expect().body(equalTo("something")).when().get("/headers");This will send a GET request to "/headers" with two headers:
headers
- The headers to use in the requestWebTestClientRequestSpecification header(String headerName, Object headerValue, Object... additionalHeaderValues)
given().header("username", "John").and().expect().body(equalTo("something")).when().get("/header");This will set the header
username=John
in the GET request to "/header".
You can also specify several headers like this:
given().header("username", "John").and().header("zipCode", "12345").and().expect().body(equalTo("something")).when().get("/header");If you specify
additionalHeaderValues
then the Header will be a multi-value header. This means that you'll create several headers with the
same name but with different values.headerName
- The header nameheaderValue
- The header valueadditionalHeaderValues
- Additional header values. This will actually create two headers with the same name but with different values.headers(String, Object, Object...)
WebTestClientRequestSpecification header(io.restassured.http.Header header)
Header
to send with the request.
Header someHeader = new Header("some_name", "some_value"); given().header(someHeader).and().expect().body(equalTo("x")).when().get("/header");This will set the header
some_name=some_value
in the GET request to "/header".
header
- The header to add to the requestheaders(Headers)
WebTestClientRequestLogSpecification log()
WebTestClientRequestLogSpecification
that allows you to log different parts of the WebTestClientRequestSpecification
.
This is mainly useful for debug purposes when writing your tests.WebTestClientRequestSpecification params(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
given().params("username", "John", "token", "1234").when().get("/parameters").then().assertThat().body(equalTo("username, token"));This will send a GET request to "/parameters" with two parameters:
firstParameterName
- The name of the first parameterfirstParameterValue
- The value of the first parameterparameterNameValuePairs
- Additional parameters in name-value pairs.WebTestClientRequestSpecification params(Map<String,?> parametersMap)
Map<String, String> parameters = new HashMap<String, String>(); parameters.put("username", "John"); parameters.put("token", "1234"); given().params(parameters).when().get("/cookie").then().assertThat().body(equalTo("username, token")).;This will send a GET request to "/cookie" with two parameters:
parametersMap
- The Map containing the parameter names and their values to send with the request.WebTestClientRequestSpecification param(String parameterName, Object... parameterValues)
given().parameter("username", "John").and().expect().body(equalTo("username")).when().get("/cookie");This will set the parameter
username=John
in the GET request to "/cookie".
You can also specify several parameters like this:
given().param("username", "John").and().param("password", "1234").when().get("/cookie").then().assertThat().body(equalTo("username")).;
parameterName
- The parameter nameparameterValues
- Zero to many parameter values for this parameter nameparams(String, Object, Object...)
WebTestClientRequestSpecification param(String parameterName, Collection<?> parameterValues)
given().param("cars", asList("Volvo", "Saab"))..;This will set the parameter
cars=Volvo
and cars=Saab
.
parameterName
- The parameter nameparameterValues
- The parameter valuesWebTestClientRequestSpecification queryParams(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
params(String, Object, Object...)
for all http methods except for POST where params(String, Object, Object...)
sets the form parameters and this method sets the
query parameters.firstParameterName
- The name of the first parameterfirstParameterValue
- The value of the first parameterparameterNameValuePairs
- The value of the first parameter followed by additional parameters in name-value pairs.WebTestClientRequestSpecification queryParams(Map<String,?> parametersMap)
params(Map)
for all http methods except for POST where params(Map)
sets the form parameters and this method sets the
query parameters.parametersMap
- The Map containing the parameter names and their values to send with the request.WebTestClientRequestSpecification queryParam(String parameterName, Object... parameterValues)
param(String, Object...)
for all http methods except for POST where param(String, Object...)
adds a form parameter and this method sets a
query parameter.parameterName
- The parameter nameparameterValues
- Zero to many parameter values, i.e. you can specify multiple values for the same parameterparam(String, Object...)
WebTestClientRequestSpecification queryParam(String parameterName, Collection<?> parameterValues)
given().queryParam("cars", asList("Volvo", "Saab"))..;This will set the parameter
cars=Volvo
and cars=Saab
.
Note that this method is the same as param(String, java.util.Collection)
for all http methods except for POST where param(String, java.util.Collection)
adds a form parameter and
this method sets a query parameter.parameterName
- The parameter nameparameterValues
- The parameter valuesWebTestClientRequestSpecification formParams(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
params(String, Object, Object...)
for all http methods except for POST where params(String, Object, Object...)
sets the form parameters and this method sets the
form parameters.firstParameterName
- The name of the first parameterfirstParameterValue
- The value of the first parameterparameterNameValuePairs
- The value of the first parameter followed by additional parameters in name-value pairs.WebTestClientRequestSpecification formParams(Map<String,?> parametersMap)
params(Map)
for all http methods except for POST where params(Map)
sets the form parameters and this method sets the
form parameters.parametersMap
- The Map containing the parameter names and their values to send with the request.WebTestClientRequestSpecification formParam(String parameterName, Object... parameterValues)
param(String, Object...)
for all http methods except for POST where param(String, Object...)
adds a form parameter and this method sets a
form parameter.parameterName
- The parameter nameparameterValues
- Zero to many parameter values, i.e. you can specify multiple values for the same parameterparam(String, Object...)
WebTestClientRequestSpecification formParam(String parameterName, Collection<?> parameterValues)
given().formParam("cars", asList("Volvo", "Saab"))..;This will set the parameter
cars=Volvo
and cars=Saab
.
Note that this method is the same as param(String, java.util.Collection)
for all http methods except for POST where param(String, java.util.Collection)
adds a form parameter and
this method sets a form parameter.parameterName
- The parameter nameparameterValues
- The parameter valuesWebTestClientRequestSpecification attribute(String attributeName, Object attributeValue)
attributeName
- The attribute nameattributeValue
- The attribute valueWebTestClientRequestSpecification attributes(Map<String,?> attributesMap)
attributesMap
- The Map containing the request attribute names and their valuesWebTestClientRequestSpecification body(String body)
Example of use:
given().body("{ \"message\" : \"hello world\"}").then().expect().body(equalTo("hello world")).when().post("/json");This will POST a request containing JSON to "/json" and expect that the response body equals to "hello world".
body
- The body to send.WebTestClientRequestSpecification body(byte[] body)
Example of use:
byte[] someBytes = .. given().body(someBytes).then().expect().body(equalTo("hello world")).when().post("/json");This will POST a request containing
someBytes
to "/json" and expect that the response body equals to "hello world".
body
- The body to send.WebTestClientRequestSpecification body(File body)
Example of use:
File myFile = .. given().content(myFile).when().post("/json").then().content(equalTo("hello world"));This will POST a request containing
myFile
to "/json" and expect that the response content equals to "hello world".
body
- The content to send.WebTestClientRequestSpecification body(Object object)
Example of use:
Message message = new Message(); message.setMessage("My beautiful message"); given(). contentType("application/json"). body(message). expect(). content(equalTo("Response to a beautiful message")). when(). post("/beautiful-message");Since the content-type is "application/json" then REST Assured will automatically try to serialize the object using Jackson or Gson if they are available in the classpath. If any of these frameworks are not in the classpath then an exception is thrown.
object
- The object to serialize and send with the requestWebTestClientRequestSpecification body(Object object, io.restassured.mapper.ObjectMapper mapper)
Message message = new Message(); message.setMessage("My beautiful message"); given(). body(message, new MyObjectMapper()). expect(). content(equalTo("Response to a beautiful message")). when(). post("/beautiful-message");
object
- The object to serialize and send with the requestmapper
- The object mapperWebTestClientRequestSpecification body(Object object, io.restassured.mapper.ObjectMapperType mapperType)
Message message = new Message(); message.setMessage("My beautiful message"); given(). body(message, ObjectMapper.GSON). expect(). content(equalTo("Response to a beautiful message")). when(). post("/beautiful-message");
object
- The object to serialize and send with the requestmapperType
- The object mapper type to be usedWebTestClientRequestSpecification cookies(String firstCookieName, Object firstCookieValue, Object... cookieNameValuePairs)
given().cookies("username", "John", "token", "1234").then().expect().body(equalTo("username, token")).when().get("/cookie");This will send a GET request to "/cookie" with two cookies:
firstCookieName
- The name of the first cookiefirstCookieValue
- The value of the first cookiecookieNameValuePairs
- Additional cookies in name-value pairs.WebTestClientRequestSpecification cookies(Map<String,?> cookies)
Map<String, String> cookies = new HashMap<String, String>(); cookies.put("username", "John"); cookies.put("token", "1234"); given().cookies(cookies).then().expect().body(equalTo("username, token")).when().get("/cookie");This will send a GET request to "/cookie" with two cookies:
cookies
- The Map containing the cookie names and their values to set in the request.WebTestClientRequestSpecification cookies(io.restassured.http.Cookies cookies)
Cookies
:
Cookie cookie1 = Cookie.Builder("username", "John").setComment("comment 1").build(); Cookie cookie2 = Cookie.Builder("token", 1234).setComment("comment 2").build(); Cookies cookies = new Cookies(cookie1, cookie2); given().cookies(cookies).then().expect().body(equalTo("username, token")).when().get("/cookie");This will send a GET request to "/cookie" with two cookies:
cookies
- The cookies to set in the request.WebTestClientRequestSpecification cookie(String cookieName, Object value, Object... additionalValues)
given().cookie("username", "John").and().expect().body(equalTo("username")).when().get("/cookie");This will set the cookie
username=John
in the GET request to "/cookie".
You can also specify several cookies like this:
given().cookie("username", "John").and().cookie("password", "1234").and().expect().body(equalTo("username")).when().get("/cookie");If you specify
additionalValues
then the Cookie will be a multi-value cookie. This means that you'll create several cookies with the
same name but with different values.cookieName
- The cookie cookieNamevalue
- The cookie valueadditionalValues
- Additional cookies values. This will actually create two cookies with the same name but with different values.cookies(String, Object, Object...)
WebTestClientRequestSpecification cookie(io.restassured.http.Cookie cookie)
Cookie
to send with the request.
Cookie someCookie = new Cookie.Builder("some_cookie", "some_value").setSecured(true).build(); given().cookie(someCookie).and().expect().body(equalTo("x")).when().get("/cookie");This will set the cookie
someCookie
in the GET request to "/cookie".
cookie
- The cookie to add to the requestcookies(Cookies)
WebTestClientRequestSpecification multiPart(File file)
file
- The file to uploadWebTestClientRequestSpecification multiPart(String controlName, File file)
file
- The file to uploadcontrolName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.WebTestClientRequestSpecification multiPart(String controlName, File file, String mimeType)
file
- The file to uploadcontrolName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.mimeType
- The mime-typeWebTestClientRequestSpecification multiPart(String controlName, Object object)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.object
- The object to serialize to JSON or XML and send to the serverWebTestClientRequestSpecification multiPart(String controlName, Object object, String mimeType)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.object
- The object to serialize to JSON or XML and send to the servermimeType
- The mime-typeWebTestClientRequestSpecification multiPart(String controlName, String filename, Object object, String mimeType)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.filename
- The name of the content you're uploadingobject
- The object to serialize to JSON or XML and send to the servermimeType
- The mime-typeWebTestClientRequestSpecification multiPart(String controlName, String fileName, byte[] bytes)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.fileName
- The name of the content you're uploadingbytes
- The bytes you want to sendWebTestClientRequestSpecification multiPart(String controlName, String fileName, byte[] bytes, String mimeType)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.fileName
- The name of the content you're uploadingbytes
- The bytes you want to sendmimeType
- The mime-typeWebTestClientRequestSpecification multiPart(String controlName, String fileName, InputStream stream)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.fileName
- The name of the content you're uploadingstream
- The stream you want to sendWebTestClientRequestSpecification multiPart(String controlName, String fileName, InputStream stream, String mimeType)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.fileName
- The name of the content you're uploadingstream
- The stream you want to sendmimeType
- The mime-typeWebTestClientRequestSpecification multiPart(String controlName, String contentBody)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.contentBody
- The string to sendWebTestClientRequestSpecification multiPart(String controlName, String contentBody, String mimeType)
controlName
- Defines the control name of the body part. In HTML this is the attribute name of the input tag.contentBody
- The string to sendmimeType
- The mime-typeWebTestClientRequestSpecification config(RestAssuredWebTestClientConfig config)
given().config(newConfig().logConfig(new LogConfig(captor, true))). ..
newConfig()
can be statically imported from RestAssuredWebTestClientConfig
.config
- The configuration to use for this request. If null
no config will be used.WebTestClientRequestSpecification config(SpecificationConfig config)
WebTestClientRequestSpecification spec(WebTestClientRequestSpecification requestSpecificationToMerge)
WebTestClientRequestSpecification requestSpec = new WebTestClientRequestSpecBuilder().addParam("parameter1", "value1").build(); given(). spec(requestSpec). param("parameter2", "value2"). when(). get("/something");This is useful when you want to reuse an entire specification across multiple requests. The specification passed to this method is merged with the current specification. Note that the supplied specification can overwrite data in the current specification. The following settings are overwritten:
requestSpecificationToMerge
)requestSpecificationToMerge
- The specification to merge with.WebTestClientRequestSpecification sessionId(String sessionIdValue)
RestAssured.config = newConfig().sessionConfig(new SessionConfig().sessionIdName(<sessionIdName>));or you can use the
sessionId(String, String)
method to set it for this request only.sessionIdValue
- The session id value.WebTestClientRequestSpecification sessionId(String sessionIdName, String sessionIdValue)
RestAssured.config = newConfig().sessionConfig(new SessionConfig().sessionIdName(<sessionIdName>));and then you can use the
sessionId(String)
method to set the session id value without specifying the name for each request.sessionIdName
- The session id namesessionIdValue
- The session id value.WebTestClientRequestSender when()
WebTestClientRequestSender
that let's you send the request.WebTestClientRequestSpecification standaloneSetup(Object... controllerOrWebTestClientConfigurer)
WebTestClient
by registering one or more @Controller
's
instances and configuring Spring infrastructure programmatically.
This allows full control over the instantiation and initialization of
controllerOrWebTestClientConfigurer, and their dependencies, similar to plain unit tests while
also making it possible to test one controller at a time.
This uses the WebTestClient.bindToController(Object...)
method under the hood.
controllerOrWebTestClientConfigurer
- one or more @Controller
's to test
or a combination of controllers and WebTestClientConfigurer
WebTestClientRequestSpecification standaloneSetup(org.springframework.test.web.reactive.server.WebTestClient.Builder builder)
WebTestClient
by using a provided AbstractWebTestClientBuilder
for configuring Spring infrastructure programmatically.
This allows full control over the instantiation and initialization of
controllers, and their dependencies, similar to plain unit tests while
also making it possible to test one controller at a time.
This uses the WebTestClient.Builder
to set up the WebTestClient instance.
builder
- WebTestClient.Builder
to build the WebTestClient instance.WebTestClientRequestSpecification standaloneSetup(org.springframework.web.reactive.function.server.RouterFunction routerFunction, org.springframework.test.web.reactive.server.WebTestClientConfigurer... configurers)
WebTestClientRequestSpecification webTestClient(org.springframework.test.web.reactive.server.WebTestClient webTestClient)
WebTestClient
instance to that REST Assured will use when making this request.webTestClient
- WebTestClient instance to use.WebTestClientRequestSpecification webAppContextSetup(org.springframework.web.context.WebApplicationContext context, org.springframework.test.web.reactive.server.WebTestClientConfigurer... configurers)
WebTestClient
using the given, fully initialized, i.e.
refreshed, WebApplicationContext
and assign it to REST Assured.
This method has been kept for consistency, but, actually, it is only be used as ApplicationContext
.
The effect of calling this method is same as for applicationContextSetup(ApplicationContext, WebTestClientConfigurer...)
context
- The web application context to useconfigurers
- WebTestClientConfigurer
's to be applied when creating a WebTestClient
instance of this WebApplicationContext (optional)WebTestClientRequestSpecification applicationContextSetup(org.springframework.context.ApplicationContext context, org.springframework.test.web.reactive.server.WebTestClientConfigurer... configurers)
WebTestClientRequestSpecification and()
WebTestClientRequestSpecification
instance.Copyright © 2010–2022. All rights reserved.