From: Jeff M. <cus...@us...> - 2003-03-24 11:23:22
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory sc8-pr-cvs1:/tmp/cvs-serv11550/src/jdk/common/com/mockobjects/io Modified Files: MockOutputStream.java Log Message: Added expectations for flush() calls on MockOutputStream. patch from Francois Beausoleil Index: MockOutputStream.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockOutputStream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockOutputStream.java 8 Jul 2002 18:31:29 -0000 1.3 +++ MockOutputStream.java 24 Mar 2003 11:23:16 -0000 1.4 @@ -12,6 +12,7 @@ public class MockOutputStream extends OutputStream implements Verifiable { private ExpectationValue myWriteWasCalled = new ExpectationValue("MockOutputStream.writeWasCalled"); private ExpectationCounter myCloseCalls = new ExpectationCounter("MockOutputStream.close()"); + private ExpectationCounter myFlushCalls = new ExpectationCounter("MockOutputStream.flush()"); private ByteArrayOutputStream myBuffer = new ByteArrayOutputStream(); private boolean shouldThrowException = false; @@ -27,6 +28,10 @@ myCloseCalls.inc(); } + public void flush() throws IOException { + myFlushCalls.inc(); + } + public String getContents() { return myBuffer.toString(); } @@ -42,6 +47,10 @@ myCloseCalls.setExpected(closeCall); } + public void setExpectedFlushCalls(int flushCall) { + myFlushCalls.setExpected(flushCall); + } + public void setExpectingWriteCalls(boolean expectingWriteCall) { myWriteWasCalled.setExpected(expectingWriteCall); } @@ -56,7 +65,7 @@ public void write(int b) throws IOException { myWriteWasCalled.setActual(true); - if(shouldThrowException) { + if (shouldThrowException) { throw new IOException("Test IOException generated by request"); } myBuffer.write(b); |