|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jayway.restassured.internal.RequestSpecificationImpl
public class RequestSpecificationImpl
| 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()
|
|
|
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 |
|---|
public RequestSpecificationImpl(String baseURI,
int requestPort,
String basePath,
AuthenticationScheme defaultAuthScheme,
List<Filter> filters,
KeystoreSpec keyStoreSpec,
Object defaultRequestContentType,
RequestSpecification defaultSpec,
boolean urlEncode)
| Method Detail |
|---|
public groovy.lang.MetaClass getMetaClass()
getMetaClass in interface groovy.lang.GroovyObjectpublic void setMetaClass(groovy.lang.MetaClass mc)
setMetaClass in interface groovy.lang.GroovyObject
public Object invokeMethod(String method,
Object arguments)
invokeMethod in interface groovy.lang.GroovyObjectpublic Object getProperty(String property)
getProperty in interface groovy.lang.GroovyObject
public void setProperty(String property,
Object value)
setProperty in interface groovy.lang.GroovyObjectpublic AuthenticationScheme getAuthenticationScheme()
getAuthenticationScheme in interface FilterableRequestSpecificationpublic void setAuthenticationScheme(AuthenticationScheme value)
public RequestSpecification when()
RequestSpecification
expect().body(containsString("OK")).when().get("/something");
is that same as:
expect().body(containsString("OK")).get("/something");
when in interface RequestSpecificationpublic RequestSpecification given()
RequestSpecification
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");
given in interface RequestSpecificationpublic RequestSpecification that()
RequestSpecification
expect().that().body(containsString("OK")).when().get("/something");
is that same as:
expect().body(containsString("OK")).get("/something");
that in interface RequestSpecificationpublic ResponseSpecification response()
RequestSpecification
given().param("name", "value").then().response().body(equalTo("something")).when().get("/something");
response in interface RequestSpecification
public Response get(String path,
Object[] pathParams)
RequestSenderpath. 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.
get in interface RequestSenderpath - 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);.
public Response post(String path,
Object[] pathParams)
RequestSenderpath. 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.
post in interface RequestSenderpath - 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);.
public Response put(String path,
Object[] pathParams)
RequestSenderpath. 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.
put in interface RequestSenderpath - 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);.
public Response delete(String path,
Object[] pathParams)
RequestSenderpath. 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.
delete in interface RequestSenderpath - 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);.
public Response head(String path,
Object[] pathParams)
RequestSenderpath. 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.
head in interface RequestSenderpath - 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);.
public Response get(String path,
Map<String,Object> pathParams)
RequestSenderpath. 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.
get in interface RequestSenderpath - The path to send the request to.pathParams - The path parameters.
public Response post(String path,
Map<String,Object> pathParams)
RequestSenderpath. 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.
post in interface RequestSenderpath - The path to send the request to.pathParams - The path parameters.
public Response put(String path,
Map<String,Object> pathParams)
RequestSenderpath. 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.
put in interface RequestSenderpath - The path to send the request to.pathParams - The path parameters.
public Response delete(String path,
Map<String,Object> pathParams)
RequestSenderpath. 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.
delete in interface RequestSenderpath - The path to send the request to.pathParams - The path parameters.
public Response head(String path,
Map<String,Object> pathParams)
RequestSenderpath. 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.
head in interface RequestSenderpath - The path to send the request to.pathParams - The path parameters.
public RequestSpecification parameters(String parameterName,
String[] parameterNameValuePairs)
RequestSpecification
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:
parameters in interface RequestSpecificationparameterName - The name of the first parameterparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
public RequestSpecification parameters(Map<String,String> parametersMap)
RequestSpecification
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:
parameters in interface RequestSpecificationparametersMap - The Map containing the parameter names and their values to send with the request.
public RequestSpecification params(String parameterName,
String[] parameterNameValuePairs)
RequestSpecificationRequestSpecification.parameters(String, String...).
params in interface RequestSpecificationparameterName - The name of the first parameterparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
RequestSpecification.parameters(String, String...)public RequestSpecification params(Map<String,String> parametersMap)
RequestSpecificationRequestSpecification.parameters(Map).
params in interface RequestSpecificationparametersMap - The Map containing the parameter names and their values to send with the request.
RequestSpecification.parameters(Map)
public RequestSpecification param(String parameterName,
String parameterValue,
String[] additionalParameterValues)
RequestSpecificationRequestSpecification.parameter(String, String, String...).
param in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter valueadditionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
RequestSpecification.parameter(String, String, String...)
public RequestSpecification parameter(String parameterName,
List<String> parameterValues)
RequestSpecification
given().parameter("cars", asList("Volvo", "Saab"))..;
This will set the parameter cars=Volvo and cars=Saab.
parameter in interface RequestSpecificationparameterName - The parameter keyparameterValues - The parameter values
public RequestSpecification param(String parameterName,
List<String> parameterValues)
RequestSpecificationRequestSpecification.parameter(String, java.util.List) }.
param in interface RequestSpecificationparameterName - The parameter keyparameterValues - The parameter values
public RequestSpecification queryParameter(String parameterName,
List<String> parameterValues)
RequestSpecification
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.
queryParameter in interface RequestSpecificationparameterName - The parameter keyparameterValues - The parameter values
public RequestSpecification queryParam(String parameterName,
List<String> parameterValues)
RequestSpecificationRequestSpecification.queryParameter(String, java.util.List).
queryParam in interface RequestSpecificationparameterName - The parameter keyparameterValues - The parameter values
RequestSpecification.queryParam(String, java.util.List)
public RequestSpecification parameter(String parameterName,
String parameterValue,
String[] additionalParameterValues)
RequestSpecification
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");
parameter in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter valueadditionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
RequestSpecification.parameters(String, String...)
public RequestSpecification queryParameters(String parameterName,
String[] parameterNameValuePairs)
RequestSpecificationRequestSpecification.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.
queryParameters in interface RequestSpecificationparameterName - The name of the first parameterparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
public RequestSpecification queryParameters(Map<String,String> parametersMap)
RequestSpecificationRequestSpecification.parameters(Map)
for all http methods except for POST where RequestSpecification.parameters(Map) sets the form parameters and this method sets the
query parameters.
queryParameters in interface RequestSpecificationparametersMap - The Map containing the parameter names and their values to send with the request.
public RequestSpecification queryParameter(String parameterName,
String parameterValue,
String[] additionalParameterValues)
RequestSpecificationRequestSpecification.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.
queryParameter in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter valueadditionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
RequestSpecification.parameter(String, String, String...)
public RequestSpecification queryParams(String parameterName,
String[] parameterNameValuePairs)
RequestSpecificationRequestSpecification.queryParameters(String, String...).
queryParams in interface RequestSpecificationparameterName - The name of the first parameterparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
RequestSpecification.queryParameters(String, String...)public RequestSpecification queryParams(Map<String,String> parametersMap)
RequestSpecificationRequestSpecification.queryParams(java.util.Map).
queryParams in interface RequestSpecificationparametersMap - The Map containing the parameter names and their values to send with the request.
RequestSpecification.queryParams(java.util.Map)
public RequestSpecification queryParam(String parameterName,
String parameterValue,
String[] additionalParameterValue)
RequestSpecificationRequestSpecification.queryParameter(String, String, String...).
queryParam in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter valueadditionalParameterValue - Additional parameter values if you want to specify multiple values for the same parameter
RequestSpecification.parameter(String, String, String...)
public RequestSpecification formParameter(String parameterName,
List<String> parameterValues)
RequestSpecification
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.
formParameter in interface RequestSpecificationparameterName - The parameter keyparameterValues - The parameter values
public RequestSpecification formParam(String parameterName,
List<String> parameterValues)
RequestSpecificationRequestSpecification.formParameter(String, java.util.List).
formParam in interface RequestSpecificationparameterName - The parameter keyparameterValues - The parameter values
RequestSpecification.formParam(String, java.util.List)
public RequestSpecification formParameters(String parameterName,
String[] parameterNameValuePairs)
RequestSpecificationRequestSpecification.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.
formParameters in interface RequestSpecificationparameterName - The name of the first parameterparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
public RequestSpecification formParameters(Map<String,String> parametersMap)
RequestSpecificationRequestSpecification.parameters(Map)
for all http methods except for PUT where RequestSpecification.parameters(Map) sets the query parameters and this method sets the
form parameters.
formParameters in interface RequestSpecificationparametersMap - The Map containing the parameter names and their values to send with the request.
public RequestSpecification formParameter(String parameterName,
String parameterValue,
String[] additionalParameterValues)
RequestSpecificationRequestSpecification.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.
formParameter in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter valueadditionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
RequestSpecification.parameter(String, String, String...)
public RequestSpecification formParams(String parameterName,
String[] parameterNameValuePairs)
RequestSpecificationRequestSpecification.formParameters(String, String...).
formParams in interface RequestSpecificationparameterName - The name of the first parameterparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
RequestSpecification.formParameters(String, String...)public RequestSpecification formParams(Map<String,String> parametersMap)
RequestSpecificationRequestSpecification.formParams(java.util.Map).
formParams in interface RequestSpecificationparametersMap - The Map containing the parameter names and their values to send with the request.
RequestSpecification.formParams(java.util.Map)
public RequestSpecification formParam(String parameterName,
String parameterValue,
String[] additionalParameterValue)
RequestSpecificationRequestSpecification.formParameter(String, String, String...).
formParam in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter valueadditionalParameterValue - Additional parameter values if you want to specify multiple values for the same parameter
RequestSpecification.parameter(String, String, String...)public RequestSpecification urlEncodingEnabled(boolean isEnabled)
RequestSpecification
urlEncodingEnabled in interface RequestSpecificationisEnabled - Specify whether or not URL encoding should be enabled or disabled.
public RequestSpecification pathParameter(String parameterName,
Object parameterValue)
RequestSpecification
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);
pathParameter in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter value
public RequestSpecification pathParameters(String parameterName,
Object[] parameterNameValuePairs)
RequestSpecification
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);
pathParameters in interface RequestSpecificationparameterName - The parameter keyparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
public RequestSpecification pathParameters(Map<String,Object> parameterNameValuePairs)
RequestSpecification
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);
pathParameters in interface RequestSpecificationparameterNameValuePairs - A map containing the path parameters.
public RequestSpecification pathParam(String parameterName,
Object parameterValue)
RequestSpecificationRequestSpecification.pathParameter(String, Object).
pathParam in interface RequestSpecificationparameterName - The parameter keyparameterValue - The parameter value
RequestSpecification.pathParameter(String, Object)
public RequestSpecification pathParams(String parameterName,
Object[] parameterNameValuePairs)
RequestSpecificationRequestSpecification.pathParameters(String, Object...).
pathParams in interface RequestSpecificationparameterName - The parameter keyparameterNameValuePairs - The value of the first parameter followed by additional parameters in name-value pairs.
RequestSpecification.pathParameters(String, Object...)public RequestSpecification pathParams(Map<String,Object> parameterNameValuePairs)
RequestSpecificationRequestSpecification.pathParameters(java.util.Map).
pathParams in interface RequestSpecificationparameterNameValuePairs - A map containing the path parameters.
RequestSpecification.pathParameters(java.util.Map)
public RequestSpecification keystore(String pathToJks,
String password)
RequestSpecification
$ 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 keystoreNow you want to use this truststore in your client:
RestAssured.keystore("/truststore.jks", "test1234");
or
given().keystore("/truststore.jks", "test1234"). ..
keystore in interface RequestSpecificationpathToJks - The path to the JKSpassword - The store passpublic RequestSpecification filter(Filter filter)
RequestSpecification
filter in interface RequestSpecificationfilter - The filter to add
public RequestSpecification filters(List<Filter> filters)
RequestSpecification
filters in interface RequestSpecificationfilters - The filters to add
public RequestSpecification log()
RequestSpecificationgiven().filter(ResponseLoggingFilter.responseLogger()). ..
log in interface RequestSpecificationpublic RequestSpecification logOnError()
RequestSpecificationgiven().filter(ErrorLoggingFilter.errorLogger()). ..
logOnError in interface RequestSpecificationpublic RequestSpecification and()
RequestSpecification
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");
and in interface RequestSpecificationpublic RequestSpecification request()
RequestSpecification
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");
request in interface RequestSpecificationpublic RequestSpecification with()
RequestSpecification
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");
with in interface RequestSpecificationpublic ResponseSpecification then()
RequestSpecification
given().param("name", "value").then().body(equalTo("something")).when().get("/something");
then in interface RequestSpecificationpublic ResponseSpecification expect()
RequestSpecification
given().param("name", "value").and().expect().body(equalTo("something")).when().get("/something");
expect in interface RequestSpecificationpublic AuthenticationSpecification auth()
RequestSpecificationRequestSpecification.authentication().
auth in interface RequestSpecificationRequestSpecification.authentication(),
AuthenticationSpecificationpublic AuthenticationSpecification authentication()
RequestSpecification
authentication in interface RequestSpecificationAuthenticationSpecificationpublic RequestSpecification port(int port)
RequestSpecification
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");
port in interface RequestSpecificationport - The port of URI
public RequestSpecification body(String body)
RequestSpecificationExample 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.
body in interface RequestSpecificationbody - The body to send.
public RequestSpecification content(String content)
RequestSpecificationExample 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.
content in interface RequestSpecificationcontent - The content to send.
public RequestSpecification body(byte[] body)
RequestSpecificationExample 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.
body in interface RequestSpecificationbody - The body to send.
public RequestSpecification content(byte[] content)
RequestSpecificationExample 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.
content in interface RequestSpecificationcontent - The content to send.
public RequestSpecification contentType(groovyx.net.http.ContentType contentType)
RequestSpecification
contentType in interface RequestSpecificationcontentType - The content type of the request
ContentTypepublic RequestSpecification contentType(String contentType)
RequestSpecification
contentType in interface RequestSpecificationcontentType - The content type of the request
ContentTypepublic RequestSpecification headers(Map<String,String> headers)
RequestSpecification
Map<String, String> headers = new HashMap<String, String>();
parameters.put("headerName1", "headerValue1");
parameters.put("headerName2", "headerValue2");
given().headers(headers).then().expect().body(equalTo("something")).when().get("/headers");
This will send a GET request to "/headers" with two headers:
headers in interface RequestSpecificationheaders - The Map containing the header names and their values to send with the request.
public RequestSpecification header(String headerName,
String headerValue)
RequestSpecification
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");
header in interface RequestSpecificationheaderName - The header nameheaderValue - The header value
RequestSpecification.headers(String, String...)
public RequestSpecification headers(String headerName,
String[] headerNameValueParis)
RequestSpecification
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:
headers in interface RequestSpecificationheaderName - The name of the first headerheaderNameValueParis - The value of the first header followed by additional headers in name-value pairs.
public RequestSpecification cookies(String cookieName,
String[] cookieNameValuePairs)
RequestSpecification
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:
cookies in interface RequestSpecificationcookieName - The name of the first cookiecookieNameValuePairs - The value of the first cookie followed by additional cookies in name-value pairs.
public RequestSpecification cookies(Map<String,String> cookies)
RequestSpecification
Map<String, String> cookies = new HashMap<String, String>();
cookies.put("username", "John");
cookies.put("token", "1234");
given().cookies(cookies).then().expect().body(equalTo("username, token")).when().get("/cookie");
This will send a GET request to "/cookie" with two cookies:
cookies in interface RequestSpecificationcookies - The Map containing the cookie names and their values to set in the request.
public RequestSpecification cookie(String cookieName,
String value)
RequestSpecification
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");
cookie in interface RequestSpecificationcookieName - The cookie cookieNamevalue - The cookie value
RequestSpecification.cookies(String, String...)public RequestSpecification cookie(String cookieName)
RequestSpecification
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".
cookie in interface RequestSpecificationcookieName - The cookie cookieName
RequestSpecification.cookies(String, String...)public RequestSpecification spec(RequestSpecification requestSpecificationToMerge)
RequestSpecification
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:
RequestSpecification.specification(RequestSpecification) but the name is a bit shorter.
spec in interface RequestSpecificationrequestSpecificationToMerge - The specification to merge with.
public RequestSpecification specification(RequestSpecification requestSpecificationToMerge)
RequestSpecification
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:
RequestSpecification.specification(RequestSpecification) but the name is a bit shorter.
specification in interface RequestSpecificationrequestSpecificationToMerge - The specification to merge with.
public Object invokeFilterChain(Object path,
Object method,
Object assertionClosure)
public void setResponseSpecification(ResponseSpecification responseSpecification)
public String getBaseUri()
getBaseUri in interface FilterableRequestSpecificationpublic String getBasePath()
getBasePath in interface FilterableRequestSpecificationpublic int getPort()
getPort in interface FilterableRequestSpecificationpublic Map<String,String> getRequestParams()
getRequestParams in interface FilterableRequestSpecificationpublic Map<String,String> getQueryParams()
getQueryParams in interface FilterableRequestSpecificationpublic Map<String,String> getHeaders()
getHeaders in interface FilterableRequestSpecificationpublic Map<String,String> getCookies()
getCookies in interface FilterableRequestSpecificationpublic <T> T getBody()
getBody in interface FilterableRequestSpecificationpublic List<Filter> getDefinedFilters()
getDefinedFilters in interface FilterableRequestSpecificationpublic String getRequestContentType()
getRequestContentType in interface FilterableRequestSpecification
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||