com.atlassian.sal.testresources.net
Class MockResponse

java.lang.Object
  extended by com.atlassian.sal.testresources.net.MockResponse
All Implemented Interfaces:
Response

public class MockResponse
extends Object
implements Response

Mock response that provides setters for all properties


Constructor Summary
MockResponse()
           
 
Method Summary
<T> T
getEntity(Class<T> entityClass)
          Unmarshall the response body as the specified type
 String getHeader(String name)
          Get's the header by the given name
 Map<String,String> getHeaders()
          Get a map of all the headers
 InputStream getResponseBodyAsStream()
           
 String getResponseBodyAsString()
           
 int getStatusCode()
           
 String getStatusText()
           
 boolean isSuccessful()
           
 void setHeaders(Map<String,String> headers)
           
 void setResponseBodyAsStream(InputStream responseBodyAsStream)
           
 void setResponseBodyAsString(String responseBodyAsString)
           
 void setStatusCode(int statusCode)
           
 void setStatusText(String statusText)
           
 void setSuccessful(boolean successful)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockResponse

public MockResponse()
Method Detail

getHeader

public String getHeader(String name)
Description copied from interface: Response
Get's the header by the given name

Specified by:
getHeader in interface Response
Parameters:
name - The name of the header
Returns:
The value of the header. This will include all values, comma separated, if multiple header fields with the given name were specified, as per RFC2616. When the specified header key is not present, null is returned.

getStatusCode

public int getStatusCode()
Specified by:
getStatusCode in interface Response
Returns:
status code of the request.

setStatusCode

public void setStatusCode(int statusCode)

getResponseBodyAsString

public String getResponseBodyAsString()
Specified by:
getResponseBodyAsString in interface Response
Returns:
the response body of the request.

setResponseBodyAsString

public void setResponseBodyAsString(String responseBodyAsString)

getResponseBodyAsStream

public InputStream getResponseBodyAsStream()
Specified by:
getResponseBodyAsStream in interface Response
Returns:
the response body of the request.

setResponseBodyAsStream

public void setResponseBodyAsStream(InputStream responseBodyAsStream)

getEntity

public <T> T getEntity(Class<T> entityClass)
            throws ResponseException
Description copied from interface: Response
Unmarshall the response body as the specified type

Specified by:
getEntity in interface Response
Parameters:
entityClass - the type of the response
Returns:
the unmarshalled object
Throws:
ResponseException - if there was difficulty reading the response or unmarshalling the object

getStatusText

public String getStatusText()
Specified by:
getStatusText in interface Response
Returns:
status test of the response

setStatusText

public void setStatusText(String statusText)

isSuccessful

public boolean isSuccessful()
Specified by:
isSuccessful in interface Response
Returns:
true if network returned a status code in the 200 range or 300 range

setSuccessful

public void setSuccessful(boolean successful)

getHeaders

public Map<String,String> getHeaders()
Description copied from interface: Response
Get a map of all the headers

Specified by:
getHeaders in interface Response
Returns:
A map of header names to header values. The header values will include all values, comma seperated, if multiple header fields with the given name were specified, as per RFC2616.

setHeaders

public void setHeaders(Map<String,String> headers)


Copyright © 2015 Atlassian. All rights reserved.