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.*;
06: import java.util.Properties;
07: import fitnesse.wiki.FileSystemPage;
08:
09: public class PropertiesToXmlUpdateTest extends AbstractUpdateTestCase {
10: private String pageOneOldFilename = testDir + "/" + rootName
11: + "/PageOne" + PropertiesToXmlUpdate.old_propertiesFilename;
12:
13: private String pageTwoOldFilename = testDir + "/" + rootName
14: + "/PageOne/PageTwo"
15: + PropertiesToXmlUpdate.old_propertiesFilename;
16:
17: private String pageOneXmlFilename = testDir + "/" + rootName
18: + "/PageOne" + FileSystemPage.propertiesFilename;
19:
20: private String pageTwoXmlFilename = testDir + "/" + rootName
21: + "/PageOne/PageTwo" + FileSystemPage.propertiesFilename;
22:
23: public void setUp() throws Exception {
24: super .setUp();
25: deleteXmlPropertiesFiles();
26: Properties props = makeSampleProperties();
27: writeOldPropertiesFiles(props);
28: }
29:
30: public void testThatItWorks() throws Exception {
31: update.doUpdate();
32: assertTrue(new File(pageOneXmlFilename).exists());
33: assertFalse(new File(pageOneOldFilename).exists());
34: assertTrue(new File(pageTwoXmlFilename).exists());
35: assertFalse(new File(pageTwoOldFilename).exists());
36: }
37:
38: protected Update makeUpdate() throws Exception {
39: return new PropertiesToXmlUpdate(updater);
40: }
41:
42: private void writeOldPropertiesFiles(Properties props)
43: throws IOException {
44: OutputStream os1 = new FileOutputStream(pageOneOldFilename);
45: props.store(os1, "test");
46: os1.close();
47: OutputStream os2 = new FileOutputStream(pageTwoOldFilename);
48: props.store(os2, "test");
49: os2.close();
50: }
51:
52: private Properties makeSampleProperties() {
53: Properties props = new Properties();
54: props.put("Key1", "value1");
55: props.put("Key2", "value2");
56: props.put("Key3", "false");
57: return props;
58: }
59:
60: private void deleteXmlPropertiesFiles() {
61: new File(pageOneXmlFilename).delete();
62: new File(pageTwoXmlFilename).delete();
63: }
64:
65: }
|