From: Jeff M. <je...@mk...> - 2002-11-05 09:57:08
|
I've plonked the patch in. Did make one change which was to change the verify method to use Verifier.verify(this); rather than having to verify each expectation. On Mon, 2002-11-04 at 23:21, Francois Beausoleil wrote: > 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 > > > ------------------------------------------------------- > This SF.net email is sponsored by: ApacheCon, November 18-21 in > Las Vegas (supported by COMDEX), the only Apache event to be > fully supported by the ASF. http://www.apachecon.com > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev -- jeff martin information technologist mkodo limited mobile: 44 (0) 78 5547 8331 phone: 44 (0) 20 2226 4545 email: je...@mk... www.mkodo.com |