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.updates;
04:
05: import java.io.File;
06:
07: public class FileUpdateTest extends UpdateTest {
08: public final File testFile = new File("classes/testFile");
09:
10: protected Update makeUpdate() throws Exception {
11: return new FileUpdate(updater, "testFile", "files/images");
12: }
13:
14: public void setUp() throws Exception {
15: super .setUp();
16: testFile.createNewFile();
17: }
18:
19: public void tearDown() throws Exception {
20: super .tearDown();
21: testFile.delete();
22: }
23:
24: public void testSimpleFunctions() throws Exception {
25: assertTrue("doesn't want to apply", update.shouldBeApplied());
26: assertTrue("wrong starting of message", update.getMessage()
27: .startsWith("Installing file: "));
28: assertTrue("wrong end of message", update.getMessage()
29: .endsWith("testFile"));
30: assertEquals("FileUpdate(testFile)", update.getName());
31: }
32:
33: public void testUpdateWithMissingDirectories() throws Exception {
34: update.doUpdate();
35:
36: File file = new File(context.rootPagePath
37: + "/files/images/testFile");
38: assertTrue(file.exists());
39:
40: assertFalse(update.shouldBeApplied());
41: }
42:
43: public void testFileMissing() throws Exception {
44: update = new FileUpdate(updater, "images/missingFile",
45: "files/images");
46:
47: try {
48: update.doUpdate();
49: fail();
50: } catch (Exception e) {
51: }
52: }
53: }
|