com.atlassian.sal.testresources.net
Class MockRequest

java.lang.Object
  extended by com.atlassian.sal.testresources.net.MockRequest
All Implemented Interfaces:
Request<MockRequest,MockResponse>

public class MockRequest
extends Object
implements Request<MockRequest,MockResponse>

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)
           
 MockRequest addBasicAuthentication(String username, String password)
           
 MockRequest addHeader(String headerName, String headerValue)
           
 MockRequest addRequestParameters(String... params)
           
 MockRequest addSeraphAuthentication(String username, String password)
           
 MockRequest addTrustedTokenAuthentication()
           
 MockRequest addTrustedTokenAuthentication(String username)
           
 String execute()
           
 void execute(ResponseHandler responseHandler)
           
<RET> RET
executeAndReturn(ReturningResponseHandler<MockResponse,RET> responseHandler)
           
 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)
           
 MockRequest setEntity(Object entity)
           
 MockRequest setFiles(List<RequestFilePart> files)
           
 MockRequest setFollowRedirects(boolean follow)
           
 MockRequest setHeader(String headerName, String headerValue)
           
 MockRequest setRequestBody(String requestBody)
           
 MockRequest setRequestContentType(String contentType)
           
 void setResponse(MockResponse response)
           
 void setResponseBody(String responseBody)
           
 MockRequest setSoTimeout(int soTimeout)
           
 MockRequest setUrl(String url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockRequest

public MockRequest(Request.MethodType methodType,
                   String url)
Method Detail

setConnectionTimeout

public MockRequest setConnectionTimeout(int connectionTimeout)
Specified by:
setConnectionTimeout in interface Request<MockRequest,MockResponse>

setSoTimeout

public MockRequest setSoTimeout(int soTimeout)
Specified by:
setSoTimeout in interface Request<MockRequest,MockResponse>

setUrl

public MockRequest setUrl(String url)
Specified by:
setUrl in interface Request<MockRequest,MockResponse>

setRequestBody

public MockRequest setRequestBody(String requestBody)
Specified by:
setRequestBody in interface Request<MockRequest,MockResponse>

setFiles

public MockRequest setFiles(List<RequestFilePart> files)
Specified by:
setFiles in interface Request<MockRequest,MockResponse>

setEntity

public MockRequest setEntity(Object entity)
Specified by:
setEntity in interface Request<MockRequest,MockResponse>

setRequestContentType

public MockRequest setRequestContentType(String contentType)
Specified by:
setRequestContentType in interface Request<MockRequest,MockResponse>

addRequestParameters

public MockRequest addRequestParameters(String... params)
Specified by:
addRequestParameters in interface Request<MockRequest,MockResponse>

addHeader

public MockRequest addHeader(String headerName,
                             String headerValue)
Specified by:
addHeader in interface Request<MockRequest,MockResponse>

setHeader

public MockRequest setHeader(String headerName,
                             String headerValue)
Specified by:
setHeader in interface Request<MockRequest,MockResponse>

setFollowRedirects

public MockRequest setFollowRedirects(boolean follow)
Specified by:
setFollowRedirects in interface Request<MockRequest,MockResponse>

addAuthentication

public MockRequest addAuthentication(Authenticator authenticator)
Specified by:
addAuthentication in interface Request<MockRequest,MockResponse>

addTrustedTokenAuthentication

public MockRequest addTrustedTokenAuthentication()
Specified by:
addTrustedTokenAuthentication in interface Request<MockRequest,MockResponse>

addTrustedTokenAuthentication

public MockRequest addTrustedTokenAuthentication(String username)
Specified by:
addTrustedTokenAuthentication in interface Request<MockRequest,MockResponse>

addBasicAuthentication

public MockRequest addBasicAuthentication(String username,
                                          String password)
Specified by:
addBasicAuthentication in interface Request<MockRequest,MockResponse>

addSeraphAuthentication

public MockRequest addSeraphAuthentication(String username,
                                           String password)
Specified by:
addSeraphAuthentication in interface Request<MockRequest,MockResponse>

executeAndReturn

public <RET> RET executeAndReturn(ReturningResponseHandler<MockResponse,RET> responseHandler)
                     throws ResponseException
Specified by:
executeAndReturn in interface Request<MockRequest,MockResponse>
Throws:
ResponseException

execute

public void execute(ResponseHandler responseHandler)
             throws ResponseException
Specified by:
execute in interface Request<MockRequest,MockResponse>
Throws:
ResponseException

execute

public String execute()
               throws ResponseException
Specified by:
execute in interface Request<MockRequest,MockResponse>
Throws:
ResponseException

getMethodType

public Request.MethodType getMethodType()

getUrl

public String getUrl()

getConnectionTimeout

public int getConnectionTimeout()

getSoTimeout

public int getSoTimeout()

getRequestBody

public String getRequestBody()

getRequestContentType

public String getRequestContentType()

getRequestParameters

public List<String> getRequestParameters()

getHeaders

public Map<String,List<String>> getHeaders()
Specified by:
getHeaders in interface Request<MockRequest,MockResponse>

getHeader

public List<String> getHeader(String headerName)

getAuthenticators

public List<Authenticator> getAuthenticators()

isTrustedTokenAuthentication

public boolean isTrustedTokenAuthentication()

getTrustedTokenUser

public String getTrustedTokenUser()

getBasicUser

public String getBasicUser()

getBasicPassword

public String getBasicPassword()

getSeraphUser

public String getSeraphUser()

getSeraphPassword

public String getSeraphPassword()

getResponse

public Response getResponse()

setResponse

public void setResponse(MockResponse response)

setResponseBody

public void setResponseBody(String responseBody)


Copyright © 2013 Atlassian. All Rights Reserved.