01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.responders.files;
04:
05: import fitnesse.util.FileUtil;
06: import java.io.File;
07:
08: public class SampleFileUtility {
09: public static final String TEMP_TEST_DIR = System
10: .getProperty("java.io.tmpdir")
11: + File.separator + "testDir";
12:
13: public static File filesDir;
14:
15: public static File testDir;
16:
17: public static File testFile1;
18:
19: public static File testFile2;
20:
21: public static File testFile3;
22:
23: public static File testFile4;
24:
25: public static void makeSampleFiles() {
26: File dir = new File(TEMP_TEST_DIR);
27: dir.mkdir();
28: filesDir = new File(dir, "files");
29: filesDir.mkdir();
30: testDir = new File(filesDir, "testDir");
31: testDir.mkdir();
32:
33: testFile1 = FileUtil.createFile(TEMP_TEST_DIR
34: + "/files/testFile1", "file1 content");
35: testFile2 = FileUtil.createFile(TEMP_TEST_DIR
36: + "/files/testDir/testFile2", "file2 content");
37: testFile3 = FileUtil.createFile(TEMP_TEST_DIR
38: + "/files/testDir/testFile3", "file3 content");
39: testFile4 = FileUtil.createFile(TEMP_TEST_DIR
40: + "/files/file4 with spaces.txt", "file4 content");
41: }
42:
43: public static void deleteSampleFiles() {
44: FileUtil.deleteFileSystemDirectory(TEMP_TEST_DIR);
45: }
46:
47: public static void addFile(String name, String content) {
48: FileUtil.createFile(TEMP_TEST_DIR + name, content);
49: }
50: }
|