|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.sal.testresources.net.MockRequest
public class MockRequest
Mock request that provides getters to all the information that is passed in, and also setters for the response body that should be returned for execute(), or the response that should be passed to the response handler.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.atlassian.sal.api.net.Request |
|---|
Request.MethodType |
| Constructor Summary | |
|---|---|
MockRequest(Request.MethodType methodType,
String url)
|
|
| Method Summary | ||
|---|---|---|
MockRequest |
addAuthentication(Authenticator authenticator)
Adds generic Authenticator to the request. |
|
MockRequest |
addBasicAuthentication(String username,
String password)
Adds basic authentication to the request. |
|
MockRequest |
addHeader(String headerName,
String headerValue)
Adds the specified header to the request, not overwriting any previous value. |
|
MockRequest |
addRequestParameters(String... params)
Sets parameters of the request. |
|
MockRequest |
addSeraphAuthentication(String username,
String password)
Adds seraph authentication to the request. |
|
MockRequest |
addTrustedTokenAuthentication()
Adds TrustedTokenAuthentication to the request. |
|
MockRequest |
addTrustedTokenAuthentication(String username)
Adds TrustedTokenAuthentication to the request. |
|
String |
execute()
Executes a request and if response is successful, returns response as a string. |
|
void |
execute(ResponseHandler responseHandler)
Executes the request. |
|
|
executeAndReturn(ReturningResponseHandler<MockResponse,RET> responseHandler)
Executes the request and returns a result value. |
|
List<Authenticator> |
getAuthenticators()
|
|
String |
getBasicPassword()
|
|
String |
getBasicUser()
|
|
int |
getConnectionTimeout()
|
|
List<String> |
getHeader(String headerName)
|
|
Map<String,List<String>> |
getHeaders()
|
|
Request.MethodType |
getMethodType()
|
|
String |
getRequestBody()
|
|
String |
getRequestContentType()
|
|
List<String> |
getRequestParameters()
|
|
Response |
getResponse()
|
|
String |
getSeraphPassword()
|
|
String |
getSeraphUser()
|
|
int |
getSoTimeout()
|
|
String |
getTrustedTokenUser()
|
|
String |
getUrl()
|
|
boolean |
isTrustedTokenAuthentication()
|
|
MockRequest |
setConnectionTimeout(int connectionTimeout)
Setting connection timeout in milliseconds. |
|
MockRequest |
setEntity(Object entity)
Set an entity as the request body |
|
MockRequest |
setFiles(List<RequestFilePart> files)
Sets file parts of the request. |
|
MockRequest |
setFollowRedirects(boolean follow)
Sets whether the request should transparently follow a redirect from the server. |
|
MockRequest |
setHeader(String headerName,
String headerValue)
Sets the specified header to the request, overwriting any previous value. |
|
MockRequest |
setRequestBody(String requestBody)
Sets the body of the request. |
|
MockRequest |
setRequestContentType(String contentType)
Sets Content-Type of the body of the request. |
|
void |
setResponse(MockResponse response)
|
|
void |
setResponseBody(String responseBody)
|
|
MockRequest |
setSoTimeout(int soTimeout)
Setting socket timeout in milliseconds. |
|
MockRequest |
setUrl(String url)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MockRequest(Request.MethodType methodType,
String url)
| Method Detail |
|---|
public MockRequest setConnectionTimeout(int connectionTimeout)
Request
setConnectionTimeout in interface Request<MockRequest,MockResponse>connectionTimeout - The timeout in milliseconds
public MockRequest setSoTimeout(int soTimeout)
Request
setSoTimeout in interface Request<MockRequest,MockResponse>soTimeout - the timeout in milliseconds
public MockRequest setUrl(String url)
setUrl in interface Request<MockRequest,MockResponse>url - the url to request
public MockRequest setRequestBody(String requestBody)
RequestRequest.MethodType.POST and Request.MethodType.PUT can have a request body.
setRequestBody in interface Request<MockRequest,MockResponse>requestBody - the body of the request
public MockRequest setFiles(List<RequestFilePart> files)
RequestRequest.MethodType.POST and Request.MethodType.PUT can have file parts.
setFiles in interface Request<MockRequest,MockResponse>files - the file parts, cannot be null.
public MockRequest setEntity(Object entity)
Request
setEntity in interface Request<MockRequest,MockResponse>entity - the request entity to be marshalled, not null
public MockRequest setRequestContentType(String contentType)
RequestRequest.MethodType.POST and Request.MethodType.PUT can have a request body.
setRequestContentType in interface Request<MockRequest,MockResponse>contentType - the contentType of the request
public MockRequest addRequestParameters(String... params)
RequestRequest.MethodType.POST can have parameters.
For other requests include parameters in url. This method accepts an even number of arguments, in form of name, value, name, value, name, value, etc
addRequestParameters in interface Request<MockRequest,MockResponse>params - parameters of the request in as name, value pairs
public MockRequest addHeader(String headerName,
String headerValue)
Request
addHeader in interface Request<MockRequest,MockResponse>headerName - the header's nameheaderValue - the header's value
RequestFactory.supportsHeader()
public MockRequest setHeader(String headerName,
String headerValue)
Request
setHeader in interface Request<MockRequest,MockResponse>headerName - the header's nameheaderValue - the header's value
RequestFactory.supportsHeader()public MockRequest setFollowRedirects(boolean follow)
Request
setFollowRedirects in interface Request<MockRequest,MockResponse>follow - set this to false to have the request not transparently follow redirects.
public MockRequest addAuthentication(Authenticator authenticator)
Request
addAuthentication in interface Request<MockRequest,MockResponse>authenticator - the authenticator to use for authentication
public MockRequest addTrustedTokenAuthentication()
Request
addTrustedTokenAuthentication in interface Request<MockRequest,MockResponse>public MockRequest addTrustedTokenAuthentication(String username)
Request
addTrustedTokenAuthentication in interface Request<MockRequest,MockResponse>username - The user to make the request with
public MockRequest addBasicAuthentication(String username,
String password)
Request
addBasicAuthentication in interface Request<MockRequest,MockResponse>username - The user namepassword - The password
public MockRequest addSeraphAuthentication(String username,
String password)
Request
addSeraphAuthentication in interface Request<MockRequest,MockResponse>username - The user namepassword - The password
public <RET> RET executeAndReturn(ReturningResponseHandler<MockResponse,RET> responseHandler)
throws ResponseException
Request
executeAndReturn in interface Request<MockRequest,MockResponse>responseHandler - Callback handler of the response.
ResponseProtocolException - If the server returned a malformed response
ResponseTimeoutException - If a connection timeout or read timeout occurred
ResponseTransportException - If an I/O error occurred in request transport
ResponseException - For all errors not otherwise specified
public void execute(ResponseHandler responseHandler)
throws ResponseException
Request
execute in interface Request<MockRequest,MockResponse>responseHandler - Callback handler of the response.
ResponseProtocolException - If the server returned a malformed response
ResponseTimeoutException - If a connection timeout or read timeout occurred
ResponseTransportException - If an I/O error occurred in request transport
ResponseException - For all errors not otherwise specified
public String execute()
throws ResponseException
RequestResponse.getResponseBodyAsString()
execute in interface Request<MockRequest,MockResponse>ResponseStatusException - If the server returned a response that contained an error code
ResponseProtocolException - If the server returned a malformed response
ResponseTimeoutException - If a connection timeout or read timeout occurred
ResponseTransportException - If an I/O error occurred in request transport
ResponseException - For all errors not otherwise specifiedpublic Request.MethodType getMethodType()
public String getUrl()
public int getConnectionTimeout()
public int getSoTimeout()
public String getRequestBody()
public String getRequestContentType()
public List<String> getRequestParameters()
public Map<String,List<String>> getHeaders()
getHeaders in interface Request<MockRequest,MockResponse>public List<String> getHeader(String headerName)
public List<Authenticator> getAuthenticators()
public boolean isTrustedTokenAuthentication()
public String getTrustedTokenUser()
public String getBasicUser()
public String getBasicPassword()
public String getSeraphUser()
public String getSeraphPassword()
public Response getResponse()
public void setResponse(MockResponse response)
public void setResponseBody(String responseBody)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||