Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.mockobjects.io
Class MockOutputStream  view MockOutputStream download MockOutputStream.java

java.lang.Object
  extended byjava.io.OutputStream
      extended bycom.mockobjects.io.MockOutputStream
All Implemented Interfaces:
com.mockobjects.Verifiable

public class MockOutputStream
extends java.io.OutputStream
implements com.mockobjects.Verifiable


Field Summary
private  java.io.ByteArrayOutputStream myBuffer
           
private  com.mockobjects.ExpectationCounter myCloseCalls
           
private  com.mockobjects.ExpectationCounter myFlushCalls
           
private  com.mockobjects.ExpectationValue myWriteWasCalled
           
private  boolean shouldThrowException
           
 
Constructor Summary
MockOutputStream()
           
 
Method Summary
 void clearActualBuffer()
           
 void close()
          This method closes the stream.
 void flush()
          This method forces any data that may have been buffered to be written to the underlying output device.
 java.lang.String getContents()
           
 byte[] getContentsAsByteArray()
          Added in response to Bug report 546661.
 void setExpectedCloseCalls(int closeCall)
           
 void setExpectedFlushCalls(int flushCall)
           
 void setExpectingWriteCalls(boolean expectingWriteCall)
           
 void setupThrowIOException(boolean throwException)
           
 void verify()
          Throw an AssertionFailedException if any expectations have not been met.
 void write(int b)
          This method writes a single byte to the output stream.
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myWriteWasCalled

private com.mockobjects.ExpectationValue myWriteWasCalled

myCloseCalls

private com.mockobjects.ExpectationCounter myCloseCalls

myFlushCalls

private com.mockobjects.ExpectationCounter myFlushCalls

myBuffer

private java.io.ByteArrayOutputStream myBuffer

shouldThrowException

private boolean shouldThrowException
Constructor Detail

MockOutputStream

public MockOutputStream()
Method Detail

clearActualBuffer

public void clearActualBuffer()

close

public void close()
           throws java.io.IOException
Description copied from class: java.io.OutputStream
This method closes the stream. Any internal or native resources associated with this stream are freed. Any subsequent attempt to access the stream might throw an exception.

This method in this class does nothing.


flush

public void flush()
           throws java.io.IOException
Description copied from class: java.io.OutputStream
This method forces any data that may have been buffered to be written to the underlying output device. Please note that the host environment might perform its own buffering unbeknowst to Java. In that case, a write made (for example, to a disk drive) might be cached in OS buffers instead of actually being written to disk.

This method in this class does nothing.


getContents

public java.lang.String getContents()

getContentsAsByteArray

public byte[] getContentsAsByteArray()
Added in response to Bug report 546661.


setExpectedCloseCalls

public void setExpectedCloseCalls(int closeCall)

setExpectedFlushCalls

public void setExpectedFlushCalls(int flushCall)

setExpectingWriteCalls

public void setExpectingWriteCalls(boolean expectingWriteCall)

setupThrowIOException

public void setupThrowIOException(boolean throwException)

verify

public void verify()
Description copied from interface: com.mockobjects.Verifiable
Throw an AssertionFailedException if any expectations have not been met.

Specified by:
verify in interface com.mockobjects.Verifiable

write

public void write(int b)
           throws java.io.IOException
Description copied from class: java.io.OutputStream
This method writes a single byte to the output stream. The byte written is the low eight bits of the int passed and a argument.

Subclasses must provide an implementation of this abstract method