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.wiki;
04:
05: import junit.framework.TestCase;
06: import java.util.*;
07:
08: public class InMemoryPageTest extends TestCase {
09: private WikiPage root;
10:
11: private PageCrawler crawler;
12:
13: private WikiPage page1;
14:
15: private WikiPage page2;
16:
17: public void setUp() throws Exception {
18: root = InMemoryPage.makeRoot("RooT");
19: crawler = root.getPageCrawler();
20: page1 = crawler.addPage(root, PathParser.parse("PageOne"),
21: "page one");
22: page2 = crawler.addPage(root, PathParser.parse("PageTwo"),
23: "page two");
24: }
25:
26: public void tearDown() throws Exception {
27: }
28:
29: public void testCommitUsesProperPageWhenCommitingFromOtherPage()
30: throws Exception {
31: PageData data = page1.getData();
32: page2.commit(data);
33: data = page2.getData();
34:
35: assertSame(page2, data.getWikiPage());
36: }
37:
38: public void testVersions() throws Exception {
39: PageData data = page1.getData();
40: data.setContent("version 1");
41: page1.commit(data);
42: data.setContent("version 2");
43: page1.commit(data);
44:
45: data = page1.getData();
46: Set versions = data.getVersions();
47:
48: assertEquals(3, versions.size());
49: }
50:
51: public void testVersionAuthor() throws Exception {
52: PageData data = page1.getData();
53: Set versions = data.getVersions();
54: for (Iterator iterator = versions.iterator(); iterator
55: .hasNext();) {
56: VersionInfo versionInfo = (VersionInfo) iterator.next();
57: assertEquals("", versionInfo.getAuthor());
58: }
59:
60: data.setAttribute(WikiPage.LAST_MODIFYING_USER, "Joe");
61: page1.commit(data);
62: page1.commit(data);
63:
64: data = page1.getData();
65: versions = data.getVersions();
66: boolean joeFound = false;
67: for (Iterator iterator = versions.iterator(); iterator
68: .hasNext();) {
69: VersionInfo versionInfo = (VersionInfo) iterator.next();
70: if ("Joe".equals(versionInfo.getAuthor()))
71: joeFound = true;
72: }
73:
74: assertTrue(joeFound);
75: }
76: }
|