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

java.lang.Object
  extended by com.google.api.client.testing.http.MockHttpContent
All Implemented Interfaces:
HttpContent

public class MockHttpContent
extends Object
implements HttpContent

Mock for HttpContent.

Implementation is not thread-safe.

Since:
1.3
Author:
Yaniv Inbar

Constructor Summary
MockHttpContent()
           
 
Method Summary
 byte[] getContent()
          Returns the HTTP content.
 String getEncoding()
          Returns the content encoding (for example "gzip") or null for none.
 long getLength()
          Returns the content length or less than zero if not known.
 String getType()
          Returns the content type or null for none.
 boolean retrySupported()
          Returns whether or not retry is supported on this content type.
 MockHttpContent setContent(byte[] content)
          Sets the HTTP content.
 MockHttpContent setEncoding(String encoding)
          Sets the HTTP content encoding or null for none.
 MockHttpContent setLength(long length)
          Returns the HTTP content length or -1 for unknown.
 MockHttpContent setType(String type)
          Sets the HTTP content type or null for none.
 void writeTo(OutputStream out)
          Writes the content to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockHttpContent

public MockHttpContent()
Method Detail

getEncoding

public String getEncoding()
Description copied from interface: HttpContent
Returns the content encoding (for example "gzip") or null for none.

Specified by:
getEncoding in interface HttpContent

getLength

public long getLength()
               throws IOException
Description copied from interface: HttpContent
Returns the content length or less than zero if not known.

Specified by:
getLength in interface HttpContent
Throws:
IOException

getType

public String getType()
Description copied from interface: HttpContent
Returns the content type or null for none.

Specified by:
getType in interface HttpContent

writeTo

public void writeTo(OutputStream out)
             throws IOException
Description copied from interface: HttpContent
Writes the content to the given output stream.

The recommendation for implementations is that they should not close the output stream. Callers should not assume whether or not the output stream has been closed. Implementations that do not close the output stream should flush it at the end of the method.

Specified by:
writeTo in interface HttpContent
Throws:
IOException

retrySupported

public boolean retrySupported()
Description copied from interface: HttpContent
Returns whether or not retry is supported on this content type.

Specified by:
retrySupported in interface HttpContent

getContent

public final byte[] getContent()
Returns the HTTP content.

Since:
1.5

setContent

public MockHttpContent setContent(byte[] content)
Sets the HTTP content.

Default value is an empty byte array.

Since:
1.5

setEncoding

public MockHttpContent setEncoding(String encoding)
Sets the HTTP content encoding or null for none.

Since:
1.5

setLength

public MockHttpContent setLength(long length)
Returns the HTTP content length or -1 for unknown.

Default value is -1.

Since:
1.5

setType

public MockHttpContent setType(String type)
Sets the HTTP content type or null for none.

Since:
1.5


Copyright © 2011-2012 Google. All Rights Reserved.