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