com.jayway.restassured.internal
Class RequestSpecificationImpl

java.lang.Object
  extended by com.jayway.restassured.internal.RequestSpecificationImpl
All Implemented Interfaces:
FilterableRequestSpecification, RequestSender, RequestSpecification, groovy.lang.GroovyObject

public class RequestSpecificationImpl
extends Object
implements FilterableRequestSpecification, groovy.lang.GroovyObject


Constructor Summary
RequestSpecificationImpl(String baseURI, int requestPort, String basePath, AuthenticationScheme defaultAuthScheme, List<Filter> filters, KeystoreSpec keyStoreSpec, Object defaultRequestContentType, RequestSpecification defaultSpec, boolean urlEncode)
           
 
Method Summary
 RequestSpecification and()
          Syntactic sugar, e.g.
 AuthenticationSpecification auth()
          A slightly short version of RequestSpecification.authentication().
 AuthenticationSpecification authentication()
          If you need to specify some credentials when performing a request.
 RequestSpecification body(byte[] body)
          Specify a byte array request body that'll be sent with the request.
 RequestSpecification body(String body)
          Specify a String request body (such as e.g.
 RequestSpecification content(byte[] content)
          Specify a byte array request content that'll be sent with the request.
 RequestSpecification content(String content)
          Specify a String request content (such as e.g.
 RequestSpecification contentType(groovyx.net.http.ContentType contentType)
          Specify the content type of the request.
 RequestSpecification contentType(String contentType)
          Specify the content type of the request.
 RequestSpecification cookie(String cookieName)
          Specify a cookie with no value that'll be sent with the request e.g:
 RequestSpecification cookie(String cookieName, String value)
          Specify a cookie that'll be sent with the request e.g:
 RequestSpecification cookies(Map<String,String> cookies)
          Specify the cookies that'll be sent with the request as Map e.g:
 RequestSpecification cookies(String cookieName, String[] cookieNameValuePairs)
          Specify the cookies that'll be sent with the request.
 Response delete(String path, Map<String,Object> pathParams)
          Perform a DELETE request to a path.
 Response delete(String path, Object[] pathParams)
          Perform a DELETE request to a path.
 ResponseSpecification expect()
          Returns the response specification so that you can setup the expectations on the response.
 RequestSpecification filter(Filter filter)
          Add a filter that will be used in the request.
 RequestSpecification filters(List<Filter> filters)
          Add filters that will be used in the request.
 RequestSpecification formParam(String parameterName, List<String> parameterValues)
          A slightly shorter version of RequestSpecification.formParameter(String, java.util.List).
 RequestSpecification formParam(String parameterName, String parameterValue, String[] additionalParameterValue)
          A slightly shorter version of RequestSpecification.formParameter(String, String, String...).
 RequestSpecification formParameter(String parameterName, List<String> parameterValues)
          Specify a multi-value form parameter that'll be sent with the request e.g:
 RequestSpecification formParameter(String parameterName, String parameterValue, String[] additionalParameterValues)
          Specify a form parameter that'll be sent with the request.
 RequestSpecification formParameters(Map<String,String> parametersMap)
          Specify the form parameters that'll be sent with the request.
 RequestSpecification formParameters(String parameterName, String[] parameterNameValuePairs)
          Specify the form parameters that'll be sent with the request.
 RequestSpecification formParams(Map<String,String> parametersMap)
          A slightly shorter version of RequestSpecification.formParams(java.util.Map).
 RequestSpecification formParams(String parameterName, String[] parameterNameValuePairs)
          A slightly shorter version of RequestSpecification.formParameters(String, String...).
 Response get(String path, Map<String,Object> pathParams)
          Perform a GET request to a path.
 Response get(String path, Object[] pathParams)
          Perform a GET request to a path.
 AuthenticationScheme getAuthenticationScheme()
           
 String getBasePath()
           
 String getBaseUri()
           
<T> T
getBody()
           
 Map<String,String> getCookies()
           
 List<Filter> getDefinedFilters()
           
 Map<String,String> getHeaders()
           
 groovy.lang.MetaClass getMetaClass()
           
 int getPort()
           
 Object getProperty(String property)
           
 Map<String,String> getQueryParams()
           
 String getRequestContentType()
           
 Map<String,String> getRequestParams()
           
 RequestSpecification given()
          Syntactic sugar, e.g.
 Response head(String path, Map<String,Object> pathParams)
          Perform a HEAD request to a path.
 Response head(String path, Object[] pathParams)
          Perform a HEAD request to a path.
 RequestSpecification header(String headerName, String headerValue)
          Specify a header that'll be sent with the request e.g:
 RequestSpecification headers(Map<String,String> headers)
          Specify the headers that'll be sent with the request as Map e.g:
 RequestSpecification headers(String headerName, String[] headerNameValueParis)
          Specify the headers that'll be sent with the request.
 Object invokeFilterChain(Object path, Object method, Object assertionClosure)
           
 Object invokeMethod(String method, Object arguments)
           
 RequestSpecification keystore(String pathToJks, String password)
          The following documentation is taken from http://groovy.codehaus.org/modules/http-builder/doc/ssl.html:
 RequestSpecification log()
          Log (i.e.
 RequestSpecification logOnError()
          Log (i.e.
 RequestSpecification param(String parameterName, List<String> parameterValues)
          A slightly shorter version of RequestSpecification.parameter(String, java.util.List) }.
 RequestSpecification param(String parameterName, String parameterValue, String[] additionalParameterValues)
          A slightly shorter version of RequestSpecification.parameter(String, String, String...).
 RequestSpecification parameter(String parameterName, List<String> parameterValues)
          Specify a multi-value parameter that'll be sent with the request e.g:
 RequestSpecification parameter(String parameterName, String parameterValue, String[] additionalParameterValues)
          Specify a parameter that'll be sent with the request e.g:
 RequestSpecification parameters(Map<String,String> parametersMap)
          Specify the parameters that'll be sent with the request as Map e.g:
 RequestSpecification parameters(String parameterName, String[] parameterNameValuePairs)
          Specify the parameters that'll be sent with the request.
 RequestSpecification params(Map<String,String> parametersMap)
          A slightly shorter version of RequestSpecification.parameters(Map).
 RequestSpecification params(String parameterName, String[] parameterNameValuePairs)
          A slightly shorter version of RequestSpecification.parameters(String, String...).
 RequestSpecification pathParam(String parameterName, Object parameterValue)
          A slightly shorter version of RequestSpecification.pathParameter(String, Object).
 RequestSpecification pathParameter(String parameterName, Object parameterValue)
          Specify a path parameter.
 RequestSpecification pathParameters(Map<String,Object> parameterNameValuePairs)
          Specify multiple path parameter name-value pairs.
 RequestSpecification pathParameters(String parameterName, Object[] parameterNameValuePairs)
          Specify multiple path parameter name-value pairs.
 RequestSpecification pathParams(Map<String,Object> parameterNameValuePairs)
          A slightly shorter version of RequestSpecification.pathParameters(java.util.Map).
 RequestSpecification pathParams(String parameterName, Object[] parameterNameValuePairs)
          A slightly shorter version of RequestSpecification.pathParameters(String, Object...).
 RequestSpecification port(int port)
          Specify the port of the URI.
 Response post(String path, Map<String,Object> pathParams)
          Perform a POST request to a path.
 Response post(String path, Object[] pathParams)
          Perform a POST request to a path.
 Response put(String path, Map<String,Object> pathParams)
          Perform a PUT request to a path.
 Response put(String path, Object[] pathParams)
          Perform a PUT request to a path.
 RequestSpecification queryParam(String parameterName, List<String> parameterValues)
          A slightly shorter version of RequestSpecification.queryParameter(String, java.util.List).
 RequestSpecification queryParam(String parameterName, String parameterValue, String[] additionalParameterValue)
          A slightly shorter version of RequestSpecification.queryParameter(String, String, String...).
 RequestSpecification queryParameter(String parameterName, List<String> parameterValues)
          Specify a multi-value query parameter that'll be sent with the request e.g:
 RequestSpecification queryParameter(String parameterName, String parameterValue, String[] additionalParameterValues)
          Specify a query parameter that'll be sent with the request.
 RequestSpecification queryParameters(Map<String,String> parametersMap)
          Specify the query parameters that'll be sent with the request.
 RequestSpecification queryParameters(String parameterName, String[] parameterNameValuePairs)
          Specify the query parameters that'll be sent with the request.
 RequestSpecification queryParams(Map<String,String> parametersMap)
          A slightly shorter version of RequestSpecification.queryParams(java.util.Map).
 RequestSpecification queryParams(String parameterName, String[] parameterNameValuePairs)
          A slightly shorter version of RequestSpecification.queryParameters(String, String...).
 RequestSpecification request()
          Syntactic sugar, e.g.
 ResponseSpecification response()
          Returns the response specification so that you can setup the expectations on the response.
 void setAuthenticationScheme(AuthenticationScheme value)
           
 void setMetaClass(groovy.lang.MetaClass mc)
           
 void setProperty(String property, Object value)
           
 void setResponseSpecification(ResponseSpecification responseSpecification)
           
 RequestSpecification spec(RequestSpecification requestSpecificationToMerge)
          Add request data from a pre-defined specification.
 RequestSpecification specification(RequestSpecification requestSpecificationToMerge)
          Add request data from a pre-defined specification.
 RequestSpecification that()
          Syntactic sugar, e.g.
 ResponseSpecification then()
          Returns the response specification so that you can setup the expectations on the response.
 RequestSpecification urlEncodingEnabled(boolean isEnabled)
          Specifies if Rest Assured should url encode the URL automatically.
 RequestSpecification when()
          Syntactic sugar, e.g.
 RequestSpecification with()
          Syntactic sugar, e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestSpecificationImpl

public RequestSpecificationImpl(String baseURI,
                                int requestPort,
                                String basePath,
                                AuthenticationScheme defaultAuthScheme,
                                List<Filter> filters,
                                KeystoreSpec keyStoreSpec,
                                Object defaultRequestContentType,
                                RequestSpecification defaultSpec,
                                boolean urlEncode)
Method Detail

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass mc)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public Object invokeMethod(String method,
                           Object arguments)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public Object getProperty(String property)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(String property,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject

getAuthenticationScheme

public AuthenticationScheme getAuthenticationScheme()
Specified by:
getAuthenticationScheme in interface FilterableRequestSpecification
Returns:
The authentication scheme defined in the request

setAuthenticationScheme

public void setAuthenticationScheme(AuthenticationScheme value)

when

public RequestSpecification when()
Description copied from interface: RequestSpecification
Syntactic sugar, e.g.
 expect().body(containsString("OK")).when().get("/something");
 
is that same as:
 expect().body(containsString("OK")).get("/something");
 

Specified by:
when in interface RequestSpecification
Returns:
the request specification

given

public RequestSpecification given()
Description copied from interface: RequestSpecification
Syntactic sugar, e.g.
 given().param("name1", "value1").and().given().param("name2", "value2").when().get("/something");
 
is that same as:
 given().param("name1", "value1").and().param("name2", "value2").when().get("/something");
 

Specified by:
given in interface RequestSpecification
Returns:
the request specification

that

public RequestSpecification that()
Description copied from interface: RequestSpecification
Syntactic sugar, e.g.
 expect().that().body(containsString("OK")).when().get("/something");
 
is that same as:
 expect().body(containsString("OK")).get("/something");
 

Specified by:
that in interface RequestSpecification
Returns:
the request specification

response

public ResponseSpecification response()
Description copied from interface: RequestSpecification
Returns the response specification so that you can setup the expectations on the response. E.g.
 given().param("name", "value").then().response().body(equalTo("something")).when().get("/something");
 

Specified by:
response in interface RequestSpecification
Returns:
the response specification

get

public Response get(String path,
                    Object[] pathParams)
Description copied from interface: RequestSender
Perform a GET request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
get in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do get("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

post

public Response post(String path,
                     Object[] pathParams)
Description copied from interface: RequestSender
Perform a POST request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
post in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do post("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

put

public Response put(String path,
                    Object[] pathParams)
Description copied from interface: RequestSender
Perform a PUT request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
put in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do put("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

delete

public Response delete(String path,
                       Object[] pathParams)
Description copied from interface: RequestSender
Perform a DELETE request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
delete in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do delete("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

head

public Response head(String path,
                     Object[] pathParams)
Description copied from interface: RequestSender
Perform a HEAD request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
head in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters. E.g. if path is "/book/{hotelId}/{roomNumber}" you can do head("/book/{hotelName}/{roomNumber}", "Hotels R Us", 22);.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

get

public Response get(String path,
                    Map<String,Object> pathParams)
Description copied from interface: RequestSender
Perform a GET request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
get in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

post

public Response post(String path,
                     Map<String,Object> pathParams)
Description copied from interface: RequestSender
Perform a POST request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
post in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

put

public Response put(String path,
                    Map<String,Object> pathParams)
Description copied from interface: RequestSender
Perform a PUT request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
put in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

delete

public Response delete(String path,
                       Map<String,Object> pathParams)
Description copied from interface: RequestSender
Perform a DELETE request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
delete in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

head

public Response head(String path,
                     Map<String,Object> pathParams)
Description copied from interface: RequestSender
Perform a HEAD request to a path. Normally the path doesn't have to be fully-qualified e.g. you don't need to specify the path as http://localhost:8080/path. In this case it's enough to use /path.

Specified by:
head in interface RequestSender
Parameters:
path - The path to send the request to.
pathParams - The path parameters.
Returns:
The response of the request. The response can only be returned if you don't use any REST Assured response expectations.

parameters

public RequestSpecification parameters(String parameterName,
                                       String[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
Specify the parameters that'll be sent with the request. This is done by specifying the parameters in name-value pairs, e.g:
 given().parameters("username", "John", "token", "1234").then().expect().body(equalTo("username, token")).when().get("/parameters");
 
This will send a GET request to "/parameters" with two parameters:
  1. username=John
  2. token=1234
and expect that the response body is equal to "username, token".

Specified by:
parameters in interface RequestSpecification
Parameters:
parameterName - The name of the first parameter
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification

parameters

public RequestSpecification parameters(Map<String,String> parametersMap)
Description copied from interface: RequestSpecification
Specify the parameters that'll be sent with the request as Map e.g:
 Map<String, String> parameters = new HashMap<String, String>();
 parameters.put("username", "John");
 parameters.put("token", "1234");
 given().parameters(parameters).then().expect().body(equalTo("username, token")).when().get("/cookie");
 
This will send a GET request to "/cookie" with two parameters:
  1. username=John
  2. token=1234
and expect that the response body is equal to "username, token".

Specified by:
parameters in interface RequestSpecification
Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification

params

public RequestSpecification params(String parameterName,
                                   String[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.parameters(String, String...).

Specified by:
params in interface RequestSpecification
Parameters:
parameterName - The name of the first parameter
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification
See Also:
RequestSpecification.parameters(String, String...)

params

public RequestSpecification params(Map<String,String> parametersMap)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.parameters(Map).

Specified by:
params in interface RequestSpecification
Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification
See Also:
RequestSpecification.parameters(Map)

param

public RequestSpecification param(String parameterName,
                                  String parameterValue,
                                  String[] additionalParameterValues)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.parameter(String, String, String...).

Specified by:
param in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification
See Also:
RequestSpecification.parameter(String, String, String...)

parameter

public RequestSpecification parameter(String parameterName,
                                      List<String> parameterValues)
Description copied from interface: RequestSpecification
Specify a multi-value parameter that'll be sent with the request e.g:

 given().parameter("cars", asList("Volvo", "Saab"))..;
 
This will set the parameter cars=Volvo and cars=Saab.

Specified by:
parameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification

param

public RequestSpecification param(String parameterName,
                                  List<String> parameterValues)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.parameter(String, java.util.List) }.

Specified by:
param in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification

queryParameter

public RequestSpecification queryParameter(String parameterName,
                                           List<String> parameterValues)
Description copied from interface: RequestSpecification
Specify a multi-value query parameter that'll be sent with the request e.g:

 given().queryParameter("cars", asList("Volvo", "Saab"))..;
 
This will set the parameter cars=Volvo and cars=Saab.

Note that this method is the same as RequestSpecification.parameter(String, java.util.List) for all http methods except for POST where RequestSpecification.parameter(String, java.util.List) adds a form parameter and this method sets a query parameter.

Specified by:
queryParameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification

queryParam

public RequestSpecification queryParam(String parameterName,
                                       List<String> parameterValues)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.queryParameter(String, java.util.List).

Specified by:
queryParam in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification
See Also:
RequestSpecification.queryParam(String, java.util.List)

parameter

public RequestSpecification parameter(String parameterName,
                                      String parameterValue,
                                      String[] additionalParameterValues)
Description copied from interface: RequestSpecification
Specify a parameter that'll be sent with the request e.g:

 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().parameter("username", "John").and().parameter("password", "1234").and().expect().body(equalTo("username")).when().get("/cookie");
 

Specified by:
parameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification
See Also:
RequestSpecification.parameters(String, String...)

queryParameters

public RequestSpecification queryParameters(String parameterName,
                                            String[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
Specify the query parameters that'll be sent with the request. Note that this method is the same as RequestSpecification.parameters(String, String...) for all http methods except for POST where RequestSpecification.parameters(String, String...) sets the form parameters and this method sets the query parameters.

Specified by:
queryParameters in interface RequestSpecification
Parameters:
parameterName - The name of the first parameter
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification

queryParameters

public RequestSpecification queryParameters(Map<String,String> parametersMap)
Description copied from interface: RequestSpecification
Specify the query parameters that'll be sent with the request. Note that this method is the same as RequestSpecification.parameters(Map) for all http methods except for POST where RequestSpecification.parameters(Map) sets the form parameters and this method sets the query parameters.

Specified by:
queryParameters in interface RequestSpecification
Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification

queryParameter

public RequestSpecification queryParameter(String parameterName,
                                           String parameterValue,
                                           String[] additionalParameterValues)
Description copied from interface: RequestSpecification
Specify a query parameter that'll be sent with the request. Note that this method is the same as RequestSpecification.parameter(String, String, String...) for all http methods except for POST where RequestSpecification.parameter(String, String, String...) adds a form parameter and this method sets a query parameter.

Specified by:
queryParameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification
See Also:
RequestSpecification.parameter(String, String, String...)

queryParams

public RequestSpecification queryParams(String parameterName,
                                        String[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.queryParameters(String, String...).

Specified by:
queryParams in interface RequestSpecification
Parameters:
parameterName - The name of the first parameter
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification
See Also:
RequestSpecification.queryParameters(String, String...)

queryParams

public RequestSpecification queryParams(Map<String,String> parametersMap)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.queryParams(java.util.Map).

Specified by:
queryParams in interface RequestSpecification
Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification
See Also:
RequestSpecification.queryParams(java.util.Map)

queryParam

public RequestSpecification queryParam(String parameterName,
                                       String parameterValue,
                                       String[] additionalParameterValue)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.queryParameter(String, String, String...).

Specified by:
queryParam in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValue - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification
See Also:
RequestSpecification.parameter(String, String, String...)

formParameter

public RequestSpecification formParameter(String parameterName,
                                          List<String> parameterValues)
Description copied from interface: RequestSpecification
Specify a multi-value form parameter that'll be sent with the request e.g:

 given().formParameter("cars", asList("Volvo", "Saab"))..;
 
This will set the parameter cars=Volvo and cars=Saab.

Note that this method is the same as RequestSpecification.parameter(String, java.util.List) for all http methods except for PUT where RequestSpecification.parameter(String, java.util.List) adds a query parameter and this method sets a form parameter.

Specified by:
formParameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification

formParam

public RequestSpecification formParam(String parameterName,
                                      List<String> parameterValues)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.formParameter(String, java.util.List).

Specified by:
formParam in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification
See Also:
RequestSpecification.formParam(String, java.util.List)

formParameters

public RequestSpecification formParameters(String parameterName,
                                           String[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
Specify the form parameters that'll be sent with the request. Note that this method is the same as RequestSpecification.parameters(String, String...) for all http methods except for PUT where RequestSpecification.parameters(String, String...) sets the query parameters and this method sets the form parameters.

Specified by:
formParameters in interface RequestSpecification
Parameters:
parameterName - The name of the first parameter
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification

formParameters

public RequestSpecification formParameters(Map<String,String> parametersMap)
Description copied from interface: RequestSpecification
Specify the form parameters that'll be sent with the request. Note that this method is the same as RequestSpecification.parameters(Map) for all http methods except for PUT where RequestSpecification.parameters(Map) sets the query parameters and this method sets the form parameters.

Specified by:
formParameters in interface RequestSpecification
Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification

formParameter

public RequestSpecification formParameter(String parameterName,
                                          String parameterValue,
                                          String[] additionalParameterValues)
Description copied from interface: RequestSpecification
Specify a form parameter that'll be sent with the request. Note that this method is the same as RequestSpecification.parameter(String, String, String...) for all http methods except for PUT where RequestSpecification.parameter(String, String, String...) adds a query parameter and this method sets a form parameter.

Specified by:
formParameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification
See Also:
RequestSpecification.parameter(String, String, String...)

formParams

public RequestSpecification formParams(String parameterName,
                                       String[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.formParameters(String, String...).

Specified by:
formParams in interface RequestSpecification
Parameters:
parameterName - The name of the first parameter
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification
See Also:
RequestSpecification.formParameters(String, String...)

formParams

public RequestSpecification formParams(Map<String,String> parametersMap)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.formParams(java.util.Map).

Specified by:
formParams in interface RequestSpecification
Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification
See Also:
RequestSpecification.formParams(java.util.Map)

formParam

public RequestSpecification formParam(String parameterName,
                                      String parameterValue,
                                      String[] additionalParameterValue)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.formParameter(String, String, String...).

Specified by:
formParam in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValue - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification
See Also:
RequestSpecification.parameter(String, String, String...)

urlEncodingEnabled

public RequestSpecification urlEncodingEnabled(boolean isEnabled)
Description copied from interface: RequestSpecification
Specifies if Rest Assured should url encode the URL automatically. Usually this is a recommended but in some cases e.g. the query parameters are already be encoded before you provide them to Rest Assured then it's useful to disable URL encoding.

Specified by:
urlEncodingEnabled in interface RequestSpecification
Parameters:
isEnabled - Specify whether or not URL encoding should be enabled or disabled.
Returns:
the request specification

pathParameter

public RequestSpecification pathParameter(String parameterName,
                                          Object parameterValue)
Description copied from interface: RequestSpecification
Specify a path parameter. Path parameters are used to improve readability of the request path. E.g. instead of writing:
 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);
 

Specified by:
pathParameter in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
Returns:
The request specification

pathParameters

public RequestSpecification pathParameters(String parameterName,
                                           Object[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
Specify multiple path parameter name-value pairs. Path parameters are used to improve readability of the request path. E.g. instead of writing:
 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);
 

Specified by:
pathParameters in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification

pathParameters

public RequestSpecification pathParameters(Map<String,Object> parameterNameValuePairs)
Description copied from interface: RequestSpecification
Specify multiple path parameter name-value pairs. Path parameters are used to improve readability of the request path. E.g. instead of writing:
 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);
 

Specified by:
pathParameters in interface RequestSpecification
Parameters:
parameterNameValuePairs - A map containing the path parameters.
Returns:
The request specification

pathParam

public RequestSpecification pathParam(String parameterName,
                                      Object parameterValue)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.pathParameter(String, Object).

Specified by:
pathParam in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterValue - The parameter value
Returns:
The request specification
See Also:
RequestSpecification.pathParameter(String, Object)

pathParams

public RequestSpecification pathParams(String parameterName,
                                       Object[] parameterNameValuePairs)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.pathParameters(String, Object...).

Specified by:
pathParams in interface RequestSpecification
Parameters:
parameterName - The parameter key
parameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
Returns:
The request specification
See Also:
RequestSpecification.pathParameters(String, Object...)

pathParams

public RequestSpecification pathParams(Map<String,Object> parameterNameValuePairs)
Description copied from interface: RequestSpecification
A slightly shorter version of RequestSpecification.pathParameters(java.util.Map).

Specified by:
pathParams in interface RequestSpecification
Parameters:
parameterNameValuePairs - A map containing the path parameters.
Returns:
The request specification
See Also:
RequestSpecification.pathParameters(java.util.Map)

keystore

public RequestSpecification keystore(String pathToJks,
                                     String password)
Description copied from interface: RequestSpecification
The following documentation is taken from http://groovy.codehaus.org/modules/http-builder/doc/ssl.html:

SSL Configuration

SSL should, for the most part, "just work." There are a few situations where it is not completely intuitive. You can follow the example below, or see HttpClient's SSLSocketFactory documentation for more information.

SSLPeerUnverifiedException

If you can't connect to an SSL website, it is likely because the certificate chain is not trusted. This is an Apache HttpClient issue, but explained here for convenience. To correct the untrusted certificate, you need to import a certificate into an SSL truststore. First, export a certificate from the website using your browser. For example, if you go to https://dev.java.net in Firefox, you will probably get a warning in your browser. Choose "Add Exception," "Get Certificate," "View," "Details tab." Choose a certificate in the chain and export it as a PEM file. You can view the details of the exported certificate like so:
 $ 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.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 keystore
 
Now you want to use this truststore in your client:
 RestAssured.keystore("/truststore.jks", "test1234");
 
or
 given().keystore("/truststore.jks", "test1234"). ..
 

Specified by:
keystore in interface RequestSpecification
Parameters:
pathToJks - The path to the JKS
password - The store pass

filter

public RequestSpecification filter(Filter filter)
Description copied from interface: RequestSpecification
Add a filter that will be used in the request.

Specified by:
filter in interface RequestSpecification
Parameters:
filter - The filter to add
Returns:
the request specification

filters

public RequestSpecification filters(List<Filter> filters)
Description copied from interface: RequestSpecification
Add filters that will be used in the request.

Specified by:
filters in interface RequestSpecification
Parameters:
filters - The filters to add
Returns:
the request specification

log

public RequestSpecification log()
Description copied from interface: RequestSpecification
Log (i.e. print to system out) the response body to system out. This is mainly useful for debug purposes when writing your tests. A shortcut for:
 given().filter(ResponseLoggingFilter.responseLogger()). ..
 

Specified by:
log in interface RequestSpecification
Returns:
the request specification

logOnError

public RequestSpecification logOnError()
Description copied from interface: RequestSpecification
Log (i.e. print to system out) the response body to system out if an error occurs. This is mainly useful for debug purposes when writing your tests. A shortcut for:
 given().filter(ErrorLoggingFilter.errorLogger()). ..
 

Specified by:
logOnError in interface RequestSpecification
Returns:
the request specification

and

public RequestSpecification and()
Description copied from interface: RequestSpecification
Syntactic sugar, e.g.
 expect().body(containsString("OK")).and().body(containsString("something else")).when().get("/something");
 
is that same as:
 expect().body(containsString("OK")).body(containsString("something else")).when().get("/something");
 

Specified by:
and in interface RequestSpecification
Returns:
the request specification

request

public RequestSpecification request()
Description copied from interface: RequestSpecification
Syntactic sugar, e.g.
 given().request().param("name", "John").then().expect().body(containsString("OK")).when().get("/something");
 
is that same as:
 given().param("name", "John").then().expect().body(containsString("OK")).when().get("/something");
 

Specified by:
request in interface RequestSpecification
Returns:
the request specification

with

public RequestSpecification with()
Description copied from interface: RequestSpecification
Syntactic sugar, e.g.
 expect().body(containsString("OK")).and().with().request().parameters("param1", "value1").get("/something");
 
is that same as:
 expect().body(containsString("OK")).and().request().parameters("param1", "value1").get("/something");
 

Specified by:
with in interface RequestSpecification
Returns:
the request specification

then

public ResponseSpecification then()
Description copied from interface: RequestSpecification
Returns the response specification so that you can setup the expectations on the response. E.g.
 given().param("name", "value").then().body(equalTo("something")).when().get("/something");
 

Specified by:
then in interface RequestSpecification
Returns:
the response specification

expect

public ResponseSpecification expect()
Description copied from interface: RequestSpecification
Returns the response specification so that you can setup the expectations on the response. E.g.
 given().param("name", "value").and().expect().body(equalTo("something")).when().get("/something");
 

Specified by:
expect in interface RequestSpecification
Returns:
the response specification

auth

public AuthenticationSpecification auth()
Description copied from interface: RequestSpecification
A slightly short version of RequestSpecification.authentication().

Specified by:
auth in interface RequestSpecification
Returns:
The authentication specification
See Also:
RequestSpecification.authentication(), AuthenticationSpecification

authentication

public AuthenticationSpecification authentication()
Description copied from interface: RequestSpecification
If you need to specify some credentials when performing a request.

Specified by:
authentication in interface RequestSpecification
Returns:
The authentication specification
See Also:
AuthenticationSpecification

port

public RequestSpecification port(int port)
Description copied from interface: RequestSpecification
Specify the port of the URI. E.g.

 given().port(8081).and().expect().statusCode(200).when().get("/something");
 
will perform a GET request to http;//localhost:8081/something. It will override the default port of REST assured for this request only.

Note that it's also possible to specify the port like this:

 expect().statusCode(200).when().get("http://localhost:8081/something");
 

Specified by:
port in interface RequestSpecification
Parameters:
port - The port of URI
Returns:
The request specification

body

public RequestSpecification body(String body)
Description copied from interface: RequestSpecification
Specify a String request body (such as e.g. JSON or XML) that'll be sent with the request. This works for the POST and PUT methods only. Trying to do this for the other http methods will cause an exception to be thrown.

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".

Note that RequestSpecification.body(String) and RequestSpecification.content(String) are the same except for the syntactic difference.

Specified by:
body in interface RequestSpecification
Parameters:
body - The body to send.
Returns:
The request specification

content

public RequestSpecification content(String content)
Description copied from interface: RequestSpecification
Specify a String request content (such as e.g. JSON or XML) that'll be sent with the request. This works for the POST and PUT methods only. Trying to do this for the other http methods will cause an exception to be thrown.

Example of use:

 given().content("{ \"message\" : \"hello world\"}").then().expect().content(equalTo("hello world")).when().post("/json");
 
This will POST a request containing JSON to "/json" and expect that the response content equals to "hello world".

Note that RequestSpecification.body(String) and RequestSpecification.content(String) are the same except for the syntactic difference.

Specified by:
content in interface RequestSpecification
Parameters:
content - The content to send.
Returns:
The request specification

body

public RequestSpecification body(byte[] body)
Description copied from interface: RequestSpecification
Specify a byte array request body that'll be sent with the request. This only works for the POST http method. Trying to do this for the other http methods will cause an exception to be thrown.

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".

Note that RequestSpecification.body(byte[]) and RequestSpecification.content(byte[]) are the same except for the syntactic difference.

Specified by:
body in interface RequestSpecification
Parameters:
body - The body to send.
Returns:
The request specification

content

public RequestSpecification content(byte[] content)
Description copied from interface: RequestSpecification
Specify a byte array request content that'll be sent with the request. This only works for the POST http method. Trying to do this for the other http methods will cause an exception to be thrown.

Example of use:

 byte[] someBytes = ..
 given().content(someBytes).then().expect().content(equalTo("hello world")).when().post("/json");
 
This will POST a request containing someBytes to "/json" and expect that the response content equals to "hello world".

Note that RequestSpecification.body(byte[]) and RequestSpecification.content(byte[]) are the same except for the syntactic difference.

Specified by:
content in interface RequestSpecification
Parameters:
content - The content to send.
Returns:
The request specification

contentType

public RequestSpecification contentType(groovyx.net.http.ContentType contentType)
Description copied from interface: RequestSpecification
Specify the content type of the request.

Specified by:
contentType in interface RequestSpecification
Parameters:
contentType - The content type of the request
Returns:
The request specification
See Also:
ContentType

contentType

public RequestSpecification contentType(String contentType)
Description copied from interface: RequestSpecification
Specify the content type of the request.

Specified by:
contentType in interface RequestSpecification
Parameters:
contentType - The content type of the request
Returns:
The request specification
See Also:
ContentType

headers

public RequestSpecification headers(Map<String,String> headers)
Description copied from interface: RequestSpecification
Specify the headers that'll be sent with the request as Map e.g:
 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:
  1. headerName1=headerValue1
  2. headerName2=headerValue2
and expect that the response body is equal to "something".

Specified by:
headers in interface RequestSpecification
Parameters:
headers - The Map containing the header names and their values to send with the request.
Returns:
The request specification

header

public RequestSpecification header(String headerName,
                                   String headerValue)
Description copied from interface: RequestSpecification
Specify a header that'll be sent with the request e.g:

 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");
 

Specified by:
header in interface RequestSpecification
Parameters:
headerName - The header name
headerValue - The header value
Returns:
The request specification
See Also:
RequestSpecification.headers(String, String...)

headers

public RequestSpecification headers(String headerName,
                                    String[] headerNameValueParis)
Description copied from interface: RequestSpecification
Specify the headers that'll be sent with the request. This is done by specifying the headers in name-value pairs, e.g:
 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:
  1. headerName1=headerValue1
  2. headerName2=headerValue2
and expect that the response body is equal to "something".

Specified by:
headers in interface RequestSpecification
Parameters:
headerName - The name of the first header
headerNameValueParis - The value of the first header followed by additional headers in name-value pairs.
Returns:
The request specification

cookies

public RequestSpecification cookies(String cookieName,
                                    String[] cookieNameValuePairs)
Description copied from interface: RequestSpecification
Specify the cookies that'll be sent with the request. This is done by specifying the cookies in name-value pairs, e.g:
 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:
  1. username=John
  2. token=1234
and expect that the response body is equal to "username, token".

Specified by:
cookies in interface RequestSpecification
Parameters:
cookieName - The name of the first cookie
cookieNameValuePairs - The value of the first cookie followed by additional cookies in name-value pairs.
Returns:
The request specification

cookies

public RequestSpecification cookies(Map<String,String> cookies)
Description copied from interface: RequestSpecification
Specify the cookies that'll be sent with the request as Map e.g:
 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:
  1. username=John
  2. token=1234
and expect that the response body is equal to "username, token".

Specified by:
cookies in interface RequestSpecification
Parameters:
cookies - The Map containing the cookie names and their values to set in the request.
Returns:
The request specification

cookie

public RequestSpecification cookie(String cookieName,
                                   String value)
Description copied from interface: RequestSpecification
Specify a cookie that'll be sent with the request e.g:

 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");
 

Specified by:
cookie in interface RequestSpecification
Parameters:
cookieName - The cookie cookieName
value - The cookie value
Returns:
The request specification
See Also:
RequestSpecification.cookies(String, String...)

cookie

public RequestSpecification cookie(String cookieName)
Description copied from interface: RequestSpecification
Specify a cookie with no value that'll be sent with the request e.g:

 given().cookie("some_cookie"").and().expect().body(equalTo("x")).when().get("/cookie");
 
This will set the cookie some_cookie in the GET request to "/cookie".

Specified by:
cookie in interface RequestSpecification
Parameters:
cookieName - The cookie cookieName
Returns:
The request specification
See Also:
RequestSpecification.cookies(String, String...)

spec

public RequestSpecification spec(RequestSpecification requestSpecificationToMerge)
Description copied from interface: RequestSpecification
Add request data from a pre-defined specification. E.g.
 RequestSpecification requestSpec = new RequestSpecBuilder().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:

The following settings are merged: This method is the same as RequestSpecification.specification(RequestSpecification) but the name is a bit shorter.

Specified by:
spec in interface RequestSpecification
Parameters:
requestSpecificationToMerge - The specification to merge with.
Returns:
the request specification

specification

public RequestSpecification specification(RequestSpecification requestSpecificationToMerge)
Description copied from interface: RequestSpecification
Add request data from a pre-defined specification. E.g.
 RequestSpecification requestSpec = new RequestSpecBuilder().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:

The following settings are merged: This method is the same as RequestSpecification.specification(RequestSpecification) but the name is a bit shorter.

Specified by:
specification in interface RequestSpecification
Parameters:
requestSpecificationToMerge - The specification to merge with.
Returns:
the request specification

invokeFilterChain

public Object invokeFilterChain(Object path,
                                Object method,
                                Object assertionClosure)

setResponseSpecification

public void setResponseSpecification(ResponseSpecification responseSpecification)

getBaseUri

public String getBaseUri()
Specified by:
getBaseUri in interface FilterableRequestSpecification
Returns:
The base URI defined in the request

getBasePath

public String getBasePath()
Specified by:
getBasePath in interface FilterableRequestSpecification
Returns:
The base path defined in the request

getPort

public int getPort()
Specified by:
getPort in interface FilterableRequestSpecification
Returns:
The port defined in the request

getRequestParams

public Map<String,String> getRequestParams()
Specified by:
getRequestParams in interface FilterableRequestSpecification
Returns:
The request parameters defined in the request

getQueryParams

public Map<String,String> getQueryParams()
Specified by:
getQueryParams in interface FilterableRequestSpecification
Returns:
The query parameters defined in the request

getHeaders

public Map<String,String> getHeaders()
Specified by:
getHeaders in interface FilterableRequestSpecification
Returns:
The headers defined in the request

getCookies

public Map<String,String> getCookies()
Specified by:
getCookies in interface FilterableRequestSpecification
Returns:
The cookies defined in the request

getBody

public <T> T getBody()
Specified by:
getBody in interface FilterableRequestSpecification
Returns:
The request body

getDefinedFilters

public List<Filter> getDefinedFilters()
Specified by:
getDefinedFilters in interface FilterableRequestSpecification
Returns:
The filters (unmodifiable)

getRequestContentType

public String getRequestContentType()
Specified by:
getRequestContentType in interface FilterableRequestSpecification
Returns:
The request content type defined in the request


Copyright © 2010-2011. All Rights Reserved.