From: Francois B. <fbe...@ft...> - 2002-11-04 23:22:05
|
Hi ! Simple patch to expect calls to flush(). I also reordered the methods so that all expectations are first, then the overriden methods, and finally, the verify() method. Have a nice day ! Francois Beausoleil Index: MockPrintWriter.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockPrintWriter.java,v retrieving revision 1.2 diff -u -r1.2 MockPrintWriter.java --- MockPrintWriter.java 22 Aug 2002 09:33:44 -0000 1.2 +++ MockPrintWriter.java 4 Nov 2002 23:19:00 -0000 @@ -1,21 +1,22 @@ package com.mockobjects.io; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.Writer; - import com.mockobjects.ExpectationCounter; import com.mockobjects.ExpectationSegment; import com.mockobjects.Verifiable; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; + /** * @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,26 +26,35 @@ super(writer); } - public void close() { - super.close(); - myCloseCalls.inc(); - } - public void setExpectedCloseCalls(int calls) { myCloseCalls.setExpected(calls); } + public void setExpectedFlushCalls(int calls) { + myFlushCalls.setExpected(calls); + } + public void setExpectedSegment(String aString) { mySegment.setExpected(aString); } - public void verify() { - mySegment.verify(); - myCloseCalls.verify(); + public void flush() { + super.flush(); + myFlushCalls.inc(); + } + + public void close() { + super.close(); + myCloseCalls.inc(); } public void write(String s) { super.write(s); mySegment.setActual(s); + } + + public void verify() { + mySegment.verify(); + myCloseCalls.verify(); } } -- http://fastmail.fm - The holy hand grenade of email services |