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

java.lang.Object
  extended by com.google.api.client.http.LowLevelHttpRequest
      extended by com.google.api.client.testing.http.MockLowLevelHttpRequest

public class MockLowLevelHttpRequest
extends LowLevelHttpRequest

Mock for LowLevelHttpRequest.

Implementation is not thread-safe.

Since:
1.3
Author:
Yaniv Inbar

Constructor Summary
MockLowLevelHttpRequest()
           
MockLowLevelHttpRequest(String url)
           
 
Method Summary
 void addHeader(String name, String value)
          Adds a header to the HTTP request.
 LowLevelHttpResponse execute()
          Executes the request and returns a low-level HTTP response object.
 HttpContent getContent()
          Returns the HTTP content or null for none.
 Map<String,List<String>> getHeaders()
          Returns the map of header name to values.
 MockLowLevelHttpResponse getResponse()
          HTTP response to return from execute().
 String getUrl()
          Returns the request URL or null for none.
 void setContent(HttpContent content)
          Sets the HTTP request content.
 MockLowLevelHttpRequest setResponse(MockLowLevelHttpResponse response)
          Sets the HTTP response to return from execute().
 MockLowLevelHttpRequest setUrl(String url)
          Sets the request URL or null for none.
 
Methods inherited from class com.google.api.client.http.LowLevelHttpRequest
setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockLowLevelHttpRequest

public MockLowLevelHttpRequest()

MockLowLevelHttpRequest

public MockLowLevelHttpRequest(String url)
Parameters:
url - Request URL or null for none
Since:
1.4
Method Detail

addHeader

public void addHeader(String name,
                      String value)
Description copied from class: LowLevelHttpRequest
Adds a header to the HTTP request.

Note that multiple headers of the same name need to be supported, in which case LowLevelHttpRequest.addHeader(java.lang.String, java.lang.String) will be called for each instance of the header.

Specified by:
addHeader in class LowLevelHttpRequest
Parameters:
name - header name
value - header value

execute

public LowLevelHttpResponse execute()
                             throws IOException
Description copied from class: LowLevelHttpRequest
Executes the request and returns a low-level HTTP response object.

Specified by:
execute in class LowLevelHttpRequest
Throws:
IOException

setContent

public void setContent(HttpContent content)
                throws IOException
Description copied from class: LowLevelHttpRequest
Sets the HTTP request content.

Specified by:
setContent in class LowLevelHttpRequest
Throws:
IOException - I/O exception

getUrl

public String getUrl()
Returns the request URL or null for none.

Since:
1.5

getHeaders

public Map<String,List<String>> getHeaders()
Returns the map of header name to values.

Since:
1.5

setUrl

public MockLowLevelHttpRequest setUrl(String url)
Sets the request URL or null for none.

Since:
1.5

getContent

public HttpContent getContent()
Returns the HTTP content or null for none.

Since:
1.5

getResponse

public MockLowLevelHttpResponse getResponse()
HTTP response to return from execute().

Since:
1.8

setResponse

public MockLowLevelHttpRequest setResponse(MockLowLevelHttpResponse response)
Sets the HTTP response to return from execute().

By default this is a new instance of MockLowLevelHttpResponse.



Copyright © 2011-2012 Google. All Rights Reserved.