From: David S. <ds...@us...> - 2007-07-05 20:59:52
|
Update of /cvsroot/junit/junit-ant-tests/src/test/net/saff/ant In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv3239/src/test/net/saff/ant Added Files: FileMatchersTest.java Log Message: initial check-in --- NEW FILE: FileMatchersTest.java --- package test.net.saff.ant; import static net.saff.ant.FileMatchers.*; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import java.io.File; import java.io.IOException; import org.junit.After; import org.junit.Test; public class FileMatchersTest { private File tempFile; @After public void deleteFiles() { if (tempFile != null) tempFile.delete(); } private String newTempFilename() throws IOException { tempFile = File.createTempFile("temp", null); return tempFile.getAbsolutePath(); } @Test public void nameOfExistingFileIsCorrect() throws IOException { assertThat(newTempFilename(), nameOfExistingFile()); } @Test public void tempFilenameIsDeleted() throws IOException { String filename = newTempFilename(); deleteFiles(); assertThat(filename, not(nameOfExistingFile())); } @Test public void nameOfExistingFileDescribesWell() { assertThat(nameOfExistingFile().toString(), is("name of existing file")); } @Test public void someFilesDontExist() throws IOException { File file = File.createTempFile("test", "txt"); file.delete(); assertThat(file.getAbsolutePath(), not(nameOfExistingFile())); } } |