com.google.api.client.testing.http
Class MockLowLevelHttpResponse

java.lang.Object
  extended by com.google.api.client.http.LowLevelHttpResponse
      extended by com.google.api.client.testing.http.MockLowLevelHttpResponse

public class MockLowLevelHttpResponse
extends LowLevelHttpResponse

Mock for LowLevelHttpResponse.

Since:
1.3
Author:
Yaniv Inbar

Field Summary
 InputStream content
          Input stream content of HTTP response or null by default.
 String contentType
          Content type of HTTP response or null by default.
 ArrayList<String> headerNames
          List of header names of HTTP response (empty array list by default).
 ArrayList<String> headerValues
          List of header values of HTTP response (empty array list by default).
 int statusCode
          Status code of HTTP response or 200 by default.
 
Constructor Summary
MockLowLevelHttpResponse()
           
 
Method Summary
 void addHeader(String name, String value)
          Adds a header to the response.
 InputStream getContent()
          Returns the HTTP response content input stream or null for none.
 String getContentEncoding()
          Returns the content encoding (for example "gzip") or null for none.
 long getContentLength()
          Returns the content length or 0 for none.
 String getContentType()
          Returns the content type or null for none.
 int getHeaderCount()
          Returns the number of HTTP response headers.
 String getHeaderName(int index)
          Returns the HTTP response header name at the given zero-based index.
 String getHeaderValue(int index)
          Returns the HTTP response header value at the given zero-based index.
 String getReasonPhrase()
          Returns the HTTP reason phrase or null for none.
 int getStatusCode()
          Returns the response status code or 0 for none.
 String getStatusLine()
          Returns the response status line or null for none.
 void setContent(String stringContent)
          Sets the response content to the given content string.
 
Methods inherited from class com.google.api.client.http.LowLevelHttpResponse
disconnect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

content

public InputStream content
Input stream content of HTTP response or null by default.


contentType

public String contentType
Content type of HTTP response or null by default.


statusCode

public int statusCode
Status code of HTTP response or 200 by default.


headerNames

public ArrayList<String> headerNames
List of header names of HTTP response (empty array list by default).


headerValues

public ArrayList<String> headerValues
List of header values of HTTP response (empty array list by default).

Constructor Detail

MockLowLevelHttpResponse

public MockLowLevelHttpResponse()
Method Detail

addHeader

public void addHeader(String name,
                      String value)
Adds a header to the response.

Parameters:
name - header name
value - header value

setContent

public void setContent(String stringContent)
Sets the response content to the given content string.

Parameters:
stringContent - content string

getContent

public InputStream getContent()
                       throws IOException
Description copied from class: LowLevelHttpResponse
Returns the HTTP response content input stream or null for none.

Specified by:
getContent in class LowLevelHttpResponse
Throws:
IOException - I/O exception

getContentEncoding

public String getContentEncoding()
Description copied from class: LowLevelHttpResponse
Returns the content encoding (for example "gzip") or null for none.

Specified by:
getContentEncoding in class LowLevelHttpResponse

getContentLength

public long getContentLength()
Description copied from class: LowLevelHttpResponse
Returns the content length or 0 for none.

Specified by:
getContentLength in class LowLevelHttpResponse

getContentType

public String getContentType()
Description copied from class: LowLevelHttpResponse
Returns the content type or null for none.

Specified by:
getContentType in class LowLevelHttpResponse

getHeaderCount

public int getHeaderCount()
Description copied from class: LowLevelHttpResponse
Returns the number of HTTP response headers.

Note that multiple headers of the same name need to be supported, in which case each header value is treated as a separate header.

Specified by:
getHeaderCount in class LowLevelHttpResponse

getHeaderName

public String getHeaderName(int index)
Description copied from class: LowLevelHttpResponse
Returns the HTTP response header name at the given zero-based index.

Specified by:
getHeaderName in class LowLevelHttpResponse

getHeaderValue

public String getHeaderValue(int index)
Description copied from class: LowLevelHttpResponse
Returns the HTTP response header value at the given zero-based index.

Specified by:
getHeaderValue in class LowLevelHttpResponse

getReasonPhrase

public String getReasonPhrase()
Description copied from class: LowLevelHttpResponse
Returns the HTTP reason phrase or null for none.

Specified by:
getReasonPhrase in class LowLevelHttpResponse

getStatusCode

public int getStatusCode()
Description copied from class: LowLevelHttpResponse
Returns the response status code or 0 for none.

Specified by:
getStatusCode in class LowLevelHttpResponse

getStatusLine

public String getStatusLine()
Description copied from class: LowLevelHttpResponse
Returns the response status line or null for none.

Specified by:
getStatusLine in class LowLevelHttpResponse


Copyright © 2010-2011 Google. All Rights Reserved.