Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io
In directory sc8-pr-cvs1:/tmp/cvs-serv31146/src/jdk/common/com/mockobjects/io
Modified Files:
MockWriter.java MockIOFactory.java
Log Message:
Add StringWriter support to IOFactory
Index: MockWriter.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockWriter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MockWriter.java 22 Aug 2002 13:21:50 -0000 1.3
+++ MockWriter.java 25 Jun 2003 09:22:29 -0000 1.4
@@ -68,7 +68,7 @@
/**
* Sets the mock's behavior when flushing. If this method has been called,
- * then {@link #flush() flush()} will throw
+ * then {@link #flush() flush()} will throw
* an {@link java.io.IOException IOException}.
*/
public void setFlushShouldThrowException() {
@@ -76,14 +76,14 @@
}
/**
- * Sets the mock's behavior when closing.
- * If this method has been called, then {@link #close() close()} will
- * throw an {@link java.io.IOException IOException}.
+ * Sets the mock's behavior when closing.
+ * If this method has been called, then {@link #close() close()} will
+ * throw an {@link java.io.IOException IOException}.
*/
public void setCloseShouldThrowException() {
closeShouldThrowException = true;
}
-
+
/**
* Sets the expected number of times that the {@link #flush() flush()}
* method will be called.
@@ -115,6 +115,10 @@
segment.setExpected(aString);
}
+ public void setFailOnVerify(){
+ this.segment.setFailOnVerify();
+ }
+
/**
* Either throws an exception or asserts a string segment for equality.
* @see com.mockobjects.ExpectationSegment
@@ -139,7 +143,7 @@
*/
public void flush() throws IOException {
flushCallsCount.inc();
-
+
if (flushShouldThrowException) {
throw new IOException("Mock Exception");
}
@@ -158,12 +162,12 @@
*/
public void close() throws IOException {
closeCallsCount.inc();
-
+
if (closeShouldThrowException) {
throw new IOException("Mock Exception");
}
}
-
+
public void verify() {
// WARNING: If the MockWriter calls its parent no-arg constructor,
// this call will fail with a StackOverflowError. See constructor
Index: MockIOFactory.java
===================================================================
RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockIOFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MockIOFactory.java 17 Jan 2003 17:10:33 -0000 1.2
+++ MockIOFactory.java 25 Jun 2003 09:22:29 -0000 1.3
@@ -2,18 +2,17 @@
import alt.java.io.File;
import alt.java.io.IOFactory;
-import com.mockobjects.ExpectationValue;
-import com.mockobjects.MockObject;
-import com.mockobjects.ReturnValue;
-import com.mockobjects.ReturnObjectBag;
+import com.mockobjects.*;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Writer;
public class MockIOFactory extends MockObject implements IOFactory {
private final ReturnObjectBag inputStream = new ReturnObjectBag("input stream");
private final ReturnObjectBag outputStream = new ReturnObjectBag("output stream");
+ private final ReturnObjectList writers = new ReturnObjectList("writers");
private final ReturnValue file = new ReturnValue("file");
private final ExpectationValue fileName = new ExpectationValue("file name");
@@ -45,5 +44,13 @@
public File createFile(String fileName) {
this.fileName.setActual(fileName);
return (File)file.getValue();
+ }
+
+ public Writer createWriter() {
+ return (Writer)writers.nextReturnObject();
+ }
+
+ public void setupCreateWriter(Writer writer){
+ writers.addObjectToReturn(writer);
}
}
|