@Test public void testWriteToFile() throws IOException{ String fileName = "foo_written_with_FOS"; File realFile = new File(fileName); realFile.deleteOnExit(); Assert.assertFalse(realFile.exists()); File file = new MockFile(fileName); Assert.assertFalse(file.exists()); byte[] data = new byte[]{42}; MockFileOutputStream out = new MockFileOutputStream(file); out.write(data); Assert.assertTrue(file.exists()); out.close(); try{ out.write(data); Assert.fail(); } catch(Exception e){ } Assert.assertFalse(realFile.exists()); }
public boolean exists(String rawPath) { return findFSObject(rawPath) != null; }
VirtualFileSystem { public boolean exists(String rawPath) { return findFSObject(rawPath) != null; } }
VirtualFileSystem { public boolean exists(String rawPath) { return findFSObject(rawPath) != null; } private  VirtualFileSystem(); }
VirtualFileSystem { public boolean exists(String rawPath) { return findFSObject(rawPath) != null; } private  VirtualFileSystem(); static VirtualFileSystem getInstance(); void resetSingleton(); void addLeakingResource(LeakingResource resource); File getRealTmpFile(); void throwSimuledIOExceptionIfNeeded(String path); boolean isClassSupposedToThrowIOException(String path); boolean setShouldThrowIOException(EvoSuiteFile file); boolean setShouldAllThrowIOExceptions(); void init(); static String getWorkingDirPath(); static String getDefaultParent(); Set<String> getAccessedFiles(); String createTempFile(String prefix, String suffix, File directory); boolean exists(String rawPath); FSObject findFSObject(String rawPath); boolean deleteFSObject(String rawPath); boolean createFile(String rawPath); boolean rename(String source, String destination); boolean createFolder(String rawPath); }
VirtualFileSystem { public boolean exists(String rawPath) { return findFSObject(rawPath) != null; } private  VirtualFileSystem(); static VirtualFileSystem getInstance(); void resetSingleton(); void addLeakingResource(LeakingResource resource); File getRealTmpFile(); void throwSimuledIOExceptionIfNeeded(String path); boolean isClassSupposedToThrowIOException(String path); boolean setShouldThrowIOException(EvoSuiteFile file); boolean setShouldAllThrowIOExceptions(); void init(); static String getWorkingDirPath(); static String getDefaultParent(); Set<String> getAccessedFiles(); String createTempFile(String prefix, String suffix, File directory); boolean exists(String rawPath); FSObject findFSObject(String rawPath); boolean deleteFSObject(String rawPath); boolean createFile(String rawPath); boolean rename(String source, String destination); boolean createFolder(String rawPath);  }