Class MockWriter

java.lang.Object
java.io.Writer
com.mockobjects.io.MockWriter
All Implemented Interfaces:
Verifiable, Closeable, Flushable, Appendable, AutoCloseable

public class MockWriter extends Writer implements Verifiable
A mock Writer.

Example usage

You may use the MockWriter like this:

 public void testSomething() throws IOException {
     MockWriter out = new MockWriter();
     out.setExpectedSegment("some string");
     out.setExpectedFlushCalls(1);
     out.setExpectedCloseCalls(1);

     ObjectUnderTest testee = new ObjectUnderTest(out);
     out.verify();

     // If we get here, the mock's flush() and close() methods were
     // called exactly once each (order cannot be determined) and
     // the write() method was called with the string "some string" in it.
 }

Author:
Francois Beausoleil, fbos@users.sourceforge.net
  • Constructor Details

    • MockWriter

      public MockWriter()
      Instantiates a new mock writer which will act as a data sink. Once instantiated, mocks of this class do not expect anything special. Once the object is instantiated, you should set your expectations using the provided methods.
  • Method Details