From: Jeff M. <cus...@us...> - 2003-08-11 09:16:33
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory sc8-pr-cvs1:/tmp/cvs-serv19213/src/jdk/common/com/mockobjects/io Modified Files: MockFile.java MockIOFactory.java Log Message: Added mkdir for MockFile Index: MockFile.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockFile.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- MockFile.java 25 Jun 2003 09:20:28 -0000 1.7 +++ MockFile.java 11 Aug 2003 09:16:30 -0000 1.8 @@ -30,6 +30,8 @@ private final ReturnValue myPath = new ReturnValue("path"); private final ReturnValue absolutePath = new ReturnValue("absolute path"); private final ReturnValue length = new ReturnValue("length"); + private final ReturnValue lastModified = new ReturnValue("last modified"); + private final ReturnValue mkdir = new ReturnValue("mkdir"); public void setupGetName(final String name) { this.fileName.setValue(name); @@ -128,7 +130,7 @@ public boolean exists() { return exists.getBooleanValue(); } - + public void setupIsDirectory(boolean isDir) { this.isDirectory.setValue(isDir); } @@ -136,7 +138,7 @@ public boolean isDirectory() { return isDirectory.getBooleanValue(); } - + public void setupIsFile(boolean isFile) { this.isFile.setValue(isFile); } @@ -151,8 +153,11 @@ } public long lastModified() { - notImplemented(); - return 0; + return lastModified.getLongValue(); + } + + public void setupLastModified(long lastModified){ + this.lastModified.setValue(lastModified); } public void setupLength(long length){ @@ -210,8 +215,11 @@ } public boolean mkdir() { - notImplemented(); - return false; + return mkdir.getBooleanValue(); + } + + public void setupMkdir(boolean returnValue){ + mkdir.setValue(returnValue); } public void setupMkdirs(boolean mkdirs, int count) { Index: MockIOFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockIOFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockIOFactory.java 25 Jun 2003 09:22:29 -0000 1.3 +++ MockIOFactory.java 11 Aug 2003 09:16:30 -0000 1.4 @@ -4,18 +4,16 @@ import alt.java.io.IOFactory; import com.mockobjects.*; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Writer; +import java.io.*; +import java.net.URLConnection; +import java.net.URL; 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"); - + private final ReturnObjectBag file = new ReturnObjectBag("file"); + private final ReturnObjectBag connection = new ReturnObjectBag("connection"); public void setupInputStream(File expectedFile, InputStream returnStream) { this.inputStream.putObjectToReturn(expectedFile, returnStream); @@ -33,17 +31,12 @@ return (OutputStream)outputStream.getNextReturnObject(aFile); } - public void setupCreateFile(File file) { - this.file.setValue(file); - } - - public void setExpectedFileName(String fileName){ - this.fileName.setExpected(fileName); + public void setupCreateFile(String fileName, File file) { + this.file.putObjectToReturn(fileName, file); } public File createFile(String fileName) { - this.fileName.setActual(fileName); - return (File)file.getValue(); + return (File)file.getNextReturnObject(fileName); } public Writer createWriter() { @@ -52,5 +45,21 @@ public void setupCreateWriter(Writer writer){ writers.addObjectToReturn(writer); + } + + public URLConnection createConnection(URL aURL) throws IOException { + return (URLConnection) connection.getNextReturnObject(aURL); + } + + public void setupCreateConnection(URL url, URLConnection connection){ + this.connection.putObjectToReturn(url, connection); + } + + public InputStream createInputStream(URLConnection connection) throws IOException { + return (InputStream) inputStream.getNextReturnObject(connection); + } + + public void setupCreateInputStream(URLConnection connection, InputStream inputStream){ + this.inputStream.putObjectToReturn(connection, inputStream); } } |