From: Jeff M. <cus...@us...> - 2002-11-05 09:55:38
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory usw-pr-cvs1:/tmp/cvs-serv6353/mockobjects/io Modified Files: MockPrintWriter.java Log Message: Added support for counting flushes patch provided by Francois Beausoleil Index: MockPrintWriter.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockPrintWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockPrintWriter.java 22 Aug 2002 09:33:44 -0000 1.2 +++ MockPrintWriter.java 5 Nov 2002 09:55:35 -0000 1.3 @@ -7,15 +7,18 @@ import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationSegment; import com.mockobjects.Verifiable; +import com.mockobjects.util.Verifier; /** * @author st...@m3... + * @author Francois Beausoleil (fb...@us...) */ public class MockPrintWriter extends PrintWriter implements Verifiable { private ExpectationSegment mySegment = new ExpectationSegment("String segment"); private ExpectationCounter myCloseCalls = new ExpectationCounter("close calls"); + private ExpectationCounter myFlushCalls = new ExpectationCounter("flush calls"); public MockPrintWriter() { this(new StringWriter()); @@ -25,11 +28,6 @@ super(writer); } - public void close() { - super.close(); - myCloseCalls.inc(); - } - public void setExpectedCloseCalls(int calls) { myCloseCalls.setExpected(calls); } @@ -38,13 +36,26 @@ mySegment.setExpected(aString); } - public void verify() { - mySegment.verify(); - myCloseCalls.verify(); - } - public void write(String s) { super.write(s); mySegment.setActual(s); + } + + public void setExpectedFlushCalls(int calls) { + myFlushCalls.setExpected(calls); + } + + public void flush() { + super.flush(); + myFlushCalls.inc(); + } + + public void close() { + super.close(); + myCloseCalls.inc(); + } + + public void verify() { + Verifier.verifyObject(this); } } |