From: Steve F. <sm...@us...> - 2002-08-22 09:48:17
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory usw-pr-cvs1:/tmp/cvs-serv18909/src/jdk/common/com/mockobjects/io Modified Files: MockWriter.java Log Message: changed some variable names only set throwException, default is not to do anything used Verifier to verify expections Index: MockWriter.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockWriter.java 22 Aug 2002 09:41:54 -0000 1.1 +++ MockWriter.java 22 Aug 2002 09:48:14 -0000 1.2 @@ -31,9 +31,9 @@ * @author Francois Beausoleil, fb...@us... */ public class MockWriter extends Writer implements Verifiable { - private ExpectationSegment mySegment = new ExpectationSegment("String segment"); - private ExpectationCounter myFlushCalls = new ExpectationCounter("flush calls"); - private ExpectationCounter myCloseCalls = new ExpectationCounter("close calls"); + private ExpectationSegment segment = new ExpectationSegment("String segment"); + private ExpectationCounter flushCallsCount = new ExpectationCounter("flush calls"); + private ExpectationCounter closeCallsCount = new ExpectationCounter("close calls"); private boolean writeShouldThrowException = false; @@ -44,19 +44,17 @@ * the provided methods. */ public MockWriter() { + super(); } /** - * Sets the mocks behavior when writing. - * When the {@link #write(char[],int,int) write(char[], int, int)} method - * is called, if this method was called with <code>true</code>, the mock - * will throw an {@link java.io.IOException IOException} instead of - * asserting a string segment. - * @param state Set to <code>true</code> if you want the mock to throw an - * exception, <code>false</code> otherwise. + * Sets the mock's behavior when writing. + * If this method has been called, then + * {@link #write(char[],int,int) write(char[], int, int)} will throw an + * {@link java.io.IOException IOException}. */ - public void setWriteShouldThrowException(boolean state) { - writeShouldThrowException = state; + public void setWriteShouldThrowException() { + writeShouldThrowException = true; } /** @@ -65,7 +63,7 @@ * @see #flush() */ public void setExpectedFlushCalls(int calls) { - myFlushCalls.setExpected(calls); + flushCallsCount.setExpected(calls); } /** @@ -74,7 +72,7 @@ * @see #close() */ public void setExpectedCloseCalls(int calls) { - myCloseCalls.setExpected(calls); + closeCallsCount.setExpected(calls); } /** @@ -87,7 +85,7 @@ * @see #write(char[], int, int) */ public void setExpectedSegment(String aString) { - mySegment.setExpected(aString); + segment.setExpected(aString); } /** @@ -97,10 +95,10 @@ */ public void write(char cbuf[], int off, int len) throws IOException { if (writeShouldThrowException) { - throw new IOException("Exception, as requested"); + throw new IOException("Mock Exception"); } - mySegment.setActual(new String(cbuf, off, len)); + segment.setActual(new String(cbuf, off, len)); } /** @@ -109,7 +107,7 @@ * @see #setExpectedFlushCalls(int) */ public void flush() throws IOException { - myFlushCalls.inc(); + flushCallsCount.inc(); } /** @@ -118,12 +116,10 @@ * @see #setExpectedCloseCalls(int) */ public void close() { - myCloseCalls.inc(); + closeCallsCount.inc(); } public void verify() { - mySegment.verify(); - myFlushCalls.verify(); - myCloseCalls.verify(); + Verifier.verifyObject(this); } } |