public class RequestSpecBuilder extends Object
ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
RequestSpecification requestSpec = new RequestSpecBuilder().addParam("parameter1", "value1").build();
given(responseSpec, requestSpec).post("/something");
or
RequestSpecification requestSpec = new RequestSpecBuilder().addParameter("parameter1", "value1").build();
given().
spec(requestSpec).
expect().
body("x.y.z", equalTo("something")).
when().
get("/something");
| Constructor and Description |
|---|
RequestSpecBuilder() |
| Modifier and Type | Method and Description |
|---|---|
RequestSpecBuilder |
addCookie(Cookie cookie)
Add a detailed cookie
|
RequestSpecBuilder |
addCookie(String name)
Add a cookie without value to be sent with the request.
|
RequestSpecBuilder |
addCookie(String key,
Object value,
Object... cookieNameValuePairs)
Add a cookie to be sent with the request.
|
RequestSpecBuilder |
addCookies(Cookies cookies)
Specify multiple detailed cookies that'll be sent with the request.
|
RequestSpecBuilder |
addCookies(Map<String,?> cookies)
Add cookies to be sent with the request as Map e.g:
|
RequestSpecBuilder |
addFilter(Filter filter)
Add a filter that will be used in the request.
|
RequestSpecBuilder |
addFilters(List<Filter> filters)
Add filters that will be used in the request.
|
RequestSpecBuilder |
addFormParam(String parameterName,
Collection<?> parameterValues)
A slightly shorter version of
addFormParameter(String, java.util.Collection). |
RequestSpecBuilder |
addFormParam(String parameterName,
Object... parameterValues)
A slightly shorter version of
addFormParameter(String, Object...). |
RequestSpecBuilder |
addFormParameter(String parameterName,
Collection<?> parameterValues)
Add a form parameter to be sent with the request.
|
RequestSpecBuilder |
addFormParameter(String parameterName,
Object... parameterValues)
Add a form parameter to be sent with the request.
|
RequestSpecBuilder |
addFormParameters(Map<String,?> parametersMap)
Add query parameters to be sent with the request as a Map.
|
RequestSpecBuilder |
addFormParams(Map<String,?> parametersMap)
A slightly shorter version of
addFormParameters(Map). |
RequestSpecBuilder |
addHeader(String headerName,
String headerValue)
Add a header to be sent with the request e.g:
|
RequestSpecBuilder |
addHeaders(Map<String,String> headers)
Add headers to be sent with the request as Map.
|
RequestSpecBuilder |
addMultiPart(File file)
Specify a file to upload to the server using multi-part form data uploading.
|
RequestSpecBuilder |
addMultiPart(String controlName,
File file)
Specify a file to upload to the server using multi-part form data uploading with a specific
control name.
|
RequestSpecBuilder |
addMultiPart(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 content-type.
|
RequestSpecBuilder |
addMultiPart(String controlName,
String contentBody)
Specify a string to send to the server using multi-part form data.
|
RequestSpecBuilder |
addMultiPart(String controlName,
String fileName,
byte[] bytes)
Specify a byte-array to upload to the server using multi-part form data.
|
RequestSpecBuilder |
addMultiPart(String controlName,
String fileName,
byte[] bytes,
String mimeType)
Specify a byte-array to upload to the server using multi-part form data.
|
RequestSpecBuilder |
addMultiPart(String controlName,
String fileName,
InputStream stream)
Specify an inputstream to upload to the server using multi-part form data.
|
RequestSpecBuilder |
addMultiPart(String controlName,
String fileName,
InputStream stream,
String mimeType)
Specify an inputstream to upload to the server using multi-part form data.
|
RequestSpecBuilder |
addMultiPart(String controlName,
String contentBody,
String mimeType)
Specify a string to send to the server using multi-part form data with a specific mime-type.
|
RequestSpecBuilder |
addParam(String parameterName,
Collection<?> parameterValues)
A slightly shorter version of
addParameter(String, java.util.Collection). |
RequestSpecBuilder |
addParam(String parameterName,
Object... parameterValues)
A slightly shorter version of
addParameter(String, Object...). |
RequestSpecBuilder |
addParameter(String parameterName,
Collection<?> parameterValues)
Add a multi-value parameter to be sent with the request.
|
RequestSpecBuilder |
addParameter(String parameterName,
Object... parameterValues)
Add a parameter to be sent with the request.
|
RequestSpecBuilder |
addParameters(Map<String,?> parametersMap)
Add parameters to be sent with the request as Map.
|
RequestSpecBuilder |
addParams(Map<String,?> parametersMap)
A slightly shorter version of
addParameters(Map). |
RequestSpecBuilder |
addPathParam(String parameterName,
Object parameterValue)
A slightly shorter version of
addPathParameter(String, Object). |
RequestSpecBuilder |
addPathParameter(String parameterName,
Object parameterValue)
Specify a path parameter.
|
RequestSpecBuilder |
addPathParameters(Map<String,?> parameterNameValuePairs)
Specify multiple path parameter name-value pairs.
|
RequestSpecBuilder |
addPathParameters(String firstParameterName,
Object firstParameterValue,
Object... parameterNameValuePairs)
Specify multiple path parameter name-value pairs.
|
RequestSpecBuilder |
addPathParams(Map<String,?> parameterNameValuePairs)
A slightly shorter version of
addPathParameters(java.util.Map). |
RequestSpecBuilder |
addPathParams(String firstParameterName,
Object firstParameterValue,
Object... parameterNameValuePairs)
A slightly shorter version of
addPathParameters(String, Object, Object...). |
RequestSpecBuilder |
addQueryParam(String parameterName,
Collection<?> parameterValues)
A slightly shorter version of
addQueryParameter(String, java.util.Collection). |
RequestSpecBuilder |
addQueryParam(String parameterName,
Object... parameterValues)
A slightly shorter version of
addQueryParameter(String, Object...). |
RequestSpecBuilder |
addQueryParameter(String parameterName,
Collection<?> parameterValues)
Add a query parameter to be sent with the request.
|
RequestSpecBuilder |
addQueryParameter(String parameterName,
Object... parameterValues)
Add a query parameter to be sent with the request.
|
RequestSpecBuilder |
addQueryParameters(Map<String,?> parametersMap)
Add query parameters to be sent with the request as a Map.
|
RequestSpecBuilder |
addQueryParams(Map<String,?> parametersMap)
A slightly shorter version of
addQueryParameters(Map). |
RequestSpecBuilder |
addRequestSpecification(RequestSpecification specification)
Merge this builder with settings from another specification.
|
RequestSpecBuilder |
and()
Syntactic sugar.
|
RequestSpecification |
build()
Build RequestSpecBuilder.
|
RequestSpecBuilder |
log(LogDetail logDetail)
Enabled logging with the specified log detail.
|
RequestSpecBuilder |
setAuth(AuthenticationScheme auth)
A slightly short version of
setAuthentication(com.jayway.restassured.authentication.AuthenticationScheme) )}. |
RequestSpecBuilder |
setAuthentication(AuthenticationScheme auth)
If you need to specify some credentials when performing a request.
|
RequestSpecBuilder |
setBasePath(String path)
Set the base path that's prepended to each path by REST assured when making requests.
|
RequestSpecBuilder |
setBaseUri(String uri)
Add the baseUri property from the RequestSpecBuilder instead of using static field RestAssured.baseURI.
|
RequestSpecBuilder |
setBody(byte[] body)
Specify a byte array request body to be sent with the request.
|
RequestSpecBuilder |
setBody(Object object)
Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request.
|
RequestSpecBuilder |
setBody(Object object,
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.
|
RequestSpecBuilder |
setBody(Object object,
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.
|
RequestSpecBuilder |
setBody(String body)
Specify a String request body (such as e.g.
|
RequestSpecBuilder |
setConfig(RestAssuredConfig config)
Define a configuration for redirection settings and http client parameters.
|
RequestSpecBuilder |
setContent(byte[] content)
Specify a byte array request content to be sent with the request.
|
RequestSpecBuilder |
setContent(Object object)
Specify an Object request content that will automatically be serialized to JSON or XML and sent with the request.
|
RequestSpecBuilder |
setContent(Object object,
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.
|
RequestSpecBuilder |
setContent(Object object,
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.
|
RequestSpecBuilder |
setContent(String content)
Specify a String request content (such as e.g.
|
RequestSpecBuilder |
setContentType(ContentType contentType)
Specify the content type of the request.
|
RequestSpecBuilder |
setContentType(String contentType)
Specify the content type of the request as string.
|
RequestSpecBuilder |
setKeystore(String pathToJks,
String password)
The following documentation is taken from http://groovy.codehaus.org/modules/http-builder/doc/ssl.html:
|
RequestSpecBuilder |
setPort(int port)
Specify the port.
|
RequestSpecBuilder |
setProxy(int port)
Instruct REST Assured to connect to a proxy on the specified port on localhost.
|
RequestSpecBuilder |
setProxy(ProxySpecification proxySpecification)
Instruct REST Assured to connect to a proxy using a
ProxySpecification. |
RequestSpecBuilder |
setProxy(String host)
Instruct REST Assured to connect to a proxy on the specified host on port
8888. |
RequestSpecBuilder |
setProxy(String host,
int port)
Instruct REST Assured to connect to a proxy on the specified host and port.
|
RequestSpecBuilder |
setProxy(String host,
int port,
String scheme)
Instruct REST Assured to connect to a proxy on the specified port on localhost with a specific scheme.
|
RequestSpecBuilder |
setProxy(URI uri)
Instruct REST Assured to connect to a proxy using a URI.
|
RequestSpecBuilder |
setRelaxedHTTPSValidation()
Use relaxed HTTP validation.
|
RequestSpecBuilder |
setSessionId(String sessionIdValue)
Set the session id for this request.
|
RequestSpecBuilder |
setSessionId(String sessionIdName,
String sessionIdValue)
Set the session id name and value for this request.
|
RequestSpecBuilder |
setTrustStore(KeyStore trustStore)
Use the supplied truststore for HTTPS requests.
|
RequestSpecBuilder |
setUrlEncodingEnabled(boolean isEnabled)
Specifies if Rest Assured should url encode the URL automatically.
|
public RequestSpecBuilder setBody(String body)
Note that setBody(String) and setContent(String) are the same except for the syntactic difference.
body - The body to send.public RequestSpecBuilder setBody(byte[] body)
Note that setBody(byte[]) and setContent(byte[]) are the same except for the syntactic difference.
body - The body to send.public RequestSpecBuilder setBody(Object object)
Note that setBody(Object) and setContent(Object) are the same except for the syntactic difference.
object - The object to serialize and send with the requestpublic RequestSpecBuilder setBody(Object object, ObjectMapper mapper)
Note that setBody(Object, com.jayway.restassured.mapper.ObjectMapper) and setContent(Object, com.jayway.restassured.mapper.ObjectMapper)
are the same except for the syntactic difference.
object - The object to serialize and send with the requestmapper - The object mapperpublic RequestSpecBuilder setBody(Object object, ObjectMapperType mapperType)
Example of use:
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");
Note that setBody(Object, com.jayway.restassured.internal.mapper.ObjectMapperType) and setContent(Object, com.jayway.restassured.internal.mapper.ObjectMapperType)
are the same except for the syntactic difference.
object - The object to serialize and send with the requestmapperType - The object mapper type to be usedpublic RequestSpecBuilder setContent(String content)
Note that setBody(String) and setContent(String) are the same except for the syntactic difference.
content - The content to send.public RequestSpecBuilder setContent(byte[] content)
Note that setBody(byte[]) and setContent(byte[]) are the same except for the syntactic difference.
content - The content to send.public RequestSpecBuilder setContent(Object object)
Note that setBody(Object) and setContent(Object) are the same except for the syntactic difference.
object - The object to serialize and send with the requestpublic RequestSpecBuilder setContent(Object object, ObjectMapper mapper)
Note that setBody(Object, com.jayway.restassured.mapper.ObjectMapper) and setContent(Object, com.jayway.restassured.mapper.ObjectMapper)
are the same except for the syntactic difference.
object - The object to serialize and send with the requestmapper - The object mapperpublic RequestSpecBuilder setContent(Object object, ObjectMapperType mapperType)
Example of use:
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");
Note that setBody(Object, com.jayway.restassured.internal.mapper.ObjectMapperType) and setContent(Object, com.jayway.restassured.internal.mapper.ObjectMapperType)
are the same except for the syntactic difference.
object - The object to serialize and send with the requestmapperType - The object mapper type to be usedpublic RequestSpecBuilder addCookies(Map<String,?> cookies)
cookies - The Map containing the cookie names and their values to set in the request.public RequestSpecBuilder addCookie(Cookie cookie)
cookie - The cookie to add.public RequestSpecBuilder addCookie(String key, Object value, Object... cookieNameValuePairs)
key - The cookie keyvalue - The cookie valuecookieNameValuePairs - Additional cookies values. This will actually create two cookies with the same name but with different values.public RequestSpecBuilder addCookie(String name)
name - The cookie namepublic RequestSpecBuilder addCookies(Cookies cookies)
cookies - The cookies to set in the request.RequestSpecification.cookies(com.jayway.restassured.response.Cookies)public RequestSpecBuilder addFilter(Filter filter)
filter - The filter to addpublic RequestSpecBuilder addFilters(List<Filter> filters)
filters - The filters to addpublic RequestSpecBuilder addParameters(Map<String,?> parametersMap)
parametersMap - The Map containing the parameter names and their values to send with the request.public RequestSpecBuilder addParameter(String parameterName, Object... parameterValues)
parameterName - The parameter nameparameterValues - Zero to many parameter values for this parameter name.public RequestSpecBuilder addParameter(String parameterName, Collection<?> parameterValues)
parameterName - The parameter keyparameterValues - The parameter valuespublic RequestSpecBuilder addParams(Map<String,?> parametersMap)
addParameters(Map).parametersMap - The Map containing the parameter names and their values to send with the request.public RequestSpecBuilder addParam(String parameterName, Object... parameterValues)
addParameter(String, Object...).parameterValues - Zero to many parameter values for this parameter name.addParameter(String, Object...)public RequestSpecBuilder addParam(String parameterName, Collection<?> parameterValues)
addParameter(String, java.util.Collection).parameterName - The parameter keyparameterValues - The parameter valuesaddParameter(String, Object...)public RequestSpecBuilder addQueryParameters(Map<String,?> parametersMap)
addParameters(java.util.Map)
for all HTTP methods except POST where this method can be used to differentiate between form and query params.parametersMap - The Map containing the parameter names and their values to send with the request.public RequestSpecBuilder addQueryParameter(String parameterName, Object... parameterValues)
addParameter(String, Object...) )}
for all HTTP methods except POST where this method can be used to differentiate between form and query params.parameterName - The parameter keyparameterValues - Zero to many parameter values for this parameter name.public RequestSpecBuilder addQueryParameter(String parameterName, Collection<?> parameterValues)
addParameter(String, java.util.Collection)
for all HTTP methods except POST where this method can be used to differentiate between form and query params.parameterName - The parameter keyparameterValues - The parameter valuespublic RequestSpecBuilder addQueryParam(String parameterName, Collection<?> parameterValues)
addQueryParameter(String, java.util.Collection).parameterName - The parameter keyparameterValues - The parameter valuesaddQueryParam(String, Object...)public RequestSpecBuilder addQueryParams(Map<String,?> parametersMap)
addQueryParameters(Map).parametersMap - The Map containing the parameter names and their values to send with the request.addQueryParameters(java.util.Map)public RequestSpecBuilder addQueryParam(String parameterName, Object... parameterValues)
addQueryParameter(String, Object...).parameterName - The parameter keyparameterValues - Zero to many parameter values for this parameter name.addQueryParameter(String, Object...)public RequestSpecBuilder addFormParameters(Map<String,?> parametersMap)
addParameters(java.util.Map)
for all HTTP methods except POST where this method can be used to differentiate between form and query params.parametersMap - The Map containing the parameter names and their values to send with the request.public RequestSpecBuilder addFormParameter(String parameterName, Object... parameterValues)
addParameter(String, Object...) )}
for all HTTP methods except PUT where this method can be used to differentiate between form and query params.parameterName - The parameter keyparameterValues - Zero to many parameter values for this parameter name.public RequestSpecBuilder addFormParameter(String parameterName, Collection<?> parameterValues)
addParameter(String, java.util.Collection)
for all HTTP methods except PUT where this method can be used to differentiate between form and query params.parameterName - The parameter keyparameterValues - The parameter valuespublic RequestSpecBuilder addFormParam(String parameterName, Collection<?> parameterValues)
addFormParameter(String, java.util.Collection).parameterName - The parameter keyparameterValues - The parameter valuesaddFormParam(String, Object...)public RequestSpecBuilder addFormParams(Map<String,?> parametersMap)
addFormParameters(Map).parametersMap - The Map containing the parameter names and their values to send with the request.addFormParameters(java.util.Map)public RequestSpecBuilder addFormParam(String parameterName, Object... parameterValues)
addFormParameter(String, Object...).parameterName - The parameter nameparameterValues - Zero to many parameter values for this parameter name.addFormParam(String, Object...)public RequestSpecBuilder addPathParameter(String parameterName, Object parameterValue)
expect().statusCode(200).when().get("/item/"+myItem.getItemNumber()+"/buy/"+2);
you can write:
given().
pathParameter("itemNumber", myItem.getItemNumber()).
pathParameter("amount", 2).
expect().
statusCode(200).
when().
get("/item/{itemNumber}/buy/{amount}");
which improves readability and allows the path to be reusable in many tests. Another alternative is to use:
expect().statusCode(200).when().get("/item/{itemNumber}/buy/{amount}", myItem.getItemNumber(), 2);
parameterName - The parameter keyparameterValue - The parameter valuepublic RequestSpecBuilder addPathParameters(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
expect().statusCode(200).when().get("/item/"+myItem.getItemNumber()+"/buy/"+2);
you can write:
given().
pathParameters("itemNumber", myItem.getItemNumber(), "amount", 2).
expect().
statusCode(200).
when().
get("/item/{itemNumber}/buy/{amount}");
which improves readability and allows the path to be reusable in many tests. Another alternative is to use:
expect().statusCode(200).when().get("/item/{itemNumber}/buy/{amount}", myItem.getItemNumber(), 2);
firstParameterName - The name of the first parameterfirstParameterValue - The value of the first parameterparameterNameValuePairs - Additional parameters in name-value pairs.public RequestSpecBuilder addPathParameters(Map<String,?> parameterNameValuePairs)
expect().statusCode(200).when().get("/item/"+myItem.getItemNumber()+"/buy/"+2);
you can write:
Map<String,Object> pathParams = new HashMap<String,Object>();
pathParams.add("itemNumber",myItem.getItemNumber());
pathParams.add("amount",2);
given().
pathParameters(pathParams).
expect().
statusCode(200).
when().
get("/item/{itemNumber}/buy/{amount}");
which improves readability and allows the path to be reusable in many tests. Another alternative is to use:
expect().statusCode(200).when().get("/item/{itemNumber}/buy/{amount}", myItem.getItemNumber(), 2);
parameterNameValuePairs - A map containing the path parameters.public RequestSpecBuilder addPathParam(String parameterName, Object parameterValue)
addPathParameter(String, Object).parameterName - The parameter keyparameterValue - The parameter valueaddPathParameter(String, Object)public RequestSpecBuilder addPathParams(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
addPathParameters(String, Object, Object...).firstParameterName - The name of the first parameterfirstParameterValue - The value of the first parameterparameterNameValuePairs - Additional parameters in name-value pairs.addPathParameters(String, Object, Object...)public RequestSpecBuilder addPathParams(Map<String,?> parameterNameValuePairs)
addPathParameters(java.util.Map).parameterNameValuePairs - A map containing the path parameters.addPathParameters(java.util.Map)public RequestSpecBuilder setKeystore(String pathToJks, String password)
$ keytool -printcert -file EquifaxSecureGlobaleBusinessCA-1.crt Owner: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Issuer: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Serial number: 1 Valid from: Mon Jun 21 00:00:00 EDT 1999 until: Sun Jun 21 00:00:00 EDT 2020 Certificate fingerprints: MD5: 8F:5D:77:06:27:C4:98:3C:5B:93:78:E7:D7:7D:9B:CC SHA1: 7E:78:4A:10:1C:82:65:CC:2D:E1:F1:6D:47:B4:40:CA:D9:0A:19:45 Signature algorithm name: MD5withRSA Version: 3 ....Now, import that into a Java keystore file:
$ keytool -importcert -alias "equifax-ca" -file EquifaxSecureGlobaleBusinessCA-1.crt -keystore truststore_javanet.jks -storepass test1234 Owner: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Issuer: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US Serial number: 1 Valid from: Mon Jun 21 00:00:00 EDT 1999 until: Sun Jun 21 00:00:00 EDT 2020 Certificate fingerprints: MD5: 8F:5D:77:06:27:C4:98:3C:5B:93:78:E7:D7:7D:9B:CC SHA1: 7E:78:4A:10:1C:82:65:CC:2D:E1:F1:6D:47:B4:40:CA:D9:0A:19:45 Signature algorithm name: MD5withRSA Version: 3 ... Trust this certificate? [no]: yes Certificate was added to keystoreNow you want to use this truststore in your client:
RestAssured.keystore("/truststore_javanet.jks", "test1234");
or
given().keystore("/truststore_javanet.jks", "test1234"). ..
pathToJks - The path to the JKSpassword - The store passpublic RequestSpecBuilder addHeaders(Map<String,String> headers)
headers - The Map containing the header names and their values to send with the request.public RequestSpecBuilder addHeader(String headerName, String headerValue)
headerName - The header nameheaderValue - The header valuepublic RequestSpecBuilder setContentType(ContentType contentType)
contentType - The content type of the requestContentTypepublic RequestSpecBuilder setContentType(String contentType)
contentType - The content type of the requestpublic RequestSpecBuilder addMultiPart(File file)
file - The file to uploadpublic RequestSpecBuilder addMultiPart(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.public RequestSpecBuilder addMultiPart(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 content-typepublic RequestSpecBuilder addMultiPart(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 sendpublic RequestSpecBuilder addMultiPart(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 content-typepublic RequestSpecBuilder addMultiPart(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 sendpublic RequestSpecBuilder addMultiPart(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 content-typepublic RequestSpecBuilder addMultiPart(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 sendpublic RequestSpecBuilder addMultiPart(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-typepublic RequestSpecBuilder setAuthentication(AuthenticationScheme auth)
public RequestSpecBuilder setAuth(AuthenticationScheme auth)
setAuthentication(com.jayway.restassured.authentication.AuthenticationScheme) )}.setAuthentication(com.jayway.restassured.authentication.AuthenticationScheme)public RequestSpecBuilder setPort(int port)
port - The port of URIpublic RequestSpecBuilder setUrlEncodingEnabled(boolean isEnabled)
isEnabled - Specify whether or not URL encoding should be enabled or disabled.public RequestSpecBuilder setSessionId(String sessionIdValue)
RestAssured.config = newConfig().sessionConfig(new SessionConfig().sessionIdName(<sessionIdName>));
or you can use the setSessionId(String, String) method to set it for this request only.sessionIdValue - The session id value.public RequestSpecBuilder setSessionId(String sessionIdName, String sessionIdValue)
RestAssured.config = newConfig().sessionConfig(new SessionConfig().sessionIdName(<sessionIdName>));
and then you can use the setSessionId(String) method to set the session id value without specifying the name for each request.sessionIdName - The session id namesessionIdValue - The session id value.public RequestSpecBuilder addRequestSpecification(RequestSpecification specification)
specification - The specification to addpublic RequestSpecBuilder setConfig(RestAssuredConfig config)
config - The configuration to use for this request. If null no config will be used.public RequestSpecification build()
public RequestSpecBuilder setBaseUri(String uri)
RequestSpecBuilder builder = new RequestSpecBuilder();
builder.setBaseUri("http://example.com");
RequestSpecification specs = builder.build();
given().specification(specs)
uri - The URIpublic RequestSpecBuilder setBasePath(String path)
http://localhost and basePath is /resource
then
..when().get("/something");
will make a request to http://localhost/resource.path - The base path to set.public RequestSpecBuilder log(LogDetail logDetail)
LogConfig to configure the print stream and pretty printing options.logDetail - The log detail.public RequestSpecBuilder setTrustStore(KeyStore trustStore)
given().config(RestAssured.config().sslConfig(sslConfig().trustStore(truststore));
A trust store is a KeyStore that has been loaded with the password.
If you wish that REST Assured loads the KeyStore store and applies the password (thus making it a trust store) please see one of the
keystore methods such as setKeystore(String, String).
trustStore - The truststore.setKeystore(String, String)public RequestSpecBuilder setRelaxedHTTPSValidation()
setKeystore(String, String) or trust store (see setTrustStore(java.security.KeyStore).
This is just a shortcut for:
given().config(RestAssured.config().sslConfig(sslConfig().relaxedHTTPSValidation())). ..;
public RequestSpecBuilder setProxy(String host, int port)
host - The hostname of the proxy to connect to (for example 127.0.0.1)port - The port of the proxy to connect to (for example 8888)public RequestSpecBuilder setProxy(String host)
8888.host - The hostname of the proxy to connect to (for example 127.0.0.1). Can also be a URI represented as a String.setProxy(String)public RequestSpecBuilder setProxy(int port)
port - The port of the proxy to connect to (for example 8888)setProxy(int)public RequestSpecBuilder setProxy(String host, int port, String scheme)
host - The hostname of the proxy to connect to (for example 127.0.0.1)port - The port of the proxy to connect to (for example 8888)scheme - The http scheme (http or https)public RequestSpecBuilder setProxy(URI uri)
uri - The URI of the proxypublic RequestSpecBuilder setProxy(ProxySpecification proxySpecification)
ProxySpecification.proxySpecification - The proxy specification to use.RequestSpecification.proxy(com.jayway.restassured.specification.ProxySpecification)public RequestSpecBuilder and()
Copyright © 2010–2014. All rights reserved.